python

retrieve links from web page using python and beautiful soup

How can I retrieve the links of a webpage and copy the url adress of the links using Python? ...

How to reload a Python module that was imported in another file?

I am trying to learn how Python reloads modules, but have hit a roadblock. Let's say I have: dir1\file1.py: from dir2.file2 import ClassOne myObject = ClassOne() dir1\dir2\file2.py: class ClassOne(): def reload_module(): reload(file2) The reload call fails to find module "file2". My question is, how do I do this properl...

handler not working in gae python

I have two handlers in webapp.WSGIApplication for two forms in a django template, one of the handler works on dopost but the other one goes to blank page. Why is this so? ...

Removing the Label From Django's TextArea Widget

How do I remove the label that comes attached to the TextArea I am trying to use with Django? I'm trying to find ANY information about this issue but I cannot seem to find anything relating to my problem. This is what I'm doing in my code: class CommentForm(forms.Form): comment = forms.CharField(widget=forms.Textarea()) This is th...

In Python, how do you change an instantiated object after a reload?

Let's say you have an object that was instantiated from a class inside a module. Now, you reload that module. The next thing you'd like to do is make that reload affect that class. mymodule.py --- class ClassChange(): def run(self): print 'one' myexperiment.py --- import mymodule from mymodule import ClassChange # why is t...

screenshot an application in python, regardless of what's in front of it

So I can use PIL to grab a screenshot of the desktop, and then use pywin32 to get its rectangle and crop out the part I want. However, if there's something in front of the window I want, it'll occlude the application I wanted a screenshot of. Is there any way to get what windows would say an application is currently displaying? It has th...

Changes to Python since Dive into Python

I've been teaching myself Python by working through Dive Into Python by Mark Pilgrim. I thoroughly recommend it, as do other Stack Overflow users. However, the last update to Dive Into Python was five years ago. I look forward to reading the new Dive into Python 3 When I make the switch to 3.x, but for now, using django means I'll stick...

How Do I Remove Text From Generated Django Form?

So earlier I asked a question about removing the label that Django forms have by default. That worked out great, and I removed the label. However, the text that is generated by the form is still there! I would very much like to remove the text. Here is what I mean: <p>Text: <textarea rows="10" cols="40" name="text"></textarea></p> I w...

Accessing Python Objects in a Core Dump

Is there anyway to discover the python value of a PyObject* from a corefile in gdb ...

Implementing a custom Python authentication handler

The answer to a previous question showed that Nexus implement a custom authentication helper called "NxBASIC". How do I begin to implement a handler in python? Update: Implementing the handler per Alex's suggestion looks to be the right approach, but fails trying to extract the scheme and realm from the authreq. The returned value f...

Decompile .swf file to get images in python

I would like to decompile a .swf file and get all the images from it, in python. Are there any libraries that do this? ...

Inheriting from instance in Python

Hello, In Python, I would like to construct an instance of the Child's class directly from an instance of the Parent class. For example: A = Parent(x, y, z) B = Child(A) This is a hack that I thought might work: class Parent(object): def __init__(self, x, y, z): print "INITILIZING PARENT" self.x = x sel...

How do you do something after you render the view? (Django)

I want to do something after I have rendered the view using return render_to_response() Are signals the only way to do this? Do I need to write a custom signal or does request_finished give me enough information? Basically I need to know what page was rendered, and then do an action in response to that. Thanks. UPDATE FROM COMMENTS...

How can I report the API of a class programmatically?

Dear stackoverflow- My goal is to parse a class and return a data-structure (object, dictionary, etc) that is descriptive of the methods and the related parameters contained within the class. Bonus points for types and returns... Requirements: Must be Python For example, the below class: class Foo: def bar(hello=None): ...

python tab completion in windows

I'm writing a cross-platform shell like program in python and I'd like to add custom tab-completion actions. On Unix systems I can use the built-in readline module and use code like the following to specify a list of possible completions when I hit the TAB key: import readline readline.parse_and_bind( 'tab: complete' ) readline.set_comp...

Python: How to set breakpoints on mac with IDLE debugger?

I have access to both a PC and a mac for a python class. I find I am unable to set breakpoints in the IDLE debugger in the mac (works fine on the PC). I've tried "ctrl-click" and configuring the touchpad to recognize two taps at once as a secondary click. I don't have a mouse for the mac, just the touchpad. MAC OS 10.4.10 tiger Pyt...

Which is the most mature Python XMPP library for a GChat client?

There seem to be several options for Python XMPP client libraries -- I'm not totally sure what I'm getting myself into (just fiddling around at this point), so I'm looking for some advice on which XMPP library has the most mature/Pythonic client API. (Or, to be more objective about it, an assessment of the relative strengths/weaknesses o...

Transition from Python2.4 to Python2.6 on CentOS. Module migration problem.

Hey guys, I have a problem of upgrading python from 2.4 to 2.6: I have CentOS 5 (Full) It has python 2.4 living in /usr/lib/python2.4/ Additional modules are living in /usr/lib/python2.4/site-packages/ I've built python 2.6 from sources at /usr/local/lib/python2.6/ I've set default python to python2.6 Now old modules for 2.4 are out...

PYTHON: Update MULTIPLE COLUMNS with python variables

Hello everybody, I'm trying to write a valid mysql statement that would allow me to update multiple columns in one record with values provided as python variables. My statement would look like this: db = MySQLdb.connect(host="localhost", user="user", passwd="password", db="dbname") cursor = db.cursor() sql_update = "UPDATE table_name ...

How to recommend the next achievement

Short version: I have a similar setup to StackOverflow. Users get Achievements. I have many more achievements than SO, lets say on the order of 10k, and each user has in the 100s of achievements. Now, how would you recommend (to recommend) the next achievement for a user to try for? Long version: The objects are modeled like this in ...