python

How to use session on Google app engine

Hi, im building an application using Google app engine with python, and im stuck with making a sessions. Is there any app that does that alreadyfor app engine? Thank you. ...

type of class in python

why if I do: class C(): pass type(C()) I got: <type 'instance'>, but if I do: class C(object): pass type(c()) I got: <class '__main__.c'> ? The first is not very userfull ...

How do I remove the y-axis from a Pylab-generated picture?

import pylab # matplotlib x_list = [1,1,1,1,5,4] y_list = [1,2,3,4,5,4] pylab.plot(x_list, y_list, 'bo') pylab.show() What I want to do is remove the y-axis from the diagram, only keeping the x-axis. And adding more margin to the diagram, we can see that a lot of dots are on the edge of the canvas and don't look good. ...

Display array as raster image in python

I've got a numpy array in Python and I'd like to display it on-screen as a raster image. What is the simplest way to do this? It doesn't need to be particularly fancy or have a nice interface, all I need to do is to display the contents of the array as a greyscale raster image. I'm trying to transition some of my IDL code to Python with...

Changing the active database in django

Hello, i'm writing a testing application that i'm using to test the rest of my code base. What i'd like to be able to do for it is when i test using this manage.py command, automatically change to be logging to a different database. is there a good way to do this? ...

Installing a module/script in Python on OSX

Hi, I am running Python 2.6.2 in Mac OSX 10.5.8. I am trying to generate scientific graphs for a publication and am experimenting with python/matplotlib to do that. Varun Hiremath created a module called plot_settings.py (link text and I am trying to figure out how to install the module so that I can import it. I'm not sure if easy_in...

Is appengine Python datastore query much (>3x) slower than Java?

I've been investigating the appengine to see if I can use it for a project and while trying to choose between Python and Java, I ran into a surprising difference in datastore query performance: medium to large datastore queries are more than 3 times slower in Python than in Java. My question is: is this performance difference for datast...

python: how to get numbers after decimal point?

how do i get the numbers after a decimal point? for example if i have 5.55 how do i get .55? ...

random object in GAE python

Possible Duplicate: Fetching a random record from the Google App Engine Datastore? Hi there, I'm looking for an equivalent of Entry.objects.order_by('?') without using Django. I just want to get a random instance of my model using GAE datastore. ...

python: breaking a string into substrings using a for loop

i have a string like this: row='saint george 1739 1799 violin concerti g 029 039 050 symphonie concertante for two violins g 024 bertrand cervera in 024 039 christophe guiot in 024 029 and thibault vieux violin soloists orchestre les archets de paris' i have this loop: for n in range (1,int(len(row)/55)+1): print row[(n-1)*55:n*55] ...

PyQT4 and Ctrl C

I have a programs that runs several threads (on a while loop until Ctrl C is pressed). The app also has a GUI that I developed in PyQt. However, I am facing the following problem: If I press Ctrl C on the console, and then close the GUI, the program exits fine. However, if I close the GUI first, the other threads won't stop and the prog...

python: turning textwarp into a list

i have a variable: row='saint george 1739 1799 violin concerti g 029 039 050 symphonie concertante for two violins g 024 bertrand cervera in 024 039 christophe guiot in 024 029 and thibault vieux violin soloists orchestre les archets de paris' i am doing this: textwrap.fill(row,55) i would like some list line to have line[0]='saint...

switch case in python doesn't work; need another pattern

Hello, I need a help with a code here, i wanted to implement the switch case pattern in python so like some tutorial said , i can use a dictionary for that but here is my problem: # type can be either create or update or .. message = { 'create':msg(some_data), 'update':msg(other_data) # can have more ...

How to get setuptools to use a relative path in easy-install.pth when doing "setup.py develop"

I'm installing a python egg using setuptools with the "python setup.py develop" command. It's important that all install paths be relative. I see that I can do: python setup.py develop --egg-path ../../../../my_directory and the .egg-link file uses that relative path. However, the path added to easy-install.pth still is an absolute...

Tuple to string

Hi there. I have a tuple. tst = ([['name', u'bob-21'], ['name', u'john-28']], True) And I want to convert it to a string.. print tst2 "([['name', u'bob-21'], ['name', u'john-28']], True)" what is a good way to do this? Thanks! ...

Basic Widget Interaction with PyQt

Hi, Please can someone tell me what im doing wrong here with respect to calling pwTxt.text. #!/usr/bin/python import sys from PyQt4 import QtCore, QtGui from mainwindow import Ui_MainWindow class MyForm(QtGui.QMainWindow): def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) self.ui = Ui_MainWind...

Available properties for a WnckWindow

There are .get_property, .set_property, .get_properties and .set_properties available in the wnck.Window (WnckWindow) class, but what are the available properties one can use here? ...

How to distinguish different types of NaN float in Python

I'm writing Python 2.6 code that interfaces with NI TestStand 4.2 via COM in Windows. I want to make a "NAN" value for a variable, but if I pass it float('nan'), TestStand displays it as IND. Apparently TestStand distinguishes between floating point "IND" and "NAN" values. According to TestStand help: IND corresponds to Signaling NaN ...

Letting users to choose what type of content they want to input

Hi, This is my first post here, and I'd like to describe what I want to do as specific as possible. I'd like to make a model that is 'selectable.' for example, class SimpleModel(models.Model): property = models.CharField(max_length=255) value = GeneralField() GeneralField can be "CharField", "URLField", "TextField" so that ...

Why does initializing a variable via a python default variable keep state across object instantiation?

I hit an interesting python bug today in which instantiating a class repeatedly appears to be holding state. In later instantiation calls the variable is already defined. I boiled down the issue into the following class/shell interaction. I realize that this is not the best way to initialize a class variable, but it sure should not be ...