how to find the drive in python/cygwin?

2005-04-26 Thread Mayer
ample, the letter 'g'? My program needs to run on an external media that comes with Cygwin on it. I have no control over what drive is assigned to that media, but for some reason, I do need to know the letter. Please help! Thanks, Mayer -- http://mail.python.org/mailman/listinfo/python-list

names of methods, exported functions

2005-04-27 Thread Mayer
eturn a list of strings. Thanks, Mayer -- http://mail.python.org/mailman/listinfo/python-list

annonymous functions -- how to

2005-05-04 Thread Mayer
Hello: I would like to define a very large annonymous function, one with several statements in sequence. I know how to define annonymous functions, but I don't know how to define a sequence of statements in their body. Can this be done in Python? If so, how? Thanks, Mayer --

help with generators

2005-05-18 Thread Mayer
if n == 0: yield s else: s.append(0) bin(n - 1) s.pop() s.append(1) bin(n - 1) s.pop() return bin(n) yet this doesn't work as expected. Can someone please explain why? Thanks, Mayer Goldberg -- http://

Re: help with generators

2005-05-19 Thread Mayer
e set of all possible words that are made up of that phone number. It's not a terribly useful program, but it's short and it's a lot of fun. Mayer import string def addKeyString(keyString): for ch in keyString: keypad[ch] = keyString keypad = {} addKeyString(

UserDict deprecated

2005-01-01 Thread Uwe Mayer
Hi, Why is the UserDict module is deprecated after Python 2.2. The application of it I have in mind is, i.e. multiple inheritance from "file" and "dic" - which is not possible. If I used UserDict I would not need to specify all methods UserDict provides alreay, anyway. Ciao Uwe -- http://mail.

Re: UserDict deprecated

2005-01-01 Thread Uwe Mayer
Saturday 01 January 2005 22:48 pm Hans Nowak wrote: > Uwe Mayer wrote: > >> Why is the UserDict module is deprecated after Python 2.2. The >> application of it I have in mind is, i.e. multiple inheritance from >> "file" and "dic" - which is not possib

Re: UserDict deprecated

2005-01-02 Thread Uwe Mayer
Saturday 01 January 2005 23:34 pm Steven Bethard wrote: [...] > If you implemented the file interface functions yourself, why do you > want to inherit from file? [...] > But just inheriting from list won't make this work, will it? Don't you > want to do something like: [...] Right. I guess th

missing sys.setappdefaultencoding

2005-01-07 Thread Uwe Mayer
Hi, well, I wrote a nice python program which won't work if the default encoding has not been set from ascii to latin-1 or latin-15. However, the command sys.setappdefaultencoding is missing on a Python installation with Python 2.3.4 on Gentoo where it is present on Debian. Any ideas how to deal

deleting from tarfile

2005-01-15 Thread Uwe Mayer
Hi, is it possible to delete a file from a tar-archive using the tarfile module? Thanks Uwe -- http://mail.python.org/mailman/listinfo/python-list

accessing class variables of private classes

2005-01-16 Thread Uwe Mayer
Hi, I need to access class variables of a class I'd like to make private: i.e. class __Bar(object): pass class __Foo(__Bar): def __init__(self): super(__Foo, self).__init__() >>> __Foo() Name Error: global name '_Foo__Foo' is not defined Here I want to prevent the user of instanciating

make install with python

2005-01-21 Thread Uwe Mayer
Hi, I am writing a Python application and use the GNU auto-tools to compile what needs compilation (i.e. Qt's .ui files). However, I don't know how to write an automake file that installs the main file (lmc.py) and some library files (i.e. ClassA.py, ClassB.py) into the appropriate directories.

Re: make install with python

2005-01-21 Thread Uwe Mayer
Friday 21 January 2005 20:47 pm Reinhold Birkenfeld wrote: [...] > The regular way is to use distutils and a setup.py file (google for > documentation). Ok, thanks. The document described just what I was looking for. Any suggestions how I handle

example needed: sip + Qt

2005-01-28 Thread Uwe Mayer
Hi, can someone provide me with a running example for subclassing QWidget (or something similarly simple) in C++ and then creating SIP (4.x+) bindings for in for Python (2.3+)? I am looking for something I can start of with and work my way towards more complicated stuff (with Qt). The QLabel ex

Re: example needed: sip + Qt

2005-01-28 Thread Uwe Mayer
On Friday 28 January 2005 14:47 pm, Phil Thompson wrote: > > The QLabel example in the SIP reference manual yields syntax errors for > > me. > > What syntax errors? If there is a documentation bug then I'll fix it. I'll come to that a little later, that happened in the simple c++ word example.

Re: example needed: sip + Qt

2005-01-28 Thread Uwe Mayer
On Friday 28 January 2005 14:24 pm, Craig Ringer wrote: > Out of curiosity, would this be for an extension module used in an > embedded Python interpreter, or for plain extension module for use with > a standalone interpreter? I am writing an application program using Python and PyQt: https://sava

Re: example needed: sip + Qt

2005-01-28 Thread Uwe Mayer
Friday 28 January 2005 23:18 pm Uwe Mayer wrote: > Traceback (most recent call last): > File "", line 1, in ? > ImportError: ./hello.so: undefined symbol: _ZTV5Hello > > $ c++filt _ZTV5Hello > vtable for Hello > > The compilation did not give any warnings or

Re: example needed: sip + Qt

2005-01-28 Thread Uwe Mayer
Friday 28 January 2005 23:39 pm Uwe Mayer wrote: > Friday 28 January 2005 23:18 pm Uwe Mayer wrote: >> Traceback (most recent call last): >> File "", line 1, in ? >> ImportError: ./hello.so: undefined symbol: _ZTV5Hello >> >> $ c++filt _ZTV5Hello >

Re: example needed: sip + Qt

2005-01-28 Thread Uwe Mayer
Saturday 29 January 2005 00:23 am Phil Thompson wrote: > So have you created the library you are trying to wrap? The documentation > is describing how to wrap a library and describes a fictional library as > the basis for the example. No, the extracts from before are from the code example of the

don't understand MRO

2005-06-23 Thread Uwe Mayer
Hi, I have a subclassed PyQt class: class Node(object): def move(self, x,y): pass class CRhomb(QCanvasPolygon, Node): pass $ python v2.4.1 >>> CRhomb.mro() [, , , , , , , ] >>> a = CRhomb() >>> a.move(1,2) This executes also Node.move(a, 1,2) Why? Because even QCanvasItem.move deleg

Re: don't understand MRO

2005-06-23 Thread Uwe Mayer
Thursday 23 June 2005 19:22 pm Terry Reedy wrote: [...] > In the absence of other information, I would presume that none of the > other classes have a move() method. move() is implemented in the class qtcanvas.QCanvasItem I checked the pyqt sources and it is linked via sip to the C++ object file.

Re: Favorite non-python language trick?

2005-06-24 Thread Uwe Mayer
Friday 24 June 2005 09:18 am Enrico wrote: [...] >> --This code will, because the first two dashes make the rest a comment, >> breaking the block >> ---[[ >> print(10) >> --]] [...] > python: > > """ > print 10 > """ > > and > > #""" > print 10 > #""" > > C++: > > /* > print(10); > */ > > a

Life of Python

2005-06-25 Thread Uwe Mayer
Hi, I have come across the following statement a number of times: http://mail.python.org/pipermail/python-list/2003-July/171805.html [... how to enforce pure abstract class ...] > Python, in general, doesn't try to stop the programmer doing things, the > way many other languages do. This is know

super problem

2005-06-25 Thread Uwe Mayer
Hi, I have a diamond-shaped multiple inheritanc chain with new style classes, but super() does not call the parent class correctly: -- snip -- from qtcanvas import * class B2(QCanvasItem): def move(self, x,y): super(B2, self).move(0,0) print "B2" class C2(QCanvasItem): d

Bug on Python2.3.4 [FreeBSD]?

2005-08-12 Thread Uwe Mayer
Hi, AFAICT there seems to be a bug on FreeBSD's Python 2.3.4 open function. The documentation states: > Modes 'r+', 'w+' and 'a+' open the file for updating (note that 'w+' > truncates the file). Append 'b' to the mode to open the file in binary > mode, on systems that differentiate between bin

Re: Bug on Python2.3.4 [FreeBSD]?

2005-08-12 Thread Uwe Mayer
Friday 12 August 2005 22:12 pm paolino wrote: [...] >f = open('test', 'a+') >f.read() >> >> '' >> >> -> append mode does not read from file, *not ok* >> >> > This is right IMO 'a' is appending so seek(-1) True, thank you. f.tell() shows the file pointer is at EOF. On my Debian Linux (u

Re: Bug on Python2.3.4 [FreeBSD]?

2005-08-12 Thread Uwe Mayer
Friday 12 August 2005 22:12 pm David Bolen wrote: > Which version of FreeBSD are you running? I thought it might be a > dependency on needing to seek between reads and writes on a duplex > stream (which is ANSI), but FreeBSD doesn't require that, at least > back as far as a 4.7 system I have, and

Re: Bug on Python2.3.4 [FreeBSD]?

2005-08-13 Thread Uwe Mayer
Saturday 13 August 2005 06:18 am Donn Cave wrote: > Of course, but the question was, where do reads start? I would > guess the GNU C library "innovated" on this point. But in the > end it doesn't really matter unless Python is going to try to > square that all up and make open() consistent acros

high resolution time needed

2005-02-21 Thread Uwe Mayer
Hi, I need a function returning a time value with a higher resolution that the standard 1sec unix timestamp. I found the clock() function in the time module, but that seems to return the same value (in the Python shell) each time I call it (Debian Linux speaking here). Any ideas? Thanks, Uwe -

non blocking read()

2004-12-01 Thread Uwe Mayer
Hi, I use select() to wait for a file object (stdin) to become readable. In that situation I wanted to read everything available from stdin and return to the select statement to wait for more. However, the file object's read method blocks if the number of bytes is 0 or negative. Is there no way

PHP vs. Python

2004-12-22 Thread stephen . mayer
Anyone know which is faster? I'm a PHP programmer but considering getting into Python ... did searches on Google but didn't turn much up on this. Thanks! Stephen -- http://mail.python.org/mailman/listinfo/python-list

subclassing list

2004-12-23 Thread Uwe Mayer
Hi, I want to subclass "list". The documentation states to prefer subclassing list instead of UserList. How to you clear the contents of a list subclass without creating a new object? Thanks in advance Uwe -- http://mail.python.org/mailman/listinfo/python-list

emulating python shell

2004-12-28 Thread Uwe Mayer
Hi, in an application I want to provide direct access to the python interpreter of the running program. I use rawinput() and exec() to read an input string and a self-made function to check wether the inputed block is closed and then execute it. When running python interactively the result of the

changing from python2.3 to python2.4

2005-04-08 Thread Uwe Mayer
I've written a little application which uses the bang-line #!/usr/bin/python to call the interpreter. As python 2.4 comes distributed with other distroes this breaks my application as its modules are installed in /usr/local/lib/python2.3/site-packages/... and python2.4 does not look there. How d

unknown encoding problem

2005-04-08 Thread Uwe Mayer
Hi, I need to read in a text file which seems to be stored in some unknown encoding. Opening and reading the files content returns: >>> f.read() '\x00 \x00 \x00<\x00l\x00o\x00g\x00E\x00n\x00t\x00r\x00y\x00... Each character has a \x00 prepended to it. I suspect its some kind of unicode - how do

singleton objects with decorators

2005-04-11 Thread Uwe Mayer
Hi, I've been looking into ways of creating singleton objects. With Python2.3 I usually used a module-level variable and a factory function to implement singleton objects. With Python2.4 I was looking into decorators. The examples from PEP 318 http://www.python.org/peps/pep-0318.html#examples do

Re: singleton objects with decorators

2005-04-12 Thread Uwe Mayer
Tuesday 12 April 2005 06:36 am Steven Bethard wrote: > Uwe Mayer wrote: >> I've been looking into ways of creating singleton objects. > > It strikes me that I've never wanted or needed a singleton object. > Would you mind sharing your use case? I'm just curio

Re: singleton objects with decorators

2005-04-12 Thread Uwe Mayer
Tuesday 12 April 2005 10:01 am Steven Bethard wrote: >> I am using a class to manage configuration settings in an application. >> This object should only existe once so that when the user >> changes a setting through a configuration dialog the change imminent in >> all locations where access to con

Re: singleton objects with decorators

2005-04-12 Thread Uwe Mayer
Tuesday 12 April 2005 12:09 pm Michele Simionato wrote: > Steven Bethard: >> It strikes me that I've never wanted or needed a singleton object. >> Would you mind sharing your use case? I'm just curious. > > "Singleton" is the most idiotic pattern ever. If you want an instance, > just > instantia

Re: singleton objects with decorators

2005-04-12 Thread Uwe Mayer
Tuesday 12 April 2005 14:51 pm Michele Simionato wrote: > No. Not everybody knows about Singleton. It is an acquired knowledge. Well, what isn't? What I ment to say, but failed to do so more explicitly, was that it is a term I felt which was generally known to "the programming society". Or that

Re: singleton objects with decorators

2005-04-12 Thread Uwe Mayer
Tuesday 12 April 2005 17:00 pm Michele Simionato wrote: > I did not put memoize on __new__. I put it on the metaclass __call__. > Here is my memoize: [...] Clever, thanks! :) Ciao Uwe -- http://mail.python.org/mailman/listinfo/python-list

Re: singleton objects with decorators

2005-04-12 Thread Uwe Mayer
Tuesday 12 April 2005 17:00 pm Michele Simionato wrote: > I did not put memoize on __new__. I put it on the metaclass __call__. > Here is my memoize: > > def memoize(func): > memoize_dic = {} > def wrapped_func(*args): > if args in memoize_dic: > return memoize_di

Re: singleton objects with decorators

2005-04-12 Thread Uwe Mayer
Tuesday 12 April 2005 18:51 pm Michele Simionato wrote: > Uhm? If I pass different parameters I want to have > different instances. The Singleton behaviour is recovered > only when I pass always the same arguments, in > particular when I pass 0-arguments: > class Foobar: > ... __metaclas

sscanf needed

2005-04-17 Thread Uwe Mayer
Hi, I've got a ISO 8601 formatted date-time string which I need to read into a datetime object. Is there a shorter way than using regular expressions? Is there a sscanf function as in C? Thanks, Uwe -- http://mail.python.org/mailman/listinfo/python-list

anonymous function objects?

2005-04-28 Thread Uwe Mayer
Is it possible to specify anonymous functions, something like: >>> f = {print "hello world"} >>> f() hello world in Pyton? Lambda expressions don't work here. Thanks, Uwe -- http://mail.python.org/mailman/listinfo/python-list

Re: anonymous function objects?

2005-04-28 Thread Uwe Mayer
Friday 29 April 2005 00:06 am Paul Rubin wrote: > Closest you can come is: > >f = lambda: sys.stdout.write("hello world\n") Ah. :)) Why does the "print" statement return a syntax error here? >>> lambda: print("hallo") File "", line 1 lambda: print("hallo") ^ SyntaxErro

Re: anonymous function objects?

2005-04-29 Thread Uwe Mayer
Friday 29 April 2005 05:40 am Michele Simionato wrote: > Uwe Mayer: >> Why does the "print" statement return a syntax error here? > > Google for "Python regrets" where Guido admits that > 'print' should have been a function. :) Will this c

AM_PATH_PYTHON - version problem

2005-06-01 Thread Uwe Mayer
Hi, I use the GNU autotools for packaging my python applications. My problem is that as I have both python2.3 and python2.4 installed the automake macros always detects the newest version and sets it path variables accordingly. How can I package the program for different versions of Python? (i.

Project layout / Import files from different subdirectories

2008-11-10 Thread Markus Mayer
Hi folks. I'm new to python and have a slight problem importing - or maybe understanding - modules. I'm writing a GUI application using Qt4 and wanted to separate the business from the view logic. So I have my folder structure as following: project/ main.py important.py project/ gui/ __

Re: Project layout / Import files from different subdirectories

2008-11-11 Thread Markus Mayer
Diez B. Roggisch schrieb: > > By placing a __init__.py into project, and then > > import project.main > import project.gui.mainwindow > > > Diez Ouch. Thanks. Markus -- PGP/GPG key 0x2EB39BF9 -- http://mail.python.org/mailman/listinfo/python-list

Re: Project layout / Import files from different subdirectories

2008-11-11 Thread Markus Mayer
Steve Holden schrieb: > If you want shorter names in your main code, of course, you can use > > import project.main as main > import project.gui.mainwindow as window > > or somethihg similar. > > regards > Steve Yeah, I was going with the "from x import y" scheme by now, didn't know "as" was a

Bug in PIL 1.1.6

2008-11-11 Thread Markus Mayer
Hi again. I seem to have stumbled over a bug in PIL 1.1.6's ImageQt module. It has problems with _some_ GIFs, which appear sheared after the conversion. Seems to be a scanline length problem or something. > ImageQt(Image.open(specific_gif_file)) displayed using a PyQt4 painter. Any idea where I

Re: Bug in PIL 1.1.6

2008-11-11 Thread Markus Mayer
[EMAIL PROTECTED] schrieb: > Markus Mayer: >> Any idea where I should send this (and/or more) information to? > > You can send your note and and image to effbot. > You can also put an image online somewhere and give here the link (a > small image, to avoid saturating your s

Re: Bug in PIL 1.1.6

2008-11-11 Thread Markus Mayer
Steve Holden schrieb: > [EMAIL PROTECTED] wrote: > From > > http://www.pythonware.com/products/pil/ > > """ > You can join the Image SIG via python.org's subscription page, or by > sending a mail to [EMAIL PROTECTED] Put subscribe in the > message body to automatically subscribe to the list, or

Re: Bug in PIL 1.1.6

2008-11-11 Thread Markus Mayer
Markus Mayer schrieb: > Okay, for the* tip, here we go: *2nd tip that is. I need some sleep. -- PGP/GPG key 0x2EB39BF9 -- http://mail.python.org/mailman/listinfo/python-list

prevent memory leak in C+Python

2006-03-20 Thread Uwe Mayer
Hi, I am wrapping a C function returning large amount of binary data back to Python using SWIG. I have the data malloc()ed or new()ed on the heap and buffer objects seem a good way to wrap it in python (http://docs.python.org/api/bufferObjects.html) >From the documentation it seems PyBuffer_Fro