python

"no matching architecture in universal wrapper" problem in wxPython?

I am running Python 2.7 under Mac OS 10.6.4, and I just installed wxPython from the wxPython2.8-osx-unicode-2.8.11.0-universal-py2.7.dmg binary. I am getting a weird error on the import wx line in my Python scripts. FYI, I can import the wx module just fine from PyCrust. I don't really see what I have done wrong here. Could anyone please...

Create a new array from numpy array based on the conditions from a list

Suppose that I have an array defined by: data = np.array([('a1v1', 'a2v1', 'a3v1', 'a4v1', 'a5v1'), ('a1v1', 'a2v1', 'a3v1', 'a4v2', 'a5v1'), ('a1v3', 'a2v1', 'a3v1', 'a4v1', 'a5v2'), ('a1v2', 'a2v2', 'a3v1', 'a4v1', 'a5v2'), ('a1v2', 'a2v3', 'a3v2', 'a4v1', 'a5v2'), ('a1v2', 'a2v3', 'a3v2', 'a4v2', 'a...

Module vs object-oriented programming in vba

My first "serious" language was Java, so I have comprehended object-oriented programming in sense that elemental brick of program is a class. Now I write on VBA and Python. There are module languages and I am feeling persistent discomfort: I don't know how should I decompose program in a modules/classes. I understand that one module cor...

How to edit a StringListProperty value in Google App Engine?

Hi, I would like to edit the value of a StringListProperty variable on App Engine. Is it possible? I don't see any sign of editable field for a StringListProperty variable right inside the DataViewer panel. ...

How to read symbols of an object file using C

Hi guys, Question is simple, i have a object file and i want to read the symbols of the object file via code. I am aware that the linux command "nm" would be able to do this, but i want to be able to do it inside code. Also note id like to do this either via C or Python. Regards Paul ...

Fast, thread-safe Python ORM?

Can you recommend a high-performance, thread-safe and stable ORM for Python? The data I need to work with isn't complex, so SQLAlchemy is probably an overkill. ...

Python regex with unicode characters bug?

Long story short: >>> re.compile(r"\w*").match(u"Français") <_sre.SRE_Match object at 0x1004246b0> >>> re.compile(r"^\w*$").match(u"Français") >>> re.compile(r"^\w*$").match(u"Franais") <_sre.SRE_Match object at 0x100424780> >>> Why doesn't it match the string with unicode characters with ^ and $ in the regex? As far as I understand ...

python and ruby equivalent of perls Template::Declare?

CPAN has the Template::Declare package. A declarative way to create html templates in perl code without any html directly written. I would love to use similar packages in python and ruby. Are there equivalent packages for those languages? ...

Django pre_save signal: check if instance is created not updated, does kwargs['created'] (still) exist?

I am using Django's pre_save signal to implement auto_now_add. There is a lot of discussion on the internet on why you should or shouldn't implement it yourself. I do not appreciate comments on this. Neither on whether I should be rewriting the save function (I have a lot of models that use auto_now_add so using signals makes sense). My...

Uninstall and Install Programs in windows using python script

Possible Duplicate: Add/remove programs in Windows XP with Python script I am a newbie in python and basically do windows sysadmin tasks and sometimes write batch script. However i am trying to learn python by implementing the scripts in windows tasks. The actual task i want to do is a follows: To remove acrobat reader or acro...

part of GtkLabel clickable

how to do, that just a part of GtkLabel has a clicked event and calls a function. i make a twitter client, witch shows tweets and i would like to, when in the tweet is a # hashtag and i click it, the application shows a new window with search of this #hashtag. and i dont know how to do that just the #hashtag would invoke this event. so...

IDE Suggestion for python and javascript

I am using python for web programming and javascript heavily. Currently, i am using NetBeans but i am looking for another IDE. NetBeans is not very good while programming with python and javascript. Any suggestion? ...

Python: How can I find all files with a particular extension?

I am trying to find all the .c files in a directory using Python. I wrote this, but it is just returning me all files - not just .c files. import os import re results = [] for folder in gamefolders: for f in os.listdir(folder): if re.search('.c', f): results += [f] print results How can I just get the .c f...

How does python load Boost.Python libraries?

Considering the following archetypal Boost.Python module, which brings a class "D" from a separate C++ header file. /* file: a/b.cpp */ BOOST_PYTHON_MODULE(c) { class_<d>("D") } When I compile this to a shared library, I'm confused how I can expose it to Python. What should I call the library? a.so? liba.so? b.so? libb.so? Where...

Execute a python command within vim and getting the output

When Vim is compiled with Python support, you can script Vim with Python using the :python command. How would I go about using this to execute the command and insert the result under the cursor? For example, if I were to execute :python import os; os.listdir('aDirectory')[0], I would want the first filename returned to be inserted under ...

Smart way to find out string encoding?

I wonder whether it is possible to find what is the encoding of string? I know that it may be impossible for some strings (e.g. that do not have non-ASCII characters). Maybe it is possible to obtain a list of encodings that may be correct (possible) for a given string? I'm looking for some other way than trying to decode/encode and wait...

Python - Timeit within a class

I'm having some real trouble with timing a function from within an instance of a class. I'm not sure I'm going about it the right way (never used timeIt before) and I tried a few variations of the second argument importing things, but no luck. Here's a silly example of what I'm doing: import timeit class TimedClass(): def __init__(...

Converting integer hex format into strings

Hi everybody, I am programming an application to send data using UDP sockets with Python 3.1. The command socket.send requires data in bytes format. The problem I am having is that the package I have to send has three different fields, the first one contains a 16 bits integer variable (c_ushort) and so does the second field whereas th...

Building a midi file - Python

Hi folks!! This is a follow-up on my previous question. I have successfully extracted a set of frequencies from input audio, now what would you guys recommend for building a MIDI file? Thanks for your help! ...

Skip python "import" statements in exuberant ctags

if I have two files file a.py: class A(): pass file b.py: from a import A b = A() When I use ctags and press Ctrl+] in vim, it redirects me to import statement, not to class definition. In this code all is ok: file a.py: class A(): pass file b.py: from a import * b = A() ...