python

How do I take the output of one program and use it as the input of another?

I've looked at this and it wasn't much help. I have a Ruby program that puts a question to the cmd line and I would like to write a Python program that can return an answer. Does anyone know of any links or in general how I might go about doing this? Thanks for your help. EDIT Thanks to the guys that mentioned piping. I haven't use...

How do I make IPython organize tab completion possibilities by class?

When an object has hundreds of methods, tab completion is hard to use. More often than not the interesting methods are the ones defined or overridden by the inspected object's class and not its base classes. How can I get IPython to group its tab completion possibilities so the methods and properties defined in the inspected object's cl...

What is a simple way to generate keywords from a text?

I suppose I could take a text and remove high frequency English words from it. By keywords, I mean that I want to extract words that are most the characterizing of the content of the text (tags ) . It doesn't have to be perfect, a good approximation is perfect for my needs. Has anyone done anything like that? Do you known a Perl or Pyt...

Delphi-like GUI designer for Python

Is there any GUI toolkit for Python with form designer similar to Delphi, eg where one can drag and drop controls to form, move them around etc. ...

How to make a model instance read-only after saving it once?

One of the functionalities in a Django project I am writing is sending a newsletter. I have a model, Newsletter and a function, send_newsletter, which I have registered to listen to Newsletter's post_save signal. When the newsletter object is saved via the admin interface, send_newsletter checks if created is True, and if yes it actually...

How can I hide the python.exe window in a pyqt app when running on Windows?

Surely this is possible? I have been hunting through pyqt tutorials and documentation but cannt find the answer to it. Probably I just need to phrase my search query differently. [Edit] Thanks PEZ for the answer - more details including use of the .pyw extension in Python Programming on Win32 chapter 20 ...

How can I generate multi-line build commands?

In SCons, my command generators create ridiculously long command lines. I'd like to be able to split these commands across multiple lines for readability in the build log. e.g. I have a SConscipt like: import os # create dependency def my_cmd_generator(source, target, env, for_signature): return r'''echo its a small world after ...

Converting string into datetime

Short and simple. I've got a huge list of date-times like this as strings: Jun 1 2005 1:33PM Aug 28 1999 12:00AM I'm going to be shoving these back into proper datetime fields in a database so I need to magic them into real datetime objects. Any help (even if it's just a kick in the right direction) would be appreciated. Edit: Thi...

How can I set it up so that threads communicate they're complete with their task?

Conceptually, I would like to accomplish the following but have had trouble understand how to code it properly in Python: from threading import Thread for i in range(0,3): t = Thread(target=myfunction) t.start() # wait until threads have finished executing print 'complete!' ...

Why do I have to specify my own class when using super(), and is there a way to get around it?

When using Python's super() to do method chaining, you have to explicitly specify your own class, for example: class MyDecorator(Decorator): def decorate(self): super(MyDecorator, self).decorate() I have to specify the name of my class MyDecorator as an argument to super(). This is not DRY. When I rename my ...

How can I return system information in Python?

Using Python, how can information such as CPU usage, memory usage (free, used, etc), process count, etc be returned in a generic manner so that the same code can be run on Linux, Windows, BSD, etc? Alternatively, how could this information be returned on all the above systems with the code specific to that OS being run only if that OS i...

reading/writing xmp metadatas on pdf files through pypdf

I can read xmp metadatas through pyPdf with this code: a = pyPdf.PdfFileReader(open(self.fileName)) b = a.getXmpMetadata() c = b.pdf_keywords but: is this the best way? And if I don't use the pdf_keywords property? And is there any way to set these metadatas with pyPdf? ...

Python piping on Windows: Why does this not work?

I'm trying something like this Output.py print "Hello" Input.py greeting = raw_input("Give me the greeting. ") print "The greeting is:", greeting At the cmd line Output.py | Input.py But it returns an EOFError. Can someone tell me what I am doing wrong? Thanks for your help. EDIT Patrick Harrington solution works but I don'...

How will Python and Ruby applications be affected by .NET?

I'm curious about how .NET will affect Python and Ruby applications. Will applications written in IronPython/IronRuby be so specific to the .NET environment, that they will essentially become platform specific? If they don't use any of the .NET features, then what is the advantage of IronPython/IronRuby over their non .NET counterpar...

WURFL with python issues

I've been attempting to setup pywurfl so that I can perform handset lookups to pull attributes from the wurfl api, but I'm currently having issues when attempting the select_ua() request. This is what I'm using : http://celljam.net/ Anyone out there have experience with Python and WURFL? ...

python: list comprehension tactics

I'm looking to take a string and create a list of strings that build up the original string. e.g.: "asdf" => ["a", "as", "asd", "asdf"] I'm sure there's a "pythonic" way to do it; I think I'm just losing my mind. What's the best way to get this done? ...

How to prevent overwriting an object someone else has modified

I would like to find a generic way of preventing to save an object if it is saved after I checked it out. We can assume the object has a timestamp field that contains last modification time. If I had checked out (visited a view using a ModelForm for instance) at t1 and the object is saved again at t2, given t2 > t1 I shouldn't be able t...

How can I read system information in Python on OS X?

Following from this OS-agnostic question, specifically this response, similar to data available from the likes of /proc/meminfo on Linux, how can I read system information from OS X using Python (including, but not limited to memory usage). ...

How can I read system information in Python on Windows?

Following from this OS-agnostic question, specifically this response, similar to data available from the likes of /proc/meminfo on Linux, how can I read system information from Windows using Python (including, but not limited to memory usage). ...

Implementing a "rules engine" in Python

I'm writing a log collection / analysis application in Python and I need to write a "rules engine" to match and act on log messages. It needs to feature: Regular expression matching for the message itself Arithmetic comparisons for message severity/priority Boolean operators I envision An example rule would probably be something lik...