python

Python drawing on screen

I'm coding an application that needs to select an area of the screen. I need to change the cursor to a cross and then draw a rectangle on the user selection. The first thing I searched for is how to manipulate the cursor and I came across wxPython. With wxPython I could easily do this on a Frame with a Panel, the thing is that I'd need t...

Is there any difference between cpython and python

Guys i am newbee and i am sorry if my question sounds a bit stupid. I really want to know the difference between cpython and python because from what i have heared is that python is developed in C then what is the use of CPython then ?? Thanks in Adavnce ...

Deplying Django with WSGI: App Import Error

Hi I am new in apache, linux and python world. I am trying to deploy django application on apache using WSGI (the recommended way). My django project directory structure is as follows... / /apache/django.wsgi /apps/ #I put all my apps in this directory /apps/providers/ /apps/shopping/ /apps/... /middleware/ ... In apache I have fo...

How to calculate the statistics "t-test" with numpy

I'm looking to generate some statistics about a model I created in python. I'd like to generate the t-test on it, but was wondering if there was an easy way to do this with numpy/scipy. Are there any good explanations around? For example, I have three related datasets that look like this: [55.0, 55.0, 47.0, 47.0, 55.0, 55.0, 55.0, 6...

What is the official name of this construct ?

In python: >>> a = b or {} ...

Is line wrap comment possible in Python?

I have a long string that I build with a bunch of calculated values. I then write this string to a file. I have it formatted like: string = str(a/b)+\ '\t'+str(c)\ '\t'+str(d)\ ... '\n' I would like to add comment to what each value represents but commenting with # or ''' doesn't work. Here's an ex...

Problem compiling mod_wsgi on Solaris 10 with Cool Stack 1.3.1

I try to compile mod_wsgi with Cool Stack 1.3.1 on the Solaris platform: export PATH=/usr/sbin:/usr/bin:/usr/local/bin:/usr/sfw/bin:/usr/ccs/bin FLAGS="-I/opt/coolstack/include" LIBS="-lintl -lgettextlib" \ LD_LIBRARY_PATH=/opt/coolstack/lib LDFLAGS="-L/opt/coolstack/lib -R/opt/coolstack/lib" \ ./configure --prefix=/usr/local/mod_wsgi ...

Debugging python programs in emacs

How to debug python programs in emacs? I use python-mode.el I get reference like import pdb; pdb.set_trace(); but not sure how to use it. ...

Please, I just need to improve my dictionary project in python...

Hi! I have 2 different dictionary programs that I want combined (or put together). The first one has the possibility to get good translation with grammar etc. Here is the code so far: words = {('i',): 'jeg', ('read',): 'leste', ('the', 'book'): 'boka'} max_group = len(max(words)) sentence = "I read the book".lower().split() translation ...

How do I activate (execute) methods of a class in Python?

I have a program (simple web server) which I try to understand. There is a class called MyHandler. In this class we define 2 methods do_GET and do_POST. I do not understand several things: Where do we use the two above defined methods? I would expect to see something like that objectname.do_GET() and objectname.do_POST() but I do not ...

Count warnings in Python 2.4

I've got some tests that need to count the number of warnings raised by a function. In Python 2.6 this is simple, using with warnings.catch_warnings(record=True) as warn: ... self.assertEquals(len(warn), 2) Unfortunately, with is not available in Python 2.4, so what else could I use? I can't simply check if there's been a sing...

Creating Python RPM

Hello, I have been reading about creating an RPM for Python 2.6.4. In this page: http://docs.python.org/distutils/builtdist.html it says you can create an RPM of the current Python using python setup.py bdist_rpm. The question's I have are: Do you have to type this command in your Python installation directory? Does this command, pack...

Why join is faster than normal concatenation

Hi, I've seen several examples from different languages that unambiguously prove that joining elements of a list(array) is times faster that just concatenating string. Unfortunately I didn't find an explanation why? Can someone explain the inner algorithm that works under both operations and why is the one faster than another. Here is...

How to redefine a wx.GridSizer?

Hello, I have this code: class SoundLog(wx.Frame): def __init__(self, *args, **kwargs): wx.Frame.__init__(self, size=(500, 350), *args, **kwargs) self.SetBackgroundColour((110,110,110)) self.sizer = wx.BoxSizer(wx.VERTICAL) pluginsNumber = len(plugins) - len(pluginsToHide) self.gs = wx.Grid...

Django admin - Restrict user view by permission

Hello, I'm starting to learn Django and I have a question. Is there any way to restric views in the administration interface? I see there are "change, "add" and "delete" permissions, but I wanted to restrict views also. For example: Two users, "User 1" is superuser and "User 2" is in the editor group. User 1 has access to everything, ...

Working with itertools.product and lists in python 3.

I'm trying to create a possible list of codons given a protein sequence. Basically, the script i'm trying to create will process a given string input and outputs a possible combinations of another set of strings the input represents. For example, the character 'F' represents either 'UUU' or 'UUC'; the character 'I' represents either 'A...

How to handle conditional-imports-dependent exceptions?

Hi, I'm wondering what is the most elegant way to handle exceptions that depend on a conditional import. For example: import ldap try: ... l = ldap.open(...) l.simple_bind_s(...) ... except ldap.INVALID_CREDENTIALS, e: pass except ldap.SERVER_DOWN, e: pass In the real-world scenario (the one that made me think ...

Python path: Reusing Python module

Hi, I have written a small DB access module that is extensively reused in many programs. My code is stored in a single directory tree /projects for backup and versioning reasons, and so the module should be placed within this directory tree, say at /projects/my_py_lib/dbconn.py. I want to easily configure Python to automatically sear...

Problem with makefile

Hello. I created a python project in IDE Anjuta, added some python files and the problem follows. I need that would make the program after a few .py files lying in src copied to dir /usr/bin. Anjuta generates enormous configure- and makefiles. 'll Show you need to register and where that would make described above. Thank you. ...

How to fix "ImportError: No module named ..." error in Python?

What is the correct way to fix this ImportError error? I have the following directory structure: /home/bodacydo /home/bodacydo/work /home/bodacydo/work/project /home/bodacydo/work/project/programs /home/bodacydo/work/project/foo And I am in the directory /home/bodacydo/work/project Now if I type python ./programs/my_python_progra...