Hello,
I am trying to script the bringing online (or putting offline) an account, looking at purple-url-handler script I see that simple snippet which looks perfect for me :
def bring_account_online(account):
if not cpurple.PurpleAccountIsConnected(account):
# The last argument is meant to be a GList * but the D-Bus bindin...
Hi everyone
While trying to learn a little more about regular expressions, a tutorial suggested that you can use the \b to match a word boundary. However, the following snippet in the Python interpreter does not work as expected:
>>> x = 'one two three'
>>> y = re.search("\btwo\b", x)
y should have been a match object if anything wa...
I have read from the django-jython wiki that 1.1.1 is not compatible with django 1.2, and that jython does not works with the default django backend.
Does this means I'm unable to use django 1.2 with jython at the moment?
...
In django, in TextField, how to we replace,
[vimeo 123456]
with
<iframe src="http://player.vimeo.com/video/123456" width="400" height="225" frameborder="0"></iframe>
Thank you.
...
Hello guys,
I'm tring to install Hookbox but without success, when I call easy_install or
python setup.py install
it gives me [Errno 13] Permission denied: '/usr/local/lib/python2.6/site-packages/test-easy-install-68779.write-test'
When I try to grant write permissions to this derectory it gives
chmod: /usr/local/lib/python2.6/si...
Hey,
I'm creating a C Lexical analyzer using python as part of developing a parser.Here in my code i have written some methods for identifying keywords,numbers,operators etc. No error is shown after compiling. While executing i could input a .c file.My output should list all the keywords,identifiers etc in the input file. But it is not ...
I want to define a set of constants in a class like:
class Foo(object):
(NONEXISTING,VAGUE,CONFIRMED) = (0,1,2)
def __init__(self):
self.status = VAGUE
However, I get
NameError: global name 'VAGUE' is not defined
Is there a way of defining these constants to be visiable inside the class without resorting to global or ...
def foo(a, b, c = 0):
return a+b
I have dozens of functions like 'foo', which all have different argument numbers and names. Is there a common way that I can get the return values of these functions and do just a single extra operation like pformat to them?
Yes I can just generate a new function like the following:
func = ... # ...
I was wondering why this works:
sys.path.append('/home/user/django')
sys.path.append('/home/user/django/mysite')
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
but this doesn't?
sys.path.append('/home/user/django')
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
I thought that adding the django folder would aut...
While working on a Pylons app, I accidentally typed
python setup.py install
in the home directory of a project, instead of what I meant to type, namely
python setup.py egg_info
Oops. It looks like the Pylons app has now been installed as a Python package. Whenever I make changes to the project, they don't get propagated unless I r...
Hi I am trying to build an application which has models resembling something like the below ones:-(While it would be easy to merge the two models into one and use them , but that is not feasible in the actual app)
class User(db.Model):
username=db.StringProperty()
email=db.StringProperty()
class UserLikes(db.Model):
use...
I've seen the usage of exit status 3 in several python scripts that restart processes. As far as I know the convention is only about 0 and "not 0" on Unix/Linux.
Is there a convention defining other values like 3.
...
I have a slider and I want to call a specific function only when the interaction is complete. The idea is to call a function after 500ms (and not before). If the slider continues to move then the call is canceled. In other words, if the slider "rests" for more than 500ms than the function is call.
Thanks
Update
#slider
def up...
I'm looking for a Python (<3) validation API something like Java's Bean Validation or Spring validation. I'm not looking for a library that is limited to form validation, since I want to validate domain objects.
Do you know a Python API for validating of domain objects?
...
I wrote the following code in python
self._job = None
#slider
def sliderCallback(self):
if self._job:
And I get this error message
AttributeError: 'str' object has no attribute '_job'
why ? I thought I have initialized the variable before...
Update
Same issue with Timer variable
import Tkinter as tk
import vtk
from time impor...
Possible Duplicate:
Python try-else
Comming from a Java background, I don't quite get what the else clause is good for.
According to the docs
It is useful for code that must be
executed if the try clause does not
raise an exception.
But why not put the code after the try block? It seems im missing something importan...
With having the with statement, is there ever a need to open a file/check for exceptions/do manual closing of resources, like in
try:
f = open('myfile.txt')
for line in f:
print line
except IOError:
print 'Could not open/read file'
finally:
f.close()
...
Hey,
I have the following regex:
regex = compile("((?P<lastyear>[\dBFUPR]+)/)*((?P<lastseason>[\dBFUPR]+))*(^|-(?P<thisseason>[\dBFUPR]*))")
Which I am using to process horce racing form strings. Sometimes a horses' form will look like this "1234-" meaning that it has not raced yet this season (there are no numbers to the right of th...
The txt is about 22,000 lines, and it's about 3.5MB. There are lots of duplicate lines in it. I simply want to remove the duplicate lines and also some lines which include specific strings not needed.
My way is to read the file into a big list using readlines() method, then read the file as a big string using read() method. Iterate the...
Hey Guys,
Assuming you have a project setup like this
-WebApp
|_ requirements.txt
|_ bootstrap.py (virtualenv bootstrap script)
|_ src
|_ setup.py
|_ develop-app
|_ somecode.py
|_ morecode.py
The bootstap.py is created with virtualenv:
http://pypi.python.org/pypi/virtualenv#creating-y...