Hi,
I am a little bit stuck. I have been commanded to do an exersice which
states in one of the steps to associate a method with an instance (as
I understood), here a closer explanation:
I have a model, wich have different methods, each of them execute some
tests given that model's instance fields.
Then, I have another model which ...
I've been learning Python for a couple of weeks, and although I've been successfully develop apps for Google App Engine with Python 2.6.5, it specifically requires Python 2.5.
Being mindful of compatibility issues when uploading apps (it's a situation I'd rather avoid while learning Python), I wonder if it's possible to have 2.5 and 2.6...
Unless I'm missing something, the usual suspects don't have this....
...
I am in simple doubt... I created the following dictionary:
>>> alpha={'a': 10, 'b': 5, 'c': 11}
But, when I want to see the dictionary keys and values I got:
>>> alpha
{'a': 10, 'c': 11, 'b': 5}
See that the "b" and "c" has swapped their position. How can I make the position be the same of the moment that the dictionary was create...
If you are parsing html or xml (with python), and looking for certain tags, it can hurt performance to lower or uppercase an entire document so that your comparisons are accurate. What percentage (estimated) of xml and html docs use any upper case characters in their tags?
...
I have a somewhat unique request. What I am looking to do is listen on a specific port for all traffic coming through via IRC protocol. I then want to log all of those messages/commands/ect. I do not, however, want to join the channel. I just want to listen and log. Is there an easy built in way to do this? I have been looking at the irc...
Hi,
I'm developing a web application and would like to display user's current date basing on his timezone. Here is my code:
userTimezone = -5 #EAST is positive, WEST negative
utcTimestamp = time.mktime(time.gmtime())
userDate = time.gmtime(utcTimestamp+userTimezone*60*60)
I think the problem is with gmtime() since it does some conve...
I'm looking for a Ruby or Python implementation of the Git client that can be used to update and commit changes in a local repository.
I prefer if the library does not use shell commands at all but keeps everything in "pure code".
Are there any?
Thank you in advance.
...
In the WSGIApplication's constructor, it takes a debug argument. Is there a way to access the value set for this from the the handler classes that inherit from webapp.RequestHandler?
def main():
application = webapp.WSGIApplication([('/', fooHandler)
],
...
I have Django set up on my server at http://stevencampbell.org/
I want to be able to run WordPress at stevencampbell.org/blog/
I'm running all my Python and Django files through Fast_CGI (only Django option on my server). My .htaccess file looks like this:
AddHandler fastcgi-script .fcgi
RewriteEngine On
RewriteRule ^(/media.*)$ /$1 [...
I'd like a global variable to determine if I'm in debug mode or not. Is that what __debug__ is for? How do I set/read it on Google App Engine?
If I use logging.debug(), will that automatically be turned off if I don't run the app with debug=True?
application = webapp.WSGIApplication(# ...
debug=T...
Hi
I'm trying to find a xml-interpret function (like the simplexml_load_string) in Python, but with no success :/
Let's say I have xml in a string
my_xml_string = """
<root>
<content>
<one>A value</one>
<two>Here goes for ...</two>
</content>
</root>"""
To read an value in php I would normaly do something...
I want to write some python package installing script in Python into virtualenv. I write a function for installing virtualenv
def prepareRadioenv():
if not os.path.exists('radioenv'):
print 'Create radioenv'
system('easy_install virtualenv')
system('virtualenv --no-site-package radioenv')
print 'Activate...
I'm trying to capture the configure-event for every window to create a windows 7-esque snap feature. I know there are solutions involving compiz-fusion, but my installation is running within vmware and doesn't have hardware acceleration to run compiz. I figured a simple python script could do what I wanted, but I can't seem to find the r...
As the title states, I am looking for something, that will help me automate form processing (validation/rendering/etc) in twisted.web. I am also looking for a suitable templating toolkit to use with it.
As for templating, it is not so much of an issue as there are a lot of libraries in python, that do it. I was considering the following...
OS:WinXP
Python 2.6
A Python project in Eclipse, if you go to 'run configuration' arguments tab. There's a section for 'Python VM arguments (Python.exe)'. Does anyone know where to find a reference for what arguments does Python VM have? I tried keyword 'Python (VM or Virtual Machine) arguments' but couldn't find it. Thanks.
...
The following Python code ...
html_data = urllib2.urlopen(some_url).read()
f = codecs.open(filename, 'w', encoding='utf-8')
f.write(html_data)
f.close()
... sometimes fails with UnicodeDecodeError ...
File "/.../lib/python2.6/codecs.py", line 686, in write
return self.writer.write(data)
File "/.../lib/python2.6/codecs.py", line 351...
The typical header should be
#!/usr/bin/env python
But I found below also works when executing the script like $python ./my_script.py
#!/usr/bin/python
#!python
What's difference between these 2 headers? What could be the problem for 2nd one? Please also discussing the case for python interpreter is in PATH or not. Thanks.
...
I wrote the beautiful python example code below. Now how do I make it so when I exit then restart the program it remembers the last position of the scale?
import Tkinter
root = Tkinter.Tk()
root.sclX = Tkinter.Scale(root, from_=0, to=1500, orient='horizontal', resolution=1)
root.sclX.pack(ipadx=75)
root.resizable(False,False)
root.t...
I am installing an application and have installed python and easy_install. I now have two steps to complete:
5. Make a config file as follows::
paster make-config openbiblio development.ini
6. Tweak the config file as appropriate and then setup the application::
paster setup-app config.ini
I have read Stackoverflow answers ...