Re: Python component model

2006-10-10 Thread Georg Brandl
Bruno Desthuilliers wrote: > Marc 'BlackJack' Rintsch wrote: > (snip) > Python itself is a RAD tool. > > +1 QOTW > Agreed. Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: OT: Sarcasm and irony

2006-10-10 Thread Georg Brandl
Steve Holden wrote: >> is that 'in America' meant to be an addendum to what I said, as in >> this is the situation in America and not elsewhere? If so I should >> probably point out that I am writing from Denmark and was thinking >> specifically of a situation where a dane told me they were be

Re: operator overloading + - / * = etc...

2006-10-09 Thread Georg Brandl
Bruno Desthuilliers wrote: > Steven D'Aprano wrote: >> On Sat, 07 Oct 2006 17:21:55 -0500, Tim Chase wrote: >> > With the caveat of the "=" mentioned in the subject-line (being > different from "==")...I haven't found any way to override > assignment in the general case. Why would

Re: file system iteration

2006-10-09 Thread Georg Brandl
Jonathan Hartley wrote: > Georg Brandl wrote: > >> Which application needs to walk over ALL files? > > How about 'updatedb' for starters, the index-maintainer for the common > *nix command-line utility 'locate'. > > I'm pretty sure that os.w

Re: file system iteration

2006-10-09 Thread Georg Brandl
rick wrote: > Georg Brandl wrote: > >> Which application needs to walk over ALL files? Normally, you just have a >> starting path and walk over everything under it. > > Searching for a file by name. Scanning for viruses. Etc. There are lots > of legitimate reas

Re: file system iteration

2006-10-09 Thread Georg Brandl
rick wrote: > In Unix, the file system hierarchy is like a tree that has a base or > 'root' that exposes objects (files and folders) that can easily be > iterated over. > > > \ \ | / / > \ \ | / / >\ \|/ / > \ | / > \|/ > | > | > Root > > So, when I do os.chdi

Re: Python to use a non open source bug tracker?

2006-10-09 Thread Georg Brandl
Magnus Lycka wrote: > Fredrik Lundh wrote: >> you're not on the infrastructure list, I hear. > > I tried to figure out where that list is, so I could have > a look at the archives, but I didn't find it in the (for > me) obvious places. Could someone please provide a link > to the archives for th

Re: operator overloading + - / * = etc...

2006-10-07 Thread Georg Brandl
Tim Chase wrote: >>> Can these operators be overloaded? >> >> Yes. > > With the caveat of the "=" mentioned in the subject-line (being > different from "==")...I haven't found any way to override > assignment in the general case. There might be some oddball way > to do it via property() but A

Re: Automatic import PEP

2006-10-06 Thread Georg Brandl
Dan Bishop wrote: > On Sep 22, 10:09 pm, Connelly Barnes <[EMAIL PROTECTED]> wrote: >> Hi, >> >> I wrote the 'autoimp' module [1], which allows you to import lazy modules: >> >> from autoimp import * (Import lazy wrapper objects around all modules; >> "lazy >>module

Re: Metaprogramming question

2006-10-06 Thread Georg Brandl
Steve Menard wrote: > I have a need to create class instance without invokking the class' __init__ > method. > > Were I using old-style classes, I'd use new.instance() function. However, I > am using new-style classes and new.instance() complain "TypeError: > instance() argument 1 must be clas

Re: Python to use a non open source bug tracker?

2006-10-05 Thread Georg Brandl
Fredrik Lundh wrote: > Georg Brandl wrote: > >>> The python foundation suggests a non-python non-open-source bugtracking >>> tool for python. >> >> Actually, it suggests two bugtracking tools, one of them written in >> Python. > > the announcema

Re: Python to use a non open source bug tracker?

2006-10-05 Thread Georg Brandl
Ilias Lazaridis wrote: > Giovanni Bajo wrote: >> Hello, >> >> I just read this mail by Brett Cannon: >> http://mail.python.org/pipermail/python-dev/2006-October/069139.html >> where the "PSF infrastracture committee", after weeks of evaluation, >> recommends >> using a non open source tracker (cal

Re: What value should be passed to make a function use the default argument value?

2006-10-04 Thread Georg Brandl
Paul Rubin wrote: > Antoon Pardon <[EMAIL PROTECTED]> writes: >> repeat(object[, times]) >> Make an iterator that returns object over and over again. Runs >> indefinitely unless the times argument is specified. ... >> >> My first impression from this, is that it is possible to call >> this

Re: What value should be passed to make a function use the default argument value?

2006-10-04 Thread Georg Brandl
Antoon Pardon wrote: > On 2006-10-04, Paul Rubin wrote: >> Antoon Pardon <[EMAIL PROTECTED]> writes: >>> Now in this case you could start by assigning arg the value 1 and >>> eliminate the if test. However that only works if you know the >>> default value for the argument. What he seems to be aski

Re: why logging re-raise my exception and can't be caught?

2006-09-30 Thread Georg Brandl
Steve Holden wrote: > Ben Finney wrote: > [...] >> A 'try ... except' statement is not an exception handler. [...] > > Just as a matter of interest, what would your definition of an exception > handler be, then? Specifically, what's the "except" clause for? > > The docs for looging.except should

Re: Can string formatting be used to convert an integer to its binary form ?

2006-09-29 Thread Georg Brandl
Neil Cerutti wrote: > On 2006-09-29, Steve Holden <[EMAIL PROTECTED]> wrote: >> MonkeeSage wrote: >>> So far as unobfuscated versions go, how about the simple: >>> >>> def to_bin(x): >>> out = [] >>> while x > 0: >>> out.insert(0, str(x % 2)) >>> x = x / 2 >>> return ''.join(out) >>>

Re: remove the last character or the newline character?

2006-09-28 Thread Georg Brandl
Daniel Mark wrote: > Hello all: > > I have the following snippet: > > In [1]: fileName = 'Perfect Setup.txt\n' > In [2]: fileName = fileName[0:len(fileName)-1)] # remove the '\n' > character > In [3]: fileName > Out[3]: 'Perfect Setup.txt' > > Question one: > Does python provide any function t

Re: Resuming a program's execution after correcting error

2006-09-28 Thread Georg Brandl
Sheldon wrote: > Hi. > > Does anyone know if one can resume a python script at the error point > after the error is corrected? > I have a large program that take forever if I have to restart from > scratch everytime. The error was the data writing a file so it seemed > such a waste if all the data

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

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: 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: 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: 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: 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
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: 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: 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: 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: 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-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: 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]>, 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]>, 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: 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: 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: 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: 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: > 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]>, 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: 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: +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: 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: 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: 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: 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: 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: 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-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: 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: 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: 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

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: 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

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: 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-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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: Dr. Dobb's Python-URL! - weekly Python news and links (Aug 23)

2006-08-23 Thread Georg Brandl
Jack Diederich wrote: > QOTW: "Because there's no chance that the original request is sane." - Georg > Brandl (responding to a question involving a Banana) Looks like I'm trying to fulfil my bot duties from time to time ;) > "this is one of your last chances

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

2006-08-23 Thread Georg Brandl
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 >> its own name(s) (even if that name doesnt exist). > > > please note: in my above comment, i was completely disregarding any > notion

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

2006-08-22 Thread Georg Brandl
Steven D'Aprano wrote: > On Tue, 22 Aug 2006 10:12:00 -0700, BartlebyScrivener wrote: > how difficult would it be to assign a string name(s) to an object upon creation (and upon referencing)? >> >> Exactly the point that's being made. It's so easy just do it yourself: >> >> banana={"na

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

2006-08-22 Thread Georg Brandl
jojoba wrote: > Hello again, > > Fredrick said: > >> Python's object model. an object has a value, a type, and an identity, >> but no name. > > I say: > > Thank you Fredrick for the reply! > However, although python's object model does not currently support what > i am asking for, how difficul

Re: CONSTRUCT - Module Attributes and Execution Environment

2006-08-22 Thread Georg Brandl
Larry Bates wrote: > lazaridis_com wrote: >> I would like to change the construct: >> >> if __name__ == '__main__': >> >> to something like: >> >> if exec.isMain(): >> >> My (OO thought) is to place a class in an separate code module and to >> instantiate an singleton instance which would keep

Re: Problem of function calls from map()

2006-08-22 Thread Georg Brandl
Paul McGuire wrote: > "Dasn" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> >> Hi, there. >> >> 'lines' is a large list of strings each of which is seperated by '\t' >> >>> lines = ['bla\tbla\tblah', 'bh\tb\tb', ... ] >> >> I wanna split each string into a list. For speed, using m

Re: sum and strings

2006-08-21 Thread Georg Brandl
Steven D'Aprano wrote: > On Fri, 18 Aug 2006 19:08:37 -0700, Paul Rubin wrote: > >> If the args are strings, the above is a quadratic time algorithm and >> it's better to throw an error than create such a trap for an unwary user. > > That's a nonsense argument. There is no shortage of slow algori

Re: Input from the same file as the script

2006-08-20 Thread Georg Brandl
[EMAIL PROTECTED] wrote: > Can the input to the python script be given from the same file as the > script itself. e.g., when we execute a python script with the command > 'python > When I ran the below the python interpreter gave an error. *sigh* Why do you think that we could guess what error t

Re: import

2006-08-20 Thread Georg Brandl
01 wrote: > Georg Brandl wrote: >> [EMAIL PROTECTED] wrote: >> > bugnthecode 写道: >> > >> >> How are you trying to import it? Is it in the same directory as your >> >> other script? If not is your python path set correctly? >> >> >

Re: import

2006-08-20 Thread Georg Brandl
[EMAIL PROTECTED] wrote: > bugnthecode 写道: > >> How are you trying to import it? Is it in the same directory as your >> other script? If not is your python path set correctly? >> >> When importing a module that you have written you exlude the .py >> extension. You should be using: >> import hello

Re: sum and strings

2006-08-19 Thread Georg Brandl
Bill Pursell wrote: > Georg Brandl wrote: >> Paul Rubin wrote: >> > Sybren Stuvel <[EMAIL PROTECTED]> writes: >> >> Because of "there should only be one way to do it, and that way should >> >> be obvious". There are already the str.

Re: sum and strings

2006-08-18 Thread Georg Brandl
Paul Rubin wrote: > Georg Brandl <[EMAIL PROTECTED]> writes: >> Why would you try to sum up strings? Besides, the ''.join idiom is quite >> common in Python. > > Just because it's common doesn't mean it's obvious. In my opinion > it&#x

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

2006-08-18 Thread Georg Brandl
Andy Terrel wrote: > Why bang your head? Because there's no chance that the original request is sane. If you want your objects to know their name, give them a name as an attribute. > It was a stupid hack that has lots of problems, > but done in a way that is readable. Sure I could do something

Re: sum and strings

2006-08-18 Thread Georg Brandl
Paddy wrote: > Sybren Stuvel wrote: >> Paddy enlightened us with: >> > Well, after all the above, there is a question: >> > >> > Why not make sum work for strings too? >> >> Because of "there should only be one way to do it, and that way should >> be obvious". There are already the str.join and u

Re: Clean way to not get object back from instantiation attempt gone bad

2006-08-18 Thread Georg Brandl
tobiah wrote: > Suppose I do: > > > myfoo = Foo('grapes', 'oranges') > > And in the __init__() of Foo, there is > a real problem with the consumption of fruit. > Is there a clean way to ensure that myfoo > will be None after the call? Would the > __init__() just do del(self), or is there > a be

Re: sum and strings

2006-08-18 Thread Georg Brandl
Paul Rubin wrote: > Sybren Stuvel <[EMAIL PROTECTED]> writes: >> Because of "there should only be one way to do it, and that way should >> be obvious". There are already the str.join and unicode.join methods, > > Those are obvious??? Why would you try to sum up strings? Besides, the ''.join idio

Re: Optimization of __len__() in cgi.py

2006-08-16 Thread Georg Brandl
Bob Kline wrote: > I have a suggestion for speeding up the performance of code like this: > > fields = cgi.FieldStorage() > if fields: ... > > which, as it turns out, invokes FieldStorage.__len__(), which in turn > calls FieldStorage.keys(), which builds a list of keys by hand, taking > several m

Re: do people really complain about significant whitespace?

2006-08-10 Thread Georg Brandl
Gerhard Fiedler wrote: > function() > loop1() > blah > blah > > loop2() > blah > > loop3() > blah > #end loop3() > >

Re: singleton decorator

2006-08-08 Thread Georg Brandl
Andre Meyer wrote: > While looking for an elegant implementation of the singleton design > pattern I came across the decorator as described in PEP318 > . > Unfortunately, the following does not work, because decorators only work > on functions or methods

Re: Ann: SE 2.2b

2006-08-08 Thread Georg Brandl
Anthra Norell wrote: > If you go to http://www.python.org/pypi. you see it about in the middle of > the recently updated packages. It's blue, so you can > click it and you're there. > The update page shows only the twenty most recent updates. So they drop > out at the bottom rather fast. If

Re: Ann: SE 2.2b

2006-08-06 Thread Georg Brandl
[EMAIL PROTECTED] wrote: > Frederic> In the short period of time since I introduced SE. the > Frederic> feedback has been overwhelmingly postive. > > Ummm... what is it? The last SE I had was a Mac. It is supposed to be a Stream Editor (in the spirit of sed, I think). However, the PyPI

Re: New release of Diet Python (0.2 Beta)!!!

2006-07-27 Thread Georg Brandl
The Eternal Squire wrote: > A developer's installation of PSF, including Pywin, WxPython, Numpy, > Scipy I believe can run up to 300 MB, no? > > Otherwise, I'll put up a different percentage. Well, if you refer to a Python installation including all these packages (anyway, I don't think it would

Re: New release of Diet Python (0.2 Beta)!!!

2006-07-27 Thread Georg Brandl
The Eternal Squire wrote: > Diet Python is a flavor of Python with allegro, multiarray, umath, > calldll, npstruct and curses builtin, all else nonessential to language > > ripped out. Total size < 3MB, 1% of PSF Python. Diet Python helps keep > clients thin :) Erm... Which "PSF Python" are you

Re: How can I optimise this? [intended in good humour]

2006-07-25 Thread Georg Brandl
John Machin wrote: > Markus wrote: >> You know you're guilty of early/over optimisation, when it's almost two >> in the morning and the file open in front of you reads as follows. >> >> The code you are about to read is real... >> Some of the variable names have been changed >> to protect the

Re: How to recognise "generator functions" ?

2006-07-19 Thread Georg Brandl
imho wrote: > Hi all. > > Is there a way to know if a function object is actually a "generator > function" or not ? e.g.: > > def f(): > pass > > def g(): > yield None > > f.__class__ is the same as g.__class__ , i.e. "function" type. > But i "know" that the second, when invoked, r

Re: Coding style

2006-07-19 Thread Georg Brandl
Antoon Pardon wrote: >> Other than in PHP, Python has clear rules when an object of a builtin type >> is considered false (i.e. when it's empty). So why not take advantage of >> this? > > Because it doesn't always do what I want. > > I once had a producer consumer code. When the client asked whe

Re: Coding style

2006-07-19 Thread Georg Brandl
Lawrence D'Oliveiro wrote: > In message <[EMAIL PROTECTED]>, Bob Greschke wrote: > >> I'd go even one step further. Turn it into English (or your favorite >> non-computer language): >> >> 1. While list, pop. >> >> 2. While the length of the list is greater than 0, pop. >> >> Which one makes mo

Re: timeit module for comparing the performance of two scripts

2006-07-12 Thread Georg Brandl
3c273 wrote: > "John Machin" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> You appear to know what a switch is. I'm therefore surprised that you >> appear not to >> know that the convention is that any program that uses >> command-line switches should do something informative whe

<    1   2   3   4   >