python

Python Debugging

I'm not sure if 'debugging' is the right word, but I'm looking for a tool/IDE that would show my which statement/block will be executed next in a particular module. This feature I remember was available in Turbo C++ years back so I assume something similar might be available in some Python IDE? Thanks ...

Python Encoding Issue

I am really lost in all the encoding/decoding issues with Python. Having read quite few docs about how to handle incoming perfectly, i still have issues with few languages, like Korean. Anyhow, here is the what i am doing. korean_text = korean_text.encode('utf-8', 'ignore') korean_text = unicode(korean_text, 'utf-8') I save the above ...

Multithreading python application hangs while running its threads.

I am trying to create a MainObject which is availible as a DBus service. This MainObject should always stay responsive to other objects/processes and for this non-blocking even while processing its items. for that reason items are processed in a seperate thread one after another (queue-style). You can add items to the MainObject via DBus...

python equivalent of '#define func() ' or how to comment out a function call in python

my python code is interlaced with lots of function calls used for (debugging|profiling|tracing etc.) for example: import logging logging.root.setLevel(logging.DEBUG) logging.debug('hello') j = 0 for i in range(10): j += i logging.debug('i %d j %d' % (i,j)) print(j) logging.debug('bye') i want to #define these resource consumi...

Click overlay for html page with click stats

How would you setup click overlay for html page that has click stats with number of clicks stored. Is there a jquery example for something like this. The ideal click overlay will have have a little box on top on each link with how many times it was clicked. ...

making undo in python

hello first of all .. sorry if my english was bad. its my 3rd language im working on a paint software that draw over images and save them again ( for commenting propose ) i use pile and wxpython. but im still having problems with some features .. what is the ideal way to make the undo option ? another question .. when the user scal...

Executing python script in background in init.d

to interact with my iPhone, i have created a python script that sends and recives data through a socket, the script must be started after emule in order to work, i have thought of something like this: PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DAEMON=/usr/local/bin/amuled WEB=/usr/local/bin/amuleweb NAME=amuled DE...

How to share data between python processes without writing to disk.

Helllo, I would like to share small amounts of data (< 1K) between python and processes. The data is physical pc/104 IO data which changes rapidly and often (24x7x365). There will be a single "server" writing the data and multiple clients reading portions of it. The system this will run on uses flash memory (CF card) rather than a hard d...

Email multiple contacts in Python

Hello, I am trying to send an email to multiple people. The code below shows what I'm trying to do. When I add 2 addresses the email does not send to the second person. The code is: me = '[email protected]' you = '[email protected], [email protected]' msg['Subject'] = "The Nightly Build Results" msg['From'] = me msg['To'] = you # Send the message...

How can I disable clear of clipboard on exit of PyQt4 application?

I have a simple PyQt4 application (see the code below) that reveals next problem: if I select the text from QLineEdit and copy it to clipboard then I can paste it to another application only while my application is running. It seems that on exit PyQt application clears the clipboard so I can't paste the text after the application is clos...

Piston customize response representation

I am using piston and I would like to spit out a custom format for my response. My model is something like this: class Car(db.Model): name = models.CharField(max_length=256) color = models.CharField(max_length=256) Now when I issue a GET request to something like /api/cars/1/ I want to get a response like this: {'name' : 'BMW'...

pygtk: cannot set parent on toplevel widget

I'm working on a project that has a glade GUI. I need the main window to have 2 section, divided by a gtk.Hpaned widget (horizontal panes). The left pane would have a tool-bar like layout of buttons, maybe 3 or more. What I need is a way to create different windows and display them on the right pane of the main window. This way, when ...

How to get the difference between two list based on substrings withing each string in the seperate lists.

I have two long list, one from a log file that contains lines formatted like 201001050843 blah blah blah <[email protected]> blah blah and a second file in csv format. I need to generate a list of all the entries in file2 that do not contain a email address in the log file, while maintaining the csv format. Example Log file contains: 2...

Python decorator with instantiation-time variable?

I want to make a decorator that creates a new function/method that makes use of an object obj. If the decorated object is a function, obj must be instantiated when the function is created. If the decorated object is a method, a new obj must be instantiated and bound to each instance of the class whose method is decorated. I can't put the...

How to use C# client to consume Django/Python web service (all methods are returning null)?

I have a C# command-line client that I'm testing the consumption of SOAP/WSDL via Django/Python/soaplib created WSDL. I've managed to successfully connect to the web service by adding a service reference. I then call one of service's methods, and the service processes the data I send, but it returns null instead of the integer I'm expect...

Can you recommend an Amazon AMI for Python?

I want to remove as much complexity as I can from administering Python in on Amazon EC2 following some truly awful experiences with hosting providers who claim support for Python. I am looking for some guidance on which AMI to choose so that I have a stable and easily managed environment which already included Python and ideally an Apac...

How to debug dynamically defined functions in Python?

Is there a way to debug a function that is defined dynamically in run time? Or at least is there an easy way to find out where this function is produced? Update to give more detail: I used inspect module: ipdb> inspect.getmodule(im.get_thumbnail_url) Out[0]: <module 'django.utils.functional' from 'C:\java\python\Python25\Lib\site -p...

Display objects within a function, how to NOT terminate the program after close the display?

Hi all, see the example: from visual import * def hello(): newyear=2010 sphere() return newyear my problem here is when I call function hello(), a sphere display window shows up, and also prints 2010, however if I close the display window, the program terminates. That is not what I want, how can I avoid this? also, in my ...

Python + Facebook, getting info about a group easily

I have a need to display some basic info about a facebook group on a website i am building. All i am really looking to show is the total number of members, and maybe a list of the few most recent people who joined. I would like to not have to login to FB to accomplish this, is there an API for groups that allows anonymous access? or do...

python struct pack double

I want to convert -123.456 into a C double for network transmission in python. So I tried this: struct.pack('d', -123.456) I get this as a result: 'w\xbe\x9f\x1a/\xdd^\xc0' Obviously there is some hex in there, but what is with the w, /, and ^ sprinkled in there? ...