python

Python handing of Web Forms

Hi, I am having some trouble generating a web form using fields specified in an ascii file. What I want to do is the following: 1) Read in the ascii file. This is of the form (can have N elements): Object1 value1 Object2 value2 Object3 value3 Object4 value4 ... 2) Generate a web form from the ascii file contents. Each line in the a...

How can I turn a single element in a list into multiple elements using Python?

I have a list of elements, and each element consists of four seperate values that are seperated by tabs: ['A\tB\tC\tD', 'Q\tW\tE\tR', etc.] What I want is to create a larger list without the tabs, so that each value is a seperate element: ['A', 'B', 'C', 'D', 'Q', 'W', 'E', 'R', etc.] How can I do that in Python? I need it for my cou...

Problem running a Python program, error: Name 's' is not defined.

Here's my code: #This is a game to guess a random number. import random guessTaken = 0 print("Hello! What's your name kid") myName = input() number = random.randint(1,20) print("Well, " + myName + ", I'm thinking of a number between 1 and 20.") while guessTaken < 6: print("Take a guess.") guess = input() guess = int(guess)...

How can I maximize a specific window with Python?

I'm trying to maximize a specific window with python... Here is the deal: I have a script that opens 2 firefox windows (selenium rc), and I need to maximize the second window, the last one that opens... How can I do it? I'm using this command window = win32gui.GetForegroundWindow() win32gui.MoveWindow(window, 0, 0, 1440, 900, True) ...

Python: can't pickle module objects error

i'm trying to pickle a big class and getting "TypeError: can't pickle module objects". despite looking around the web, i can't exactly figure out what this means. and i'm not sure which "module object" is causing the trouble. is there a way to find the culprit? the stack trace doesn't seem to indicate anything. ...

Are there commerical companies using google appengine? is it stable for production?

Are there commerical companies using google appengine? is it stable for production? ...

Can i pass class method as and a default argument to another class method

i want to to pass class method as and a default argument to another class method, so that i can re-use the method as a @classmethod @classmethod class foo: def func1(self,x): do somthing; def func2(self, aFunc = self.func1): # make some a call to afunc afunc(4) this why when the method func2 is called within the class aFunc de...

Convert seconds to end to date format.

Hi! SOAP client return seconds to end event. How can I get from this seconds date in format "yyy-mm-dd hh:ii:ss" ...

Matplotlib Contour Clabel Location

I would like to control the location of matplotlib clabels on a contour plot, but without utilizing the manual=True flag in clabel. For example, I would like to specify an x-coordinate, and have labels created at the points that pass through this line. I see that you can get the location of the individual labels using get_position(), but...

How do I take out the focus or minimize a window with Python?

I need to get focus to a specified window, and the only way I'm seeing on my head, is minimizing all windows on front of it until I get the right one... How can I do it? Windows 7, and no specific toolkit.... Every type of window, for example, firefox and console command ...

Passing C++ object to C++ code through Python?

Hi all, I have written some physics simulation code in C++ and parsing the input text files is a bottleneck of it. As one of the input parameters, the user has to specify a math function which will be evaluated many times at run-time. The C++ code has some pre-defined function classes for this (they are actually quite complex on the mat...

Can you authenticate Facebook Graph entirely from command line with Python?

I'm writing a (tabbed) application for Facebook that requires a background process to run on a server and, periodically, upload images to an album on this application's page. What I'm trying to do is create a script that will: a) authenticate me with the app b) upload an image to a specific album All of this entirely from the command...

Why do you need this method inside a Django model ?

Class mytable(models.Model): abc = ... xyz = ... def unicode(self): Why is the def ___unicode___ necessary? ...

testing existing attribute of a @classmethod function, yields AttributeError

i have a function which is a class method, and i want to test a attribute of the class which may or may not be None, but will exist always. class classA(): def __init__(self, var1, var2 = None): self.attribute1 = var1 self.attribute2 = var2 @classmethod def func(self,x): if self.attribute2 is None: do something i get th...

Which is the easiest way to simulate keyboard and mouse on Python?

I need to do some macros and I wanna know what is the most recommended way to do it... So, I need to write somethings and click some places with it and I need to emulate the TAB key to.. Thank you ...

Speed vs security vs compatibility over methods to do string concatenation in Python

Similar questions have been brought (good speed comparison there) on this same subject. Hopefully this question is different and updated to Python 2.6 and 3.0. So far I believe the faster and most compatible method (among different Python versions) is the plain simple + sign: text = "whatever" + " you " + SAY But I keep hearing and r...

python httplib httpexception error codes

Does httplib.HTTPException have error codes? If so how do I get at them from the exception instance? Any help is appreciated. ...

twitter api post rate limit

Does anyone know Twitter's rate limit on posting? Looking at their web page they claimed to not have one but I get an exception thrown if my program posts too fast... Any help is appreciated. ...

Boost.Python wrapping hierarchies avoiding diamond inheritance

I'm having some trouble seeing what the best way to wrap a series of classes with Boost.Python while avoiding messy inheritance problems. Say I have the classes A, B, and C with the following structure: struct A { virtual void foo(); virtual void bar(); virtual void baz(); }; struct B : public A { virtual void quux(); }...

How do I query for this in Django?

| random_code | varchar(200) | YES | UNI | NULL | | MyTable.objects.filter(random_code = None) Is this correct? Will this SELECT where there is no random code set? Above is my table. ...