python

How do I edit the url in python and open a new page without having a new window or tab opened?

I am trying to create a python script that opens a single page at a time, however python + mozilla make it so everytime I do this, it opens up a new tab. I want it to keep just a single window open so that it can loop forever without crashing due to too many windows or tabs. It will be going to about 6-7 websites and the current code i...

python: saving images on disk

is there i can save images on disk using python an example of an image would be: http://chart.apis.google.com/chart?chxl=1:|0|10|100|1%2C000|10%2C000|100%2C000|1%2C000%2C000|2:||Excretion+in+Nanograms+per+gram+creatinine+milliliter+(logarithmic+scale)|&chxp=1,0|2,0&chxr=0,0,12.1|1,0,3&chxs=0,676767,13.5,0,lt,676767|1,676767...

intellisense for eclipse

Does anyone know how to get an intellisense like functionality (better than default) in eclipse for python development? I am using Eclipse 3.5 with aptana and pydev and the interpreter is python 2.5.2 ...

How do I do conditional array arithmetic on a numpy array?

Hey all, I'm trying to get a better grip on numpy arrays, so I have a sample question to ask about them: Say I have a numpy array called a. I want to perform an operation on a that increments all the values inside it that are less than 0 and leaves the rest alone. for example, if I had: a = np.array([1,2,3,-1,-2,-3]) I would want to...

Django Filtering MySQL Warnings

Hi all, Before you all point me to here and here mine a bit different. So I started getting the famous error after shifting to my production server. django/db/backends/mysql/base.py:86: Warning: Data truncated for column 'slug' at row 1 The first thing I did was start googling this after I fixed the problem. To fix this, I tweak...

Uploading a video to google app engine blobstore

I'm trying to associate a video file to a record with a bunch of properties, but can't seem to allow the user to do everything in one form - name the video, provide description and answer some question, AND upload the file. Here are the steps I'd like to perform: User is served with a page containing a form with the following fields: ...

How to handle undecodable filenames in Python?

I'd really like to have my Python application deal exclusively with Unicode strings internally. This has been going well for me lately, but I've run into an issue with handling paths. The POSIX API for filesystems isn't Unicode, so it's possible (and actually somewhat common) for files to have "undecodable" names: filenames that aren't e...

how to determine if a variable exists in another python file

I have two python files. From python file #1, I want to check to see if there is a certain global variable defined in python file #2. What is the best way to do this? ...

Problems with the relation one to many

Hello, I got this error when I've tried to relate some classes: "UnmappedClassError: Class 'zeppelinlib.user.UserTest.User' is not mapped" I don't get errors when I have relation many-to-many. This is my file where I store all the User classes. user_channels = Table( "user_channels", metadata, Col...

Appengine Blobstore - Video Streaming

Hey folks, I'm trying to setup a video streaming app via the Google Appengine Blobstore. Just wanted to know if this was possible, as there isn't too much regarding this in the Appengine Documentation. Basically I want to serve these videos through a flash player. Thanks ...

Python threading.Event() - Ensuring all waiting threads wake up on event.set()

I have a number of threads which wait on an event, perform some action, then wait on the event again. Another thread will trigger the event when it's appropriate. I can't figure out a way to ensure that each waiting thread triggers exactly once upon the event being set. I currently have the triggering thread set it, sleep for a bit, the...

Accessing Dictionaries VS Accessing Shelves

Currently, I have a dictionary that has a number as the key and a Class as a value. I can access the attributes of that Class like so: dictionary[str(instantiated_class_id_number)].attribute1 Due to memory issues, I want to use the shelve module. I am wondering if doing so is plausible. Does a shelve dictionary act the exact same as a...

subprocess.Popen() and Shell=True results in error 'The syntax of the command is incorrect'

Hi everyone. I seem to have discovered a problem with subprocess.Popen() on a Windows XP x64 machine. If Popen() is called with Shell=True, instead of a subprocess being created, the error The syntax of the command is incorrect is printed to the command prompt. The problem was discovered when trying to use Mercurial on the comman...

Define dTypes in NumPy using a list?

Hi, I just am having a problem with NumPy dtypes. Essentially I'm trying to create a table that looks like the following (and then save it using rec2csv): name1 name2 name3 . . . name1 # # # name2 # # # name2 # # # . . . The matrix (numerical array in the center), is already computed bef...

wxPython: how to determine source of an event

I have a Panel with several images on it, each of which is bound to the same event handler. How can I determine which image is being clicked from the event handler? I tried using Event.GetEventObject() but it returns the parent panel instead of the image that was clicked. Here's some sample code: import math import wx class MyFrame(wx...

python: unhashable type error

Traceback (most recent call last): File "<pyshell#80>", line 1, in <module> do_work() File "C:\pythonwork\readthefile080410.py", line 14, in do_work populate_frequency5(e,data) File "C:\pythonwork\readthefile080410.py", line 157, in populate_frequency5 data=medications_minimum3(data,[drug.upper()],1) File "C:\pythonwo...

python, svn, deploy applications with shared code

I have a few related applications that I want to deploy to different computers. They each share a large body of common code, and have some things unique to them. For example, I have a server and a client which use a lot of common classes to communicate to each other. I have yet more servers and clients which use some of the same classes,...

Writing a Shell in Python?

Why is this such a bad idea? (According to many people) ...

What is the difference between StringIO and io.StringIO in Python2.7?

Besides the obvious (one is a type, the other a class)? What should be preferred? Any notable difference in use cases, perhaps? ...

Python module paramiko cannot connect as paramiko.Tranport((host,port)).connect(username = username, password = password)

This is an example which works fine on friend's computer: import paramiko host = "157.178.35.134" port = 222 username = "stackoverflow" password = "e2fghK3" transport = paramiko.Transport((host, port)) transport.connect(username = username, password = password) sftp = paramiko.SFTPClient.from_transport(transport) import sys path = ...