Re: lacking follow-through

2008-09-12 Thread Terry Reedy
Carl Banks wrote: I'm surprised there is anyone who still gives castironpi credit for being fully human. His recent posts have generally been quite different from those of some months ago. Even he recognizes that they were somewhat weird and has tried to do better. Did he ever make any de

Re: ctypes: Get full contents of character array

2008-09-12 Thread Aaron "Castironpi" Brady
On Sep 12, 6:38 pm, [EMAIL PROTECTED] wrote: > Hello! > > I wanted to get the full contents of a character array stored in a > struct, i.e. > _fields_ = [...("array", c_char * 12)...] > however, ctypes seems to try to return struct.array as a Python string > rather than a character array, and stops

Re: lacking follow-through

2008-09-12 Thread Carl Banks
On Sep 12, 8:16 am, Steve Holden <[EMAIL PROTECTED]> wrote: > castironpi wrote: > > On Sep 7, 5:03 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > >> On Mon, 08 Sep 2008 07:34:55 +1000, James Mills wrote: > >>> This is the strangest post I've seen > >>> since I've joined this list (only >

Re: lacking follow-through

2008-09-12 Thread Carl Banks
On Sep 12, 12:35 pm, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Steve Holden wrote: > > The defence rests. > > can you please stop quoting that guy, so we don't have to killfile you > as well... Guy? Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: n00b question: Better Syntax for Coroutines?

2008-09-12 Thread Carl Banks
On Sep 12, 9:08 pm, [EMAIL PROTECTED] wrote: > First off, I'm a python n00b, so feel free to comment on anything if > I'm doing it "the wrong way." I'm building a discrete event simulation > tool. I wanted to use coroutines. However, I want to know if there's > any way to hide a yield statement. >

Wrong application name in menubar of OS X

2008-09-12 Thread erikcw
Hi, The menubar of OS X is showing the application name as Python instead of the name of my wxpython gui app. How do I make my application name show-up in the menu bar? Thanks! Erik -- http://mail.python.org/mailman/listinfo/python-list

Re: universal unicode font for reportlab

2008-09-12 Thread Tim Roberts
Duncan Booth <[EMAIL PROTECTED]> wrote: > >The not too scientific test I did was to copy the font embedding example >from the Reportlab documentation, modify it enough to make it actually >run, and then change the output to have only one glyph. The resulting >PDF is virtually identical. I'm not

Re: n00b question: Better Syntax for Coroutines?

2008-09-12 Thread Aaron "Castironpi" Brady
On Sep 12, 8:08 pm, [EMAIL PROTECTED] wrote: > First off, I'm a python n00b, so feel free to comment on anything if > I'm doing it "the wrong way." I'm building a discrete event simulation > tool. I wanted to use coroutines. However, I want to know if there's > any way to hide a yield statement. >

Insider information, fackbook labs open today, we the first to register!

2008-09-12 Thread [EMAIL PROTECTED]
Insider information, fackbook labs open today, we the first to register! www.fackbooklabs.com -- http://mail.python.org/mailman/listinfo/python-list

Re: Good python web programming books

2008-09-12 Thread Sean DiZazzo
On Sep 12, 6:08 pm, "Chris Rebert" <[EMAIL PROTECTED]> wrote: > I've heard good things about The Django Book:http://www.djangobook.com/ > - Chris > > > > On Fri, Sep 12, 2008 at 5:57 PM, bhaarat Sharma <[EMAIL PROTECTED]> wrote: > > Hi Guys, > > > I am very new to python.  I am looking for a good b

Re: GUI programming with python

2008-09-12 Thread David Boddie
On Saturday 13 September 2008 01:04, sturlamolden wrote: > On Sep 12, 8:33 pm, [EMAIL PROTECTED] (Al Dykes) wrote: > >> OK, what are my choices for an IDE/GUI development tool that runs on XP? [...] > Cpython with PyQt: BlackAdder People using this combination apparently prefer Eric, these day

RELEASED Python 2.6rc1

2008-09-12 Thread Barry Warsaw
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On behalf of the Python development team and the Python community, I am happy to announce the first release candidate for Python 2.6. This is a release candidate, so while it is not suitable for production environments, we strongly encourage you

Re: Good python web programming books

2008-09-12 Thread bhaarat Sharma
That will be concentrating more on the Django framework On Fri, Sep 12, 2008 at 6:08 PM, Chris Rebert <[EMAIL PROTECTED]> wrote: > I've heard good things about The Django Book: http://www.djangobook.com/ > - Chris > > On Fri, Sep 12, 2008 at 5:57 PM, bhaarat Sharma <[EMAIL PROTECTED]> > wrote: >

n00b question: Better Syntax for Coroutines?

2008-09-12 Thread ig
First off, I'm a python n00b, so feel free to comment on anything if I'm doing it "the wrong way." I'm building a discrete event simulation tool. I wanted to use coroutines. However, I want to know if there's any way to hide a yield statement. I have a class that I'd like to look like this: class

Re: Good python web programming books

2008-09-12 Thread Chris Rebert
I've heard good things about The Django Book: http://www.djangobook.com/ - Chris On Fri, Sep 12, 2008 at 5:57 PM, bhaarat Sharma <[EMAIL PROTECTED]> wrote: > Hi Guys, > > I am very new to python. I am looking for a good book about python web > programming. > > I looked at a few online like Web Pr

Good python web programming books

2008-09-12 Thread bhaarat Sharma
Hi Guys, I am very new to python. I am looking for a good book about python web programming. I looked at a few online like Web Programming In Python but most are quite old. If you've read a good book on python web programming can you please suggest some? Thanks -- http://mail.python.org/mailma

Re: Gateway to python-list is generating bounce messages.

2008-09-12 Thread MRAB
On Sep 12, 11:15 pm, Matt Nordhoff <[EMAIL PROTECTED]> wrote: > Steven D'Aprano wrote: > > On Thu, 11 Sep 2008 17:27:33 +0200, Sjoerd Mullender wrote: > > >> When mail messages bounce, the MTA (Message Transfer Agent--the program > >> that handles mail) *should* send the bounce message to whatever

Re: Gateway to python-list is generating bounce messages.

2008-09-12 Thread Matt Nordhoff
Grant Edwards wrote: > On 2008-09-12, Matt Nordhoff <[EMAIL PROTECTED]> wrote: > >> I think you misunderstand. He's referring to the Sender >> header, not the From header. The messages the listbot sends >> out have a Sender header of >> "[EMAIL PROTECTED]" (supposing >> the subscriber's email addr

ctypes: Get full contents of character array

2008-09-12 Thread overdrigzed
Hello! I wanted to get the full contents of a character array stored in a struct, i.e. _fields_ = [...("array", c_char * 12)...] however, ctypes seems to try to return struct.array as a Python string rather than a character array, and stops as soon as it encounters a null within the character arra

Re: Gateway to python-list is generating bounce messages.

2008-09-12 Thread Grant Edwards
On 2008-09-12, Matt Nordhoff <[EMAIL PROTECTED]> wrote: > I think you misunderstand. He's referring to the Sender > header, not the From header. The messages the listbot sends > out have a Sender header of > "[EMAIL PROTECTED]" (supposing > the subscriber's email address is [EMAIL PROTECTED]). Bou

Re: conditional install/distribution

2008-09-12 Thread i3dmaster
On Sep 11, 11:07 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > i3dmasterschrieb: > > > Is there a feature in distutils or easy_install to specify what > > version of python that the target package can be installed? For > > example, if a package has a module that only needed if the python > >

Re: GUI programming with python

2008-09-12 Thread sturlamolden
On Sep 12, 8:33 pm, [EMAIL PROTECTED] (Al Dykes) wrote: > OK, what are my choices for an IDE/GUI development tool that runs on XP? That depends on the GUI toolkit you are using. My suggestion: CPython with wxPython: wxFormBuilder Cpython with PyQt: BlackAdder CPython with PyGTK: GLADE 3 Jytho

Re: setattr in class

2008-09-12 Thread Michael Palmer
On Sep 12, 11:08 am, Bojan Mihelac <[EMAIL PROTECTED]> wrote: > Hi all - when trying to set some dynamic attributes in class, for > example: > > class A: > for lang in ['1', '2']: > exec('title_%s = lang' % lang) #this work but is ugly > # setattr(A, "title_%s" % lang, lang) # t

Re: Python a good choice for experimenting with Win32 API?

2008-09-12 Thread sturlamolden
> (1) Would CPython be a good choice for this? How about iron python? How > about Jython (probably not). You can use CPython without any problems. Alternatives are pywin32, ctypes, cython, pyrex, Python C API. You can use .NET platform invoke from IronPython. You can use JNI from Jython, or an

Re: Gateway to python-list is generating bounce messages.

2008-09-12 Thread Matt Nordhoff
Steven D'Aprano wrote: > On Thu, 11 Sep 2008 17:27:33 +0200, Sjoerd Mullender wrote: > >> When mail messages bounce, the MTA (Message Transfer Agent--the program >> that handles mail) *should* send the bounce message to whatever is in >> the Sender header, and only if that header does not exist, s

Re: Accessing __slots__ from C

2008-09-12 Thread Carl Banks
On Sep 12, 10:01 am, Hrvoje Niksic <[EMAIL PROTECTED]> wrote: > Chris <[EMAIL PROTECTED]> writes: > >> descr = GetAttrString(cls,"varname"); > >> offset = descr->d_member->offset; > >> slotvar = (PyObject*)(((char*)obj)+offset) > > > Unfortunately, I am inexperienced at this kind of thing, so I was

Re: Python and Open Office

2008-09-12 Thread Gary Herron
Greg Lindstrom wrote: Hello, I would like to create and manipulate Open Office documents using Python. I have found then UNO Python page and odfpy modules which seem to be exactly what I need. The odfpy manual is, to me, a confusing list of objects and methods (it's an impressive list!), bu

Re: Which version

2008-09-12 Thread Don
Eric,Fredrik, Many thanks for your prompt advice, it was a 'better safe than sorry' type of question. Don -- http://mail.python.org/mailman/listinfo/python-list

Re: setattr in class

2008-09-12 Thread Arnaud Delobelle
On Sep 12, 4:30 pm, Bojan Mihelac <[EMAIL PROTECTED]> wrote: > On Sep 12, 5:21 pm, Christian Heimes <[EMAIL PROTECTED]> wrote: > > > Bojan Mihelac wrote: > > > I guess A class not yet exists in line 4. Is it possible to achive > > > adding dynamic attributes without using exec? > > > Correct, the c

Re: String to hexadecimal conversion

2008-09-12 Thread imageguy
On Sep 8, 5:05 am, Praveena P <[EMAIL PROTECTED]> wrote: > Hi folks, > > I am new to Python... so am not too sure about how the type conversion > works. > > I have to read a file that contains hexadecimal data and use the data > further to do some arithmetic calculations. > A sample of the input is

lxml build error in sun

2008-09-12 Thread Owen Zhang
I am trying to build lxml package in SunOS 5.10. I got the following errors. Does anybody know why? $ python setup.py build Building lxml version 2.1. NOTE: Trying to build without Cython, pre-generated 'src/lxml/ lxml.etree.c' needs to be available. Using build configuration of libxslt 1.1.7 Buil

Re: manipulating files within 'for'

2008-09-12 Thread bearophileHUGS
Matt Nordhoff: > BTW, I could easily be wrong, but I think C behaves the same way as Python. C syntax has many traps that are much better out of modern languages like Python/D/etc. I think C has that feature because it lacks an operator for string concatenation, while both Python and D have one (

Re: manipulating files within 'for'

2008-09-12 Thread bearophileHUGS
Matt Nordhoff: > It's useful when wrapping a line. For lack of better lorem ipsum: > > whatever = some_function("Your mistake is caused by Python not " > "following one of its general rules:\n\n" > "Explicit is better than implicit.") > > You can a

Re: GUI programming with python

2008-09-12 Thread Mike Driscoll
On Sep 12, 1:33 pm, [EMAIL PROTECTED] (Al Dykes) wrote: > In article <[EMAIL PROTECTED]>, > Alan Franzoni  <[EMAIL PROTECTED]> wrote: > > >zamil was kind enough to say: > > >[cut] > > >If your needs are very basic, you can stick with the tk module that comes > >with python. It's not really feature-

Re: book example confusion

2008-09-12 Thread byron
On Sep 12, 3:51 pm, John Machin <[EMAIL PROTECTED]> wrote: > On Sep 13, 5:36 am, byron <[EMAIL PROTECTED]> wrote: > > > > > I am reading o'reilly's learning python (great book), but i came > > across an example (pg 291, pdf) that I am not quite understanding the > > reasoning for the author's expla

Re: Matching horizontal white space

2008-09-12 Thread John Machin
On Sep 13, 12:52 am, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > multipleSpaces = re.compile(u'\\h+') > > > importantTextString = '\n  \n  \n \t\t  ' > > importantTextString = multipleSpaces.sub("M", importantTextString) > > what's "\\h" supposed to mean? Match *h*orizo

Re: GUI programming with python

2008-09-12 Thread Stef Mientki
Al Dykes wrote: In article <[EMAIL PROTECTED]>, Alan Franzoni <[EMAIL PROTECTED]> wrote: zamil was kind enough to say: [cut] If your needs are very basic, you can stick with the tk module that comes with python. It's not really feature-packed, but it's maintained and pretty cross-platform.

Re: manipulating files within 'for'

2008-09-12 Thread Matt Nordhoff
[EMAIL PROTECTED] wrote: > Ben Keshet: >> ...wrong. I thought I should omit the comma and didn't put it. I guess >> that stating the obvious should be the first attempt with beginners like >> me. Thanks for thinking about it (it's running perfect now). > > In CLisp, Scheme etc, lists such comma

Re: book example confusion

2008-09-12 Thread John Machin
On Sep 13, 5:36 am, byron <[EMAIL PROTECTED]> wrote: > I am reading o'reilly's learning python (great book), but i came > across an example (pg 291, pdf) that I am not quite understanding the > reasoning for the author's explanation: > > if f1() or f2(): > > The author states that do to the nature

Re: book example confusion

2008-09-12 Thread Chris Rebert
Note the parentheses after f1 and f2 in the second example. That's what calls the functions and causes them to be evaluated and run. - Chris Sent from my iPod On Sep 12, 2008, at 12:36 PM, byron <[EMAIL PROTECTED]> wrote: I am reading o'reilly's learning python (great book), but i came acro

Re: book example confusion

2008-09-12 Thread Bruno Desthuilliers
byron a écrit : I am reading o'reilly's learning python (great book), but i came across an example (pg 291, pdf) that I am not quite understanding the reasoning for the author's explanation: if f1() or f2(): The author states that do to the nature of that expression, if f1() returns True, f2()

book example confusion

2008-09-12 Thread byron
I am reading o'reilly's learning python (great book), but i came across an example (pg 291, pdf) that I am not quite understanding the reasoning for the author's explanation: if f1() or f2(): The author states that do to the nature of that expression, if f1() returns True, f2() will not be evalua

Re: Python on Windows XP 64-bit: python not found in registry

2008-09-12 Thread Martin v. Löwis
> Anybody here that had the same problem and solved it? Did you install the 32-bit or the 64-bit installer? If the 64-bit installer, did you also install 32-bit or 64-bit installers for iPython, PIL, and easy_install? If you try to use 32-bit extensions or installers to locate a 64-bit Python, t

Re: manipulating files within 'for'

2008-09-12 Thread bearophileHUGS
Ben Keshet: > ...wrong. I thought I should omit the comma and didn't put it. I guess > that stating the obvious should be the first attempt with beginners like > me. Thanks for thinking about it (it's running perfect now). In CLisp, Scheme etc, lists such commas aren't necessary, but in Python

Need help with the 'transport' for setting the header while calling a function at server side

2008-09-12 Thread Usman Ajmal
I am getting an Internal Server Error 500 when i run my client code. I am trying to call a function at the server side which for now only returns a string. Meanwhile this calling i also set the header of HTTP request. Following are my client and server code. Am i doing something wrong? #-

Re: Getting Linux partition info programmatically

2008-09-12 Thread Christian Heimes
python dev wrote: Hello everyone, I am trying to get a list of all the partitions (along with their respective file system types) listed in the /media directory. Does anybody know if there is a way to do this using Python, or do I have to get this information by parsing the output of a Linux co

Re: GUI programming with python

2008-09-12 Thread Al Dykes
In article <[EMAIL PROTECTED]>, Alan Franzoni <[EMAIL PROTECTED]> wrote: >zamil was kind enough to say: > >[cut] > >If your needs are very basic, you can stick with the tk module that comes >with python. It's not really feature-packed, but it's maintained and pretty >cross-platform. OK, what are

Getting Linux partition info programmatically

2008-09-12 Thread python dev
Hello everyone, I am trying to get a list of all the partitions (along with their respective file system types) listed in the /media directory. Does anybody know if there is a way to do this using Python, or do I have to get this information by parsing the output of a Linux command? Thanks in ad

Re: manipulating files within 'for'

2008-09-12 Thread Ben Keshet
Emile van Sebille wrote: Ben Keshet wrote: Hi Pythoneers, I have a question about a code I wrote with the help of someone. The code below copy a few lines from different files into one file. It works fine as it is given here and generates the new file 'pockets.out' correctly, but says:"p

Re: manipulating files within 'for'

2008-09-12 Thread Arnaud Delobelle
On Sep 12, 6:11 pm, Ben Keshet <[EMAIL PROTECTED]> wrote: > Hi Pythoneers, > > I have a question about a code I wrote with the help of someone. The > code below copy a few lines from different files into one file. It works > fine as it is given here and generates the new file 'pockets.out' > correc

Re: manipulating files within 'for'

2008-09-12 Thread Emile van Sebille
Ben Keshet wrote: Hi Pythoneers, I have a question about a code I wrote with the help of someone. The code below copy a few lines from different files into one file. It works fine as it is given here and generates the new file 'pockets.out' correctly, but says:"py returned exit code 0". H

Re: Which version

2008-09-12 Thread Fredrik Lundh
Eric Wertman wrote: The subprocess module is one though footnote: subprocess works on older versions too, and can be trivially installed along with your application under Python 2.2 and 2.3. binary builds for Windows are available here: http://effbot.org/downloads/#subprocess -- http:

Re: Which version

2008-09-12 Thread Fredrik Lundh
Don wrote: I'm a reasonably experienced in other languages and have just decided to get my feet wet with Python. But I'm using FC6 which has v2.4.4 installed, is this good enough to start out with or am I likely to encounter bugs that have been fixed in later versions. Python 2.4 is definitely

Re: Which version

2008-09-12 Thread Eric Wertman
> I'm a reasonably experienced in other languages and have just decided to > get my feet wet with Python. But I'm using FC6 which has v2.4.4 installed, > is this good enough to start out with or am I likely to encounter bugs that > have been fixed in later versions. I'm sure there will be other op

Which version

2008-09-12 Thread Don
Hi, I'm a reasonably experienced in other languages and have just decided to get my feet wet with Python. But I'm using FC6 which has v2.4.4 installed, is this good enough to start out with or am I likely to encounter bugs that have been fixed in later versions. Don -- http://mail.python.org/mail

Re: lacking follow-through

2008-09-12 Thread Aahz
In article <[EMAIL PROTECTED]>, Fredrik Lundh <[EMAIL PROTECTED]> wrote: >Steve Holden wrote: >> >> The defence rests. > >can you please stop quoting that guy, so we don't have to killfile you >as well... +1 -- Aahz ([EMAIL PROTECTED]) <*> http://www.pythoncraft.com/ "Argue f

manipulating files within 'for'

2008-09-12 Thread Ben Keshet
Hi Pythoneers, I have a question about a code I wrote with the help of someone. The code below copy a few lines from different files into one file. It works fine as it is given here and generates the new file 'pockets.out' correctly, but says:"py returned exit code 0". However, if I add m

Re: dict slice in python (translating perl to python)

2008-09-12 Thread Nick Craig-Wood
Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Thu, 11 Sep 2008 03:36:35 -0500, Nick Craig-Wood wrote: > > > As an ex-perl programmer and having used python for some years now, I'd > > type the explicit > > > > v1,v2,v3 = mydict['one'], mydict['two'], mydict['two'] # 54 chars > > > > Or mayb

Re: lacking follow-through

2008-09-12 Thread Fredrik Lundh
Steve Holden wrote: The defence rests. can you please stop quoting that guy, so we don't have to killfile you as well... -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie Question:Please help

2008-09-12 Thread Steve Holden
Karthik Krishnan wrote: > Hi, > > I am a newbie to python and I hope this is not a stupid question. I am > trying to run a main method from a Python command line using the command > shell using the command. > > python main_test.py > > I get the following error. > > > File "", line 1 > python

Re: lacking follow-through

2008-09-12 Thread Steve Holden
Aaron "Castironpi" Brady wrote: > On Sep 12, 7:23 am, Steve Holden <[EMAIL PROTECTED]> wrote: >> castironpi wrote: >> >> If you are flattered to be compared to an AI you must come from the same >> race as Mr. Spock in Star Trek. > > No, I said 'for my logic to compared'. Speaking of which, I thin

Re: Python a good choice for experimenting with Win32 API?

2008-09-12 Thread Mike Driscoll
On Sep 12, 10:36 am, "Siegfried Heintze" <[EMAIL PROTECTED]> wrote: > I need to understand some User32.dll functions and I'm making an elaborate > GUI so I can easily experiment with different parameters. This is taking a > long time. I'm new to python and I'm thinking it would sure be nice to have

Re: Checking the boolean value of a collection

2008-09-12 Thread bearophileHUGS
Marco Bizzarri: > >>> any([x for x in [1, 2, 3]]) > > I mean, I'm afraid I can't use an expression like that without > building a list... not at least in python2.3 Note that you don't need a list comp there: >>> any([x for x in [1, 2, 3]]) True >>> any([1, 2, 3]) True so this may suffice: any(s

Re: Checking the boolean value of a collection

2008-09-12 Thread Bruno Desthuilliers
Marco Bizzarri a écrit : (snip) I'm afraid this have another problem for me... [EMAIL PROTECTED]:/var/local/zope28/porting/Products/PAFlow$ python2.3 Python 2.3.5 (#2, Oct 18 2006, 23:04:45) [GCC 4.1.2 20061015 (prerelease) (Debian 4.1.1-16.1)] on linux2 Type "help", "copyright", "credits" or "

Re: Checking the boolean value of a collection

2008-09-12 Thread Fredrik Lundh
D'Arcy J.M. Cain wrote: Is there ever any advantage to having something as a builtin rather than as a regular user method? What difference does it make to the running script? I can see that adding "bar" from module "foo" to "__builtins__" means that you can use "bar()" instead of "foo.bar()".

Re: setattr in class

2008-09-12 Thread Bojan Mihelac
On Sep 12, 5:35 pm, Wojtek Walczak <[EMAIL PROTECTED]> wrote: > On Fri, 12 Sep 2008 08:08:18 -0700 (PDT), Bojan Mihelac wrote: > > Hi all - when trying to set some dynamic attributes in class, for > > example: > > > class A: > >     for lang in ['1', '2']: > >         exec('title_%s = lang' % lang)

Python a good choice for experimenting with Win32 API?

2008-09-12 Thread Siegfried Heintze
I need to understand some User32.dll functions and I'm making an elaborate GUI so I can easily experiment with different parameters. This is taking a long time. I'm new to python and I'm thinking it would sure be nice to have an interpreter I can type a few lines of code into and test things. (

Re: setattr in class

2008-09-12 Thread Wojtek Walczak
On Fri, 12 Sep 2008 08:08:18 -0700 (PDT), Bojan Mihelac wrote: > Hi all - when trying to set some dynamic attributes in class, for > example: > > class A: > for lang in ['1', '2']: > exec('title_%s = lang' % lang) #this work but is ugly > # setattr(A, "title_%s" % lang, lang) #

Re: setattr in class

2008-09-12 Thread Bojan Mihelac
On Sep 12, 5:21 pm, Christian Heimes <[EMAIL PROTECTED]> wrote: > Bojan Mihelac wrote: > > I guess A class not yet exists in line 4. Is it possible to achive > > adding dynamic attributes without using exec? > > Correct, the class doesn't exist until the end of the class body. You > can either do i

Re: setattr in class

2008-09-12 Thread Christian Heimes
Bojan Mihelac wrote: I guess A class not yet exists in line 4. Is it possible to achive adding dynamic attributes without using exec? Correct, the class doesn't exist until the end of the class body. You can either do it outside the class definition or you can use a metaclass. Christian --

Re: Checking the boolean value of a collection

2008-09-12 Thread D'Arcy J.M. Cain
On Fri, 12 Sep 2008 17:11:47 +0200 Fredrik Lundh <[EMAIL PROTECTED]> wrote: > The "__builtins__" object is an implementation detail, and shouldn't be > accessed directly. And I hope I don't need to point out that adding > custom builtins nillywilly is a bad idea... Is there ever any advantage t

Re: setattr in class

2008-09-12 Thread Fredrik Lundh
Bojan Mihelac wrote: Hi all - when trying to set some dynamic attributes in class, for example: class A: for lang in ['1', '2']: exec('title_%s = lang' % lang) #this work but is ugly # setattr(A, "title_%s" % lang, lang) # this wont work setattr(A, "title_1", "x") # this wo

Re: Checking the boolean value of a collection

2008-09-12 Thread Fredrik Lundh
Marco Bizzarri wrote: I would like to make this available to the whole project. I suspect I could put it in the package __init__.py... in that way, the __builtins__ namespace should have it... am I right? the __init__ module for package "foo" defines the contents of the "foo" module; it does

setattr in class

2008-09-12 Thread Bojan Mihelac
Hi all - when trying to set some dynamic attributes in class, for example: class A: for lang in ['1', '2']: exec('title_%s = lang' % lang) #this work but is ugly # setattr(A, "title_%s" % lang, lang) # this wont work setattr(A, "title_1", "x") # this work when outside class p

Re: Checking the boolean value of a collection

2008-09-12 Thread Marco Bizzarri
On Fri, Sep 12, 2008 at 4:44 PM, Diez B. Roggisch <[EMAIL PROTECTED]> wrote: >>> if any(instance.forbitToClose(archivefolder) for instance in >>> self.findActiveOutgoingRegistrationInstances()) >> >> Can you clarify where I can find "any"? It seems to me I'm unable to find >> it... > > It's part of

Re: Checking the boolean value of a collection

2008-09-12 Thread Marco Bizzarri
On Fri, Sep 12, 2008 at 4:44 PM, Diez B. Roggisch <[EMAIL PROTECTED]> wrote: >>> if any(instance.forbitToClose(archivefolder) for instance in >>> self.findActiveOutgoingRegistrationInstances()) >> >> Can you clarify where I can find "any"? It seems to me I'm unable to find >> it... > > It's part of

Re: Matching horizontal white space

2008-09-12 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: multipleSpaces = re.compile(u'\\h+') importantTextString = '\n \n \n \t\t ' importantTextString = multipleSpaces.sub("M", importantTextString) what's "\\h" supposed to mean? I would have expected consecutive spaces and tabs to be replaced by M but nothing is bein

Re: Checking the boolean value of a collection

2008-09-12 Thread Fredrik Lundh
Marco Bizzarri wrote: Can you clarify where I can find "any"? It seems to me I'm > unable to find it... it's a 2.5 addition. to use this in a "future-compatible" way in 2.3, you can add try: any except NameError: def any(iterable): for element in it

Re: Checking the boolean value of a collection

2008-09-12 Thread Diez B. Roggisch
if any(instance.forbitToClose(archivefolder) for instance in self.findActiveOutgoingRegistrationInstances()) Can you clarify where I can find "any"? It seems to me I'm unable to find it... It's part of python2.5. If you don't have that, you can write it your own and stuff it into __builtins_

Re: Accessing __slots__ from C

2008-09-12 Thread Hrvoje Niksic
Hrvoje Niksic <[EMAIL PROTECTED]> writes: > Chris <[EMAIL PROTECTED]> writes: > >>> descr = GetAttrString(cls,"varname"); >>> offset = descr->d_member->offset; >>> slotvar = (PyObject*)(((char*)obj)+offset) >> >> Unfortunately, I am inexperienced at this kind of thing, so I wasn't >> able to get s

Re: Checking the boolean value of a collection

2008-09-12 Thread Marco Bizzarri
On Fri, Sep 12, 2008 at 4:09 PM, Diez B. Roggisch <[EMAIL PROTECTED]> wrote: > Marco Bizzarri schrieb: >> >> Hi all. >> >> In many parts of my code I've the following schema of code: >> >>def isInUseByOutgoingRegistrations(self, archivefolder): >>for instance in self.findActiveOutgoingR

Re: Checking the boolean value of a collection

2008-09-12 Thread Diez B. Roggisch
Marco Bizzarri schrieb: Hi all. In many parts of my code I've the following schema of code: def isInUseByOutgoingRegistrations(self, archivefolder): for instance in self.findActiveOutgoingRegistrationInstances(): if instance.forbidToClose(archivefolder):

Re: Accessing __slots__ from C

2008-09-12 Thread Hrvoje Niksic
Chris <[EMAIL PROTECTED]> writes: >> descr = GetAttrString(cls,"varname"); >> offset = descr->d_member->offset; >> slotvar = (PyObject*)(((char*)obj)+offset) > > Unfortunately, I am inexperienced at this kind of thing, so I wasn't > able to get something working. Maybe someone could tell me what's

Re: lacking follow-through

2008-09-12 Thread Aaron "Castironpi" Brady
On Sep 12, 7:23 am, Steve Holden <[EMAIL PROTECTED]> wrote: > castironpi wrote: > > If you are flattered to be compared to an AI you must come from the same > race as Mr. Spock in Star Trek. No, I said 'for my logic to compared'. Speaking of which, I think you excluded the possibility of diligent

Re: Accessing __slots__ from C

2008-09-12 Thread Hrvoje Niksic
Chris <[EMAIL PROTECTED]> writes: >> In my experience, as long as you're >> accessing simple slots, you should notice a difference. > > (I'm not sure what you mean by a 'simple slot'. I mean a slot defined by __slots__ = slot1, slot2, slot3, ..., without descriptors or specific __getattribute__ c

Checking the boolean value of a collection

2008-09-12 Thread Marco Bizzarri
Hi all. In many parts of my code I've the following schema of code: def isInUseByOutgoingRegistrations(self, archivefolder): for instance in self.findActiveOutgoingRegistrationInstances(): if instance.forbidToClose(archivefolder): return True return

Re: Injecting new names into the above frame

2008-09-12 Thread Carsten Haese
Peter Waller wrote: > Dear Pythoners, > > I know this will probably be perceived as 'evil voodoo', and fair > enough: it probably is. I guess it is unpythonic. > > .. but I want to know how to do it anyway - mostly for my own > interest. Well, if you're really just asking out of curiosity, it sh

Re: Accessing __slots__ from C

2008-09-12 Thread Chris
Hrvoje Niksic xemacs.org> writes: ... > Chris users.sourceforge.net> writes: > > >> PyObject_GetAttrString is convenient, but it creates a Python string > >> only so it can intern it (and in most cases throw away the freshly > >> created version). For maximum efficiency, pre-create the string >

Injecting new names into the above frame

2008-09-12 Thread Peter Waller
Dear Pythoners, I know this will probably be perceived as 'evil voodoo', and fair enough: it probably is. I guess it is unpythonic. .. but I want to know how to do it anyway - mostly for my own interest. Consider the following snippet of code: --- def Get( *names ): if not names: return Non

Re: dynamic allocation file buffer

2008-09-12 Thread Aaron "Castironpi" Brady
On Sep 12, 4:34 am, Paul Boddie <[EMAIL PROTECTED]> wrote: > On 12 Sep, 08:30, Steven D'Aprano > > <[EMAIL PROTECTED]> wrote: > > > Which is why I previously said that XML was not well suited for random > > access. > > Maybe not. No, it's not. Element trees are, which if I just would have said or

Re: Please help me finding a way to implement os.path.issubpath(a, b)

2008-09-12 Thread Giampaolo Rodola'
On Sep 11, 8:04 pm, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > On Sep 11, 5:40 pm, "Giampaolo Rodola'" <[EMAIL PROTECTED]> wrote: > > > > > Hi, > > I'm trying to implement a function which returns whether a path is a > > subpath of another one (e.g. /a/b/c is a subpath of /a/b). > > I wrote this

Re: testing if another instance of a script is already running

2008-09-12 Thread Tim Golden
Tim Golden wrote: Strato wrote: Hi folks, I want to write some kind of test to check at startup if another instance of my script is already running. I don't want to handle writing of a PID file because it is too Unix/Linux specific way to do this, and I need to keep the code to be cross-pl

Re: String to hexadecimal conversion

2008-09-12 Thread Steve Holden
Praveena P wrote: > Hi folks, > > I am new to Python... so am not too sure about how the type conversion > works. > > I have to read a file that contains hexadecimal data and use the data > further to do some arithmetic calculations. > A sample of the input is : 20E032F840

Re: testing if another instance of a script is already running

2008-09-12 Thread Tim Golden
Strato wrote: Hi folks, I want to write some kind of test to check at startup if another instance of my script is already running. I don't want to handle writing of a PID file because it is too Unix/Linux specific way to do this, and I need to keep the code to be cross-platform. I think t

Re: Gateway to python-list is generating bounce messages.

2008-09-12 Thread Steven D'Aprano
On Thu, 11 Sep 2008 17:27:33 +0200, Sjoerd Mullender wrote: > When mail messages bounce, the MTA (Message Transfer Agent--the program > that handles mail) *should* send the bounce message to whatever is in > the Sender header, and only if that header does not exist, should it use > the From header

Re: Accessing __slots__ from C

2008-09-12 Thread Chris
Carl Banks gmail.com> writes: ... > You can determine the offset the of the slot in the object structure > by > querying the member descriptor of the type object. That sounds like just the kind of thing we were looking for - thanks! > descr = GetAttrString(cls,"varname"); > offset = descr->d_mem

Re: lacking follow-through

2008-09-12 Thread Steve Holden
castironpi wrote: [...] > For example, I sometimes hear people talk about salary as though it > were social approval, and vice versa. Even though the analogy doesn't > hold in every case generally, it is still a good way to express > yourself in many contexts, and especially when the more precise

Re: lacking follow-through

2008-09-12 Thread Steve Holden
castironpi wrote: > On Sep 7, 5:03 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: >> On Mon, 08 Sep 2008 07:34:55 +1000, James Mills wrote: >>> This is the strangest post I've seen >>> since I've joined this list (only >>> recently). What the ? >> Yeah, castironpi sometimes doesn't make mu

testing if another instance of a script is already running

2008-09-12 Thread Strato
Hi folks, I want to write some kind of test to check at startup if another instance of my script is already running. I don't want to handle writing of a PID file because it is too Unix/Linux specific way to do this, and I need to keep the code to be cross-platform. I think the better way t

Matching horizontal white space

2008-09-12 Thread Magnus . Moraberg
multipleSpaces = re.compile(u'\\h+') importantTextString = '\n \n \n \t\t ' importantTextString = multipleSpaces.sub("M", importantTextString) I would have expected consecutive spaces and tabs to be replaced by M but nothing is being replaced. If I try the following, then I'm left only with M,

  1   2   >