python

For Django models, is there a shortcut for seeing if a record exists?

Say I have a table 'People', is there a way to just quickly check if a People object exists with a name of 'Fred'? I know I can query People.objects.filter(Name='Fred'), and then check the length of the returned result, but is there a way to do it in a more elegant way? ...

Trying to monitor a number of remote MySQL connections

I'm trying to monitor a number of remote database connections. How can I constantly monitor a GMail account for routing emails based on their header within the same application? This will need to be standalone or basic package. Should I build a Qt or .NET app for this? ...

What's the fastest way to strip and replace a document of high unicode characters using Python?

I am looking to replace from a large document all high unicode characters, such as accented Es, left and right quotes, etc., with "normal" counterparts in the low range, such as a regular 'E', and straight quotes. I need to perform this on a very large document rather often. I see an example of this in what I think might be perl here: ht...

How should I build a simple database package for my python application?

I'm building a database library for my application using sqlite3 as the base. I want to structure it like so: db/ __init__.py users.py blah.py etc.py So I would do this in Python: import db db.users.create('username', 'password') I'm suffering analysis paralysis (oh no!) about how to handle the database connect...

What speech libraries are available in Linux?

When it comes to TTS (text-to-speech) libraries in Linux, what choices do developers have? What libraries ship with the majority of distros? Are there minimal libraries? What functionality does each library offer? I'm approaching this primarily from a C++ point of view, although Python would suit me too. ...

Any other way to import data files(like .csv) in python sqlite3 module ?[not insert one by one]

in sqlite3's client CLI, there is " .import file TABLE_name " to do it. But, I do not want to install sqlite3 to my server at present. in python sqlite3 module, we can creat and edit a DB. But, I have not found a way to import data-file to a TABLE, except inserting rows one by one. any other way? Thanks. ...

How to hide Cygwin Python console window in Windows?

How to hide Cygwin Python console window in Windows? Neither pythonw, nor renaming to *.pyw does not seem to apply here, since Cygwin is a different build from regular Windows CPython build. ...

comprehensive beginner's tutorial for python and sqlite?

looking for a good tutorial for learning sqlite in python- with a focus on the sql, not the bindings specifically, one that assumes no prior knowledge of sql ...

Efficient job progress update in web application

Hi, Creating a web application (Django in my case, but I think the question is more general) that is administrating a cluster of workers doing queued jobs, there is a need to track each jobs progress. When I've done it using database UPDATE (PostgreSQL in this case), it severely hits the database performance, because each UPDATE create...

How can I create a key using RSA/ECB/PKCS1Padding in python?

I am struggling to find any method of using RSA in ECB mode with PKCS1 padding in python. I've looked into pyCrypto, but they don't have PKCS1 padding in the master branch (but do in a patch). Nevertheless I found RSA with PKCS1 in the M2Crypto package, but I'm not sure if I can choose ECB mode... ...

ropemacs USAGE tutorial

There are many sites with instructions on installing ropemacs, but so far I couldn't find any with instructions on how to use it after it's already installed. I have it installed, or at least it seems so, Emacs has "Rope" menu in it's top menu bar. Now what? So far I could use only "Show documentation" (C-c d by default). An attempt to u...

Advantages of using *args in python instead of passing a list as a parameter

Hello, python newbie here. I'm going through python and I was wondering what are the advantages of using the *args as a parameter over just passing a list as a parameter, besides aesthetics? ...

deployment public keys

How do you guys deploy your code on your servers? I am using Fabric and Python and I would like a more automated way of pulling code from the repository through the use of public keys, but without any ops or manual intervention to set up the public keys. Are you storing them in the code as text or in a database and generate the pk file ...

Show escaped string as Unicode in Python

Hello, i have just known Python for few days. Unicode seems to be a problem with Python. i have a text file stores a text string like this '\u0110\xe8n \u0111\u1ecf n\xfat giao th\xf4ng Ng\xe3 t\u01b0 L\xe1ng H\u1ea1' i can read the file and print the string out but it displays incorrectly. How can i print it out to screen correctly ...

How to start a Python script several functions in

Hello, I have a Python script and I want to call it several functions down the script. Example code below: class Name(): def __init__(self): self.name = 'John' self.address = 'Place' self.age = '100' def printName(self): print self.name def printAddress(self): print self.address ...

what is the '<app-directory>' of remote_api in google-app-engine

http://code.google.com/intl/en/appengine/docs/python/tools/uploadingdata.html the api is : Downloading Data from App Engine To start a data download, run appcfg.py download_data with the appropriate arguments: appcfg.py download_data --config_file=album_loader.py --filename=album_data_archive.csv --kind=Album <app-directory> i want...

Estimating the boundary of arbitrarily distributed data

I have two dimensional discrete spatial data. I would like to make an approximation of the spatial boundaries of this data so that I can produce a plot with another dataset on top of it. Ideally, this would be an ordered set of (x,y) points that matplotlib can plot with the plt.Polygon() patch. My initial attempt is very inelegant: ...

Python (Django). Store telnet connection

Hello. I am programming web interface which communicates with cisco switches via telnet. I want to make such system which will be storing one telnet connection per switch and every script (web interface, cron jobs, etc.) will have access to it. This is needed to make a single query queue for each device and prevent huge cisco processor ...

Marquee style progressbar in wxPython

Hi, Could anyone tell me how to implement a marquee style progress bar in wxPython? As stated on MSDN: you can animate it in a way that shows activity but does not indicate what proportion of the task is complete. Thank you. I tried this but it doesn't seem to work. The timer ticks but the gauge doesn't scroll. Any help? ...

Using Django with mod_wsgi

When you use Django with mod_wsgi, what exactly happens when a user makes a request to the server from a browser? Does apache load up your Django app when it starts and have it running in a separate process? Does it create a new Python process for every HTTP request? ...