I'm trying to create a simple XML parser where each different XML schema has it's own parser class but I can't figure out what the best way is. What I in effect would like to do is something like this:
in = sys.stdin
xmldoc = minidom.parse(in).documentElement
xmlParser = xmldoc.nodeName
parser = xmlParser()
out = parser.parse(xmldoc)
...
I've embedded python on a mobile device successfully, but now how do I include a python library such as urllib?
Additionally, how can I include my own python scripts without a PYTHONPATH?
(please note: python is not installed on this system)
...
Can you see any immediately changes I can do to increase speed and optimization in the script below?
We are suppose to write a script which implements dfs/bfs searches to find "ratatosk". Input is which function to use (dfs or bfs), number of nodes in the tree, root node, which node "ratatosk" is in and the rest of the node numbers.
...
I have a bunch of different methods that are not supposed to run concurrently, so I use a single lock to synchronize them. Looks something like this:
selected_method = choose_method()
with lock:
selected_method()
In some of these methods, I sometimes call a helper function that does some slow network IO. (Let's call that one netw...
I have three lists that define when a task should be executed:
minute: A list of integers from 0-59 that represent the minutes of an hour of when execution should occur;
hour: A list of integers from 0-23 that represent the hours of a day of when execution should occur
day_of_week: A list of integers from 0-6, where Sunday = 0 and Satu...
Hello,
I'm running my app on the GAE development server, with app-engine-patch to run Django.
One of my views is bugged , so I want to log everything that happens.
I added in myapp.views:
import logging
LOG_FILENAME = '/mylog.txt'
logging.basicConfig(filename=LOG_FILENAME,level=logging.DEBUG)
and my function is:
def function(string...
Hi!
I have a model with a list property.
I have a csv that has each list data that looks like this.
[u'1234567']
The list has only one item each.
My bulkloader.yaml has configured import_transform: transform.none_if_empty(list). It uploads the above list property as [u'[', u'u', u"'", u'1', u'2', u'3', u'4', u'5', u'6', u'7', u"'", ...
If the my_dict variable is global, you can't do:
my_dict = {}
that just create a new reference in the local scope.
Also, I found disgusting using the global keyword, so how can I empty a dict using its methods?
...
I know how to query on a model now. Suppose there is a Question model:
class Question(Base):
__tablename__ = "questions"
id=Column(...)
user_id=Column(...)
...
Now, I can do:
question = Session.query(Question).filter_by(user_id=123).one()
But, now, I have a table (not a model) questions:
questions = Table('question...
if(len(f1) > 0):
for qs in profile_map:
up = Profile.objects.get(pk=qs.emp.id)
t_name = up.first_name + up.last_name
t_arr.append((q.profile.id,emp_name))
response_dictionary.update({'tarr':t_arr})
render_to_response('project/profile_table.html',context_instance=RequestContext(request,{'response_dict...
Hello Friends,
I am a PHP developer and recently migrated to Python. In PHP, there are many classes available at for example phpclasses.org which saves a lot of developer's time. I am looking for similar kind of repository for python. I need a database wrapper class for accessing the database with python. One of the class i found was a...
Hi there-
I have a list of objects which I built with a class, and one of the properties of this class is the variable "tag". (below called tagList)
I am trying to match this variable from a record that is bought in using MySQLdb. (below called record)
I can output both to the screen, and see them identically by eye, although cannot g...
I'm planning to use Python to develop a web application. Anybody has any idea about any accelerator for python? (something like eAccelerator or apc for php) if not, is there any way to cache the pre-compiled python bytecode ?
Any idea about the performance comparison between python and php (assuming db/network latencies are same)
Thank...
What's going on with my Python variable? old_pos seems to be linked to pos:
Code:
pos = [7, 7]
direction = [1, 1]
old_pos = pos
print 'pos = '+str(pos)
print 'old_pos = '+str(old_pos)
pos[0] += direction[0]
pos[1] += direction[1]
print 'pos = '+str(pos)
print 'old_pos = '+str(old_pos)
Output:
pos = [7, 7]
old_pos = [7, 7...
Hello,
is it possible to show the assertion values that failed? It shows the traceback and what kind of exception was throw but it would more practical to know which values failed.
Example:
assert result.file == file
AssertionError
...
This code works fine and produces checkbuttons in a long long list.
def createbutton(self,name):
var = IntVar()
account = name[0]
chk = Checkbutton(self.root, text=account, variable=var)
chk.pack(side = BOTTOM)
self.states.append((name,var))
The problem is that the list of buttons is so long, that it stretches fart...
I have to get the information about the current mouse cursor from windows but I'm not managing to work this command...
what should I do?
Can someone post one example?
...
>>> l = Lock()
>>> l.acquire()
True
>>> l.release()
>>> l.release()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: semaphore or lock released too many times
throws a ValueError exception. How can I prevent to release a lock more than once? Something like l.is_released() ?
...
I have an unusual request.
I've just moved to a new apartment and I won't have my internet hooked up for over a week. I'm trying to develop my application using my phone for online documentation. Before I moved I found this video (vodpod.com/watch/4071950-building-real-time-network-applications-for-the-web-with-twisted-and-orbited-part-...
I would like to find some way of Viewing a Directory in the default file system viewer (Windows Explorer, Finder, Dolphin, etc...) that will work on all major platforms.
I do not have the detailed knowledge of Linux, nor of OSX in order to write this. Is there some script out there that will do what I want?
...