python

problem with taking file name from list and openning it?

i have list similar to this m=[['qw','wew','23','C:/xyz/s.wav'],['qw','wew','23','C:/xyz/s2.wav'],['qw','wew','23','C:/xyz/s1.wav']] now i want to these files win=wave.open(m[0][3],'rb') it is giving error how can i use this in this way... i want to take the files name from the list please suggest??? ...

Issue in exec method

Hi all, I am a having two python files file1.py and file2.py. I am using exec() to get the method/Variables defined in the file2.py. file1.py have a class as given below class one: def __init__(self): self.HOOK = None exec(file2.py) self.HOOK = Generate ### call the hook method ###...

Django get old url

In django views,From the request how would we know from which page this view was called def password_change(request): if request.method == 'POST': u=request.user u.set_password(request.POST.get('new_password')) u.save() post_change_redirect= //Need old link here return HttpResponseRedirect(post_change_...

[Python/3DS MAX] How to check if MAX has finished loading

Hi All I am trying to instantiate a program via a python script as follows os.startfile( '"C:/Program Files/Autodesk/3ds Max 2010/3dsmax.exe"' ) since Max takes a bit of time to load, I wanna wait till it has finished loading completely. I check the task manager to see if "3dsmax10.exe" is in the list, but it's in the list as soon as ...

Python finding n consecutive numbers in a list

I want to know how to find if there is a certain amount of consecutive numbers in a row in my list e.g. For example if I am looking for two 1's then: list = [1, 1, 1, 4, 6] #original list list = ["true", "true", 1, 4, 6] #after my function has been through the list. If I am looking for three 1's then: list = [1, 1, 1, 4, 6] #origina...

Downloading from links in an rss feed

Hi there I am trying to create a directory with news articles collected from an rss feed, meaning that whenever there is a link to an article within the rss feed, I would like for it to be downloaded in a directory with the title of the specific article as the filename as as a text file. Is that something Python can help me do ? Thank ...

easy, straightforward way to package a python program for debian?

i'm having trouble navigating the maze of distribution tools for python and debian; cdbs, debhelper, python-support, python-central, blah blah blah .. my application is a fairly straightforward one - a single python package (directory containing modules and a __init__.py), a script for running the program (script.py) and some icons (.pn...

Python: Problem importing pycurl

Hi All, I am working on OpenSolaris(2009.06) OS. i recently installed the pycurl libraires using the following command: $> python setup.py install --curl-config=/usr/local/bin/curl-config the installation went perfectly fine. However now when i am trying to import the pycurl library in my python program, an error is being reported >...

Python urllib2 > HTTP Proxy > HTTPS request

This work fine: import urllib2 opener = urllib2.build_opener( urllib2.HTTPHandler(), urllib2.HTTPSHandler(), urllib2.ProxyHandler({'http': 'http://user:pass@proxy:3128'})) urllib2.install_opener(opener) print urllib2.urlopen('http://www.google.com').read() But, if http change to https: ...

Question about python modules

I have recently started learning Python and I have 2 questions relating to modules. Is there a way to obtain a list of Python modules available (i.e. installed) on a mchine? I am using Ubuntu Karmic and Synaptic for package management. I have just installed a python module.Where is the module code actually stored on my machine? (is the...

Fixing Django Admin collapse error.

Hi. I've been following the Django tutorial, and so far everything's been working as planned. Except "collapse"ing. On my admin page, I get the error in my Javascript Console: Uncaught TypeError: Object #<an Object> has no method 'first' collapse.min.js:1 I'm assuming this is a bug in jQuery, or the collapse script, however my qu...

directory and file related doubts??

i have a directory with around 1000 files....i want to run a same code for each of these file... my code requires the file name to be inputted. i have written code to copy the information of one into other in other format... please suggest a method to copy all 1000 files one by one without need to change the file name every time and i...

Extracting a .app from a zip file in Python, using ZipFile

I'm trying to extract new revisions of Chromium.app from their snapshots, and I can download the file fine, but when it comes to extracting it, ZipFile either extracts the chrome-mac folder within as a file, says that directories don't exist, etc. I am very new to python, so these errors make little sense to me. Here is what I have so fa...

UDP packages appear in wireshark, but are not received by program

Hello everybody, I am trying to read UDP packages sent by an FPGA with my computer. They are sent to port 21844 and to the IP 192.168.1.2 (which is my computer's IP). I can see the package in wireshark, they have no errors. When I run however this little python script, then only a very very small fraction of all packages are received by ...

How to print unsorted dictionary in python?

Guys, I have this dict in python; d={} d['b']='beta' d['g']='gamma' d['a']='alpha' when i print the dict; for k,v in d.items(): print k i get this; a b g it seems like python sorts the dict automatically! how can i get the original unsorted list? Gath ...

Python - from file to data structure?

Hi, I have large file comprising ~100,000 lines. Each line corresponds to a cluster and each entry within each line is a reference i.d. for another file (protein structure in this case), e.g. 1hgn 1dju 3nmj 8kfn 9opu 7gfb 4bui I need to read in the file as a list of lists where each line is a sublist, thus preserving the integrity o...

Doubling binary digits

How to double a number of binary digits in an integer? For example, if bin(x)="1001" then bin(y) must be "11000011". Is there any smart and fast algorithm ? UPDATE: Here is an elegant solution: ''.join([''.join(i) for i in zip(X,X)]) where X is bin(int_x)[2:] However, I am interested in a more faster way and for the integers of any...

Django 1.2: Dates in admin forms don't work with Locales (I10N=True)

I have an application in Django 1.2. Language is selectable (I18N and Locale = True) When I select the english lang. in the site, the admin works OK. But when I change to any other language this is what happens with date inputs (spanish example): Correctly, the input accepts the spanish format %d/%m/%Y (Even selecting from the calendar...

HTTP basic authentication using sockets in python

How to connect to a server using basic http auth thru sockets in python .I don't want to use urllib/urllib2 etc as my program does some low level socket I/O operations ...

command line arg?

This is a module named XYZ. def func(x) ..... ..... if __name__=="__main__": print func(sys.argv[1]) Now I have imported this module in another code and want to use the func. How can i use it? import XYZ After this, where to give the argument, and syntax on how to call it, please? ...