wxPython: Making something expand
How do I make any wxPython widget (like wx.Panel or wx.Button) automatically expand to fill its parent window? ...
How do I make any wxPython widget (like wx.Panel or wx.Button) automatically expand to fill its parent window? ...
I would like to use python to make system calls to programs and time them. From the Linux command line if you type: $ time prog args You get something along the lines of: real 0m0.110s user 0m0.060s sys 0m0.024s if you do a 'man time', it states that you can type: $ time -f "%E" prog args in order to format to get only...
What is the most idiomatic way to do the following? def xstr(s): if s is None: return '' else: return s s = xstr(a) + xstr(b) update: I'm incorporating Tryptich's suggestion to use str(s), which makes this routine work for other types besides strings. I'm awfully impressed by Vinay Sajip's lambda suggestion, ...
Given the output of inspect.stack(), is it possible to get the function objects from anywhere from the stack frame and call these? If so, how? (I already know how to get the names of the functions.) Here is what I'm getting at: Let's say I'm a function and I'm trying to determine if my caller is a generator or a regular function? I nee...
Hey. I have a very large array and I want to find the Nth largest value. Trivially I can sort the array and then take the Nth element but I'm only interested in one element so there's probably a better way than sorting the entire array... ...
My problem is: I have 3 procs that would like to share config loaded from the same class and a couple of queues. I would like to spawn another proc as a multiprocessing.manager to share those informations. How can I do that? Could someone purchase a sample code avoiding use of global vars and making use of multiprocessing manager clas...
I've recently started to fell in love with SQLAlchemy. You can write clean and fast SQL statements without having to write one line of SQL. There is no need to write most of the meta configuration you would need for something like Hibernate. At work I managed to create a mapper for a table which doesn't have a primary key! I can have com...
I'd like to create a Word document using Python, however, I want to re-use as much of my existing document-creation code as possible. I am currently using an XSLT to generate an HTML file that I programatically convert to a PDF file. However, my client is now requesting that the same document be made available in Word (.doc) format. S...
In Python, how do I read a binary file and loop over each byte of that file? ...
I want to receive XML in this format using Soaplib: <container> <item> <var1>foo</var1> <var2>foo</var2> <var3>foo</var3> </item> <item> <var1>foo</var1> <var2>foo</var2> <var3>foo</var3> </item> <item> <var1>foo</var1> <var2>foo</var2> <var3>f...
I have created some python code which creates an object in a loop, and in every iteration overwrites this object with a new one of the same type. This is done 10.000 times, and Python takes up 7mb of memory every second until my 3gb RAM is used. Does anyone know of a way to remove the objects from memory? ...
I can run a simple "Hello World" Google App Engine application on localhost with no problems. However, when I add the line "import gdata.auth" to my Python script I get "ImportError: No module named gdata.auth". I have installed the gdata module and added the following line to my .bashrc: export PYTHONPATH=$PYTHONPATH:/Library/Python/...
I am trying to get started with scons. I have Python 3.0.1 and downloaded Scons 1.2.0; when I try to run scons I get the following error. Am I doing something wrong here? C:\tmp\scons>c:\appl\python\3.0.1\Scripts\scons Traceback (most recent call last): File "<string>", line 1, in <module> File "c:\appl\python\3.0.1\Lib\site-package...
I am working on a latex document that will require typesetting significant amounts of python source code. I'm using pygments (the python module, not the online demo) to encapsulate this python in latex, which works well except in the case of long individual lines - which simply continue off the page. I could manually wrap these lines exc...
I have a simple Python script that uses the socket module to send a UDP packet. The script works fine on my Windows box, but on my Ubuntu Linux PC the packet it sends is slightly different. On Windows the flags field in the IP header is zero, but using the same code on Linux created a packet with the flags field set to 4. I'd like to mod...
I am tired of clicking "File" and then "Save Page As" in Firefox when I want to save some websites. Is there any script to do this in Python? I would like to save the pictures and css files so that when I read it offline, it looks normal. ...
I'm trying to convert the data from a simple object graph into a dictionary. I don't need type information or methods and I don't need to be able to convert it back to an object again. I found this question about creating a dictionary from an object's fields, but it doesn't do it recursively. Being relatively new to python, I'm concer...
I am trying to use different open source apps in my project. Problem is that there is a same Model name used by two different apps with their own model definition. I tried using: class Meta: db_table = "db_name" but it didn't work. I am still getting field name clash error at syncdb. Any suggestions. Update I am actual...
I wanted to write a server that a client could connect to and receive periodic updates without having to poll. The problem I have experienced with asyncore is that if you do not return true when dispatcher.writable() is called, you have to wait until after the asyncore.loop has timed out (default is 30s). The two ways I have tried to w...
I am trying to write a Python-based Web Bot that can read and interpret an HTML page, then execute an onClick function and receive the resulting new HTML page. I can already read the HTML page and I can determine the functions to be called by the onClick command, but I have no idea how to execute those functions or how to receive the res...