python

Parsing Dates and Times from Strings using python

I'm using python, and want to parsing a string like "01-Jan-1995" to datetime type of python. who can tell me how to do it? thanks. ...

how to split a string to what I want in python

I have string ling like this: 'Toy Stroy..(II) (1995)' I want to split the line to two parts like this: ['Toy Story..(II)','1995'] How can I do it? thanks ...

Version number comparison

Python must have a more elegant solution to this ... maybe one of you can help: I want to write a cmp-like function returning -1, 0 or 1 for version numbers, allowing for an arbitrary number of subsections. Each subsection is supposed to be interpreted as a number, therefore 1.10 > 1.1. Desired function outputs are mycmp('1.0', '1'...

Strange behavior with python import

So I am trying to import a module "foo" that contains directories "bar" and "wiz". "bar" contains python files a.py, b.py, and c.py. "wiz" contains python files x.py, y.py and z.py. $ ls foo __init__.py bar wiz $ ls foo/bar __init__.py a.py b.py c.py $ ls foo/wiz __init__.py x.py y.py z.py In th...

Supervisord RPC - UNKNOWN_METHOD on any request

I've configured (almost default) supervisord.conf and started supervisord. Tasks launched and xmlrpc interfaces are up, but gives xmlrpclib.Fault: <Fault 1: 'UNKNOWN_METHOD'> on evey xmlrpc request, even when launching supervisorctl itself. There is a same message in the log: TRAC XML-RPC method called: supervisor.getAllProcessInfo() T...

Strange error in google app engine

Hi, I would like to mention before hand that I am a novice to python and with that to python platform of GAE. I have been finding this very strange error/fault when I am trying to get an entity using its key ID... Here's what I do, I am querying the datastore entity model UserDetails for the key corresponding to the user name retrieved...

win32com IE interface PAMIE javascript click

Hello, these day im making some script. i have encounter some problem with my script work. problem is i want to click emulate javascript on following site. http://news.naver.com/main/presscenter/category.nhn this site is news site. and everyday news content also changed, but javascript is not changed. for example i want to click ja...

Can't use a data obj with timeit.Time module in python

I'm trying to measure how long it takes read then encrypt some data (independently). But I can't seem to access the a pre-created data obj within timeit (as it runs in its own virtual environment) This works fine (timing file read operation): t = timeit.Timer(""" openFile = open('mytestfile.bmp', "rb") fileData = openFile.readlines() ...

Check String for / against Characters in Python

I need to be able to tell the difference between a string that can contain letters and numbers, and a string that can contain numbers, colons and hyphens. >>> def checkString(s): ... pattern = r'[-:0-9]' ... if re.search(pattern,s): ... print "Matches pattern." ... else: ... print "Does not match pattern." # 3 Numbers sep...

is there any library to deserialize with python which is serialized with java.

is there any library to deserialize with python which is serialized with java. ...

Python code comments

In C# and through Visual Studio, it is possible to comment your functions, so you can tell whoever is using your class what the input arguments should be, what it is supposed to return, etc. Is there anything remotely similar in python? ...

How to wrap built-in methods in Python? (or 'how to pass them by reference')

I want to wrap the default open method with a wrapper that should also catch exceptions. Here's a test example that works: truemethod = open def fn(*args, **kwargs): try: return truemethod(*args, **kwargs) except (IOError, OSError): sys.exit('Can\'t open \'{0}\'. Error #{1[0]}: {1[1]}'.format(args[0], sys.exc_inf...

Inline editing of ManyToMany relation in Django

After working through the Django tutorial I'm now trying to build a very simple invoicing application. I want to add several Products to an Invoice, and to specify the quantity of each product in the Invoice form in the Django admin. Now I've to create a new Product object if I've got different quantites of the same Product. Right now ...

Couple of questions regarding PyQt

I have a couple of questions. I have an algorithm that will generate a couple of pictures in python that must be displayed on a form. I am using PyGt for this. My question is: where should I run my code? Right from the initializer? In that case from what I tested, the form won't show up. Should I set up a timer in the constructor tha...

Exception message (Python 2.6)

If I want to open binary file (in Python 2.6), that doesn't exists, program exits with an error and prints this: Traceback (most recent call last): File "C:\Python_tests\Exception_Handling\src\exception_handling.py", line 4, in <module> pkl_file = open('monitor.dat', 'rb') IOError: [Errno 2] No such file or directo...

TypeError when trying to upload Pictures from Google App Engine to Picasa with the GData API

I'm trying to write a small tool to upload Pictures from Google App Engine to Picasa. Fetching the image works, but when i try to upload it i get the error "TypeError: stat() argument 1 must be (encoded string without NULL bytes), not str" The Code basically looks like this: def getfile(url): result = urlfetch.fetch(url) if re...

Best way to decode unknown unicoding encoding in Python 2.5

Have I got that all the right way round? Anyway, I am parsing a lot of html, but I don't always know what encoding it's meant to be (a surprising number lie about it). The code below easily shows what I've been doing so far, but I'm sure there's a better way. Your suggestions would be much appreciated. import logging import codecs from ...

adding a keyword argument to an overriden method and using **kwarg

I am subclassing an object in order to override a method that I want to add some functionality to. I don't want to completely replace it or add a differently named method but remain compatible to the superclasses method by just adding an optional argument to the method. Is it possible to work with *args and **kwargs to pass through all a...

Something like pubsubhubbub that does not depend on google app engine

I am looking for something like pubsubhubbub that does not depend on google app engine to run. What I need is a tool that can track for me a big very large number of rss or atom feeds and issue events when they are updated. ...

Django Form Wizard and Preview with ModelForm

I have a large Django model (73 fields) that will will be connected to a ModelForm. I'd like to use a combination of the functionality found the Form Wizard and Form Preview contrib apps. I.e., the form fields would be split over multiple pages, and the user would have a chance to review/preview the data before the model instance is cr...