python

Templates in different directory

Hi, I want to place the project hierarchy in this way project |-app | \app1 | |-templates | \app1_templ.html | |- views.py | \-models.py |-templates | \main.html |-views.py |-models.py ... But in the main.html i want to use `{%include app1_templ.html%}. Assuming the views.py from the app1: def...

CPython vs. Jython vs. IronPython for cross-platform GUI development.

I'm thinking of making some kind of experimental IDE for digital hardware design. So I can't decide witch platform to choose. I'm going to have text-editor with syntax highlighting, some vector graphics and lots of tabbed windows. My goals: 1. to make GUI using as less custom components as possible. 2. to make it as cross-platform as p...

How do I use pylons (paste) webtest with multiple checkboxes with the same name?

Suppose I have a form like this: <form id='myform'> Favorite colors? <input type='checkbox' name='color' value='Green'>Green <input type='checkbox' name='color' value='Blue'>Blue <input type='checkbox' name='color' value='Red'>Red <input type='submit' value='Submit'> </form> How do I use webtest's form library to t...

Does nesting affect efficiency?

Consider languages like Python or JavaScript that allow functions to be nested like this: print(vector(a * b),(a * c),(b * c))) or flat like this: i = (a * b) j = (a * c) k = (b * c) V = vector(i,j,k) print(V) How much does the different format affect performance? Can valid generalizations be made, or does it vary a lot by language...

Go Language Compared to Python

I am interested in hearing the differences between Go and Python and reading an overview of the similarities. I know that Google has heavy usage of Python and Go looks to be a bit related. I was searching around a bit for a comparison and discussion of the influences of Python in Go and the goals of the Go language but I did not find a ...

Avoiding CannotSendRequest exceptions when re-using httplib.HTTPSConnection objects

My code makes a bunch of https calls using httplib. I want to re-use the httplib.py connection object, but if I do, I sometimes get CannotSendRequest exceptions because the connection ends up in a strange state because some other bit of code blows up mid-way through a request. So what I want is a way to cache the connection object such...

Set global hotkey with Python 2.6

I wanna setup a global hotkey in python 2.6 that listens to the keyboard shortcut ctrl + D or ctrl + alt + D on windows, please help me ...

Python - Using os.popen() to parse Unix "ls" - Problems with Killing Child Process

Hi all. From my understanding, os.popen() opens a pipe within Python and initiates a new sub process. I have a problem when I run a for loop in conjunction with os.popen(). I can't seem to CTRL+C out of the loop. Here is my code: for FILE in os.popen("ls $MY_DIR/"): os.system("./processFile " + FILE) Whenever I try to CTRL+C, ...

Personal archive tool, looking for suggestions on improving the code

i've written a tool in python where you enter a title, content, then tags, and the entry is then saved in a pickle file. it was mainly designed for copy-paste functionality (you spot a piece of code you like on the net, copy it, and paste it into the program), not really for handwritten content, though it does that with no problem. i ma...

error: ambiguous overload for 'operator/'

Hello, I am new to c, and the following is giving me some grief: int i,j,ll,k; double ddim,ddip,ddjm,ddjp,ddlm,ddlp; for(i=1; i<(mx-1); i++){ for(j=1; j<(my-1); j++){ for(ll=1; ll<(mz-1); ll++){ ddim=0.5*k ddip=0.5*k ddjm=0.5*k ddjp=0.5*k ddlm=0.5*k ddlp=0.5*k Wijl(i,j,ll) = ((1.0/h_x)*(ddip) \ ((1.0/h_x)*(ddim)) \ ...

Mechanize does not see some hidden form inputs?

I want to scrape this web page using Mechanize. The form element looks like this: <form name="ctl00" method="post" action="PSearchResults.aspx?state=ME&amp;rp=" id="ctl00"> <div> <input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" /> <input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" /> <inpu...

Python: Sharing global variables between modules and classes therein.

I know that it's possible to share a global variable across modules in Python. However, I would like to know the extent to which this is possible and why. For example, global_mod.py x = None mid_access_mod.py from global_mod import * class delta: def __init__(self): print x bot_modif_mod.py import mid_access_mod imp...

Communication from arduino to a browser extension all run locally

Hello Everyone! I am trying to figure out how I would go about taking serial information from an arduino which controls a javascript browser extension I have running in an open browser locally on a computer. It would seem that I would need some sort of middleman to internalize the serial readings and pass them to the browser (to activa...

Decrypting a gpg file with gnupg

I'm trying to decrypt some data from gpg files that I've downloaded. Downloading the files to a directory is no problem, but I'm having trouble actually decrypting them. Here's what I'm doing right now: def extractGPGs(gpglist,path,gpgPath="\"C:\\Program Files\\GNU\\GnuPG\\gpg.exe\""): os.chdir(path) if not os.path.isdir("GPGFiles"): ...

Can't get Django localization to work

I've searched several threads and bug reports, but couldn't find a solution. I changed the locale of my Django project to pt-br but it made no difference. I excepted all input fields and outputs to localize dates and numbers, specially DECIMAL_SEPARATOR and THOUSAND_SEPARATOR, including in the admin API. But the dates there continue to ...

Which complements Python best: Java, C, or C++?

I am in the process of applying to a Computer Science program which requires students to have at least an intro-level exposure to either Java, C or C++. I have some experience with Python and I would prefer to continue working in Python before starting another language; however, the professor said that Python was too light, i.e. "it's j...

getting started with processing data with python

i have an excel spreadsheet of about 3 million cells. i asked the following question and i liked the answer about saving the spreadsheet as CSV and then processing it with python: http://stackoverflow.com/questions/3322939/solution-to-perform-lots-of-calculations-on-3-million-data-points-and-make-charts/3323168#3323168 is there a libr...

pexpect timeout is not being used, only the default of 30 is being used.

I'm trying to do a lengthy operation but pexpect with the timeout argument doesn't seem to change the length of time before the timeout exception gets fired. Here is my code: child = pexpect.spawn('scp file user@:/temp', timeout=300) whichMatched = child.expect(['(?i)Password','Are you sure you want to continue connecting (yes/no)?'], ...

Python - When Is It Ok to Use os.system() to issue common Linux commands

Spinning off from another thread, when is it appropriate to use os.system() to issue commands like rm -rf, cd, make, xterm, ls ? Considering there are analog versions of the above commands (except make and xterm), I'm assuming it's safer to use these built-in python commands instead of using os.system() Any thoughts? I'd love to hear t...

issue running a program (R) in Python to perform an operation (execute a script)

Hi all, I'm tying to execute an R script from python, ideally displaying and saving the results. Using rpy2 has been a bit of a struggle, so I thought I'd just call R directly. I have a feeling that I'll need to use something like "os.system" or "subprocess.call," but I am having difficulty deciphering the module guides. Here's the R...