python

wx.wizard and python

I have a class which derived from wx.frame and need to attach it to wx.wizard as a page is that possible and if yes how can i do that : for example i have frame=myDrevidedFrame(..) where myDervidedFrame its base class wx.frame how can i attach the frame object to wx.wizard ? ...

Is python good enough for big applications

From the moment I faced python the only thing I can say for it is "It is awesome". I am using Django framework for it and I am amazed how quick the things happen and how developer friendly this language is. But from many sides I hear that Python is scripting language, and very useful for small things, experiments etc. So the question is...

VLC Python binding and event manager

Hi everyone, I'm using libVLC with python's bindings to embeded streams in a GTK Socket; I've got a class Player for VLC: class Player(gtk.Socket): def __init__(self, id): gtk.Socket.__init__(self) def loadfile(self, filename, wid): filename=filename.replace("\"","") p=vlc.MediaPlayer(filename.strip()) ...

Python 2.5 String formatting problem!

I am trying to use the python 2.5 string formatting however I have run into problem in the following example: values = { 'url': 'http://blabla.com', 'link' : 'http://blabla.com', 'username' : 'user', 'spot' : 0, 'views' : 10, 'date' : 3232312, 'private' : 1,...

Forwarding __getitem__ to getattr

Can someone explain what is happening here? class Test(object): __getitem__ = getattr t = Test() t['foo'] gives error (in Python 2.7 and 3.1): TypeError: getattr expected at least 2 arguments, got 1 whereas: def f(*params): print params # or print(params) in 3.1 class Test(object): __getitem__ = f prints the tw...

How to format twisted logs?

Using the framework Twisted, when you use startLogging(), you get logging lines like: Y-M-D H-m-s [Class - IP] message How can I format that output in order to eliminate the date and the IP? Thanks ...

django orm versus sqlachemy, are they basically the same thing?

When using django, I believe you can swap out the built-in orm for sqlalchemy (not sure how though?). Are they both basically the same thing or there is a clear winner between the 2? ...

learning pylons now, in django, how easy is it to use sqlalchemy and a different view engine?

learning pylons now, in django, how easy is it to use sqlalchemy and a different view engine? Is it hackery or its really easy? That's pretty much the only reason I am using pylons over django. But I like that fact that django has a bigger community and easier to get answers to issues. ...

Python: `key not in my_dict` but `key in my_dict.keys()`

I have a weird situation. I have a dict, self.containing_dict. Using the debug probe, I see that dict's contents and I can see that self is a key of it. But look at this: >>> self in self.containing_dict False >>> self in self.containing_dict.keys() True >>> self.containing_dict.has_key(self) False What's going on? (I will note that ...

Installing Libraries on a Server

I'm fairly noob at the using the terminal and doing server administration. I recently "inherited" a Twitter app, and I need to install a Python OAuth library: http://dev.twitter.com/pages/oauth_libraries#python Unfortunately, I'm pretty much clueless about how to: download a library to the server installing the library on the server ...

Python changes Integer in Float by itself

Hello, I'm trying to learn Python, (i have 2.5.4) by writing a snake game, but I'm stuck. Some integers change into floats and keep changing randomly, at least from my perspective :) The problem is that Snake.spawnPoint gets changed by Cam.move() print Snake.spawnPoint # first time, this returns '[25, 20]' ,which is good. Cam.Move() p...

error in configure mod_wsgi with Apache2.2

I am follow this http://pradyumnajoshi.wordpress.com/2009/06/09/setting-up-mod_wsgi-for-apache-and-django-on-windows/ I am using python2.6, Apache2.2, Django1.3 and mod_wsgi>3 on windows xp. now I have installed Apache correctly it is running well. and I have add the following line in httpd.conf file:- LoadModule wsgi_module modules/mod...

QuerySelectField works on one server, breaks on another with same code.

I'm in the process of setting up a test installation of my current Python/Django project. Everything works great on my dev server, but we recently set up a new VM for the test and eventual production copies of the project. I'm using Python, Django, SqlAlchemy (with a MSSQL backend), and WTForms as my main packages. I'm having a proble...

How to add to the pythonpath in windows 7?

Hi There, I have a directory which hosts all my django app. *"C:\My_Projects".* I want to add this directory to my pythonpath so I can call the apps directly. I have *right clicked My Computer > Properties > Advanced System Settings > Environmental Variables. Then I added C:\My_Projects\; to my Path variable* but it still doesn't read ...

Is there a Python package to parse readable data files with sections

I am looking for a method to parse readable (i.e., not binary) data files with sections. I had been using ConfigObj to read config files (INI files?), but I ran into a problem with multi-line lists. Specifically, ConfigObj does not allow list members to contain carriage returns. In other words, the following fails to parse: [section] d...

get GPS coordinates via bluetooth with python on OSX

I just bought a GPS bluetooth receiver, which has been correctly paired with my OSX machine. Now I would like to query the device for my position with python. How do I do it? ...

Python test for a url and image type

In the following code how to test for if the type is url or if the type is an image for dictionaries in d_dict: type = dictionaries.get('type') if (type starts with http or https): logging.debug("type is url") else if type ends with .jpg or .png or .gif logging.debug("type is image") else: logging.debug("invali...

How do I add basic authentication to a Python REST request?

I have the following simple Python code that makes a simple post request to a REST service - params= { "param1" : param1, "param2" : param2, "param3" : param3 } xmlResults = urllib.urlopen(MY_APP_PATH, urllib.urlencode(params)).read() results = MyResponseParser.parse(xmlResults) The problem is that the url used to ...

How to copy InMemoryUploadedFile object to disk

I am trying to catch a file sent with form and perform some operations on it before it will be saved. So I need to create a copy of this file in temp directory, but I don't know how to reach it. Shutil's functions fail to copy this file, since there is no path to it. So is there a way to do this operation in some other way ? My code : ...

Fastest way to resolv 100 million A-records in Python

I have a list with 100 million domain names like www.microsoft.com and would like to resolve the IP-number to www.microsoft.com Running a local pdns server and query localhost using Python adns? ...