Re: Introspection Class/Instance Name

2006-04-25 Thread Roland Heiber
*binarystar* wrote: > Hello there, > > what method would you use to return the name of the class and/or > instance introspectively eg. > > class Bollocks: > > def __init__( self ): > > print self.__method_that_returns_class_name__() > print self.__method_that_ret

Re: A __getattr__ for class methods?

2006-02-08 Thread Roland Heiber
Dylan Moreland wrote: > I have a metaclass generating basic properties such as .name and .city, > but I don't want to generate a class method for every permutation of > the attributes. I'd like to have something much like __getattr__ for > instance attributes, so that if a method like > Person.find

Re: Testing for the presence of input from stdin.

2006-01-24 Thread Roland Heiber
Will McDonald wrote: > Hi all. > > I'm writing a little script that operates on either stdin or a file > specified on the command line when run. I'm trying to handle the > situation where the script's run without any input gracefully but > can't think how to test for stdin. > Hi, maybe http://d

Re: Building a function call?

2005-07-13 Thread Roland Heiber
Peter Hansen wrote: >> locals().get("dothat")(*c) This was just meant as a quick example, not as production-level code ;) Even with globals(), I think its a bit odd ..., but safer than using eval() ... HtH, Roland -- http://mail.python.org/mailman/listinfo/python-list

Re: **kwargs?

2005-07-13 Thread Roland Heiber
Francois De Serres wrote: > All your **kwargs are belong to us. > > *args is documented in the Tutorial. I reckon **kwargs represents a > dictionary of arguments. But I don't quite get the semantics of **x. > Undefined length tuple of undefined length tuples? Are there other > practical use cas

Re: Building a function call?

2005-07-13 Thread Roland Heiber
Francois De Serres wrote: > Hiho, > > Having a string: "dothat" > and a tuple: (x, y) > 1. What's the best way to build a function call like: dothat(x,y)? Not the best (not at all) but one way: def dothat(x,y): print "Called with:", x, y c = (1,2) locals().get("dothat")(*c) Called wit

Re: Frankenstring

2005-07-13 Thread Roland Heiber
Roland Heiber wrote: > class MmapWithSeekAndTell(object): > def __init__(self, m, size): .. where m is a mmap-object and size the filesize ... sorry. -- http://mail.python.org/mailman/listinfo/python-list

Re: Frankenstring

2005-07-13 Thread Roland Heiber
Thomas Lotze wrote: > AIUI (and as a little experimenting seems to confirm), you can't > reposition an iterator over an mmap'ed file by seeking. True, you have > both iterating by characters and seeking/telling, but the two > functionalities don't play together. A quick and dirty hack!? Maybe i'm

Re: Frankenstring

2005-07-13 Thread Roland Heiber
Thomas Lotze wrote: > It's definitely no help that file-like objects are iterable; I do want > to get a character, not a complete line, at a time. Hi, if i did understand what you mean, what about using mmap? Iterating over characters in a file like this: # -*- coding: iso-8859-1 -*- import os

Re: python nested class

2005-07-08 Thread Roland Heiber
Vedanta Barooah wrote: > o = mother() > o.show() > y=mother.child() > y.increase(20) > # this should print 20 > o.show() > > .. is it possible somehow ??? Hi, this should do what you want: --- test.py class mother: x=0 def __init__(self): mother.x=1 d

Re: Serving binary data from a cgi-script

2005-05-11 Thread Roland Heiber
Thomas W wrote: > print d Hi, use sys.stdout.write instead, print is adding linebreaks ... HtH, Roland -- http://mail.python.org/mailman/listinfo/python-list

Re: Python instances

2005-04-20 Thread Roland Heiber
Hi, class MyClass: list = [] you have "list" defined as a classmember, not an instancemember. So "list" ist defined ONCE for all instances. Try this instead: class MyClass: def __init__(self): self.list = [] [...] and use self.list ... HtH, Roland -- http://mail.python.org/mailman

Re: Snakelets via SSL

2005-03-23 Thread Roland Heiber
Irmen de Jong wrote: However, may I ask you to re-submit the patch but this time in the patch tracker on SF; http://sourceforge.net/tracker/?group_id=41175 because news/mail clients often mangle source code. Hi, I re-submited it as requested. It's just a quick hack, but maybe it's worth trying. H

Snakelets via SSL

2005-03-23 Thread Roland Heiber
Hi, after Irmen de Jong did another fine release with Snakelets-1.38 i just did a dirty hack for using snakelets with SSL-support. SSL-support is added through the use of tlslite from Trevor Perrin. You'll have to download and install it from http://trevp.net/tlslite/. Furthermore you need a ke

Re: ANN: Snakelets 1.38 (simple-to-use web app server with dynamic pages)

2005-03-23 Thread Roland Heiber
Irmen de Jong wrote: I'm happy to say that Snakelets 1.38 is available. Fine thing again! Maybe someone is interested in this: I just tried tlslite and did a dirty hack so you could use snakelets via SSL. See the patch below. Snip and save it, use it against snakeserver/server.py. You've to plac

Re: Linux Multimedia System

2005-03-13 Thread Roland Heiber
Marek Franke wrote: too. The whole project is just for fun. Afaik Freevo and/or MythTV are written in C/C++ and don't have any support for joysticks (afaik!). And the Freevo is pure python already ;) Greetings, Roland -- http://mail.python.org/mailman/listinfo/python-list

Re: how to control a USB DISK?

2005-03-02 Thread Roland Heiber
Hi, when you're under linux and a 2.6er kernel, take a look at hotplug, you can configure it the way that your script gets executed whenever a specific device is plugged in/out ... HtH, Roland [EMAIL PROTECTED] wrote: when a new usb disk is plugged into the usb socket, the program will copy a fi

Re: Generating .pyc/.pyo from a make file

2005-02-03 Thread Roland Heiber
Roland Heiber wrote: Tim Daneliuk wrote: under the impression that "compiled" meant optimized byte code that You where right, i was totally mislead by "optimized" ... ;) Greetings, Roland -- http://mail.python.org/mailman/listinfo/python-list

Re: Generating .pyc/.pyo from a make file

2005-02-02 Thread Roland Heiber
Tim Daneliuk wrote: It does - thanks. One more question: Are pyc and pyo file portable across operating systems? I suspect not since I generated a pyo on a FreeBSD machine that will not run on a Win32 machine. I was under the impression that "compiled" meant optimized byte code that was portabl

Re: Generating .pyc/.pyo from a make file

2005-02-02 Thread Roland Heiber
Tim Daneliuk wrote: I use a makefile to create distribution tarballs of freestanding Python programs and their documentation. I cannot seem to find the right command line option to just generate a pyc/pyo file from the program and then exit. If I use 'python - -c"import myprog"' it creates th

Best python postgres module?

2005-01-28 Thread Roland Heiber
Hi, i recently migrated from mysql to postgresql and did use severel python postgres-modules. All do what they are designed for, so which one would you use? psycopg, pygresql, pypgsql? psycopg seems to be the best solution for heavy traffic/multiple connections i have no real testing envir

Re: Creating text on images

2005-01-13 Thread Roland Heiber
morphex wrote: Hi all, I'm trying to create a script that will superimpose text on an image. I didn't find any great examples out there on how this can be done (I presume using PIL is necessary), do you know of any examples? Thanks, Morten Hi, something like this? ### from PIL import Image, ImageFo

Re: here document

2005-01-11 Thread Roland Heiber
harold fellermann wrote: f = open("/bin/exe.x","w") print >>f , """CategoryY = GRIB etc. """ This would overwrite the existing /bin/exe.x ... HtH, Roland -- http://mail.python.org/mailman/listinfo/python-list

Re: Python IDE

2004-12-16 Thread Roland Heiber
limodou wrote: http://wiki.wookpecker.org.cn/moin.cgi/NewEdit Try this instead: http://wiki.woodpecker.org.cn/moin.cgi/NewEdit ^ SCNR, Roland ;) -- http://mail.python.org/mailman/listinfo/python-list

Re: KeyError

2004-12-16 Thread Roland Heiber
[EMAIL PROTECTED] wrote: Hi "R", The only explanation I can give is that the environment varialbe REMOTE_ADDR does not exist! Wrap your high-level code with try and except. Example: try: tablesDirectory = tablesDirectoryPrefix + os.environ['REMOTE_ADDR'] except KeyError: # Code to handle the f