python

How can you check if a key is currently pressed using Tkinter in Python?

Is there any way to detect which keys are currently pressed using Tkinter? I don't want to have to use extra libraries if possible. I can already detect when keys are pressed, but I want to be able to check at any time what keys are pressed down at the moment. ...

How can I serve unbuffered CGI content from Apache 2?

I would like to be able to allow a user to view the output of a long-running GCI script as it is generated rather than after the script is complete. However even when I explicitly flush STDOUT the server seems to wait for the script to complete before sending the response to the client. This is on a Linux server running Apache 2.2.9. ...

Why isn't Django returning a datetime field from the database?

For my first Django app, I'm trying to write a simple quote collection site (think bash.org), with really simple functionality, just to get my feet wet. I'm using sqlite as my database, since it's the easiest to setup. Here's my only model right now: class Quote(models.Model): text = models.TextField(); upvotes = models.Intege...

emulating LiveHTTPheader in server side script or javascript?

Hi folks, I ran into this problem when scraping sites with heavy usage of javascript to obfuscate it's data. For example, "a href="javascript:void(0)" onClick="grabData(23)"> VIEW DETAILS This href attribute, reveals no information about the actual URL. You'd have to manually look and examine the grabData() javascript function to ge...

dynamic plotting in wxpython

Hi all, I have been developing a GUI for reading continuous data from a serial port. After reading the data, some calculations are made and the results will be plotted and refreshed (aka dynamic plotting). I use the wx backend provided in the matplotlib for this purposes. To do this, I basically use an array to store my results, in whic...

Practical point of view: Why would I want to use Python with C++ ?

I've been seeing some examples of Python being used with c++, and I'm trying to understand why would someone want to do it. What are the benefits of calling C++ code from an external language such as Python? I'd appreciate a simple example - Boost::Python will do ...

Controlling mouse with Python

How to control mouse in Python, i.e. move it to certain position and click. Thank you, Sasha ...

Python Base 36 Encoding

Hi, how can I encode an integer with Base 36 in Python and then decode it again? Thanks, Max ...

cx_Oracle MemoryError when reading lob

When trying to read data from a lob field using cx_Oralce I’m receiving “exceptions.MemoryError”. This code has been working, this one lob field seems to be too big. Example: xml_cursor = ora_connection.cursor() xml_cursor.arraysize = 2000 try: xml_cursor.execute(“select xml_data from xmlTable where id = 1”) for row_data in xml...

Python: Multicore processing?

I've been reading about Python's multiprocessing module. I still don't think I have a very good understanding of what it can do. Let's say I have a quadcore processor and I have a list with 1,000,000 integers and I want the sum of all the integers. I could simply do: list_sum = sum(my_list) But this only sends it to one core. Is i...

How can I launch a background process in Pylons?

I am trying to write an application that will allow a user to launch a fairly long-running process (5-30 seconds). It should then allow the user to check the output of the process as it is generated. The output will only be needed for the user's current session so nothing needs to be stored long-term. I have two questions regarding how t...

Alice vs Python for someone with zero experience

My brother would like to learn some programming to find out if he'd enjoy doing it. He's 16 and doesn't know much about computers in general and knows nothing about programming in particular. I'm thinking about picking either Alice or Python. I see Think Python is the often recommended read, but isn't it a bit too much (size-wise) for a...

Python dictionary/list help

This is a python application that's supposed to get all the followers from one table and get their latest updates from another table. - All happening in the dashboard. dashboard.html: http://bizteen.pastebin.com/m65c4ae2d the dashboard function in views.py: http://bizteen.pastebin.com/m39798bd5 result: http://bizteen.pastebin.com/m...

How to get the distinct value of one of my models in Google App Engine

I have a model, below, and I would like to get all the distinct area values. The SQL equivalent is select distinct area from tutorials class Tutorials(db.Model): path = db.StringProperty() area = db.StringProperty() sub_area = db.StringProperty() title = db.StringProperty() content = db.BlobProperty() rating =...

python script for downloading all Ctrl+Alt+Del webcomics?

Does anyone have one? Ive tried Comicdownloader but that only lets me download the newest comic and I dont understand Python well enough to figure out how to change it to download all the comics edit: Solved by anderstornvig thanks man ...

To SHA512-hash a password in MySQL database by Python

This question is based on the answer. I would like to know how you can hash your password by SHA1 and then remove the clear-text password in a MySQL database by Python. How can you hash your password in a MySQL database by Python? ...

Is there something like Python's 'with' in C#?

Python has a nice keyword since 2.6 called with. Is there something similar in C#? ...

Web service: PHP or Ruby on Rails or Python?

I am a .Net / SQL Server developer via my daytime job, and on the side I do some objective C development for the iPhone. I would like to develop a web service and since dreamhost supports mySql, python, ruby on rails and PHP5, I would like to create it using one of those languages. If you had no experience in either python, Ruby on Rai...

Python: Zope's BTree OOSet, IISet, etc... Effective for this requirement?

I asked another question: http://stackoverflow.com/questions/1180240/best-way-to-sort-1m-records-in-python where I was trying to determine the best approach for sorting 1 million records. In my case I need to be able to add additional items to the collection and have them resorted. It was suggested that I try using Zope's BTrees for t...

Unbuffered read from process using subprocess in Python

I am trying to read from a process that produces long and time-consuming output. However, I want to catch it's output as and when it is produced. But using something like the following seems to be buffering the command's output, so I end up getting the output lines all at once: p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIP...