python

Django Passing Custom Form Parameters to Formset

I have a Django Form that looks like this: class ServiceForm(forms.Form): option = forms.ModelChoiceField(queryset=ServiceOption.objects.none()) rate = forms.DecimalField(widget=custom_widgets.SmallField()) units = forms.IntegerField(min_value=1, widget=custom_widgets.SmallField()) def __init__(self, *args, **kwargs): ...

For my app, how many threads would be optimal?

I have a simple Python web crawler. It uses SQLite to store its output and also to keep a queue. I want to make the crawler multi-threaded so that it can crawl several pages at a time. I figured i would make a thread and just run several instances of the class at once, so they all run concurrently. But the question is, how many should i ...

Best Resource for mysql + python 2.6 programming

I need a great resource for interacting with MySql (version 5.0.45) with Python2.6. I'm using cherrypy, mako, the standard library, and nothing else. The resources can be blogs, howtos, books (online of offline), whatever. Additional information: The python mysql module, MySQLdb, is compatible with Python DB-API 2.0 . See http://sour...

How can I insert RTF into a wxpython RichTextCtrl?

Is there a way to directly insert RTF text in a RichTextCtrl, ex:without going through BeginTextColour? I would like to use pygments together with the RichTextCtrl. ...

is there a way to pickup the lat/lon from Google Map Mobile 3.0(MyLocation Feature) with a python script?

Hi, I want to fetch my current lat/lon from google maps mobile 3.0 with the help of some script which i guess could be a python one. Is this possible? and more importantly is the google maps mobile api designed of such interaction?any legal issues?? Basically i have a s60 phone that doesnt have GPS,and i have found that google maintain...

Why can't I directly add attributes to any python object?

I have this code: >>> >>> class G: ... def __init__(self): ... self.x = 20 ... >>> gg = G() >>> gg.x 20 >>> gg.y = 2000 and this code : >>> from datetime import datetime >>> my_obj = datetime.now() >>> my_obj.interesting = 1 *** AttributeError: 'datetime.datetime' object has no attribute 'interesting' From my python knowled...

What are some recommended, high quality, non-basic python books?

I'm looking for something of the quality of our friend Jon Skeet's C# in depth book, but about Python. Please leave any recommendations you have for Python books that do not cover basic programming constructs. ...

How do you add event to Trac event time line

I am writing a plug-in for Trac. I would like to add an event to the time line each time the plug-in receives some data from a Git post-receive hook. Looking at the timeline API, it seems you can only add new source of events. So you are responsible for retrieving and displaying the data. I would prefer saving my event to an existent so...

django login middleware not working as expected

A quickie, and hopefully an easy one. I'm following the docs at http://docs.djangoproject.com/en/dev/topics/auth/ to get just some simple user authentication in place. I don't have any special requirements at all, I just need to know if a user is logged in or not, that's about it. I'm using the login_required decorator, and it's working ...

wx's idle and UI update events in PyQt

wx (and wxPython) has two events I miss in PyQt: EVT_IDLE that's being sent to a frame. It can be used to update the various widgets according to the application's state EVT_UPDATE_UI that's being sent to a widget when it has to be repainted and updated, so I can compute its state in the handler Now, PyQt doesn't seem to have these,...

What should I be aware of when moving from asp.net to python for web development?

I'm thinking about converting an app from Asp.net to python. I would like to know: what are the key comparisons to be aware of when moving a asp.net app to python(insert framework)? Does python have user controls? Master pages? ...

How do I make a Django ModelForm menu item selected by default?

I am working on a Django app. One of my models, "User", includes a "gender" field, as defined below: GENDER_CHOICES = ( ('M', 'Male'), ('F', 'Female'), ) gender = models.CharField(max_length=1, choices=GENDER_CHOICES, null=True) I am using a ModelForm to generate a "new user" HTML form. My Google-fu seems to be fai...

How can I customize the output from pygments?

If I run a python source file through pygments, it outputs html code whose elements class belong to some CSS file pygments is using. Could the style attributes be included in the outputted html so that I don't have to provide a CSS file? ...

Why am I getting an invalid syntax easy_install error?

I need to use easy_install to install a package. I installed the enthought distribution, and popped into IDLE to say: >>> easy_install SQLobject SyntaxError: invalid syntax What am I doing wrong? easy_install certainly exists, as does the package. help('easy_install') gives me some basic help. import easy_install doesn't change t...

Using Django admin look and feel in my own application

I like the very simple but still really elegant look and feel of the django admin and I was wondering if there is a way to apply it to my own application. (I think that I've read something like that somewhere, but now I cannot find the page again.) (edited: what I am looking for is a way to do it automatically by extending templates, i...

Unable to install python-setuptools from source

The question is related to the post. I need to install python-setuptools to install python modules. I have extracted the installation package. I get the following error when configuring [~/wepapps/pythonModules/setuptools-0.6c9]# ./configure --prefix=/home/masi/.local -bash: ./configure: No such file or directory I did not find the ...

Why aren't signals simply called events?

From what I can tell, in Python and and Django, signals are simply delegated events. Is there anything that functionally differentiates them from the typical notion of events in C#, Java, ActionScript, etc? ...

how to detect whether a python variable is a function?

I have a variable, x, and I want to know whether it is pointing to a function or not. I had hoped I could do something like: >>> isinstance(x, function) but that gives me: Traceback (most recent call last): File "<stdin>", line 1, in ? NameError: name 'function' is not defined The reason I picked that is because >>> type(x) <t...

What will be the upgrade path to Python 3.x for Google App Engine Applications?

Is the transition to Python 3.x for Google App Engine likely to be difficult? I know Google App Engine requires the use of at least Python 2.5. Is it possible to use Python 3.0 already on Google App Engine? ...

Python __init__ and self what do they do?

I'm learning the Python programming language, and I've come across certain things I don't fully understand. I'm coming from a C background, but I never went far with that either. What I'm trying to figure out is: In a method: def method(self, blah): def __init__(?): .... .... What does self do? what is it meant to b...