help(unicode) prints something like:
class unicode(basestring)
| unicode(string [, encoding[, errors]]) -> object
...
but you can use something different from a basestring as argument, you can do unicode(1) and get u'1'. What happens in that call? int don't have a __unicode__ method to be called.
...
I know this is the basic.
I'm just wondering what is the elegant way to do it.
For example:
I want the the 'python01.wav' and 'py*thon' strings from this list
The list is like this:
[
[('name', 'entry')],
[('class', 'entry')],
[('type', 'text/javascript'), ('src', '/term_added.php?hw=python')],
[('type', 'text/javascript')],
[('clas...
I'm using ConfigParser to load in data from a configuration file as follows:
test.conf:
[myfiles]
fileone: %(datadir)s/somefile.foo
filetwo: %(datadir)s/nudderfile.foo
load.py:
import ConfigParser
config = ConfigParser.ConfigParser({'datadir': '/tmp'})
config.read('test.conf')
print config.items('myfiles')
print config.get('myfile...
I'm using pyPEG to create a parse tree for a simple grammar. The tree is represented using lists and tuples. Here's an example:
[('command',
[('directives',
[('directive',
[('name', 'retrieve')]),
('directive',
[('name', 'commit')])]),
('filename',
[('name', 'f30502')])])]
My question is what do I do with...
Hi,all
i got a performance issue when trying to do:
from twisted.internet import reactor
#some codes here
pid = os.fork()
if not pid:
#some codes blahblahblah
reactor.run()
this caused very low performance and i didn't find useful informations from the official documentation, i believe it because i import reactor module befor...
import sqlite3
conn = sqlite3.connect(r"D:\aaa.db")
Is there a way to automatically create the db file if it doesn't already exist when I connect to it?
thanks
...
Trying to decide if I should be using mako to handle the forms in my application or not. Thanks for the input.
...
I have a simple config of haystack/solr on my django app:
from the models.py of this app:
class device(models.Model):
...
hostname = models.CharField(max_length=45, help_text="The hostname for this device")
...
from the search_sites.py of this app:
class devIndex(indexes.SearchIndex):
'''Haystack class to allow for i...
There seems to be a handful of JSON libraries out there for Python even though Python has a built-in library. One even claims to be built according to http://www.json.org spec (which caused me to think 'hmmm, is Python's built in library not built fully to spec?', so I find myself here to ask what others have found when trying out differ...
I would like to flip from big to little endian this string:
\x00\x40
to have it like this:
\x40\x00
I guess the proper function to use would be struct.pack, but I can't find a way to make it properly work.
A small help would be very appreciated !
Thanks
...
In python, is there a command similar to len() which works on integers?
Thanks
...
hi, I am trying to get a normalized path on windows. The paths are stored in a list and i am looping over those as follows:
>>> lst = ['C:\\', 'C:\\Windows', 'C:\\Program Files']
>>> lst
['C:\\', 'C:\\Windows', 'C:\\Program Files']
>>> for pth in lst:
... print pth
...
C:\
C:\Windows
C:\Program Files
Notice that it has removed one ...
Is it possible to use threading when importing data from csv files to django.
...
It is very important to me.
Thanks.
...
So I've managed to get a graph drawn up on my screen like such:
class Window(QWidget):
#stuff
graphicsView = QGraphicsView(self)
scene = QGraphicsScene(self)
#draw our nodes and edges.
for i in range(0, len(MAIN_WORLD.currentMax.tour) - 1):
node = QGraphicsRectItem(MAIN_WORLD.currentM...
I am trying to translate the following code
d = {}
d[0] = None
into C++ with boost.python
boost::python::dict d;
d[0] = ?None
How can I get a None object in boost.python?
ANSWER:
boost::python::dict d;
d[0] = boost::python::object();
...
Does Python have screen scraping libraries that offer JavaScript support?
I've been using pycurl for simple HTML requests, and Java's HtmlUnit for more complicated requests requiring JavaScript support.
Ideally I would like to be able to do everything from Python, but I haven't come across any libraries that would allow me to do it. Do...
I use python to patch system settings of linux systems distributed with partimage.
I want to have the following python script structure:
/patch.d/
10_patch_netwok.py
20_patch_hostname.py
...
50_patch_software_xyz.py
InitSystem.py
The InitSytem.py should run the python scripts in /patch.d folder. Following my idea (br...
I'd like to automatically load some test data into the AppEngine datastore when a local copy is run by one of my team's developers. I know that the bulk uploader lets you do this from the command line, but I'm looking for something automatic. Inevitably we will forget to load data when we clear our test copies of the datastore.
Currentl...
Previously I got a suggedtion to Install the FreeType dev files and rebuild PIL again.
but I have no idea how to do it.
any help will be thanked for
...