Getting list of parameters inside python function
Is there an easy way to be inside a python function and get a list of the parameter names? For example: def func(a,b,c): print magic_that_does_what_I_want() >>> func() ['a','b','c'] Thanks ...
Is there an easy way to be inside a python function and get a list of the parameter names? For example: def func(a,b,c): print magic_that_does_what_I_want() >>> func() ['a','b','c'] Thanks ...
I've seen a quite a few questions on the Project Euler and other places asking how to time the execution of their solutions. Sometimes the given answers are somewhat kludgey - i.e., adding timing code to __main__, so I thought I'd share my solution. ...
I am playing around with getting some basic stuff to work in Python before i go into full speed dev mode. Here are the specifics: Python 2.5.4 PyQt4 4.4.3 SqlAlchemy 0.5.2 py2exe 0.6.9 setuptools 0.6c9 pysqlite 2.5.1 setup.py: from distutils.core import setup import py2exe setup(windows=[{"script" : "main.py"}], options={"py2exe" : ...
I am trying to organize some modules for my own use. I have something like this: lib/ __init__.py settings.py foo/ __init__.py someobject.py bar/ __init__.py somethingelse.py In lib/__init__.py, I want to define some classes to be used if I import lib. However, I can't seem to figure it out without separating t...
I find myself breaking strings constantly just to get them on the next line. And of course when I go to change those strings (think logging messages), I have to reformat the breaks to keep them within the 80 columns. How do most people deal with this? ...
I have got postfix installed on my machine and I am updating virtual_alias on the fly programmatically(using python)(on some action). Once I update the entry in the /etc/postfix/virtual_alias, I am running the command:sudo /usr/sbin/postmap /etc/postfix/virtual_alias 2>>/work/postfix_valias_errorfileBut I am getting the error:sudo: sorry...
I want to print a table mixed with string and float values, as tab delimited output printout. Sure I can get the job done: >>> tab = [['a', 1], ['b', 2]] >>> for row in tab: ... out = "" ... for col in row: ... out = out + str(col) + "\t" ... print out.rstrip() ... a 1 b 2 But I have a feeling there is a b...
Hey all, Whenever i shut down my development server (./manage.py runserver) with CTRL+c i get following message: [24/Feb/2009 22:05:23] "GET /home/ HTTP/1.1" 200 1571 [24/Feb/2009 22:05:24] "GET /contact HTTP/1.1" 301 0 [24/Feb/2009 22:05:24] "GET /contact/ HTTP/1.1" 200 2377 ^C Error in atexit._run_exitfuncs: Traceback (most recent cal...
I have a small project that would be perfect for Google App Engine. Implementing it hinges on the ability to generate a ZIP file and return it. Due to the distributed nature of App Engine, from what I can tell, the ZIP file couldn't be created "in-memory" in the traditional sense. It would basically have to be generated and and sent i...
Suppose someone is editing a HTML form, and their session times out, how can one have Django re-authenticate that individual without losing the content the user had entered into the form? The snippet Django Snippets: Require login across entire site suggests how to do site-wide authentication, but I expect it will lose the GET component...
Is there any way to set a widget's opacity in PyGTK? I know there's a function for windows: gtk.Window.set_opacity(0.85) but there seems to be no equivalent for arbitrary widgets. Anyone have any ideas? Thanks in advance for your help. ...
In this loop, I'm trying to take user input and continually put it in a list till they write "stop". When the loop is broken, the for loop prints out all of the li's. How would I take the output of the for loop and make it a string so that I can load it into a variable? x = ([]) while True: item = raw_input('Enter List Text (e.g. <...
I'm trying to line up some label and canvas widgets. To do so I need to know how wide my label boxes are. I'd like my widget to auto-adjust if the user changes the system font size, so I don't want to hard code 12 pixels per character. If I measure the label widget it's always 1 pixel wide. Until I call .update(), then I get the corr...
I have an application in Python 2.5 that listens to a beanstalk queue. It works fine on all machines I tested so far, except from my newly acquired MacBook Pro. On that computer, when I try to run it I get this error: Traceback (most recent call last): File "jobs.py", line 181, in <module> Jobs().start() File "jobs.py", line 1...
Python has a standard library module ftplib to run FTP communications. It has two means of getting a listing of directory contents. One, FTP.nlst(), will return a list of the contents of a directory given a directory name as an argument. (It will return the name of a file if given a file name instead.) This is a robust way to list the co...
Hello, guys I am working on a so-called Behavioral Risk Factor Surveillance System (BRFSS), a web query system dealing with questionnaires coming every year. I had hard time in coming up with a suitable database design for it. Here is the problem: Each questionnaire contains about 80 questions, with demographic info, e.g. age, educati...
I would like to list all strings within my large python project. Imagine the different possibilities to create a string in python: mystring = "hello world" mystring = ("hello " "world") mystring = "hello " \ "world" I need a tool that outputs "filename, linenumber, string" for each string in my project. Strin...
I don't know Python. I always think maybe I should take the time to sit down and learn it though. I know C++, C#/VB.NET, Java, and PHP. I am a student, so there's no job requirement that says I must always use x language. I've already seen Python around here at my school... But then again, there is also a LOT of Java. What's my incentiv...
In Python for Symbian60 blit() is defined as: blit(image [,target=(0,0), source=((0,0),image.size), mask=None, scale=0 ]) In the optional parameter source what is the significance of image.size? ...
I have a very basic CSV file upload module working to bulk upload my user's data into my site. I process the CSV file in the backend with a python script that runs on crontab and then email the user the results of the bulk upload. This process works ok operationally, but my issue is with the format of the csv file. Are there good to...