python

How to define the "MODULE DOCS" for display with pydoc?

The pydoc documentation of some Python modules (like math and sys) has a "MODULE DOCS" section that contains a useful link to some HTML documentation: Help on module math: NAME math FILE /sw/lib/python2.6/lib-dynload/math.so MODULE DOCS /sw/share/doc/python26/html/math.html How can such a section be included in your own...

Learning programming in general - virtual mentoring

I know some programming. I know little bit of Java, I know some C#, I know some GW Basic. I've followed those 30 minute Ruby, Python tutorials and so on. I took some computer courses in college but didn't take them very seriously at that time. After I finished school, I got an IT job but my luck (or bad luck) I ended up doing non-coding ...

Python: How to access variable declared in parent module

Using the structure from the Python docs: sound/ __init__.py effects/ __init__.py echo.py surround.py reverse.py Say I want to import sound.effects and get a list of available effects. I could do this by declaring a module-level variable in sound.effects and then appending to it when each ....

Creating Bonjour services for the Finder

I am playing around a bit with Bonjour and for prototyping I use the Pybonjour library, which seemed to work like a charm for my first trials. However, when I try to create a service that is visible in Finder, I fail hard. I used this page as a reference for the service identifiers to use. The document specifies which services are browse...

Learning programming in general - virtual mentoring

I know some programming. I know little bit of Java, I know some C#, I know some GW Basic. I've followed those 30 minute Ruby, Python tutorials and so on. I took some computer courses in college but didn't take them very seriously at that time. After I finished school, I got an IT job but my luck (or bad luck) I ended up doing non-coding ...

jQuery code generation lib

I was curious if there was anything for say PHP or Python that was able to generate jQuery components by using calls to a library. So something like this: import jQueryLib Tabs tabContainer = new Tabs(); Tab page1, page2, page3; page1.content = "bleh"; ... tabContainer.children.add(page1); tabContainer.Render(); Does anyone know o...

How to protect againt typos when setting value for class members?

Hi, consider following example: class A(): def __init__(self): self.veryImportantSession = 1 a = A() a.veryImportantSession = None # ok # 200 lines below a.veryImportantSessssionnnn = 2 # I wanna exception here!! It is typo! How could I make it so, that exception will be raised it case of I will try to set member that ...

Forcing scons to use older compiler?

Heya, I have a C++ project which is using boost. The whole project is built using scons + Visual Studio 2008. We've installed Visual Studio 2010 and it turned out scons was attempting to use the later compiler instead of the old one - and failed to build the project as boost and visual studio 2010 don't like each other very much - yet. ...

Ruby HAML with Django?

Ok, so I really love HAML. Particularly, I love the integration with RedCloth and BlueCloth, so I can use Markdown and Textile intermixed with my HAML. I also love Python and Django. So, I would like to use HAML with Django. Now, I already understand that there are some attempts at cloning HAML-like syntax in Python (SHPAML and other...

How to merge (join) two wx.bitmap using wxpython?

Hello, I have one wx.emptybitmap (1) and one wx.bitmap (2). I want to merge(join) them.. I want to create a single wx.bitmap that consists on the wx.emptybitmap (1) on the top and wx.bitmap (2) on the bottom. How can I do that? Thanks in advance! :D ...

Drag drop support for a pygtk.treeview where the model is filtered and sorted

As the title suggests, I have a pygtk.TreeView whose model is sorted and filtered. According to the documentation: "Drag and drop reordering of rows only works with unsorted stores.". The only other information given relates to using external sources, which in this case I don't need. I tried implementing it anyway, providing handlers to...

Can I use Ruby and Python together?

Is there something like JRuby but for Ruby and Python? Not that it would actually be useful to me, but just wondering. ...

doesn't python uses copy by reference?why is the following code not working then?

class x: def __init__(self): self.y=None self.sillyFunc(self.y) def sillyFunc(self,argument): if argument is None: argument='my_name_as_argument' self.printy() def printy(self): print self.y According to me the above code should print >my_name_as_argument,where am i going ...

Upload file using python simply using HTTPLIB

conn = httplib.HTTPConnection("www.encodable.com/uploaddemo/") conn.request("POST",path, chunk,headers) Above is the site "www.encodable.com/uploaddemo/" where I want to upload an image. Now problem which I am facing is I am tyro in php so I am unbale to understand the meaning of path and headers in above code, chunk is an object t...

How do you create a python package with a built in "test/main.py" main function?

Desired directory tree: Fibo |-- src | `-- Fibo.py `-- test `-- main.py What I want is to call python main.py after cd'ing into test and executing main.py will run all the unit tests for this package. Currently if I do: import Fibo def main(): Fibo.fib(100) if __name__ == "__main__": main() I get an error: "ImportE...

is mac good for python programming ?

I am programming a django based website. I actually use a small computer under Ubuntu 10.04. I would like to buy something more professional, so I am wondering whether an iMac is good for that, because : Is there a free IDE as good as eclipse on MacOS ? Is there a remote python debugger like pydev for eclipse ? Is there some typical is...

customizing basic existing Django apps that already have "nice looking" CSS/HTML templates?

I am looking for a basic Django application that "looks good" and has basic menus etc. that I could adapt for my own use. I am not doing any fancy processing of user input, but I do want to reuse an existing templates so that I don't have to worry about writing my own CSS/HTML to get clean, valid good looking webpages. Many of the Djan...

Django: return one filtered object per foreign key

Is it possible to return querysets that return only one object per foreign key? For instance, I want the to get the latest comments from django_comments, but I only want one comment (the latest comment) per object, i.e., only return the latest comment on an object and exclude all the past comments on that object. I guess this would be ...

Some questions about Django localisation

I intend to localise my Django application and began reading up on localisation on the Django site. This put a few questions in my mind: It seems that when you run the 'django-admin.py makemessages' command, it scans the files for embedded strings and generates a message file that contains the translations. These translations are mappe...

Dealing with multi-language directories (Python)

I'm trying to open a file and I just realized that py is having trouble with my username (It's in Russian). Any suggestions on how to properly decode/encode this to make idle happy? I'm using py 2.6.5 xmlfile = open(u"D:\\Users\\Эрик\\Downloads\\temp.xml", "r") Traceback (most recent call last): File "<pyshell#23>", line 1, in <modu...