Hi, i am a newbie to python 2.7 , trying to create a simple program, which takes an input string from the user, converts all the characters into their ascii values, adds 2 to all the ascii values and then converts the new values into text. So for example, if the user input is "test" , the output should be "vguv".
This is the code i have...
Hi,
I started playing around with web2py the other day for a new project. I really like the structure and the whole concept which feels like a breath of fresh air after spending a few years with PHP frameworks.
The only thing (currently) that is bothering me is the ticketing system. Each time I make a misstake a page with a link to a t...
In GAE-python, you can model a one-to-many relationship by assigning a reference property to the child model.
class Book(db.Model):
title = db.StringProperty()
class Author(db.Model):
book = db.ReferenceProperty(Book, collection_name = 'authors')
is_primary = db.BooleanProperty()
name = db.StringProperty()
This way, I can ...
So say i have
a = 5
i want to print it as a string '05'
...
I'm writing a program, with a PyQt frontend. To ensure that the UI doesn't freeze up, I use QThreads to emit signals back to the parent. Now, I have reached a point where I need my thread to stop running, emit a signal back to the parent, then wait on the parent to return an approval for the thread to continue (after the user interacts...
Hi,
I am using Emacs 23.1.1 on GNU/Linux with autocomplete.el 1.3 and Ropemacs 0.6.
In Lisp programming, autocomplete.el shows the documentation (known as 'QuickHelp' in autocomplete.el) of the suggested completions. Python completion with ropemacs works, but does not show quick help for the Python completion. Is it possible to enable ...
I am creating a web based Mock test paper, which needs to be fairly secure.
The needs are
Each question can be attempted and answered just once.
All are multiple Choice questions
Once a question is answered and the submit pressed, then that session must expire, and the same question must not appear either through back button or some o...
So I'm using static class members so I can share data between class methods and static methods of the same class (there will only be 1 instantiation of the class). I understand this fine, but I'm just wondering when the static members get initialized? Is it on import? On the first use of the class? Because I'm going to be calling the sta...
I am almost finished with a task someone gave me that at first involved easy use of the product() function from itertools.
However, the person asked that it should also do something a bit different like:
li =
[[1, 2, 3],
[4, 5, 6]]
A regular product() would give something like: [1, 4], [1, 5], [1, 6], [2, 4], [2, 5], [2, 6], [3, 4] ...
I may be posting a premature question, and maybe I'm just freaking out for no reason, but the way Oracle is handling Java is not very promising. I am a nerd who fell in love with Java from the first sight... and use it all the time in my personal/freelance projects but now I am thinking of a replacement. I am fluent in C#/VB.NET too but ...
I'm trying to install libxml2 on my Mac (OS 10.6.4). I'm actually trying to just run a Scrapy script in Python, which has required me to install Twisted, Zope, and now libxml2. I've downloaded the latest version (2.7.7, from xmlsoft.org) and tried following these instructions here. To summarize, I tried this command (in the python sub...
I've written an index and search view all in one if a GET request is detected it returns just the search results otherwise it returns all records. I've written this view below but I feel like I'm repeating myself a bit too much. Any ideas as to how I can slim this code down a bit would be much appreciated.
def index(request):
if 'q'...
My question does not really have much to do with sqlalchemy but rather with pure python.
I'd like to control the instantiation of sqlalchemy Model instances. This is a snippet from my code:
class Tag(db.Model):
__tablename__ = 'tags'
query_class = TagQuery
id = db.Column(db.Integer, primary_key=True)
name = db.Column(d...
I'm working on an application that will run on Google App Engine. I would like it to respond gracefully to App Engine maintenance periods.
According to the documentation, memcache will simply not store or retrieve data during maintenance periods:
During a read-only maintenance period,
calls to the memcache API will not
throw exc...
I'm trying to rewrite the following autohotkey script in Python:
Gui +LastFound
DllCall( "RegisterShellHookWindow", UInt,WinExist() )
MsgNum := DllCall( "RegisterWindowMessage", Str,"SHELLHOOK" )
OnMessage( MsgNum, "ShellMessage" )
LastActiveWindowID := WinActive("A")
Return ; // End...
myqueryset = Content.objects.filter(random 100)
...
How do I go about returning json data from a bottle request handler. I see a dict2json method in the bottle src but I am not sure how to use it.
What is in the documentation:
@route('/spam')
def spam():
return {'status':'online', 'servertime':time.time()}
Gives me this when I bring up the page:
<html>
<head></head>
<bod...
I'm having problems deploying a test app to my google apps domain. I know I'm missing something -- any kind souls out there see it?
sign into appengine.google.com/a/mydomain.com
create application, my-app-id
verify that app.yaml has the same app id, my-app-id
visit dashboard and add my domain
from shell on local pc,
set AUTH_DOMAIN=...
I'm building a simple short URL service, ala bitly, for our company use. And I would like to use mongodb to store the data, but I will need some kind of simple interface to add/edit short url to long url mappings.
The mongo documents will be very simple, something like this:
{
shortUrlSlug: 'pbbs',
fullUrl: 'http://example.com/pean...
I'm trying to write a program in python to run a program in C++. It wasn't working right, so I made the most basic version of each I could.
The C++ program merely takes in a string from stdin, and then prints it out.
The Python code is written as follows:
import popen2, string, StringIO
fin, fout = popen2.popen2("PyTest")
msg = ur"Hel...