When (and why) to use del?

2008-12-09 Thread Albert Hopkins
I'm looking at a person's code and I see a lot of stuff like this: def myfunction(): # do some stuff stuff my_string = function_that_returns_string() # do some stuff with my_string del my_string # do some other stuff r

Re: How to initialize a class variable once

2008-12-09 Thread George Sakkis
On Dec 9, 10:36 am, Joe Strout <[EMAIL PROTECTED]> wrote: > On Dec 9, 2008, at 4:31 AM, Brian Allen Vanderburg II wrote: > > > There is one situation where a module can be imported/executed   > > twice, if it is the __main__ module. > > That's an excellent point -- this is something I've run into,

Re: "as" keyword woes

2008-12-09 Thread Aaron Brady
On Dec 9, 8:28 am, MRAB <[EMAIL PROTECTED]> wrote: snip > In some languages (I think Delphi is one of them - it's been a while!) > some words which would normally be identifiers have a special meaning in > certain contexts, but the syntax precludes any ambiguity, and not in a > difficult way. "as"

Re: StringIO in 2.6 and beyond

2008-12-09 Thread Bill McClain
On 2008-12-08, Bill McClain <[EMAIL PROTECTED]> wrote: > On 2008-12-08, Christian Heimes <[EMAIL PROTECTED]> wrote: > > In this context 'str' means Python 3.0's str type, which is unicode in > > 2.x. Please report the misleading error message. > So this is an encoding problem? Can you give me a

Re: Google Summer of Code 2009

2008-12-09 Thread Eric
On Dec 9, 6:26 am, André <[EMAIL PROTECTED]> wrote: > On Dec 8, 10:34 pm, Eric <[EMAIL PROTECTED]> wrote: > > You should have a look athttp://wiki.python.org/moin/SummerOfCode > > It's still early, so there's nothing yet for 2009, but I am sure that > some ongoing projects mentioned in previous yea

Re: html codes

2008-12-09 Thread Daniel Fetchinson
>> I came across a javascript library that returns all sorts of html >> codes in the cookies it sets and I need my web framework (written in >> python :)) to decode them. I'm aware of htmlentitydefs but >> htmlentitydefs.entitydefs.keys( ) are of the form '&#xxx' but this >> javascript library uses

pickling a circular object inherited from list

2008-12-09 Thread Klaus Kopec
Hello everyone, I have a problem with inheritance from list. I want to create a tree like object where child nodes are kept in self[:] and every child has a field that points to its parent. Pickling such an object, however, throws an AssertionError. See below for source code and output of an

Re: 'pretty print' for built in types

2008-12-09 Thread Chris Rebert
On Tue, Dec 9, 2008 at 7:31 AM, Robert Dailey <[EMAIL PROTECTED]> wrote: > Hi, > > Is there a built in way to 'pretty print' a dict, list, and tuple > (Amongst other types)? Dicts probably print the ugliest of them all, > and it would be nice to see a way to print them in a readable way. I > can co

Re: how to get a beep, OS independent ?

2008-12-09 Thread Grant Edwards
On 2008-12-09, greg <[EMAIL PROTECTED]> wrote: > Duncan Booth wrote: > >> If I'm logged in to one of my servers in a large datacentre >> then I don't what that system to beep as that would be pretty >> useless. > > It also might cause the datacentre operators some > consternation when one of their

Re: 'pretty print' for built in types

2008-12-09 Thread aspersieman
On Tue, 09 Dec 2008 17:31:41 +0200, Robert Dailey <[EMAIL PROTECTED]> wrote: Is there a built in way to 'pretty print' a dict, list, and tuple (Amongst other types)? Dicts probably print the ugliest of them all, and it would be nice to see a way to print them in a readable way. I can come up wi

Re: 'pretty print' for built in types

2008-12-09 Thread eric
On Dec 9, 4:31 pm, Robert Dailey <[EMAIL PROTECTED]> wrote: > Hi, > > Is there a built in way to 'pretty print' a dict, list, and tuple > (Amongst other types)? Dicts probably print the ugliest of them all, > and it would be nice to see a way to print them in a readable way. I > can come up with my

Re: How to initialize a class variable once

2008-12-09 Thread Joe Strout
On Dec 9, 2008, at 4:31 AM, Brian Allen Vanderburg II wrote: There is one situation where a module can be imported/executed twice, if it is the __main__ module. That's an excellent point -- this is something I've run into, and it always feels a bit awkward to code around it. What's the stan

'pretty print' for built in types

2008-12-09 Thread Robert Dailey
Hi, Is there a built in way to 'pretty print' a dict, list, and tuple (Amongst other types)? Dicts probably print the ugliest of them all, and it would be nice to see a way to print them in a readable way. I can come up with my own function to do this, but I don't want to do this if I don't have t

Re: RuntimeError: dictionary changed size during iteration

2008-12-09 Thread Robert Dailey
On Dec 8, 10:27 pm, John Machin <[EMAIL PROTECTED]> wrote: > On Dec 9, 3:00 pm, Steven D'Aprano > > > > <[EMAIL PROTECTED]> wrote: > > On Mon, 08 Dec 2008 19:10:00 -0800, Robert Dailey wrote: > > > On Dec 8, 6:26 pm, Terry Reedy <[EMAIL PROTECTED]> wrote: > > >> Robert Dailey wrote: > > >> > stuff

Re: dBase III files and Visual Foxpro 6 files

2008-12-09 Thread imageguy
On Dec 8, 2:53 am, Ethan Furman <[EMAIL PROTECTED]> wrote: > Greetings All! > > I nearly have support complete for dBase III dbf/dbt files -- just > wrapping up support for dates.  The null value has been a hindrance for > awhile but I nearly have that solved as well. > > For any who know of a cool

Re: Learning Python now coming from Perl

2008-12-09 Thread J. Cliff Dyer
On Sun, 2008-12-07 at 11:05 +0900, Bertilo Wennergren wrote: > Aahz wrote: > > > In article <[EMAIL PROTECTED]>, > > > Bertilo Wennergren <[EMAIL PROTECTED]> wrote: > > >> I don't suppose there is any introductory material out there that is > >> based on Python 3000 and that is also geared at

Re: Guido's new method definition idea

2008-12-09 Thread ptn
On Dec 6, 10:15 am, "Russ P." <[EMAIL PROTECTED]> wrote: > On Dec 6, 4:32 am, Andreas Waldenburger <[EMAIL PROTECTED]> wrote: > > > > > On Sat, 6 Dec 2008 04:02:54 -0800 (PST) [EMAIL PROTECTED] wrote: > > > > class C: > > >     def $method(arg): > > >         $value = arg > > > > (Note there's no p

Re: Compiling and installing python 2.5.2 with Visual C++ 2008

2008-12-09 Thread Gabriel Genellina
En Tue, 09 Dec 2008 11:32:46 -0200, Juan Pablo Romero Méndez <[EMAIL PROTECTED]> escribió: I need to compile python myself because of a module (pivy). So I downloaded MS Visual C++ 2008 express edition. It apparently compiled fine but I don't know how to install it to recreate the standard dis

Re: "as" keyword woes

2008-12-09 Thread MRAB
Paul Boddie wrote: On 9 Des, 14:24, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: That is not what Guido said. What he actually said was: "That's possible with sufficiently powerful parser technology, but that's not how the Python parser (and most parsers, in my experience) trea

our real femme

2008-12-09 Thread delmararlee
Some of our real femme http://wesexy.byethost8.com/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Beginner trying to understand functions.

2008-12-09 Thread Cedric Schmeits
the following would be nicer: def run(): get_name() a = get_age() check_age(a) again() if __name__ == "__main__": run() In this setup your script will only be run if it's started by itself, but when using a import, the functions from the script can be executed separately. -

Re: Beginner trying to understand functions.

2008-12-09 Thread Bruno Desthuilliers
simonh a écrit : Thanks for the extra tips Ivan and Bruno. Here is how the program looks now. Any problems? import sys def get_name(): name = input('Please enter your name: ') print('Hello', name) This one would be better spelled "get_and_display_name" !-) def get_age(): t

Re: "as" keyword woes

2008-12-09 Thread Paul Boddie
On 9 Des, 14:24, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > > That is not what Guido said. What he actually said was: > > "That's possible with sufficiently powerful parser technology, but > that's not how the Python parser (and most parsers, in my experience) > treat reserved

Re: Learning Python now coming from Perl

2008-12-09 Thread Roy Smith
Nick Craig-Wood <[EMAIL PROTECTED]> wrote: > > On the other hand, leaving out the parens returns the function itself, > > which you can then call later. I've often used this to create data-driven > > logic. > > I didn't say it wasn't useful, just that if you came from Perl like I > did, it

Compiling and installing python 2.5.2 with Visual C++ 2008

2008-12-09 Thread Juan Pablo Romero Méndez
Hello all, I need to compile python myself because of a module (pivy). So I downloaded MS Visual C++ 2008 express edition. It apparently compiled fine but I don't know how to install it to recreate the standard distribution. In linux i'd take "make install", but on windows? Regards, Juan Pablo

Re: "as" keyword woes

2008-12-09 Thread Steven D'Aprano
On Tue, 09 Dec 2008 04:39:55 -0800, Paul Boddie wrote: > To be fair to the complainant, before mentioning the GIL, he did > initially get the usual trite fragments of the Zen of Python right back > at him ("simple is better than complex", "special cases aren't special > enough to break the rules"

Re: how to get a beep, OS independent ?

2008-12-09 Thread Duncan Booth
greg <[EMAIL PROTECTED]> wrote: > Duncan Booth wrote: >> If I'm logged in to one of my servers in a large datacentre then I >> don't what that system to beep as that would be pretty useless. > > It also might cause the datacentre operators some consternation > when one of their servers starts mys

Re: "as" keyword woes

2008-12-09 Thread BJörn Lindqvist
2008/12/4 Chris Mellon <[EMAIL PROTECTED]>: > Aside from the cultural indoctrination, though (and that may be a real > and strong force when dealing with math software, and I don't want to > discount it in general, just for purposes of this discussion) why is > it more sensible to use "x" here inst

Re: "as" keyword woes

2008-12-09 Thread Paul Boddie
On 9 Des, 05:52, alex23 <[EMAIL PROTECTED]> wrote: > > From my perspective, it was less the original complaint and more the > sudden jump to "CPython is dead! The GIL sucks! Academic eggheads!" > that prompted the comparisons to trolling. To be fair to the complainant, before mentioning the GIL, h

Re: Learning Python now coming from Perl

2008-12-09 Thread Nick Craig-Wood
Roy Smith <[EMAIL PROTECTED]> wrote: > In article <[EMAIL PROTECTED]>, > Nick Craig-Wood <[EMAIL PROTECTED]> wrote: > > > My favourite mistake when I made the transition was calling methods > > without parentheses. In perl it is common to call methods without > > parentheses - in python this

Re: close has no effect on Mac OSX Python 3.0

2008-12-09 Thread resi147
On 9 Dez., 07:51, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Mon, 08 Dec 2008 20:09:23 -0200, resi147 <[EMAIL PROTECTED]> escribió: > > > I'm wondering if it's really a bug since it's so trivial: > > > fp = open('/etc/services') > > ct = fp.read(1048) > > print(ct[-80:], end=''

Re: primera

2008-12-09 Thread Antoine De Groote
Oops, sorry, this message was not intended for the group. Apologies Antoine De Groote wrote: > zalli, > > du spills jo net mat am volley oder? mengs de du kinns dann mat mengem > auto an den MCM an eventuell op sandweiler fueren? well méindes ass > volley, densdes fussball, an mettwochs ass schon

Re: Rich Comparisons Gotcha

2008-12-09 Thread Rasmus Fogh
Steven DAprano wrote: > On Mon, 08 Dec 2008 14:24:59 +, Rasmus Fogh wrote: snip >> What might be a sensible behaviour (unlike your proposed wrapper) Sorry 1) I was rude, 2) I thanked TJR for your wrapper class proposal in a later mail. It is yours. > What do you dislike about my wrapper cla

primera

2008-12-09 Thread Antoine De Groote
zalli, du spills jo net mat am volley oder? mengs de du kinns dann mat mengem auto an den MCM an eventuell op sandweiler fueren? well méindes ass volley, densdes fussball, an mettwochs ass schon hellejen owend... nuecht antoine -- http://mail.python.org/mailman/listinfo/python-list

Re: How to initialize a class variable once

2008-12-09 Thread Brian Allen Vanderburg II
[EMAIL PROTECTED] wrote: Unless you are calling reload() on the module, it will only ever get _loaded_ once. Each additional import will just yield the existing module. Perhaps if you post an example of the behavior that leads you to believe that the class variables are getting reinitialized I c

Re: Google Summer of Code 2009

2008-12-09 Thread André
On Dec 8, 10:34 pm, Eric <[EMAIL PROTECTED]> wrote: > Hello, > I am interested in participating in Google Summer of Code 2009, > hopefully for something in Python.  I realize that this is way before > it begins, but I would like to start to get to know the community > better and find something that

Re: Rich Comparisons Gotcha

2008-12-09 Thread Mark Dickinson
On Dec 8, 2:24 pm, Rasmus Fogh <[EMAIL PROTECTED]> wrote: > So, I would much prefer a language change. I am not competent to even > propose one properly, but I'll try. I don't see any technical problems in what you propose: as far as I can see it's entirely feasible. However: > should. On the

Re: Beginner trying to understand functions.

2008-12-09 Thread simonh
Thanks for the extra tips Ivan and Bruno. Here is how the program looks now. Any problems? import sys def get_name(): name = input('Please enter your name: ') print('Hello', name) def get_age(): try: return int(input('Please enter your age: ')) except ValueE

Re: python3.0 - any hope it will get faster?

2008-12-09 Thread Christian Heimes
Helmut Jarausch wrote: I know that processing unicode is inherently slower, but still I was surprised that it's so much slower. Is there any hope Python-3.0 will get faster or is the main potential for optimizations exhausted, already? That's not to start a flame war! I know computers get faste

Re: Guido's new method definition idea

2008-12-09 Thread Antoine De Groote
[EMAIL PROTECTED] wrote: > On Dec 6, 4:15 pm, Carl Banks <[EMAIL PROTECTED]> wrote: [...] > > This brings up another question, what would one use when referencing > method names inside the class definition?: > > class C: > def self.method(arg): > self.value = arg > def self.othe

Re: python3.0 - any hope it will get faster?

2008-12-09 Thread Kay Schluehr
On 9 Dez., 11:51, Helmut Jarausch <[EMAIL PROTECTED]> wrote: > Hi, > > I was somewhat surprised when I ran pystones with python-2.5.2 and > with python-3.0 > > On my old/slow machine I get > > python-2.5.2 > from test import pystone > pystone.pystones() >gives (2.73, 18315.018315018315) > > py

python3.0 - any hope it will get faster?

2008-12-09 Thread Helmut Jarausch
Hi, I was somewhat surprised when I ran pystones with python-2.5.2 and with python-3.0 On my old/slow machine I get python-2.5.2 from test import pystone pystone.pystones() gives (2.73, 18315.018315018315) python-3.0 from test import pystone pystone.pystones() gives (4.2705,

Re: Beginner trying to understand functions.

2008-12-09 Thread Ivan Illarionov
On Dec 8, 9:02 pm, simonh <[EMAIL PROTECTED]> wrote: > Thanks for the many replies. Thanks especially to Pierre. This works > perfectly: > def getAge(): >     while True: >         try: >             age = int(input('Please enter your age: ')) >             return age > >         except ValueErr

Re: Rich Comparisons Gotcha

2008-12-09 Thread Rasmus Fogh
Steven DAprano wrote: > On Mon, 08 Dec 2008 14:24:59 +, Rasmus Fogh wrote: >> For my personal problem I could indeed wrap all objects in a wrapper >> with whatever 'correct' behaviour I want (thanks, TJR). It does seem a >> bit much, though, just to get code like this to work as intended: >>

Re: [Python 2.x] Pickling a datetime.tzinfo subclass instance?

2008-12-09 Thread Cong Ma
Gabriel Genellina wrote: > En Mon, 08 Dec 2008 12:34:03 -0200, Cong Ma <[EMAIL PROTECTED]> escribió: > >> I'm writing a program that pickles an instance of a custom subclass of >> datetime.tzinfo. I followed the guides given in the Library Reference >> (version >> 2.5.2, chapter 5.1.6), which cont

Re: Catching Python exceptions in C

2008-12-09 Thread Ivan Illarionov
On Dec 9, 12:33 pm, Ivan Illarionov <[EMAIL PROTECTED]> wrote: > On Dec 8, 9:42 pm, Senthil Kumar <[EMAIL PROTECTED]> wrote: > > > Hi Pythoneers ! > > Can somebody give a quick solution? > > I am trying to raise exceptions in python and trying to handle it in > > C. > > I am able to raise exception

Re: Catching Python exceptions in C

2008-12-09 Thread Ivan Illarionov
On Dec 8, 9:42 pm, Senthil Kumar <[EMAIL PROTECTED]> wrote: > Hi Pythoneers ! > Can somebody give a quick solution? > I am trying to raise exceptions in python and trying to handle it in > C. > I am able to raise exceptions successfully. However could not catch > those in C. > I am using the follow

Re: Guido's new method definition idea

2008-12-09 Thread Bruno Desthuilliers
william tanksley a écrit : On Dec 5, 6:21 pm, "Daniel Fetchinson" <[EMAIL PROTECTED]> wrote: I'd like this new way of defining methods, what do you guys think? Anyone ready for writing a PEP? I think it's an awesome proposal. It's about time! With this change, defining methods uses the same sp

Re: Beginner trying to understand functions.

2008-12-09 Thread Bruno Desthuilliers
simonh a écrit : Thanks for the many replies. Thanks especially to Pierre. This works perfectly: (snip) Ok, now for some algorithmic stuff: def checkAge(age,min=18,max=31): if age in list(range(min, max)): print('Come on in!') elif age < min: print('Sorry, too young.'

Re: Guido's new method definition idea

2008-12-09 Thread Aaron Brady
On Dec 8, 6:43 pm, william tanksley <[EMAIL PROTECTED]> wrote: > On Dec 5, 6:21 pm, "Daniel Fetchinson" <[EMAIL PROTECTED]> > wrote: > > > I'd like this new way of defining methods, what do you guys think? > > Anyone ready for writing a PEP? snip > > I see a lot of people are against it; I admit th

Re: ORB for Python and PHP

2008-12-09 Thread Diez B. Roggisch
Laszlo Nagy schrieb: There are others but they do not support both Python and PHP. Should I implement my own ORB, or do you know a suitable solution? The whole purpose of an ORB ist that it is interoperable. So if you have a good python orb (I personally prefer OmniORB), and a good one f

Re: ORB for Python and PHP

2008-12-09 Thread Laszlo Nagy
There are others but they do not support both Python and PHP. Should I implement my own ORB, or do you know a suitable solution? The whole purpose of an ORB ist that it is interoperable. So if you have a good python orb (I personally prefer OmniORB), and a good one for PHP - connect them.

Re: Announcement: MindTree for Python beta -- feedback appreciated

2008-12-09 Thread Johann Spies
> The MindTree project can be found and downloaded here: > http://code.google.com/p/mindtree/ > I suppose it might be a python3-problem: % /usr/local/bin/python3.0 MindTree.pyw Traceback (most recent call last): File "MindTree.pyw", line 2, in from future_builtins import * ImportError:

Re: gzip.GzipFile (was Re: Don't you just love writing this sort of thing :))

2008-12-09 Thread Jorgen Grahn
On Mon, 08 Dec 2008 14:21:40 +, MRAB <[EMAIL PROTECTED]> wrote: > Jorgen Grahn wrote: >> On Sat, 06 Dec 2008 10:01:10 +, Arnaud Delobelle <[EMAIL PROTECTED]> >> wrote: >> >> ... >>> Why use (open, gzp.GzipFile)[Entry.endswith(".gz")] when we have had >>> contitional expressions for a few

Re: html codes

2008-12-09 Thread Peter Otten
Daniel Fetchinson wrote: > I came across a javascript library that returns all sorts of html > codes in the cookies it sets and I need my web framework (written in > python :)) to decode them. I'm aware of htmlentitydefs but > htmlentitydefs.entitydefs.keys( ) are of the form '&#xxx' but this > ja

Re: html codes

2008-12-09 Thread Matt Nordhoff
Daniel Fetchinson wrote: > Hi folks, > > I came across a javascript library that returns all sorts of html > codes in the cookies it sets and I need my web framework (written in > python :)) to decode them. I'm aware of htmlentitydefs but > htmlentitydefs.entitydefs.keys( ) are of the form '&#xxx'

Re: Password input in console/terminal

2008-12-09 Thread cadmuxe
On 12月9日, 下午2时01分, "Chris Rebert" <[EMAIL PROTECTED]> wrote: > On Mon, Dec 8, 2008 at 9:53 PM, RP <[EMAIL PROTECTED]> wrote: > > Hello All, > > > This is my first REAL post(question) to Python-List. I know I can take input > > from a user with raw_input() > > How do I take password input in console

<    1   2