python

Why can't I write all the data from sys.stdin to a file in Windows?

I am trying to read binary data from sys.stdin using Python 2.7 on Windows XP. The binary data is a WAV file decoded by foobar2000. Normally, this data is sent to a command-line encoder such as lame.exe on stdin, where it is processed and written to an output file whose name is provided in the command-line arguments. I am trying to inter...

In Python is it bad to create an attribute called 'id'?

I know that there's a function called id so I wouldn't create a function or a variable called id, but what about an attribute on an object? ...

How to filter columns in two tables with many-to-many relation?

Hello, I have this table: channel_items = Table( "channel_items", metadata, Column("channel_id", Integer, ForeignKey("channels.id")), Column("media_item_id", Integer, ForeignKey("media_items.id")) ) class Channel(rdb.Model): """Set up channels table in the database""" rdb.metadata(metadata) ...

Upload an image file using python

Hello, Is there a way of uploading an image file using python ?. Im able to upload files from a simple html page consisting of the code below.But i would like to be able to do that from a python program. Can it be done using urllib2 module ?. Any example i can refer to ? Please help. Thank You. <form action="http://somesite.com/handle...

get all combinations words of a string

i want all combinations words of string "my first program" ...

Using Linux redirect to overwrite file from Python script

I have a simple python script that just takes in a filename, and spits out a modified version of that file. I would like to redirect stdout (using '>' from the command line) so that I can use my script to overwrite a file with my modifications, e.g. python myScript.py test.txt > test.txt When I do this, the resulting test.txt does not c...

what python libraries should every python programmer know?

Possible Duplicate: Favorite 3rd-party Python Libraries? there is a question Favorite 3rd-party Python Libraries? i don't want know about favorite libraries, i want know a list of essential libraries. what libraries that every python programmer should know? ...

organising classes and modules in python

I'm getting a bit of a headache trying to figure out how to organise modules and classes together. Coming from C++, I'm used to classes encapsulating all the data and methods required to process that data. In python there are modules however and from code I have looked at, some people have a lot of loose functions stored in modules, wh...

Returning a tuple of multipe objects in python C api

I am writing a native function that will return multiple python objects PyObject *V = PyList_New(0); PyObject *E = PyList_New(0); PyObject *F = PyList_New(0); return Py_BuildValue("ooo", V, E, F); This compiles fine, however, when I call it from python, I get an error\ SystemError: bad format char passed to Py_BuildValue How can t...

Python: openssl segmentation fault

I followed the instrunction on this site http://paltman.com/2007/nov/15/getting-ssl-support-in-python-251/ to install openssl. When I go to test i get this as the output: test_rude_shutdown ... test_basic ... Segmentation fault How would I resolve this? ...

Need help with a word-packing algorithm

I have a list of sub-lists of letters, where the number of letters in each sub-list can vary. The list and sub-lists are ordered. This structure can be used to produce words by choosing a number X, taking a letter from position X in every sub-list and concatenating them in order. If the number X is larger than the length of the sub-list,...

How to trigger from Python playing of a WAV or MP3 audio file on a Mac?

I'm looking for an elegant way, without a ton of dependencies as in some of the solutions I googled up. Thanks for any ideas. ...

Invalid URL message when uploading an image file using urllib2

Hello, I am trying to upload an image file to piczasso.com from python. My code is as follows: import urllib,urllib2 url='http://piczasso.com/api_handler.php' values = { 'data':open('./imagefile.jpg'), 'tags':'', 'size':'None' } data = urllib.urlencode(values) req = urllib2.Request(url,data) try: respons...

Django Boto S3 Access

I can't figure this out. Here's what I want to happen ... I have an applications that users upload files to S3 using boto and django. I want those files to be private and only accessible through my app using my api credentials. So if a user uploads a photo via my app, the only way he or anyone else can download it is via his accoun...

Error when adding value to array

hey guys, when i run: with open('file00.txt') as f00: for line in f00: farr=array.append(float(line)) print "farr= ",farr i get: farr=array.append(float(line)) AttributeError: 'module' object has no attribute 'append' does anyone know why I get this? do I have to import something? am I doing it compl...

How do you find the filename that you pass to open()?

I'm trying to open a file with Python, but I'm unsure how to find the correct filename to use. ...

Using numpy's flatten_dtype with structured dtypes that have titles

Hi, I usually don't post questions on these forums, but I've searched all over the place and I haven't found anything about this issue. I am working with structured arrays to store experimental data. I'm using titles to store information about my fields, in this case the units of measure. When I call numpy.lib.io.flatten_dtype() on my ...

How to configure Eclipse for PyDev? Python doesn't appear in Preferences window.

I'm trying to install PyDev in Eclipse 3.6 on Windows 7. I have Python 2.7 successfully installed. I installed PyDev through Eclipse, and restarted. When attempting to configure Eclipse to find my installed Python, (Window -> Preferences) the list that appears does not contain Python. (See image below.) If I go back to Help -> Ins...

I'm having trouble opening a Python file :(

I saved a file as DictionaryE.txt in a Modules folder I created within Python. Then I type: fh = open("DictionaryE.txt") I get this error message: Traceback (most recent call last): File "<pyshell#17>", line 1, in <module> fh = open("DictionaryE.txt") IOError: [Errno 2] No such file or directory: 'DictionaryE.txt' What am I d...

Pure Python in Xcode

Is there a way to program using pure python in Xcode? I want something like the c++ command line utility except for python, I found a tutorial that did not work for me: (after playing around with which active architecture finally decided on i386) when trying to print "Hello, World!" I get the following error "Data Formatters temporarily ...