python

how do I run a python script that requires pyparsing?

I got a python file which using something called pyparsing but when I run it It showed an error that pyparsing is required can any one pls tel me what to do not that I am a dump in that thing called pything I need to run that script only :)thanks ...

Learning a new web-oriented programming language, where to begin?

A bit of background: I am familiar with PHP and Java, did some C, C++ and Lisp (gasp!) back in programming classes but never used them too much. So, I've been wanting to step out of PHP a bit for web development. I have a few reasons for this (in no particular order): there's a lot of amateurish code(rs) in PHP, which somehow makes me ...

Python urllib vs httplib?

When would someone use httplib and when urllib? What are the differences? I think I ready urllib uses httplib, I am planning to make an app that will need to make http request and so far I only used httplib.HTTPConnection in python for requests, and reading about urllib I see I can use that for request too, so whats the benefit of one ...

Python -- How do you view output that doesn't fit the screen?

I should say I'm looking for a solution to the problem of viewing output that does not fit on your screen. For example, range(100) will show the last 30ish lines in your terminal of 30 height. I am only looking to be nudged in the right direction and am curious how you guys have approached this problem. What have you done when you ru...

XML parsing in Python

Having trouble getting this to work. What's strange is that I have 10 bookmarks in Delicious and it prints out 10 blank strings so it must be close to working. import urllib from xml.dom.minidom import parse FEED = 'http://feeds.delicious.com/v2/rss/migrantgeek' dom = parse(urllib.urlopen(FEED)) for item in dom.getElementsByTagName('...

What Type of Settings File to Implement?

Hey guys, I am making an auto-archiver/backup sort of thing in Python(http://sourceforge.net/projects/frozendirectory/). As of now it uses an ordinary text file to store its small amount of settings(but ever growing). I was thinking of changing it to an XML file so that it would be more flexible/scalable and thus easier to work with in t...

Python Strptime() and timezones?

Hi, I have a CSV dumpfile from a Blackberry IPD backup, created using IPDDump. The date/time strings in here look something like this (where EST is an Australian time-zone): Tue Jun 22 07:46:22 EST 2010 I need to be able to parse this date in Python. At first, I tried to use the strptime() function from datettime. >>> datetime.dateti...

Noob Question: Python + Twitter + App Engine - Oauth

I'm sorry but I'm having some trouble implementing Oauth within my app engine python project. I've been working from http://github.com/tav/tweetapp, but I don't think I have a strong enough grasp on this platform to understand how to implement this class within my main.py I'm building the rest of my app in. This maybe a feeble attempt,...

algorithms problem in uniform cost solution

I am doing the unifrom cost search algorithm. I am getting my solution slightly larger than actual. The number of expanded nodes are coming larger than actual. I used this algorithm: Get the initial node and put it into the priority queue.The P.queue will itself arranges the nodes in it according to the cost. Lower cost node will come ...

What is the Windows equivalent of pwd.getpwnam(username).pw_dir?

The Python pwd module provides access to getpwnam(3) POSIX API, which can be used to get the home directory for a particular user by username, as well determining if the username is valid at all. pwd.getpwnam will raise an exception if called with a non-existent username. At first it seems like the same result can be achieved in a cros...

On the google app engine, how do I get rid of the 'Only ancestor queries are allowed inside transactions' error?

I am having trouble with one specific query. It needs to run in a transaction, and it does, but whenever the app engine executes my query I get the following error: Only ancestor queries are allowed inside transactions You'll see that my query DOES have an ancestor. So what is the app engine really complaining about? q = db....

What is the difference between 'log' and 'symlog'?

In matplotlib, I can set the axis scaling using either pyplot.xscale() or Axes.set_xscale(). Both functions accept three different scales: 'linear' | 'log' | 'symlog'. What is the difference between 'log' and 'symlog'? In a simple test I did, they both looked exactly the same. I know the documentation says they accept different paramet...

Static memory in python: do loops create new instances of variables in memory?

I've been running Python scripts that make several calls to some functions, say F1(x) and F2(x), that look a bit like this: x = LoadData() for j in range(N): y = F1(x[j]) z[j] = F2(y) del y SaveData(z) Performance is a lot faster if I keep the "del y" line. But I don't understand why this is true. If I don't use "del y"...

Which solution is better for Django social authentication?

django-socialregistration or django-SocialAuth? For my new project, I'm thinking of having signups only through Facebook (and possibly Twitter). Don't care about OpenID, hence this question doesn't answer my concern: http://stackoverflow.com/questions/2123369/whats-the-best-solution-for-openid-with-django Both these apps seem appropria...

Python csv string to array

Anyone know of a simple library or function to parse a csv encoded string and turn it into an array or dictionary? I don't think I want the built in csv module because in all the examples I've seen that takes filepaths, not strings. Thank you ...

bottle framework....

When I run bottle development server, I notice some warning showing up. Can any one figure it out what exactly is the problem? Exception in thread Thread-1: Traceback (most recent call last): File "/usr/lib/python2.6/threading.py", line 525, in __bootstrap_inner self.run() File "/usr/local/lib/python2.6/dist-packages/bottle-0.8.1-p...

priority queue problem in python

I have a priority queue class that has only few functions like, if it is empty or not, push and pop an itme into it. But I need to check if a partuclar item is present in the queue or not? how would I do that?? ...

Using TCL extensions to set native window style in Tkinter

pythonware.com/library/tkinter/introduction/… documents a overrideredirect method that will remove thetitlebar and borders, if that is not enough you must set the native window style, I'm not sure if Tkinter gives you that kind of low-level access, if not, try the something like twapi.magicsplat.com/ui.html#set_window_...

Multilanguage URLs in Django

What is the best way to support multilanguage URLs in Django? Like: http://myenglishwebsite.com/user/foo http://mygermanwebsite.com/benutzer/foo Should I use multilang in urls.py like: (r'^%s/(?P<slug>[-w]+)/$' % _('user'), 'myapp.view.relatedaction') It doesn't seem like a good solution and I couldn't make it work :)) ...

Cannot pass an argument to python with "#!/usr/bin/env python"

I needed to have a directly executable python script, so i started the file with "#!/usr/bin/env python". However, i also need unbuffered output, so i tried "#!/usr/bin/env python -u", but that doesn't work. ("python -u: no such file or directory") I found out that "#/usr/bin/python -u" works, but it doesn't suit my needs because i need...