Re: ANN compiler2 : Produce bytecode from Python 2.5 Abstract Syntax Trees

2006-10-22 Thread Georg Brandl
Michael Spencer wrote: > Announcing: compiler2 > - > > For all you bytecode enthusiasts: 'compiler2' is an alternative to the > standard > library 'compiler' package, with several advantages. Is this a rewrite from scratch, or an improved stdlib compiler package? In the la

Re: pylint: What's wrong with the builtin map()

2006-10-22 Thread Georg Brandl
Tuomas wrote: > #!/usr/bin/python > """test pydev_0.9.3/../pylint""" > __revision__ = "test_mod 0.1 by TV 06/10/22" > > lst = ['aaa', ' bbb', '\tccc\n'] > lst = map(lambda x: x.strip(), lst) > > result = """ > No config file found, using default configuration > * Module test_mod > W:

Re: pylint: What's wrong with the builtin map()

2006-10-22 Thread Georg Brandl
Tuomas wrote: > Georg Brandl wrote: >> Some people think that all occurences of map() must be replaced >> by list comprehensions. The designer of pylint seems to be >> one of those. > > So it seems, but why? See Fredrik's post. There's no error in the

Re: ANN compiler2 : Produce bytecode from Python 2.5 Abstract Syntax Trees

2006-10-23 Thread Georg Brandl
Michael Spencer wrote: > Georg Brandl wrote: >> Michael Spencer wrote: >>> Announcing: compiler2 >>> - >>> >>> For all you bytecode enthusiasts: 'compiler2' is an alternative to the >>> standard >>&

Re: question about True values

2006-10-28 Thread Georg Brandl
J. Clifford Dyer wrote: > >>> (1 > 0) < 1 > False > >>> 1 > 0 < 1 > True > >>> 1 > (0 < 1) > False > >>> 10 > (0 < 1) > True I hope you know why this works the way it does. Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: Import if condition is correct

2006-10-28 Thread Georg Brandl
MindClass wrote: > Is possible import a library according to a condition? > > if Foo = True: > import bar > Why don't you try it? (in the above code, not the import is the problem, but using the assignment operator in an expression) Georg -- http://mail.python.org/mailman/listinfo/python-

Re: what is "@param" in docstrings?

2006-10-28 Thread Georg Brandl
[EMAIL PROTECTED] wrote: > I'm starting to read about twisted and I keep seeing things like: > [from twisted/internet/app.py] > > def __init__(self, name, uid=None, gid=None, authorizer=None, > authorizer_=None): > """Initialize me. > If uid and gid arguments are not provided,

Re: question about True values

2006-10-28 Thread Georg Brandl
J. Clifford Dyer wrote: > Georg Brandl wrote: >> J. Clifford Dyer wrote: >> >>> >>> (1 > 0) < 1 >>> False >>> >>> 1 > 0 < 1 >>> True >>> >>> 1 > (0 < 1) >>> False >>> >

Re: question about True values

2006-10-28 Thread Georg Brandl
Chetan wrote: >> Steven D'Aprano wrote: >> > On Sat, 28 Oct 2006 03:13:42 +0100, Steve Holden wrote: >> > >> >>> Finally, while True/False is a good mental mapping for numeric >> >>> comparisons, >> >>> take the following: >> >>> >> >>> >>> if "Cliff is a pillar of the open source community": >>

Re: question about True values

2006-10-29 Thread Georg Brandl
Chetan wrote: >>> I am joining after some network downtime here, so I seem to have missed what >>> the real issue here is. At the risk of being completely irrelevant to the >>> discussion here, I think it doesn't seem to be just about something or >>> nothing - is None something or nothing? It see

Re: Metaclasses are not called in subclasses. What did I wrong?

2006-10-29 Thread Georg Brandl
Létező wrote: > I use Python 2.4.4. Please read the code below: > > --- > from new import classobj > > def mymeta(name,bases,clsdict): > print 'meta: %s'%name > return classobj(name,bases,clsdict) > > class A(object): > __metacl

Re: enumerate improvement proposal

2006-10-29 Thread Georg Brandl
James Stroud wrote: > I think that it would be handy for enumerate to behave as such: > > def enumerate(itrbl, start=0, step=1): >i = start >for it in itrbl: > yield (i, it) > i += step > > This allows much more flexibility than in the current enumerate, > tightens up code in m

Re: Python Distilled

2006-11-06 Thread Georg Brandl
Marc 'BlackJack' Rintsch wrote: > In <[EMAIL PROTECTED]>, Simon Wittber > wrote: > >> I'd also like to remove any deprecated or stuff which is left in for >> backwards functionality (eg Classic classes). > > Classic classes are still needed for exceptions: > class E(object): > ...pass >

Re: Python Distilled

2006-11-06 Thread Georg Brandl
Paul McGuire wrote: > "Marc 'BlackJack' Rintsch" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> In <[EMAIL PROTECTED]>, Simon Wittber >> wrote: >> >>> I'd also like to remove any deprecated or stuff which is left in for >>> backwards functionality (eg Classic classes). >> >> Clas

Re: Unicode/ascii encoding nightmare

2006-11-06 Thread Georg Brandl
Thomas W wrote: > I'm getting really annoyed with python in regards to > unicode/ascii-encoding problems. > > The string below is the encoding of the norwegian word "fødselsdag". > s = 'f\xc3\x83\xc2\xb8dselsdag' Which encoding is this? > I stored the string as "fødselsdag" but somewhere i

Re: Is there a commas-in-between idiom?

2006-11-08 Thread Georg Brandl
Peter van Kampen schrieb: > On 2006-11-06, Fredrik Lundh <[EMAIL PROTECTED]> wrote: >> I've collected a bunch of list pydioms and other notes here: >> >> http://effbot.org/zone/python-list.htm > > """ > A = B = [] # both names will point to the same list > """ > > I've been bitten by this onc

Re: Simple question to split

2006-11-09 Thread Georg Brandl
Diez B. Roggisch schrieb: > Diez B. Roggisch schrieb: >> Matthias Winterland schrieb: >>> Hi, >>> >>> I have a simple question. When I read in a string like: >>> a='1,2,3,4,5 6 7,3,4', can I get the list l=[1,2,3,4,5,6,7,3,4] with a >>> single split-call? >> >> Nope. But you could replace the com

Re: Py3K idea: why not drop the colon?

2006-11-11 Thread Georg Brandl
Ron Adam wrote: > Michael Hobbs wrote: > >> The same problem that is solved by not having to type parens around the >> 'if' conditional, a la C and its derivatives. That is, it's unnecessary >> typing to no good advantage, IMHO. I was coding in Ruby for several >> months and got very comfortabl

Re: Py3K idea: why not drop the colon?

2006-11-11 Thread Georg Brandl
Ron Adam wrote: > Georg Brandl wrote: >> Ron Adam wrote: >>> Michael Hobbs wrote: >>> >>>> The same problem that is solved by not having to type parens around the >>>> 'if' conditional, a la C and its derivatives. That is, it's un

Re: Python 3000 idea -- + on iterables -> itertools.chain

2006-11-13 Thread Georg Brandl
George Sakkis wrote: > Fredrik Lundh wrote: > >> John Reese wrote: >> >> > It seems like it would be clear and mostly backwards compatible if the >> > + operator on any iterables created a new iterable that iterated >> > throught first its left operand and then its right, in the style of >> > iter

Re: Python 3000 idea -- + on iterables -> itertools.chain

2006-11-13 Thread Georg Brandl
Carl Banks wrote: > Georg Brandl wrote: >> What has a better chance of success in my eyes is an extension to yield >> all items from an iterable without using an explicit for loop: instead of >> >> for item in iterable: >> yield item >> >> you c

Re: Py3K idea: why not drop the colon?

2006-11-13 Thread Georg Brandl
Michael Hobbs wrote: > Georg Brandl wrote: >> Ron Adam wrote: >> >>> Michael Hobbs wrote: >>> >>> >>>> The same problem that is solved by not having to type parens around the >>>> 'if' conditional, a la C and

Re: atexit.register does not return the registered function. IMHO, it should.

2006-11-16 Thread Georg Brandl
Skip Montanaro schrieb: >> Since that the decorator syntax is upon us, I think it would be good if >> atexit.register() was returning the function passed as argument. This >> simple change to the library would solve a problem with the use of >> atexit.register as a decorator (and I can't think of

Re: is it possible to find which process dumped core

2006-06-05 Thread Georg Brandl
Steve Holden wrote: > su wrote: >> to find which process dumped core at the promt we give >> >> $ file core.28424 >> >> core.28424: ELF 32-bit LSB core file of 'soffice.bin' (signal 11), >> Intel 80386, version 1 (SYSV), from 'soffice.bin' >> >> from this command we know 'soffice.bin' process du

Re: Question about the Exception class

2006-06-14 Thread Georg Brandl
Carl J. Van Arsdall wrote: > So this is probably a fairly basic question, but help me out because I'm > just not lining things up and I'm somewhat new to the world of exception > handling. > > What's the benefit to inheriting an exception from and of the available > parent exception classes? D

Re: nested functions

2006-06-14 Thread Georg Brandl
George Sakkis wrote: > Ben Finney wrote: > >> "Gregory Petrosyan" <[EMAIL PROTECTED]> writes: >> >> > I often make helper functions nested, like this: >> > >> > def f(): >> > def helper(): >> > ... >> > ... >> > >> > is it a good practice or not? >> >> You have my blessing. Used we

Re: struct.unpack on 64-bit platforms

2006-06-22 Thread Georg Brandl
Nadav Samet wrote: > Hi, > > I am trying to unpack a 32-bit unsigned integer from a string using > struct.unpack. > so using string.unpack('L', data) would work fine on 32-bit systems, > > But apparently, on 64-bit platforms it tries to read 64-bit unsigned > integer (since > that's what the C T

Re: Immutability

2006-06-28 Thread Georg Brandl
Nick Maclaren wrote: > In article <[EMAIL PROTECTED]>, > Robert Kern <[EMAIL PROTECTED]> writes: > |> Nick Maclaren wrote: > |> > The way that I read it, Python allows only values (and hence types) > |> > to be immutable, and not class members. The nearest approach to the > |> > latter is to use t

Re: Immutability

2006-06-28 Thread Georg Brandl
Steve Holden wrote: >>>Thanks very much. And, what's more, I have even found its documentation! >>>Whatsnew2.2. The 2.4.2 reference is, er, unhelpful. >> >> >> Is it? >> >> http://docs.python.org/lib/built-in-funcs.html >> >> documents "property" quite well. >> > I can't really agree that "

Re: how do i make an array global

2006-06-28 Thread Georg Brandl
Erik Max Francis wrote: > a wrote: > >> def fn(): >> for i in range(l) >>global count >>count[i]= >> >> how do i declare count to be global if it is an array > > count = [...] > > def fn(): > global count > for i in range(l): >

Re: how do i make an array global

2006-06-28 Thread Georg Brandl
Bruno Desthuilliers wrote: > a wrote: >> def fn(): >> for i in range(l) > > l is not defined - you should have an error here. > >>global count >>count[i]= >> >> how do i declare count to be global if it is an array > > Just like it was an integer No. If he's on

Re: Immutability

2006-06-28 Thread Georg Brandl
Duncan Booth wrote: > Georg Brandl wrote: > >> In my opinion property isn't really meant to be used as a decorator since >> it's impossible to create a read-write property. The decorator pattern >> doesn't really fit here. >> > I agree that p

Re: Immutability

2006-06-28 Thread Georg Brandl
Nick Maclaren wrote: > In article <[EMAIL PROTECTED]>, > "Fredrik Lundh" <[EMAIL PROTECTED]> writes: > |> > |> identical? you only applied @property to one of the methods, and then > you're > |> surprised that only one of the methods were turned into a property? > > I wasn't expecting EITHER to

Re: how do i make an array global

2006-06-28 Thread Georg Brandl
Bruno Desthuilliers wrote: > Georg Brandl wrote: >> Bruno Desthuilliers wrote: >> >>>a wrote: >>> >>>>def fn(): >>>> for i in range(l) >>> >>>l is not defined - you should have an error here. >>> >>>

Re: Generator naming convention?

2006-06-29 Thread Georg Brandl
[EMAIL PROTECTED] wrote: > I use generators a lot. E.g. > > > def gen_words(text) > ... parse text ... > yield each word in text > > for word in gen_words(text): > print word > > > I don't like the name gen_xxx() very much. Looking for some inspiration > to name generators. Here are some

Re: Immutability

2006-06-29 Thread Georg Brandl
Steve Holden wrote: > Georg Brandl wrote: >> Nick Maclaren wrote: >> >>>In article <[EMAIL PROTECTED]>, >>>"Fredrik Lundh" <[EMAIL PROTECTED]> writes: >>>|> >>>|> identical? you only applied @property to one of the

Re: Bug reporting impossible

2006-06-29 Thread Georg Brandl
Nick Maclaren wrote: > Currently logins are disabled to sourceforge.net, and (despite the > comments) it won't let me report a bug anonymously. Does anyone > know whether this is short or long term? I have a bug in 2.5 to > report - which has been there for a while and isn't overwhelmingly > crit

Re: Immutability

2006-06-29 Thread Georg Brandl
Steve Holden wrote: > Georg Brandl wrote: >> Steve Holden wrote: > [...] >> >>>Would it make sense, in the single argument case, to default the doc >>>value to fget.__doc__ to support that use case, or should we just not >>>create read-onl

Re: Way for see if dict has a key

2006-06-30 Thread Georg Brandl
Bruno Desthuilliers wrote: > looping wrote: >> Michele Petrazzo wrote: >> >>>Bruno Desthuilliers wrote: >>> >but what the better Depends on the context. >>> >>>If know only one context: see if the key are into the dict... What other >>>context do you know? >>> >> >> Why do you

Re: Way for see if dict has a key

2006-06-30 Thread Georg Brandl
Bruno Desthuilliers wrote: >>> value = dict.get(key, None) >> >> >> value = dict.get(key) > > Yes - but : > 1/ not everybody knows that dict.get() takes a second optional param. > Note that, while it happens that the default return value of dict.get() > is the same as in the above example, but

Re: Immutability

2006-06-30 Thread Georg Brandl
Georg Brandl wrote: > Steve Holden wrote: >> Georg Brandl wrote: >>> Steve Holden wrote: >> [...] >>> >>>>Would it make sense, in the single argument case, to default the doc >>>>value to fget.__doc__ to support that use case, or sho

Re: Module executed twice when imported!

2006-06-30 Thread Georg Brandl
Michael Abbott wrote: > In article <[EMAIL PROTECTED]>, > John Salerno <[EMAIL PROTECTED]> wrote: > >> > (http://docs.python.org/lib/built-in-funcs.html#l2h-24) >> > "It is different from the import statement in that it does not use the >> > module administration --" >> >> Just after the above s

Re: Import bug: Module executed twice when imported!

2006-06-30 Thread Georg Brandl
Peter Maas wrote: > The docs tell us > (http://www.python.org/doc/2.4.2/lib/built-in-funcs.html): > > - begin --- > execfile(filename[, globals[, locals]]) > > This function is similar to the exec statement, but parses a file > instead of a str

Re: Module executed twice when imported!

2006-07-01 Thread Georg Brandl
Michael Abbott wrote: > In article <[EMAIL PROTECTED]>, > Georg Brandl <[EMAIL PROTECTED]> wrote: >> That's because __name__ is normally set to the module's name in the package >> hierarchy. When you set it to "some1.some2", Python thinks it'

Re: sqlite3 in Python 2.5b1: my out-of-the-box experience

2006-07-04 Thread Georg Brandl
John Machin wrote: > Apologies in advance if this is a bit bloggy, but I'd like to get > comments on whether I've lost the plot (or, more likely, failed to > acquire it) before I start reporting bugs etc. Please forward to Gerhard Haering if you still think these are bugs. Georg -- http://mai

Re: fonction in python

2006-07-04 Thread Georg Brandl
aliassaf wrote: > Hello, > > If we write = x^2 and if I give to the program the values of x, it will > going to calculate the values of y, and also for x. > > But it is possible ? that is if I give to the program the values of X and Y, > it will indicate to me the relation between the two

Re: Why can't I subclass off of "date" ?

2006-08-24 Thread Georg Brandl
[EMAIL PROTECTED] wrote: > Ok, maybe this is a stupid question, but why can't I make a subclass of > datetime.date and override the __init__ method? > > --- > > from datetime import date > > class A(date): > def __init__(self, a, b, c, d): > print a, b, c, d > date.__init__(s

Re: callable to disappear?

2006-08-25 Thread Georg Brandl
Antoon Pardon wrote: > I have been reading http://www.python.org/dev/peps/pep-3100/ > en there is written: > > To be removed: > ... > > callable(): just call the object and catch the exception > > ... > Is there a chance this will be reconsidered? > There was some discus

Re: List problem

2006-08-25 Thread Georg Brandl
[EMAIL PROTECTED] wrote: > For example i write the following code in the Python command line; > list = ['One,Two,Three,Four'] > > Then enter this command, which will then return the following; > > ['One,Two,Three,Four'] This is already wrong. Assignments do not return anything. Georg -- h

Re: Taking data from a text file to parse html page

2006-08-26 Thread Georg Brandl
Anthra Norell wrote: > No, I am not running Linux to any extent. But I am very strict about case. > There is not a single instance of "se.py" or "sel.py" > anywhere on my system. You' ll have to find out where lower case sneaks in on > yours. The zip file preserves case and in the zip file > the

Re: Weekly Python Patch/Bug Summary

2006-08-27 Thread Georg Brandl
Fredrik Lundh wrote: > Kurt B. Kaiser wrote: > >> Patch / Bug Summary >> ___ >> >> Patches : 407 open ( +3) / 3393 closed (+17) / 3800 total (+20) >> Bugs: 888 open (+28) / 6145 closed (+14) / 7033 total (+42) >> RFE : 232 open ( +3) / 236 closed ( +1) / 468 tot

Re: callable to disappear?

2006-08-28 Thread Georg Brandl
Bruno Desthuilliers wrote: > Georg Brandl a écrit : >> Antoon Pardon wrote: >> >>> I have been reading http://www.python.org/dev/peps/pep-3100/ >>> en there is written: >>> >>> To be removed: >>> ... >>&

Re: how do you get the name of a dictionary?

2006-08-28 Thread Georg Brandl
Antoon Pardon wrote: > On 2006-08-23, Georg Brandl <[EMAIL PROTECTED]> wrote: >> jojoba wrote: >>>> And what im saying is that isnt it silly that we need pass an entire >>>> namespace, when a much simpler notion would be to have each object know >>>&

Re: Misleading error message when opening a file (on Windows XP SP 2)

2006-08-28 Thread Georg Brandl
Claudio Grondi wrote: > Tim Peters wrote: >> [Claudio Grondi] >> >>> Here an example of what I mean >>> (Python 2.4.2, IDLE 1.1.2, Windows XP SP2, NTFS file system, 80 GByte >>> large file): >>> >>> >>> f = file('veryBigFile.dat','r') >>> >>> f = file('veryBigFile.dat','r+') >>> >>> Traceback (m

Re: What do you want in a new web framework?

2006-08-30 Thread Georg Brandl
Maxim Sloyko wrote: > Laurent Pointal wrote: >> >> Look at http://wiki.python.org/moin/WebFrameworks >> >> Do you *really* need to develop a *new* framework (maybe a scholl >> exercise - it that case, KISS)? > > Isn't the main reason why there are so many of them is that all of them > suck badly?

Re: refering to base classes

2006-08-30 Thread Georg Brandl
Chaz Ginger wrote: > glenn wrote: >>> Shouldn't that be >>> >>> beagle = animal.dog() >>> >>> to create an instance? >>> >>> We've all done it ... >> lol - actually Im confused about this - there seem to be cases where >> instantiaing with: >> instance=module.classname() >> gives me an error, but >

Re: dictionary with object's method as thier items

2006-08-30 Thread Georg Brandl
noro wrote: > Is it possible to do the following: > > for a certain class: > > > class C: > > def func1(self): > pass > def func2(self): > pass > def func4(self): > pass > > obj=C() > > > by some w

Re: M$ windows python libs installed in arbitrary directories forcustomized python distributions

2006-08-31 Thread Georg Brandl
alf wrote: > Robert Kern wrote: >> alf wrote: >> >>> Fredrik Lundh wrote: >>> http://www.catb.org/~esr/faqs/smart-questions.html#writewell >>> >>> >>> and means? >> >> >> It's his signature. >> > > The sig is delimited by '-- \n' Yes, and Earth is a disk. Georg -- http://ma

Re: Assignment-in-conditional

2006-08-31 Thread Georg Brandl
xamdam wrote: > I am not sure if this came up before, but I would love to have an > 'assignment-in-conditional' form in python, e.g > > pat = re.compile('something') > > if m = pat.match(s): > m.group(1) > > Of course there is some concern about accidentally using '=' instead of > '=='. One

Re: Classes referencing each other

2006-09-01 Thread Georg Brandl
Manuel Bleichner wrote: > Hello list, > > I have searched for some time now, but no result... > I'm having the following problem: > > In a module I have a huge number of classes of the form: > > class A(object): >connected_to = [B, C] > > > class B(object) >connected_to = [C] >

Re: IndentationError: expected an indented block

2006-09-02 Thread Georg Brandl
[EMAIL PROTECTED] wrote: > Hendrik van Rooyen wrote: >> <[EMAIL PROTECTED]> Wrote: >> >> >> | >> | Haha. How can I fix this! >> | >> | >> | >> >> Use either tabs, or spaces, but not both >> >> - Hendrik > > Haha. I know. I just find it silly that a language insists on > indentation. I'd long k

Re: CONSTRUCT -

2006-09-03 Thread Georg Brandl
lazaridis_com wrote: > I would like to fulfill the following task: > > The construct: > > if __name__ == '__main__': > > should be changed to something like: > > if identifier.name == '__main__': > > The term "identifier" should be selected based on the meaning of the > __double-underscore-enc

Re: CONSTRUCT -

2006-09-04 Thread Georg Brandl
lazaridis_com wrote: > Georg Brandl wrote: >> lazaridis_com wrote: >> > I would like to fulfill the following task: >> > >> > The construct: >> > >> > if __name__ == '__main__': >> > >> > should be changed

Re: No ValueError for large exponents?

2006-09-07 Thread Georg Brandl
enigmadude wrote: > As many have heard, IronPython 1.0 was released. When I was looking > through the listed differences between CPython and IronPython, the > document mentioned that using large exponents such as 10 ** > 735293857239475 will cause CPython to hang, whereas IronPython will > raise a

Re: CONSTRUCT -

2006-09-07 Thread Georg Brandl
Steve Holden wrote: >> I am not a (python) domain expert. >> >> Thus I am asking here for available standard-solutions, before I >> implement an own solution. >> > There is no standard solution for the problem you mention. Because it's not a problem for most people ;) Georg -- http://mail.pyt

Re: the first arg to super() must be a type, not a class obj?

2006-09-08 Thread Georg Brandl
metaperl wrote: > On p.282 of "Python Cookbook" and in the Python docs on calling super: > http://www.python.org/download/releases/2.2.3/descrintro/#cooperation > > it is clear that the first argument to super is a class and not a type. > However, for the code below, I am getting an error when att

ANN: Pocoo (bulletin board software) 0.1 beta released

2006-09-10 Thread Georg Brandl
Download the release at <http://www.pocoo.org/download>. Cheers, Georg Brandl, on behalf of the Pocoo Team -- http://mail.python.org/mailman/listinfo/python-list

Re: Converting a varargs tuple to a list - a definite pitfall for new comers to Python

2006-09-14 Thread Georg Brandl
[EMAIL PROTECTED] wrote: > The following program does not work if you uncomment #lis = > ["xmms2"] + list(args) > > Evidently Python is opting for the nullary constructor list() as > opposed to the other one which takes a sequence. But no newcomer would > know this. And the Python docs dont gi

Re: RELEASED Python 2.5 (release candidate 2)

2006-09-14 Thread Georg Brandl
Ant wrote: > Anthony Baxter wrote: > ... >> code in 2.5 before the final release. *Please* try this >> release out and let us know about any problems you find. > > Not a problem with the release, but with the docs. I've just ported a > module using the ElementTree package to 2.5, and the Module In

Re: RELEASED Python 2.5 (release candidate 2)

2006-09-14 Thread Georg Brandl
Georg Brandl wrote: > Ant wrote: >> Anthony Baxter wrote: >> ... >>> code in 2.5 before the final release. *Please* try this >>> release out and let us know about any problems you find. >> >> Not a problem with the release, but with the docs. I

Re: CONSTRUCT - Adding Functionality to the Overall System

2006-09-17 Thread Georg Brandl
Ilias Lazaridis wrote: > I understand that I can use __metaclass__ to create a class which > modifies the behaviour of another class. > > How can I add this metaclass to *all* classes in the system? > > (In ruby I would alter the "Class" class) You'd have to set __metaclass__ = whatever at the

Re: CONSTRUCT - Adding Functionality to the Overall System

2006-09-18 Thread Georg Brandl
Damjan wrote: >>> I understand that I can use __metaclass__ to create a class which >>> modifies the behaviour of another class. >>> >>> How can I add this metaclass to *all* classes in the system? >>> >>> (In ruby I would alter the "Class" class) >> >> You'd have to set >> >> __metaclass__ = w

Re: CONSTRUCT - Adding Functionality to the Overall System

2006-09-19 Thread Georg Brandl
Diez B. Roggisch wrote: >>> >>> I think '__metaclass__ = whatever' affects only the creation of >>> classes that >>> would otherwise be old-style classes? >> >> Wrong. >> >> If you set __metaclass__ = type, every class in that module will be >> new-style. >> >> If you set __metaclass__ = MyCla

Re: webbrowser module's Firefox support

2006-09-24 Thread Georg Brandl
Dustan wrote: > MonkeeSage wrote: >> Dustan wrote: >> > I did do a search here, but came up empty-handed. Can anyone tell me >> > how to get the webbrowser module to recognize firefox's existence, >> > given this information? >> >> Looks like it is checking %PATH% for firefox.exe. Try: >> >> >>> im

Re: A critique of cgi.escape

2006-09-24 Thread Georg Brandl
Lawrence D'Oliveiro wrote: > In message <[EMAIL PROTECTED]>, Fredrik > Lundh wrote: > >> Jon Ribbens wrote: >> >>> Making cgi.escape always escape the '"' character would not break >>> anything, and would probably fix a few bugs in existing code. Yes, >>> those bugs are not cgi.escape's fault, bu

Re: assignment hook

2006-09-24 Thread Georg Brandl
[EMAIL PROTECTED] wrote: > Kind people, > Is there any way one can, within Python, intercept the act of > assignment. For instance, suppose that I was obsessed with > FORTRAN II, and decided that I wanted to print a warning, > or raise an exception any time someone assigned an int to a > variable

Re: Strange __future__ behavior in Python 2.5

2006-09-24 Thread Georg Brandl
[EMAIL PROTECTED] wrote: > My understanding of the __future__ statement is that you may say > something like: > > from __future__ import foo, bar > > to enable more than one feature. However, this does not seem to be > working properly in 2.5; it behaves as expected when typed into the > interac

Re: +1 QOTW

2006-09-24 Thread Georg Brandl
Michael J. Fromberger wrote: > In article <[EMAIL PROTECTED]>, > "Terry Reedy" <[EMAIL PROTECTED]> wrote: > >> <[EMAIL PROTECTED]> wrote in message >> news:[EMAIL PROTECTED] >> > Did anyone else crack up when Larry Wall described python with the >> > statement: >> > >> > Python, as the "anti-Per

Re: Reverse a String?

2006-09-25 Thread Georg Brandl
[EMAIL PROTECTED] wrote: >> http://pyfaq.infogami.com/ > > Tell me more? > > Clueless newbie me, thru this door I'm at three deaths and counting. > Does that Py Faq Wiki have a sandbox a la alt.test, and/or a tutorial? > > // Death One: > > http://pyfaq.infogami.com/_account/in?path=/ > require

Re: A critique of cgi.escape

2006-09-25 Thread Georg Brandl
Jon Ribbens wrote: > In article <[EMAIL PROTECTED]>, Fredrik Lundh wrote: >>> There's nothing to say that cgi.escape should take them both into account >>> in the one function >> >> so what exactly are you using cgi.escape for in your code ? > > To escape characters so that they will be treated a

Re: Verify an e-mail-adress - syntax and dns

2006-09-25 Thread Georg Brandl
Christophe wrote: > Steven D'Aprano a écrit : >> By memory, in an thread about the same topic just a few days ago, Fredrik >> Lundh posted a link to Perl's FAQs that suggests a method for "validating" >> email addresses: treat it like a password and ask the user to type it >> twice. That will prote

Re: A critique of cgi.escape

2006-09-25 Thread Georg Brandl
Jon Ribbens wrote: > In article <[EMAIL PROTECTED]>, Max M wrote: >> Oh ... because you cannot see a use case for that *documented* >> behaviour, it must certainly be wrong? > > No, but if nobody else can find one either, that's a clue that maybe > it's safe to change. > > Here's a point for you

Re: Verify an e-mail-adress - syntax and dns

2006-09-25 Thread Georg Brandl
Christophe wrote: > Georg Brandl a écrit : >> Christophe wrote: >>> Steven D'Aprano a écrit : >>>> By memory, in an thread about the same topic just a few days ago, >>>> Fredrik >>>> Lundh posted a link to Perl's FAQs that suggest

Re: ruby %w equivalent

2006-09-25 Thread Georg Brandl
Thorsten Kampe wrote: > * John Machin (24 Sep 2006 15:32:20 -0700) >>Antoine De Groote wrote: >>> is there a python equivalent for the ruby %w operator? >>> %w{a b c} creates an array with strings "a", "b", and "c" in ruby... >>> >> >>| >>> "a b c".split() >>| ['a', 'b', 'c'] >> >>... appears to ma

Re: Printing a percent sign

2006-09-25 Thread Georg Brandl
[EMAIL PROTECTED] wrote: > Hi all. How do I escape the "%" sign in a print statement so that it > prints? Thanks. >>> print "%" % Did you mean in a string being interpolated with the % operator? Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: A critique of cgi.escape

2006-09-26 Thread Georg Brandl
Lawrence D'Oliveiro wrote: > In message <[EMAIL PROTECTED]>, Max M wrote: > >> Lawrence is right that the escape method doesn't work the way he expects >> it to. >> >> Rewriting a library module simply because a developer is surprised is a >> *very* bad idea. > > I'm not surprised. Disappointed,

Re: A critique of cgi.escape

2006-09-26 Thread Georg Brandl
Lawrence D'Oliveiro wrote: > In message <[EMAIL PROTECTED]>, Fredrik > Lundh wrote: > >> Lawrence D'Oliveiro wrote: >> >>>> Georg Brandl wrote: >>>> >>>>> A function is broken if its implementation doesn't matc

Re: A critique of cgi.escape

2006-09-26 Thread Georg Brandl
Lawrence D'Oliveiro wrote: > In message <[EMAIL PROTECTED]>, Georg Brandl wrote: > >> Lawrence D'Oliveiro wrote: >>> In message <[EMAIL PROTECTED]>, Max M wrote: >>> >>>> Lawrence is right that the escape method doesn't work

Re: A critique of cgi.escape

2006-09-26 Thread Georg Brandl
Lawrence D'Oliveiro wrote: > In message <[EMAIL PROTECTED]>, Georg Brandl wrote: > >> Lawrence D'Oliveiro wrote: >>> In message <[EMAIL PROTECTED]>, Georg Brandl wrote: >>> >>>> Lawrence D'Oliveiro wrote: >>>>>

Re: where are isinstance types documented?

2006-09-26 Thread Georg Brandl
Fredrik Lundh wrote: > Sion Arrowsmith wrote: >> > >>> based on http://docs.python.org/ref/types.html, here's a list of the >>> most commonly used core types: >>> [ ... ] >>> Sequences: >>> str >>> unicode >>> tuple >>> list >> >> And set, presumably. > > absolutely! > > howeve

Re: A critique of cgi.escape

2006-09-27 Thread Georg Brandl
Anthony Baxter wrote: >> I would really rather this were a discussion than an argument. You will >> now no doubt reply telling me I wouldn't. >> >> My posting was issued as a response to the irritation engendered by your >> argumentative style of debate. Your latest response simply proves that >> t

Re: What's up with site.Quitter?

2006-09-27 Thread Georg Brandl
James Stroud wrote: > Hello All, > > Still jubilantly configuring my work environment for python 2.5, I came > accross a curiosity when writing an automatic vim syntax file creator > (so I can automatically update my syntax coloring with future python > releases). > > It seems I can find a ref

Re: Surprise using the 'is' operator

2006-09-27 Thread Georg Brandl
tobiah wrote: > wesley chun wrote: >>> "Terry Reedy" <[EMAIL PROTECTED]> wrote: >>> > as a side note, the ints that are cached (for current versions of >>> > Python) are in range(-1, 100)... is this documented somewhere? >>> Not true for at least 2.4 and 2.5. The cached range has expanded >> >> o

Re: Surprise using the 'is' operator

2006-09-27 Thread Georg Brandl
tobiah wrote: >>> Suppose I fill an list with 100 million random integers in the range >>> of 1 - 65535. Wouldn't I save much memory if all of the ocurrances >>> of '12345' pointed to the same integer object? Why should more be made, >>> when they all do the same thing, and are not subject to cha

Re: Why don't optional mutable objects show up in vars(func)?

2006-09-27 Thread Georg Brandl
[EMAIL PROTECTED] wrote: > So I just got bitten by the "don't use a mutable object as an optional > argument" gotcha. I now realize that for this function: > def func(x, y=[]): > ... y.append(x) > ... print y > ... > > y is initialized when the function is imported, not when the fun

Re: Surprise using the 'is' operator

2006-09-27 Thread Georg Brandl
Terry Reedy wrote: > "Georg Brandl" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> tobiah wrote: >>> Suppose I fill an list with 100 million random integers in the range >>> of 1 - 65535. Wouldn't I save much memory if all o

Re: How to read() twice from file-like objects (and get some data)?

2006-09-27 Thread Georg Brandl
[EMAIL PROTECTED] wrote: > Hello all, please correct me, if I do... > > from ClientForm import ParseResponse > from urllib2 import urlopen > ... > response=urlopen(url) > forms=ParseResponse(response) > > I won't be able to > > print response.read() > > in order to see HTML source anymore. In o

Re: Top and Bottom Values [PEP: 326]

2006-09-28 Thread Georg Brandl
Antoon Pardon wrote: > On 2006-09-27, George Sakkis <[EMAIL PROTECTED]> wrote: >> Antoon Pardon wrote: >> >>> What bothers me a bit about the rejection of PEP 326 is that one of the >>> reasons stated is: >>> >>> http://mail.python.org/pipermail/python-dev/2004-January/042306.html >>> >>> - it

Re: Top and Bottom Values [PEP: 326]

2006-09-28 Thread Georg Brandl
Antoon Pardon wrote: > On 2006-09-27, OKB (not okblacke) <[EMAIL PROTECTED]> wrote: >> Antoon Pardon wrote: >> >>> To begin with this already fails: >>> >> for i in xrange(Top): >>> ... print i >> >> What do you expect this to do? Loop forever? > > Yes that is what I would expect. Fo

Re: Continuing after error

2006-09-28 Thread Georg Brandl
Sheldon wrote: > Hi, > > Does anyone know if it is possible to resume the execution of a program > after it stops at an error in the code and the error was corrected? try: do something except SomeException: correct the error do something else i.e. you handle the error in the except cl

<    1   2   3   4   >