python

Mixing two audio files together with python

I have two wav files that I want to mix together to form one wav file. They are both the same samples format etc... Been searching google endlessly. I would prefer to do it using the wave module in python. How can this be done? ...

Question about namedtuple construction

Suppose I have a namedtuple like >>> Point = namedtuple('Point','x y') Why is it that I construct a single object via >>> Point(3,4) yet when I want to apply Point via map, I have to call >>> map(Point._make,[(3,4),(5,6)]) I suspect this has something to do with classmethods, perhaps, and am hoping that in figuring this out I'll...

Django, Python: How do I know if users have closed their browser without click logout?

Django, Python: How do I know if users have closed their browser without click logout? Really seriously question, because I need to analyse the user activities. ...

Are boolean instance variables prepended with "is" in Python?

Is it standard practice or convention in Python to prepend boolean instance variables with is? For example: "options.isVerbose" ...

wxPython and StaticBox(Sizer) issue

Recently I've been having an issue with the code shown below and it's been bugging me for a while now. I don't know why it's happening, the only thing I know is that the python code brings up a segfault on the line noted and gdb brings up something about memory. Am I doing something wrong or is this a bug? I'd really like to get this wor...

How can I return the odd numbers of a list, using only recursion in Python?

I do not want to use while or for loops, just want to use recursion to return the odd numbers in a given list. Thanks! ...

Compatibility layer above AWS & GAE?

Has anyone developed an abstraction layer above Amazon Web Services and the Google App Engine? It would be nice to be able to develop a system that could be migrated between either of those two platforms. I am interested in Python. ...

How can I do this complex SQL query using Django ORM? (sub-query with a join)

I'm used to writing my own SQL queries and I'm trying to get used to the whole ORM thing that seems to be so popular nowadays. Here's the query: SELECT * FROM routes WHERE route_id IN ( SELECT DISTINCT t.route_id FROM stop_times AS st LEFT JOIN trips AS t ON st.trip_id=t.trip_id WHERE stop_id = %s ) where %s is an intege...

Best way to find the months between two dates (in python)

I have the need to be able to accurately find the months between two dates in python. I have a solution that works but its not very good (as in elegant) or fast. dateRange = [datetime.strptime(dateRanges[0], "%Y-%m-%d"), datetime.strptime(dateRanges[1], "%Y-%m-%d")] months = [] tmpTime = dateRange[0] oneWeek = timedelta(weeks=1) tmpT...

Convert CURL command line to Python script

Having way too much trouble making this cmd line curl statement work in python script...help! Attempting to use URLLIB. curl -X POST "http://api.postmarkapp.com/email" \ -H "Accept: application/json" \ -H "Content-Type: application/json" \ -H "X-Postmark-Server-Token: abcdef-1234-46cc-b2ab-38e3a208ab2b" \ -v \ -d "{From: 'sender@email....

How to create a form in django using ChoiceField in foms.py

I have to build a form where I want a drop down menu list, what will be the procedure. If u can then plz do tell me the stepwise procedur coz I am a beginner in python. example, what code to be written in views.py, forms.py and urls.py etc. Thanks in advance................Byeee ...

Is it possible to open up certain web addresses using the default internet browser with python?

I want python to open up a certain address using the computers default web browser. Is this possible? ...

How to make Xcode Python friendly?

I have started using Xcode as my main code editor. How might I make Xcode do things like using # instead of // for comments, and otherwise making the IDE friendlier? ...

python email encoding problem

I am extracting emails from Gmail using the following: def getMsgs(): try: conn = imaplib.IMAP4_SSL("imap.gmail.com", 993) except: print 'Failed to connect' print 'Is your internet connection working?' sys.exit() try: conn.login(username, password) except: print 'Failed to login' print 'Is the username...

Cant determine whats causing an regex error, and would like some input on the efficiency of my program

Nearing what I would like to think is completion on a tool I've been working on. What I've got going on is some code that does essentially this: open several files and urls which consist of known malware/phishing related websites/domains and create a list for each, Parse the html of a url passed when the method is called, pulling out a...

pyhton serial port

hi, I want to communicate with my serial port in python.....i installed pyserial,,,and uspp for linux....still when i run the code.. import serial ser = serial.Serial('/dev/pts/1', 19200, timeout=1) print ser.portstr #check which port was really used ser.write("hello") #write a string ser.close() # it gives t...

Help with a Python Sudoku Verifier with Loops

Hi everyone, Im working on a a sudoku program for python and i need some help. The program will ask input from the user for 9 rows of numbers that hopefully contain the digits 1-9. Once they input all 9 rows the program should then go through each row and verify and see if it satisfies the conditions of a sudoku game. If it doesnt it w...

Python OLS calculation

Hi, Is there any good library to calculate linear least squares OLS (Ordinary Least Squares) in python? Thanks. Edit: Thanks for the SciKits and Scipy. @ars: Can X be a matrix? An example: y(1) = a(1)*x(11) + a(2)*x(12) + a(3)*x(13) y(2) = a(1)*x(21) + a(2)*x(22) + a(3)*x(23) ........................................... y(n) = a(1)...

Does anyone have good examples of using mutagen to write files?

Just as the question asks - does anyone have a good example of using the Mutagen python ID3 library to write mp3 files? I'm looking in particular to add disc/track number information, but examples editing the title and artist would be helpful as well. Cheers, /YGA ...

Is it possible to list all functions in a module?

I defined a .py file in this format: foo.py def foo1(): pass def foo2(): pass def foo3(): pass I import it from another file: main.py from foo import * # or import foo Is it possible list all functions name, e.g. ["foo1", "foo2", "foo3"]? Thanks for your help, I made a class for what I want, pls comment if you have suggestion...