python

Py2App Can't find standard modules

I've created an app using py2app, which works fine, but if I zip/unzip it, the newly unzipped version can't access standard python modules like traceback, or os. The manpage for zip claims that it preserves resource forks, and I've seen other applications packaged this way (I need to be able to put this in a .zip file). How do I fix this...

free Website testing tool

I am eager to know about any website testing software which is good in usability and look and feel. Here are the main areas that software should cover. 1. Find the image size. 2. To check broken links. 3. Loading time of website. 4. Test the load with many virtual users. 5. Check for useless codes placed in the source code. In short, I ...

How to find out whether computer is connected to internet?

how can I find it in python? thanks in advance ...

JavaFX or RIA desktop app (on dvd) also available on the web?

Is it possible to develop an application easily available on the web that also can be distributed on DVD (installer or started from the dvd)? For the moment, we use static html (frameset!) pages (generated by xml files), with one difference: pdf's are only on the DVD version, the web version only shows a preview of these files. Can thi...

Use QAction without adding to menu (or toolbar)

Hi everyone, I'm trying to develop an application with a very modular approach to commands and thought it would be nice, sind I'm using pyqt, to use QAction's to bind shortcuts to the commands. However, it seems that actions shortcuts only works when the action is visible in a menu or toolbar. Does anyone know a way to get this action t...

creating class instances from a list

Using python.....I have a list that contain names. I want to use each item in the list to create instances of a class. I can't use these items in their current condition (they're strings). Does anyone know how to do this in a loop. class trap(movevariables): def __init__(self): movevariables.__init__(self) if self.X=...

Improving Python list slicing

I've wondered why extend/append methods of Python don't return a reference to result list. To build string of all combination of list with last element, I would like to write simple: for i in range(l, 0, -1): yield " ".join(src[0:i-1].append(src[-1])) But I've got: TypeError. Instead following code with intermediate variable is us...

Moving to Python 2.6.x

My stuff is developed and running on Python 2.5.2 I want to move some code to 3.x, but that isn't feasible because so many of the external packages I use are not there yet. (Like numpy for instance). So, I'll do the intermediate step and go to 2.6.2. My question: If an external module runs on 2.5.2, but doesn't explicitly state th...

ctype question char**

Hi, I'm trying to figure out why this works after lots and lots of messing about with obo.librar_version is a c function which requires char ** as the input and does a strcpy to passed in char. from ctypes import * _OBO_C_DLL = 'obo.dll' STRING = c_char_p OBO_VERSION = _stdcall_libraries[_OBO_C_DLL].OBO_VERSION OBO_VERSION.restype =...

Python version shipping with Mac OS X Snow Leopard?

I would appreciate it if somebody running the final version of Snow Leopard could post what version of Python is included with the OS (on a Terminal, just type "python --version") Thanks! ...

Summing up two columns the Unix way

# To fix the symptom How can you sum up the following columns effectively? Column 1 1 3 3 ... Column 2 2323 343 232 ... This should give me Expected result 2324 346 235 ... I have the columns in two files. # Initial situation I use sometimes too many curly brackets such that I have used one more this { than this } in my f...

Documenting class attribute

Following sample is taken from "Dive into python" book. class MP3FileInfo(FileInfo): "store ID3v1.0 MP3 tags" tagDataMap = ... This sample shows documenting the MP3FileInfo, but how can I add help to MP3FileInfo. tagDataMap ...

Generate test coverage information from pyunit unittests?

I have some pyunit unit tests for a simple command line programme I'm writing. Is it possible for me to generate test coverage numbers? I want to see what lines aren't being covered by my tests. ...

"Unicode Error "unicodeescape" codec can't decode bytes... Cannot open text files in Python 3.

I am using python 3.1, on a windows 7 machines. Russian is the default system language, and utf-8 is the default encoding. Looking at the answer to a previous question, I have attempting using the "codecs" module to give me a little luck. Here's a few examples: >>> g = codecs.open("C:\Users\Eric\Desktop\beeline.txt", "r", encoding="utf...

Confusion about the Python path in Python shell vs FCGI server: Why are they different?

I'm trying to deploy my Django app into production on a shared server. It seems I'm having problems with the Python path because I'm getting the error from the server: No module named products.models However, when I go to the root of the app and run the shell the modules load fine. '>>> from products.models import Answer '>>> import s...

How do I create a file in python without overwriting an existing file

Currently I have a loop that tries to find an unused filename by adding suffixes to a filename string. Once it fails to find a file, it uses the name that failed to open a new file wit that name. Problem is this code is used in a website and there could be multiple attempts to do the same thing at the same time, so a race condition exi...

passing ctrl+z to pexpect

How do I pass a certain key combination to a spawned/child process using the pexpect module? I'm using telnet and have to pass Ctrl+Z to a remote server. Tnx ...

Gracefully-degrading pickling in Python

(You may read this question for some background) I would like to have a gracefully-degrading way to pickle objects in Python. When pickling an object, let's call it the main object, sometimes the Pickler raises an exception because it can't pickle a certain sub-object of the main object. For example, an error I've been getting a lot is...

SQLAlchemy session query with INSERT IGNORE

Hi, I'm trying to do a bulk insert/update with SQLAlchemy. Here's a snippet: for od in clist: where = and_(Offer.network_id==od['network_id'], Offer.external_id==od['external_id']) o = session.query(Offer).filter(where).first() if not o: o = Offer() o.network_id = od['network_id'] o.externa...

Different versions of msvcrt in ctypes

In Windows, the ctypes.cdll.msvcrt object automatically exists when I import the ctypes module, and it represents the msvcrt Microsoft C++ runtime library according to the docs. However, I notice that there is also a find_msvcrt function which will "return the filename of the VC runtype library used by Python". It further states, "If y...