I've written a container type in Python and I'm trying to write a robust __repr__ method that correctly handles the case where the container contains itself.
For example, here's what the built-in list does:
>>> x = []
>>> x.append(x)
>>> repr(x)
'[[...]]'
Container types written in C for CPython can achieve this functionality by usin...
I have a python script which runs a particular script large number of times (for monte carlo purpose) and the way I have scripted it is that, I queue up the script the desired number of times it should be run then I spawn threads and each thread runs the script once and again when its done.
Once the script in a particular thread is fini...
Hi,
I'm trying to create a database connection in a python script to my DB2 database. When the connection is done I've to run some different SQL statements.
I googled the problem and has read the ibm_db API (http://code.google.com/p/ibm-db/wiki/APIs) but just can't seem to get it right.
Here is what I got so far:
import sys
import ge...
Hello, I'm working on developing a GUI for the recompilation of Linux kernel. For this I need to implement 4-5 Linux commands from Python. I use Qt as GUI designer. I have successfully implemented the commands using os.system() call. But the output is obtained at the console. The real problem is the output of command is a listing that ...
Is it possible to have multi-level polymorphism in SQLAlchemy? Here's an example:
class Entity(Base):
__tablename__ = 'entities'
id = Column(Integer, primary_key=True)
created_at = Column(DateTime, default=datetime.utcnow, nullable=False)
entity_type = Column(Unicode(20), nullable=False)
__mapper_args__ = {'polymorph...
I am having trouble reading a csv file, delimited by tabs, in python. I use the following function:
def csv2array(filename, skiprows=0, delimiter='\t', raw_header=False, missing=None, with_header=True):
"""
Parse a file name into an array. Return the array and additional header lines. By default,
parse the header lines into ...
I'm doing a little program and I want to distribute it using this recipe:
single directory with __main__.py in it
zip this directory and adding a shebang on it #!/usr/bin/env python
making it executable
The problem is that in this package I have also extra files (I'm using pygtk toolkit and I need images and ui xml files). When I try...
Is there a clean way to have your fabfile take command line arguments? I'm writing an installation script for a tool that I want to be able to specify an optional target directory via the command line.
I wrote some code to test what would happen if I passed in some command line arguments:
# fabfile.py
import sys
def install():
_g...
I've got a simple class that gets most of its arguments via init, which also runs a variety of private methods that do most of the work. Output is available either through access to object variables or public methods.
Here's the problem - I'd like my unittest framework to directly call the private methods called by init with different ...
I need to store a undirected graph in a Google App Engine database.
For optimization purposes, I am thinking to use database indexes.
Using Google App Engine, is there any way to define the columns of a database table to create its index?
I will need some optimization, since my app uses this stored undirected graph on a content-based fi...
given a list of python strings, how can I automatically convert them to their correct type? Meaning, if I have:
["hello", "3", "3.64", "-1"]
I'd like this to be converted to the list
["hello", 3, 3.64, -1]
where the first element is a stirng, the second an int, the third a float and the fourth an int.
how can I do this? thanks....
While trying to work with Mercurial on project located on TrueCrypt partition I always get en error as follows:
** unknown exception encountered, details follow
** report bug details to http://mercurial.selenic.com/bts/
** or [email protected]
** Mercurial Distributed SCM (version 1.5.2+20100502)
** Extensions loaded:
Traceback (mo...
Hi,
Would it be possible to create a class interface in python and various implementations of the interface.
Example: I want to create a class for pop3 access (and all methods etc.). If I go with a commercial component, I want to wrap it to adhere to a contract.
In the future, if I want to use another component or code my own, I wan...
Hi,
Could someone tell me how to get the parent directory of a path in Python in a cross platform way. E.g.
C:\Program Files ---> C:\
and
C:\ ---> C:\
If the directory doesn't have a parent directory, it returns the directory itself. The question might seem simple but I couldn't dig it up through Google.
Thanks.
...
I want to do some funky things with controlling MIDI streams, and I'd like to be able to pipe MIDI input into an application like Ableton or Reason. Presumably this involves some sort of driver level work?
Ultimately I'd like to write my application in Python, so if there is some Python-based solution, I'd consider it. I'm perfectly fi...
hi,
I have a wxPython application. I am taking in a directory path from a textbox using GetValue().
I notice that while trying to write this string to a variable:
"C:\Documents and Settings\tchan\Desktop\InputFile.xls",
python sees the string as
'C:\\Documents and Settings\tchan\\Desktop\\InputFile.xls' (missing a slash between "...
Hello people.
I'd like to know if the absence of element ordering of the Python's built-in set structure is "random enough". For instance, taking the iterator of a set, can it be considered a shuffled view of its elements?
(If it matters, I'm running Python 2.6.5 on a Windows host.)
...
If I use M-x shell and run the interactive Python interpreter, Emacs on Windows does not return any IO.
When I discovered M-x python-shell, I regained hope. However, instead of running the interactive Python shell, I want to run a specific Python script that features an interactive CLI. (See Python's cmd module for details).
Is there...
Is there library to edit WMV metadata using Python or PHP? I tried editing with ffmpeg but it just creates a new video file(with edited tags) rather than just editing the tags.
...
I apologize for yet another __init__.py question.
I have the following package structure:
+contrib
+--__init__.py
|
+database
+--__init__.py
|
+--connection.py
In the top-level __init__.py I define: USER='me'. If I import contrib from the command line, then I can access contrib.USER.
Now, I want to access co...