python

Submitting a form in mechanize.

I'm having issues submitting the result of a form submission (I can submit a form, but I can't submit the form on the page that follows the first). I have: browser = mechanize.Browser() browser.set_handle_robots(False) browser.open('https://www.example.com/login') browser.select_form(nr=0) browser.form['j_username'] = 'username' brows...

Problem with Prototype Ajax.Request in Internet Explorer 8 prompting file download

Have a set of prototype-enabled ajax code that is working in all browsers other than IE. In IE8 the JSON, that otherwise gets returned to the onSuccess handler function specified in Ajax.Request, gets thrown into a file download stream which pops up and prompts for where to download. askForm = $('askForm'); var askUrl = '.'; var askPar...

Debug a module built with Boost.Python in QtCreator

I have a module built with Boost.Python and I want to debug it in QtCreator (or perhaps gdb). I prefer a visual environment if possible. ...

how to add new column on elixir

i use elixir as orm for mysql database,now i want to add new column to my schema,how could i keep orginal data in the mysql and update the schema automatically,the concept called migrate on ruby on rails,it seems i didn't found relevent infomation & code in sqlalchemy & elixir,any advice is welcome. ...

How do I calculate the magnitude of the velocity of my mouse cursor, in Python?

http://dl.dropbox.com/u/779859/speedCalc_puradata.JPG I achieved it in pure data, have a look at the schematic of what I'm thinking: Recieving Midi Control input from ctlin 20 and 21 Pipe delays whatever signal it recieves Pythagoras Viola, the speed of the input. The units don't matter, as long as it is absolute. I was thinking abo...

Using Microsoft Access SQL operators in Python ODBC

Short version: When I try to use Access's DatePart function via ODBC, it cannot be resolved. Longer version: I have a Microsoft Access query which returns rows with a timestamp and a score. I want to sort it by day and then by score - effectively a high-score table for the day. For want of a better function, I used the DatePart funct...

Is there a better way to specify named arguments when calling in Python

template.render(current_user=current_user, thread=thread, messages=messages) Is there a dont-repeat-yourself compliant way to do whatever=whatever? Like a magic symbol to prepend the variable name with or something like this ~whatever, ~something, ~etc? ...

Is it possible to save SymPy's image to the image object from PIL Image?

Hi, there. May I ask is it possible to save SymPy's image to the image object from PIL Image? I really need to do this. And so far I 've got no idea around this, please help with this, thank you! ...

Escaping unicode strings for MySQL in Python (avoiding exceptions.UnicodeEncodeError)

I am using Twisted to asynchronously access our database in Python. My code looks like this: from twisted.enterprise import adbapi from MySQLdb import _mysql as mysql ... txn.execute(""" INSERT INTO users_accounts_data_snapshots (accountid, programid, fieldid, value, timestamp, jobid) VALUES ('%s', '%s', '%s', '%s', '%s', '%s...

What does a audio frame contain?

Im doing some research on how to compare sound files(wave). Basically i want to compare stored soundfiles (wav) with sound from a microphone. So in the end i would like to pre-store some voice commands of my own and then when Im running my app I would like to compare the pre-stored files with input from the microphone. My thought was to...

Mathematica to Python

How can this Mathematica code be ported to Python? I do not know the Mathematica syntax and am having a hard time understanding how this is described in a more traditional language. Source (pg 5): http://subjoin.net/misc/m496pres1.nb.pdf ...

How to match pattrns "begins with A or ends with B" with regular expression?

r'(^|^A)(\S+)(B$|$)' results to matches everything, which actually equals to ^\S$. How to write one matches "begins with A or ends with B, may both but not neither?" PS: I also need refer to group (\S+) in the substring module. Example: Match Aanything, anythingB, and refer anything group in the replace. ...

how itertools.tee works, can type 'itertools.tee' be duplicated in order to save it's "status" ?

All, pls see below test code about itertools.tee: li = [x for x in range(10)] ite = iter(li) ================================================== it = itertools.tee(ite, 5) >>> type(ite) <type 'listiterator'> >>> type(it) <type 'tuple'> >>> type(it[0]) <type 'itertools.tee'> >>> >>> list(ite) ...

QComboBox replacing edit text if case differs from existing item.

Hi I'm having a problem with QComboBox not allowing me to change the edit text to anything existing item of differing case. Example code is below. What I'd like to do is enter 'one' into a combo box already containing the item 'One' without the side effect of the text being changed to 'One'. Currently it's changed back to 'One' as...

how to set the default value for grouped choices in django

If I have some grouped choices for a models.IntegerField, how can I set the default value to a combination of those choices ex: class ForumThread(): STATE_CHOICES = ( ('Sticky', ( (True, 'True'), (False, 'False') ) ), ('Blocked', ( (False, 'False') (True, 'Tru...

How trasform a python program .py in an executable program in Ubuntu ?

I have a simple python program .py and I want an executable version ( for UBUNTU LINUX ) of this program and avoid to run it by terminal with "python myprogram.py". How can I do that ? ...

Loading a large dictionary using python pickle

I have a full inverted index in form of nested python dictionary. Its structure is : {word : { doc_name : [location_list] } } For example let the dictionary be called index, then for a word " spam ", entry would look like : { spam : { doc1.txt : [102,300,399], doc5.txt : [200,587] } } I used this structure as python dict are pretty o...

What is the best way to detect and redirect a mobile browsser in AppEngine?

Specfically, I am working in Python. ...

Determine if a Python list is 95% the same?

This question asks how to determine if every element in a list is the same. How would I go about determining if 95% of the elements in a list are the same in a reasonably efficient way? For example: >>> ninety_five_same([1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]) True >>> ninety_five_same([1,1,1,1,1,1,2,1]) # only 80% the same Fals...

What are the benefits of using Elixir...

... vs declarative sqlalchemy ? ...