python

How can I download files form web pages?

Some web pages, having their urls, have "Download" Text, which are hyperlinks. How can I get the hyperlinks form the urls/pages by python or ironpython. And can I download the files with these hyperlinks by python or ironpython? How can I do that? Are there any C# tools? I am not native english speaker, so sorry for my english. ...

wxPython: "Super" wx.SpinCtrl with float values, layout inside sizer

wx.SpinCtrl is limited to spinning across integers, and not floats. Therefore, I am building a wx.TextCtrl + wx.SpinButton combo class which enables me to spin across floats. I am able to size and layout both of them programmatically so that the combo looks exactly the same as an ordinary wx.SpinCtrl. I am subclassing this combo from th...

Parsing XML response of bit.ly

I was trying out the bit.ly api for shorterning and got it to work. It returns to my script an xml document. I wanted to extract out the tag but cant seem to parse it properly. askfor = urllib2.Request(full_url) response = urllib2.urlopen(askfor) the_page = response.read() So the_page contains the xml document. I tried: from xml.dom...

Translating Python into JavaScript — Lists?

octopusList = {"first": ["red", "white"], "second": ["green", "blue", "red"], "third": ["green", "blue", "red"]} squidList = ["first", "second", "third"] for i in range(1): squid = random.choice(squidList) octopus = random.choice(octopusList[squid]) print squid + " " + octopus Can anyone help me write ...

Use bluetooth and FTP to transfer files from PC to handset?

I have a Windows XP PC and a handset that supports FTP file transfers via bluetooth. Note that I cannot run python on the handset. Is there a way to transfer files from the PC to the handset using Python and the appropriate Bluetooth extension module? Right now, I am doing it manually by navigating to the handset using Windows Explorer a...

Why can't I import pygtk?

I followed the instructions in this post. Everything installed successfully. However, when I run python I cannot import pygtk. Specifically, it says this: >>> import pygtk \n “ImportError: No module named pygtk” I'm guessing I have to do some commands like make or something, but I can't find anywhere where it says what to do. Please h...

Does anyone have example code for a sqlite pipeline in Scrapy?

I am looking for some example code of a SQLite pipeline in Scrapy. I know there is no built in support for it, but I'm sure it has been done. Only actual code can help me, as I only know enough Python and Scrapy to complete my very limited task, and need the code as a starting point. ...

Git "failed to push some refs to..." with custom Git bridge

I have been working on setting up a git server by using Paramiko to act as an SSH bridge for Git. I am able to clone my repository without issue, and even push changes up, however I get an annoying error message. Pushing to git@localhost:/pckprojects/heyworld Counting objects: 5, done. Delta compression using up to 2 threads. Compressin...

dictionary in python problem

problem.getSuccessors(getStartState()) - it returns something like ( (4,5) , north, 1) - that means 3 things - tuple, direction,cost. I'm using a dictionary ,closed = {} Now I need to put the output of above function in the dictionary "closed" - how can I do that?? I need to use only dictionary because I need to return "action" i.e N...

Pausing a thread using threading class

I have a long process that i've scheduled to run in a thread, because otherwise it will freeze the ui in my wxpython application. I'm using threading.Thread(target = myLongProcess).start() to start the thread and it works, but I don't know how to pause and resume the thread. I looked in the python docs for the above methods, but was...

Finding missing values in a numpy array

Alright, extreme rookie question here. In my program, I generate a 2D numpy array, some of whom's entries are missing (not the "nan" kind of nonexistant, but the "None" kind, or NoneType). I'd like to put a mask over these entries, but I seem to be having some trouble doing so. Ordinarily, to mask over, say, all entries with value 2, ...

Check Pending AJAX requests or HTTP GET/POST request.

How do i check if the page has pending AJAX or HTTP GET/POST requests? I use javascript and/or python for this checking. what i wanted to do is execute a script if a page has finished all requests. onload doesn't work for me, if you used firebugs net panel, you would know. onload fires when the page is loaded but there is a possibility...

Get thumbnail image for Yahoo video? (python)

Hi The question has a similar intent as this question: http://stackoverflow.com/questions/1361149/get-img-thumbnails-from-vimeo but that one was for vimeo. So, I have a url for the yahoo video, is there any way I could get the standard thumbnail using the url? Thanks ...

Validating a yaml document in python

One of the benefits of XML is being able to validate a document against an XSD. YAML doesn't have this feature, so how can I validate that the YAML document I open is in the format expected by my application? ...

Accessing CPU temperature in python

I need an example code for accessing CPU temperature in python. I'm running windows 7, BTW. ...

High Dimension Nearest Neighbor Search and Locality Sensitivity Hashing

Here is the main problem. I have very large database (25,000 or so) of 48 dimensional vectors, each populated with values ranging from 0-255. The specifics are not so important but I figure it might help give context. I don't need a nearest neighbor, so approximate neighbor searches that are within a degree of accuracy are acceptable....

How to decode JSON string to string, not unicode

I'm trying to decode a json of a dictionary with strings as keys. The result is a dictionary with unicode keys. What is the best way to decode to a dictionary with string keys? Better: how do I prevent that strings are decoded into unicode strings? Off course I can loop afterwards... What happens: >>> import simplejson >>> simplejson.l...

pyobjc build problem

I am trying to build pyobjc from trunk. My system is Mac OS X 10.5.8, Xcode 3.1.3 developer tools and I have installed python from http://www.python.org/ftp/python/2.5.4/python-2.5.4-macosx.dmg when i go to pyobjc-core folder and do $ python setup.py test I get error: lipo: can't figure out the architecture type of: /var/tmp//ccVTu...

Type error in python!!!

closedset = set() root = (5,6) for u,v in root: if v is not closedset: closedset.add(root) print closedset Error: for u,v in root: TypeError: unpack non-sequence What should i do with type of error? ...

Python: Why does the tab character show up weird in Tkinter?

This a screenshot from a Tkinter Listbox in a program I'm writing: Why does the \t character show up as a black bar? On a Mac it shows up normally (as a tab), but on Windows I get this. I think it might have something to do with character encoding because strings are unicode by default in OS X but not Windows? I tried writing the ta...