python

Python Windows service autostarts too early.

I am running a Python script as a Windows service, but it seems to be failing whenever I set it to auto-start. I believe this may be because the service uses network resources that are not yet mounted when the service starts. Is there a way I can get it to wait until startup is complete before running? ...

SQLAlchemy: avoiding repetition in declarative style class definition

I'm using SQLAlchemy, and many classes in my object model have the same two attributes: id and (integer & primary key), and name (a string). I'm trying to avoid declaring them in every class like so: class C1(declarative_base()): id = Column(Integer, primary_key = True) name = Column(String) #... class C2(declarative_base()...

Can one use negative numbers as seeds for random number generation?

Hi, This is not a coding question, but am hoping that someone has come across this in the forums here. I am using Python to run some simulations. I need to run many replications using different random number seeds. I have two questions: Are negative numbers okay as seeds? Should I keep some distance in the seeds? Currently I am usi...

Modifying Exchange ACL for folders with python

Hi folks, while try to read the ACL Table of a folder, I ran into this problem: In a C++ tool (MFCMAPI) this method is used to get the Property PR_ACL_TABLE in a usable data type: // Open the table in an IExchangeModifyTable interface EC_H(lpMAPIProp->OpenProperty( ulPropTag, (LPGUID)&IID_IExchangeModifyTable, 0, MAPI_DEFERRE...

Python: How exactly can you take a string, split it, reverse it and join it back together again?

How exactly can you take a string, split it, reverse it and join it back together again without the brackets, commas, etc. using python? ...

how to create a mdb file from a csv file in python?

I have several csv files that I need to transfer over to mdb format. I tried the answer in this post as a starting point: http://stackoverflow.com/questions/3094537/how-do-you-create-a-mdb-database-file-in-python Source: from comtypes.client import CreateObject access = CreateObject('Access.Application') from comtypes.gen import Acc...

Using PyFlakes and the del operator

When making use of del in a Python function, I'm getting false positives from PyFlakes telling me that the variable is undefined. def foo(bar): # what if it's ham? eww if bar == 'ham': del bar return # otherwise yummy! print bar The above function will return the following error: C:\temp\test.py:7: und...

Case insensitive 'in' - Python

Hi folks, I love using the expression if 'MICHAEL89' in USERNAMES: ... where USERNAMES is a list Is there any way to match items with case insensitivity or do I need to use a custom method? Just wondering if there is need to write extra code for this. Thanks to everyone! ...

Best output type and coding practices for __repr__() functions?

Lately, I've had lots of trouble with __repr__(), format(), and encodings. Should the output of __repr__() be encoded or be a unicode string? Is there a best encoding for the result of __repr__() in Python? What I want to output does have non-ASCII characters. I use Python 2.x, and want to write code that can easily be adapted to Pyt...

Python Logic Help:

I am writing a game where there are two losing conditions: Forming a word longer than 3 letters. Bee is okay, Beer is not. Forming a word that can't be made into a longer word. Zebra is okay, Zebras is not. Wordlist is a list of words, frag is the previous fragment and a is the new letter a player enters. so frag may look like 'app'...

remove item from python path

I have added a path to the system pythonpath on linux and now i've broken it. How may i remove it ? [EDIT] Finally i solved it removing the script that added that path + installing something to rebuild the path. ...

Advice on backgrounding a task with variables?

I have a python webapp which accepts some data via POST. The method which is called can take a while to complete (30-60s), so I would like to "background" the method so I can respond to the user with a "processing" message. The data is quite sensitive, so I'd prefer not to use any queue-based solutions. I also want to ensure that the b...

Python - How do I save a file delivered from html?

Hi I have a form which when submitted by a user redirects to a thank you page and the file chosen for download begins to download. How can I save this file using python? I can use python's urllib.urlopen to open the url to post to but the html returned is the thank you page, which I suspected it would be. Is there a solution that allow...

How to read wav file using scipylab in Python?

Hi folks... Can you please help me with this? ...

How can I move file into Recycle Bin / trash on different platforms using PyQt4?

I would like to add the next feature to my cross-platform PyQt4 application: when user selects some file and select "remove" action on it that file will be moved to Recycle Bin folder instead of being permantly removed. I think I can find Windows-specific solution using Win32 API or something similar, but I'd like to know does similar op...

Setting up orbited development environment on windows.

Hi I am developing a comet application using python orbited and django. But I don't know how to setup the development environment. Can any one please help me out? I looked at the documentations and tutorials... But I found them confusing... What I am looking is a walk-through kind of information. ...

How to setup APE server on windows.

Hi Can any one help me set-up APE Server on windows machine... I have installed it in Ubuntu in Virtual Box. But can't access on host windows... ...

Is there an Eclipse personality settings for Wing IDE?

While PyDev turns out to be a great IDE for python, especially if you are a former Java developer accustomed to all the eclipse ubercool navigation, it still lacks some features that Wing has, like GUI for running python unit-tests. I know Wing has some "personalities" of other editors: vi, emacs, Visual Studio, ... Unfortunately, Eclip...

Programming Neural Networks with Python?

I'm a College student (Economics) and I want to program some monetary models using Neural Networks. I want those models to be able to predict future values of some variables using economic data, but I really don't know how to "model" the program itself. Is there any good Python module for that? I mean, a module for NN and a module for ec...

Would twisted be a good choice for building a multi-threaded server?

I need to pull from hundreds of pop3 email accounts, and i want to build a robust server to do this. Would twisted be a good choice for this type of project? Right now a simple prototype would be to pull from a single pop3 account, then it would pull from many but it would be a serialized process. I want to create a server that has mu...