Re: Proposal: Inline Import

2005-12-10 Thread Shane Hathaway
Kent Johnson wrote: > Shane Hathaway wrote: >>I'm talking about using imports *everywhere*. The penalty would be >>appreciable. > > > Have you tried it? > > D:\Projects\CB>python -m timeit -s "import re" "import re" > 100 loops, best of 3: 1.36 usec per loop > > You need a lot of imports

Re: how to put form and display its result(data from database) on the same window?

2005-12-10 Thread Tim Roberts
Peter Hansen <[EMAIL PROTECTED]> wrote: >[EMAIL PROTECTED] wrote: >> I have designed a web application. In its one window I put a form. User >> can click submit button of this form to run a pathon script to get data >> from database. Then User get a new window which display the result. Now >> I wa

Re: newby question: Splitting a string - separator

2005-12-10 Thread Tim Roberts
James Stroud <[EMAIL PROTECTED]> wrote: > >The one I like best goes like this: > >py> data = "Guido van Rossum Tim Peters Thomas Liesner" >py> names = [n for n in data.split() if n] >py> names >['Guido', 'van', 'Rossum', 'Tim', 'Peters', 'Thomas', 'Liesner'] > >I think it is theoretically fast

Re: How to detect the presence of a html file

2005-12-10 Thread Tim Roberts
Irmen de Jong <[EMAIL PROTECTED]> wrote: >BartlebyScrivener wrote: >>> Even weirder, >> >>> os.path.isfile(r'c://bookmarks.html') >> >> Never mind. It works that way from the command line, too. Never tried >> it before. > >Forward slashes as path separator only works on NTFS volumes I believe. W

Re: PHP = Perl Improved

2005-12-10 Thread Tim Roberts
"Xah Lee" <[EMAIL PROTECTED]> wrote: >recently i got a project that involves the use of php. In 2 days, i >read almost the entirety of the php doc. Finding it a breeze because it >is roughly based on Perl, of which i have mastery. > >i felt a sensation of neatness, as if php = Perl Improved, for a

Re: Newbie question - clearing screen @ interactive prompt

2005-12-10 Thread Kaizer
Hey matt, Thanks a ton! This works!! Have a great day Kaizer. -- http://mail.python.org/mailman/listinfo/python-list

Re: pyqt

2005-12-10 Thread Giovanni Bajo
Kuljo wrote: > - Can I execute bash commands in a python script (e.g. ls -l or grep)? Yes, for instance with os.system or os.popen. It won't be portable though. > - In the QT Designer there are also KDE-widgets but I'm not sucseeded > to get them work in pyqt (it says: "self.kProgress1 = > KPro

Re: Proposal: Inline Import

2005-12-10 Thread Steve Holden
Shane Hathaway wrote: > Benji York wrote: > >>Why not: 1) jump to the top of the file when you need to do an import >>(1G in Vim), 2) add the import, 3) jump back to where you were (Ctrl-o >>in Vim) and keep coding. This isn't Vim specific, I suspect all decent >>editors have similar capabilit

Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-10 Thread Steve Holden
Zeljko Vrba wrote: > On 2005-12-08, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > >>Making a mistake in indentation level is precisely analogous to leaving >>out markers in other languages. If your editor is smart enough, and the >> > > But look at the following example: > > if a: > some_code1

Managing import statements

2005-12-10 Thread Shane Hathaway
Let's talk about the problem I really want help with. I brought up a proposal earlier, but it was only half serious. I realize Python is too sacred to accept such a heretical change. ;-) Here's the real problem: maintaining import statements when moving sizable blocks of code between modules

Re: Proposal: Inline Import

2005-12-10 Thread Shane Hathaway
Steve Holden wrote: > Shane Hathaway wrote: >> The structure of the Java language makes this relatively easy. >> > > And there's so much more busywork in Java that it's probably worth > automating. See > >http://www.artima.com/weblogs/viewpost.jsp?thread=42242 Agreed. Here's my take on Ja

Re: lambda (and reduce) are valuable

2005-12-10 Thread Peter Otten
Alan aka David Isaac wrote: >>> #evaluate polynomial (coefs) at x using Horner's rule >>> def horner(coefs,x): return reduce(lambda a1,a2: a1*x+a2,coefs) > It just cannot get simpler or more expressive. But is it correct? >>> a0, a1, a2 = 1, 2, 3 >>> x = 2 >>> a0 + x*(a1 + x*(a2)) 17 >>> def h

Re: newby question: Splitting a string - separator

2005-12-10 Thread Fredrik Lundh
James Stroud wrote: > >> py> data = "Guido van Rossum Tim Peters Thomas Liesner" > >> py> names = [n for n in data.split() if n] > >> py> names > >> ['Guido', 'van', 'Rossum', 'Tim', 'Peters', 'Thomas', 'Liesner'] > >> > >> I think it is theoretically faster (and more pythonic) than using > >

Re: lambda (and reduce) are valuable

2005-12-10 Thread bonono
Peter Otten wrote: > Alan aka David Isaac wrote: > > >>> #evaluate polynomial (coefs) at x using Horner's rule > >>> def horner(coefs,x): return reduce(lambda a1,a2: a1*x+a2,coefs) > > > It just cannot get simpler or more expressive. > > But is it correct? > > >>> a0, a1, a2 = 1, 2, 3 > >>> x = 2

Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-10 Thread Zeljko Vrba
On 2005-12-10, Steve Holden <[EMAIL PROTECTED]> wrote: > > My advice would be to stop using punch cards and start using a sensible > text editor. > Such as..? Find me an editor which has folds like in VIM, regexp search/replace within two keystrokes (ESC,:), marks to easily navigate text in 2 key

Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-10 Thread Sybren Stuvel
Zeljko Vrba enlightened us with: > Find me an editor which has folds like in VIM, regexp search/replace > within two keystrokes (ESC,:), marks to easily navigate text in 2 > keystrokes (mx, 'x), can handle indentation-level matching as well > as VIM can handle {}()[], etc. And, unlike emacs, respe

Re: Encoding of file names

2005-12-10 Thread Martin v. Löwis
Tom Anderson wrote: >> This is a fact, but it is not a key thing. Of course Windows is >> applying a non-roundtrippable character encoding. What else could it do? > > > Well, i'm no great thinker, but i'd say that errors should never pass > silently, and that in the face of ambiguity, one shoul

Re: Properties transfer between instances of different classes, without subclassing

2005-12-10 Thread Heiko Wundram
Pierre wrote: > Ideally, 'tabv.cold' would give me 'tabv', masked where the values are > <10. > I don't want to make 'Tabl' a subclass of 'Temp'. I'd like to use it > more generically, so that when I define a 3rd class 'Color', I could > initiate 'Tabv' with an instance of 'Color', accessing the 'C

Re: Documentation suggestions

2005-12-10 Thread Fredrik Lundh
A.M. Kuchling wrote: > BThe associated text currently isn't very helpful, but I'm not sure how > to make it better. Maybe it could be "'', from '' > by ". Then the text for your file would be "'The zlib module', > from '(the eff-bot guide to) The Standard Python Library' by Fredrik Lundh." that

Re: Another newbie question

2005-12-10 Thread Xavier Morel
Mike Meyer wrote: > And you've once again missed the point. The reason you don't > manipulate the attributes directly is because it violates > encapsulation, and tightens the coupling between your class and the > classes it uses. It means you see the implementation details of the > classes you are

Re: Dr. Dobb's Python-URL! - weekly Python news and links (Dec 7)

2005-12-10 Thread Fredrik Lundh
skip wrote: > >> "Python has more web application frameworks than keywords." - Skip > >> Montanaro (but probably others going back years) > > Cameron> Incorrect. Thanks to Fredrik Lundh ... > > Yeah, I wondered about that. I was only parroting what I'd seen in Harald's > post. I jus

Re: slice notation as values?

2005-12-10 Thread Antoon Pardon
On 2005-12-09, Duncan Booth <[EMAIL PROTECTED]> wrote: > Antoon Pardon wrote: > >>> If the user can write >>> >>>for key in tree['a':'b']: >>> >>> then he can write: >>> >>>for key in tree['a':'b'].iteritems(): >> >> No he can't. tree['a':'b'] would provide a list >> of keys that all start

Re: subset permutations

2005-12-10 Thread Gerard Flanagan
Jay Parlar wrote: > On Dec 8, 2005, at 5:29 PM, [EMAIL PROTECTED] wrote: > > > > Hello all, > > > > I'm a beginner with programming. Trying to teach myself with that > > excellent rat book. Unfortunately I just can't seem to figure out a > > simple problem that has come up at my work (biology lab)

Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-10 Thread Steve Holden
Zeljko Vrba wrote: > On 2005-12-10, Steve Holden <[EMAIL PROTECTED]> wrote: > >>My advice would be to stop using punch cards and start using a sensible >>text editor. >> > > Such as..? > Since choice of text editor tends to be a religious issue, that will have to be your decision, not mine. >

Re: binascii.crc32 results not matching

2005-12-10 Thread Raymond L. Buvel
Peter Hansen wrote: > Larry Bates wrote: > >> I'm trying to get the results of binascii.crc32 >> to match the results of another utility that produces >> 32 bit unsigned CRCs. > > > What other utility? As Tim says, there are many CRC32s... the > background notes on this one happen to stumble

Re: Managing import statements

2005-12-10 Thread Chris Mellon
On 12/10/05, Shane Hathaway <[EMAIL PROTECTED]> wrote: > Let's talk about the problem I really want help with. I brought up a > proposal earlier, but it was only half serious. I realize Python is too > sacred to accept such a heretical change. ;-) > > Here's the real problem: maintaining import s

Re: lambda (and reduce) are valuable

2005-12-10 Thread Chris Mellon
On 12/9/05, David Isaac <[EMAIL PROTECTED]> wrote: > >>> Jibes against the lambda-clingers lead eventually to serious > >>> questions of style in regard to variable namespacing, > >>> lifespan, cleanup, and so on: > >>> > http://groups.google.com/group/comp.lang.python/browse_thread/thr

Re: binascii.crc32 results not matching

2005-12-10 Thread Peter Hansen
Raymond L. Buvel wrote: > Check out the unit test in the following. > > http://sourceforge.net/projects/crcmod/ > > I went to a lot of trouble to get the results to match the results of > binascii.crc32. As you will see, there are a couple of extra operations > even after you get the polynomial

Re: how to put form and display its result(data from database) on the same window?

2005-12-10 Thread Peter Hansen
Tim Roberts wrote: > Peter Hansen <[EMAIL PROTECTED]> wrote: >>[EMAIL PROTECTED] wrote: >>>... Now >>>I want to put the form and display data on the same window. >> >>The most modern approach to this...is AJAX (see >>http://en.wikipedia.org/wiki/AJAX >>and others). >>It's a non-trivial solution

Re: Another newbie question

2005-12-10 Thread Steven D'Aprano
On Sat, 10 Dec 2005 01:28:52 -0500, Mike Meyer wrote: > Steven D'Aprano <[EMAIL PROTECTED]> writes: >> On Thu, 08 Dec 2005 20:46:33 -0500, Mike Meyer wrote: >>> Steven D'Aprano <[EMAIL PROTECTED]> writes: Paul Rubin wrote: > Steven D'Aprano <[EMAIL PROTECTED]> writes: >>> Yes. Reachin

Re: binascii.crc32 results not matching

2005-12-10 Thread Tim Peters
[Raymond L. Buvel] > Check out the unit test in the following. > > http://sourceforge.net/projects/crcmod/ Cool! > I went to a lot of trouble to get the results to match the results of > binascii.crc32. As you will see, there are a couple of extra operations > even after you get the polynomial a

Re: binascii.crc32 results not matching

2005-12-10 Thread Raymond L. Buvel
Tim Peters wrote: > [Raymond L. Buvel] > >>Check out the unit test in the following. >> >>http://sourceforge.net/projects/crcmod/ > > > Cool! > > >>I went to a lot of trouble to get the results to match the results of >>binascii.crc32. As you will see, there are a couple of extra operations >

newbie question

2005-12-10 Thread Bermi
i have this program === from sys import * import math import math, Numeric from code import * from string import * from math import * from dataSet import * from string import * def drawAsciiFile(): _fileName=str(argv[1]) __localdataSet=DataSet(_fileName) #_PlotCols=str

Re: Documentation suggestions

2005-12-10 Thread Fredrik Lundh
I wrote: > if it turns out that this doesn't scale (has anyone put up that library > reference wiki yet? ;-) if anyone's interested, here's a seealso file for the python library reference: http://effbot.org/zone/seealso-python-library.xml this was generated from the global module index by t

Re: slice notation as values?

2005-12-10 Thread Steven Bethard
Antoon Pardon wrote: > So lets agree that tree['a':'b'] would produce a subtree. Then > I still would prefer the possibility to do something like: > > for key in tree.iterkeys('a':'b') > > Instead of having to write > > for key in tree['a':'b'].iterkeys() > > Sure I can now do it like this:

Re: Another newbie question

2005-12-10 Thread Antoon Pardon
On 2005-12-10, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Sat, 10 Dec 2005 01:28:52 -0500, Mike Meyer wrote: > > The not-so-wise programmer takes abstraction as an end itself, and > consequently spends more time and effort defending against events which > almost certainly will never happen tha

Re: slice notation as values?

2005-12-10 Thread Duncan Booth
Antoon Pardon wrote: > In general I use slices over a tree because I only want to iterate > over a specific subdomain of the keys. I'm not iterested in make > a tree over the subdomain. Making such a subtree would be an > enormous waste of resources. Probably not unless you have really large data

Re: slice notation as values?

2005-12-10 Thread Antoon Pardon
On 2005-12-10, Steven Bethard <[EMAIL PROTECTED]> wrote: > Antoon Pardon wrote: >> So lets agree that tree['a':'b'] would produce a subtree. Then >> I still would prefer the possibility to do something like: >> >> for key in tree.iterkeys('a':'b') >> >> Instead of having to write >> >> for k

Re: Another newbie question

2005-12-10 Thread Alex Martelli
Mike Meyer <[EMAIL PROTECTED]> wrote: ... > >> it. Nothing you do with zim.foo or zim.foo.bar can change the state of > >> zim. The only invariants you need to check are bar's, which you do at > >> the exit to it's baz method. > > So foo's class is not allowed to have as its invariant any formul

Re: small inconsistency in ElementTree (1.2.6)

2005-12-10 Thread Damjan
>>> ascii strings and unicode strings are perfectly interchangable, with >>> some minor exceptions. >> >> It's not only translate, it's decode too... > > why would you use decode on the strings you get back from ET ? Long story... some time ago when computers wouldn't support charsets people inven

Re: newbie question

2005-12-10 Thread Dody Suria Wijaya
How about this: python your_program.py examle.txt Bermi wrote: > > how i can link it to read my file examle.txt? -- http://mail.python.org/mailman/listinfo/python-list

Re: Managing import statements

2005-12-10 Thread Jean-Paul Calderone
On Sat, 10 Dec 2005 02:21:39 -0700, Shane Hathaway <[EMAIL PROTECTED]> wrote: >Let's talk about the problem I really want help with. I brought up a >proposal earlier, but it was only half serious. I realize Python is too >sacred to accept such a heretical change. ;-) > >Here's the real problem: m

Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-10 Thread Tom Anderson
On Sat, 10 Dec 2005, Sybren Stuvel wrote: > Zeljko Vrba enlightened us with: > >> Find me an editor which has folds like in VIM, regexp search/replace >> within two keystrokes (ESC,:), marks to easily navigate text in 2 >> keystrokes (mx, 'x), can handle indentation-level matching as well as >>

Re: binascii.crc32 results not matching

2005-12-10 Thread Larry Bates
Peter Hansen wrote: > Larry Bates wrote: > >> I'm trying to get the results of binascii.crc32 >> to match the results of another utility that produces >> 32 bit unsigned CRCs. > > > What other utility? As Tim says, there are many CRC32s... the > background notes on this one happen to stumble

Re: slice notation as values?

2005-12-10 Thread Antoon Pardon
On 2005-12-10, Duncan Booth <[EMAIL PROTECTED]> wrote: > Antoon Pardon wrote: >> In general I use slices over a tree because I only want to iterate >> over a specific subdomain of the keys. I'm not iterested in make >> a tree over the subdomain. Making such a subtree would be an >> enormous waste o

problems binding a dictionary

2005-12-10 Thread vida00
this has to be a very silly thing. I have a function foo taking a dictionary as parameters. i.e.: def foo(**kwargs): pass when I call foo(param1='blah',param2='bleh',param3='blih') everything is fine. but when I do: >>> def foo(**kwargs): ... pass ... >>> d=dict(param1='blah',param2='bleh',par

Re: Thoughts on object representation in a dictionary

2005-12-10 Thread Paul Rubin
"py" <[EMAIL PROTECTED]> writes: > Well the other thing is that I am allowed to store strings in this > dictionary...so I can't just store the Engine and Body object and later > use them. this is just a requirement (which i dont understand > either)...but its what I have to do. Probably so th

Re: problems binding a dictionary

2005-12-10 Thread vida00
[EMAIL PROTECTED] wrote: > this has to be a very silly thing. > > I have a function foo taking a dictionary as parameters. i.e.: def > foo(**kwargs): pass > when I call foo(param1='blah',param2='bleh',param3='blih') everything > is fine. > but when I do: > >>> def foo(**kwargs): > ... pass > .

Re: problems binding a dictionary

2005-12-10 Thread Sam Pointon
You're not 'exploding' the dict to the param1='blah' etc form - you-re actually passing it in as a single dict object. To solve this, add a ** to the front of a dict you want to explode in a function, just as you'd add a * to explode a sequence. -- http://mail.python.org/mailman/listinfo/python-l

Re: binascii.crc32 results not matching

2005-12-10 Thread Fredrik Lundh
Larry Bates wrote: > def CalculateCrc(buffer, crc): /snip/ > The algorithm looks very much like the source code for > binascii.crc32 (but I'm not a C programmer). does your Python version give the right result ? if so, the following might be somewhat helpful: def test1(text, crc=0): # l

Re: Proposal: Inline Import

2005-12-10 Thread Mike Meyer
Shane Hathaway <[EMAIL PROTECTED]> writes: > Let me fully elaborate the heresy I'm suggesting: I am talking about > inline imports on every other line of code. The obvious > implementation would drop performance by a double digit percentage. No, it wouldn't. The semantics of import pretty much re

Re: Another newbie question

2005-12-10 Thread Mike Meyer
Steven D'Aprano <[EMAIL PROTECTED]> writes: >> In particular, >> you can get most of your meaningless methods out of a properly >> designed Coordinate API. For example, add/sub_x/y_ord can all be >> handled with move(delta_x = 0, delta_y = 0). > > Here is my example again: > > [quote] > Then, somew

Re: Managing import statements

2005-12-10 Thread Kent Johnson
Jean-Paul Calderone wrote: > On Sat, 10 Dec 2005 02:21:39 -0700, Shane Hathaway > <[EMAIL PROTECTED]> wrote: >> How about PyLint / PyChecker? Can I configure one of them to tell me >> only about missing / extra imports? Last time I used one of those >> tools, it spewed excessively pedantic warni

Re: calculate system disk space

2005-12-10 Thread [EMAIL PROTECTED]
A little somehting I rigged up when I found the Python call to be Linux specific: """ mount_list Taste the system and return a list of mount points. On UNIX this will return what a df will return On DOS based systems run through a list of common drive letters and test them to see if a mount point

Re: Managing import statements

2005-12-10 Thread Shane Hathaway
Jean-Paul Calderone wrote: > On Sat, 10 Dec 2005 02:21:39 -0700, Shane Hathaway <[EMAIL PROTECTED]> wrote: >>How about PyLint / PyChecker? Can I configure one of them to tell me >>only about missing / extra imports? Last time I used one of those >>tools, it spewed excessively pedantic warnings.

Re: Proposal: Inline Import

2005-12-10 Thread Thomas Heller
Shane Hathaway <[EMAIL PROTECTED]> writes: > Xavier Morel wrote: >> Shane Hathaway wrote: >> >>>Thoughts? >> >>> import re; name_expr = re.compile('[a-zA-Z]+') >> >>> name_expr >> <_sre.SRE_Pattern object at 0x00F9D338> >> >>> >> the import statement can be called anywhere in the code, why woul

Re: Another newbie question

2005-12-10 Thread Mike Meyer
[EMAIL PROTECTED] (Alex Martelli) writes: > Mike Meyer <[EMAIL PROTECTED]> wrote: >... >> >> it. Nothing you do with zim.foo or zim.foo.bar can change the state of >> >> zim. The only invariants you need to check are bar's, which you do at >> >> the exit to it's baz method. >> > So foo's class

Re: Proposal: Inline Import

2005-12-10 Thread Benji York
Shane Hathaway wrote: > Benji York wrote: > >> OK, good. You won't have to worry about that. :) > > You didn't give a reason for disliking it. Oh, I don't particularly dislike it. I hadn't come up with a reason to like or dislike it, other than a predilection for the status quo. -- Benji York

Re: Managing import statements

2005-12-10 Thread Shane Hathaway
Chris Mellon wrote: > On 12/10/05, Shane Hathaway <[EMAIL PROTECTED]> wrote: >>I'm surprised this problem isn't more familiar to the group. Perhaps >>some thought I was asking a newbie question. I'm definitely a newbie in >>the sum of human knowledge, but at least I've learned some tiny fraction

Re: Proposal: Inline Import

2005-12-10 Thread Shane Hathaway
Benji York wrote: > Shane Hathaway wrote: > >> Benji York wrote: >> >>> OK, good. You won't have to worry about that. :) >> >> >> You didn't give a reason for disliking it. > > > Oh, I don't particularly dislike it. I hadn't come up with a reason to > like or dislike it, other than a predilec

Re: calculate system disk space

2005-12-10 Thread Heiko Wundram
[EMAIL PROTECTED] wrote: > A little somehting I rigged up when I found the Python call to be Linux > specific: os.stat isn't Linux-specific, isn't even Unix-specific, works just fine under Windows. Under Windows you don't have sparse files though, so there are no fields which give you the block-si

Re: ANN: pygene - genetic algorithms package

2005-12-10 Thread eXt
Erik Max Francis wrote: > Sure thing. Obviously I'll post an announcement here when it's ready. I'm really happy to see that someone is working on Python based GP implementation :) I'm currently trying to get into GP world (I'm the GP newbie you talked about :P) and, as I'm a Python programmer,

Re: binascii.crc32 results not matching

2005-12-10 Thread Raymond L. Buvel
Larry Bates wrote: Looking over the code, it seems very inefficient and hard to understand. You really should check out the following. http://sourceforge.net/projects/crcmod/ It will allow you to generate efficient CRC functions for use in Python and in C or C++. The only thing you need to in

Re: slice notation as values?

2005-12-10 Thread Devan L
Antoon Pardon wrote: > On 2005-12-10, Duncan Booth <[EMAIL PROTECTED]> wrote: [snip] > >> I also think that other functions could benefit. For instance suppose > >> you want to iterate over every second element in a list. Sure you > >> can use an extended slice or use some kind of while. But why n

locawapp-001.zip

2005-12-10 Thread LocaWapp
LocaWapp: localhost web applications V.0.0.1 (2005 Dec 10) Copyright (C) 2005 RDJ This code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY. http://LocaWapp.blogspot.com - Run with: python run.py - or: python run.py 8081 - and browse

double underscore attributes?

2005-12-10 Thread bobueland
Entering >>>dir(5) I get ['__abs__', '__add__', '__and__', '__class__', '__cmp__', '__coerce__', '__delattr__', '__div__', '__divmod__', '__doc__', '__float__', '__floordiv__', '__getattribute__', '__getnewargs__', '__hash__', '__hex__', '__init__', '__int__', '__invert__', '__long__', '__lshift__

Re: Another newbie question

2005-12-10 Thread Alex Martelli
Mike Meyer <[EMAIL PROTECTED]> wrote: ... > Well, the hard-core solution is to note that your class doesn't really > deal with the type Bar, but deals with a subtype of Bar for which x > > 23 in all cases. Since types are represented by classes, you should > subclass Bar so you have a class that

Re: How to find the type ...

2005-12-10 Thread Lad
Thank you ALL for help and explanation Regards, L. -- http://mail.python.org/mailman/listinfo/python-list

Re: double underscore attributes?

2005-12-10 Thread Wojciech Mula
[EMAIL PROTECTED] wrote: > Now I went to Python Library Reference and searched for "__add__" but > got zero hits. http://python.org/doc/2.4.2/ref/specialnames.html -- http://mail.python.org/mailman/listinfo/python-list

Re: slice notation as values?

2005-12-10 Thread Brian Beck
Antoon Pardon wrote: > Will it ever be possible to write things like: > > a = 4:9 I made a silly recipe to do something like this a while ago, not that I'd recommend using it. But I also think it wouldn't be too far-fetched to allow slice creation using a syntax like the above... http://aspn.

Re: double underscore attributes?

2005-12-10 Thread LocaWapp
Hi Bob, see this my example: >>> class A: ... def __add__(a,b): ... print a,b ... >>> a = A() >>> b = A() >>> a + b <__main__.A instance at 0x80c5a74> <__main__.A instance at 0x80c6234> >>> -- http://mail.python.org/mailman/listinfo/python-list

Re: Another newbie question

2005-12-10 Thread Alex Martelli
Mike Meyer <[EMAIL PROTECTED]> wrote: > > "In addition to the full set of methods which operate on the coordinate as > > a whole, you can operate on the individual ordinates via instance.x and > > instance.y which are floats." > > That's an API which makes changing the object more difficult. It m

Re: problems binding a dictionary

2005-12-10 Thread Dody Suria Wijaya
[EMAIL PROTECTED] wrote: > this has to be a very silly thing. > > I have a function foo taking a dictionary as parameters. i.e.: def > foo(**kwargs): pass > when I call foo(param1='blah',param2='bleh',param3='blih') everything > is fine. > but when I do: def foo(**kwargs): > ... pass > ..

Re: slice notation as values?

2005-12-10 Thread Steven Bethard
Antoon Pardon wrote: > On 2005-12-10, Steven Bethard <[EMAIL PROTECTED]> wrote: > >>Antoon Pardon wrote: >> >>>So lets agree that tree['a':'b'] would produce a subtree. Then >>>I still would prefer the possibility to do something like: >>> >>> for key in tree.iterkeys('a':'b') >>> >>>Instead of h

Re: double underscore attributes?

2005-12-10 Thread Steven Bethard
[EMAIL PROTECTED] wrote: > Every time I use dir(some module) I get a lot of attributes with double > underscore, for example __add__. Ok, I thought __add__ must be a method > which I can apply like this > 5.__add(8) > > However Python responded > SyntaxError: invalid syntax > > I tried > >>

Re: double underscore attributes?

2005-12-10 Thread Dan Bishop
[EMAIL PROTECTED] wrote: ... > Every time I use dir(some module) I get a lot of attributes with double > underscore, for example __add__. Ok, I thought __add__ must be a method > which I can apply like this ... > I tried > >>> help(5.__add__) > > but got > SyntaxError: invalid syntax That's becaus

Re: Proposal: Inline Import

2005-12-10 Thread Erik Max Francis
Shane Hathaway wrote: > Let me fully elaborate the heresy I'm suggesting: I am talking about > inline imports on every other line of code. The obvious implementation > would drop performance by a double digit percentage. Module importing is already idempotent. If you try to import an already

Re: Another newbie question

2005-12-10 Thread Mike Meyer
[EMAIL PROTECTED] (Alex Martelli) writes: > Mike Meyer <[EMAIL PROTECTED]> wrote: >... >> Well, the hard-core solution is to note that your class doesn't really >> deal with the type Bar, but deals with a subtype of Bar for which x > >> 23 in all cases. Since types are represented by classes, y

Re: binascii.crc32 results not matching

2005-12-10 Thread Heiko Wundram
Larry Bates wrote: > > > The algorithm looks very much like the source code for > binascii.crc32 (but I'm not a C programmer). Well... As you have access to the code, you might actually just create a thin Python-Wrapper around this so that you can get comparable results. In case you're unable to

Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-10 Thread Zeljko Vrba
On 2005-12-10, Tom Anderson <[EMAIL PROTECTED]> wrote: > > ED IS THE STANDARD TEXT EDITOR. > And: INDENTATION SUCKS BIG TIME. Using indentation without block termination markers is opposite of the way we write spoken language, terminating eac

Re: calculate system disk space

2005-12-10 Thread Neil Hodgson
Heiko Wundram: > Under Windows you don't have sparse files though, so there > are no fields ... Does too! http://msdn.microsoft.com/library/en-us/fileio/fs/fsctl_set_sparse.asp They're fairly rare though. Neil -- http://mail.python.org/mailman/listinfo/python-list

Re: ANN: pygene - genetic algorithms package

2005-12-10 Thread Erik Max Francis
eXt wrote: > I'm really happy to see that someone is working on Python based GP > implementation :) I'm currently trying to get into GP world (I'm the GP > newbie you talked about :P) and, as I'm a Python programmer, I look > towards Python based solutions. Unfortunately there are no active Pyt

Re: double underscore attributes?

2005-12-10 Thread Xavier Morel
[EMAIL PROTECTED] wrote: > Could someone explain the use of __add__ (and similar double underscore > attributes) and what their use is. > > Bob > Methods with double leading and trailing underscores are basically "magic methods" with specific meanings for the Python interpreter. You're not supp

Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-10 Thread Fredrik Lundh
Zeljko Vrba wrote: > Using indentation without block termination markers is opposite of the way we > write spoken language, terminating each sentence with . Ever wondered why > we use such things in written language, when people are much better in > guessing what the writer wanted to say then comp

OO in Python? ^^

2005-12-10 Thread Matthias Kaeppler
Hi, sorry for my ignorance, but after reading the Python tutorial on python.org, I'm sort of, well surprised about the lack of OOP capabilities in python. Honestly, I don't even see the point at all of how OO actually works in Python. For one, is there any good reason why I should ever inherit

Re: OO in Python? ^^

2005-12-10 Thread Heiko Wundram
Matthias Kaeppler wrote: > Let this enlighten your way, young padawan: [EMAIL PROTECTED] ~/gtk-gnutella-downloads $ python Python 2.4.2 (#1, Oct 31 2005, 17:45:13) [GCC 3.4.4 (Gentoo 3.4.4-r1, ssp-3.4.4-1.0, pie-8.7.8)] on linux2 Type "help", "copyright", "credits" or "license" for more informat

Re: ANN: pygene - genetic algorithms package

2005-12-10 Thread eXt
Erik Max Francis wrote: > Unfortunately I can't give a precise date. If I have the time, a > polished working system with at least the basics should only take a week > or so to finish up. Unfortunately, I have a big deadline coming up in > my day job, so I'm probably not going to get much time

Re: OO in Python? ^^

2005-12-10 Thread Fredrik Lundh
Matthias Kaeppler wrote: > polymorphism seems to be missing in Python QOTW! -- http://mail.python.org/mailman/listinfo/python-list

Re: OO in Python? ^^

2005-12-10 Thread Heiko Wundram
Fredrik Lundh wrote: > Matthias Kaeppler wrote: >> polymorphism seems to be missing in Python > > QOTW! Let's have some UQOTW: the un-quote of the week! ;-) --- Heiko. -- http://mail.python.org/mailman/listinfo/python-list

Re: Another newbie question

2005-12-10 Thread Mike Meyer
[EMAIL PROTECTED] (Alex Martelli) writes: > Mike Meyer <[EMAIL PROTECTED]> wrote: >> > "In addition to the full set of methods which operate on the coordinate as >> > a whole, you can operate on the individual ordinates via instance.x and >> > instance.y which are floats." >> That's an API which ma

Re: OO in Python? ^^

2005-12-10 Thread Brian Beck
Matthias Kaeppler wrote: > class Base: >def foo(self): # I'd like to say that children must implement foo > pass def foo(self): raise NotImplementedError("Subclasses must implement foo") Now calling foo on a child instance will fail if it hasn't implemented foo. > And how do I for

Re: Dectecting dir changes

2005-12-10 Thread chuck
I do need to stick to FTP though as indicated I could run it on a different port. Limit comes more from the client side capabilities. Did some reading about twisted and I now understand that things in general are single threaded. I started working my way through the twisted finger tutorial. Whi

Re: Dectecting dir changes

2005-12-10 Thread Fredrik Lundh
"chuck" wrote: > While I do appreciate the suggestions but I have to say that if the > twisted folks spent half the time writing documentation as they do code > - twisted would probably get used a lot more Python folks. Didn't get > much encouragement/assistance from the twisted irc channel eithe

Re: OO in Python? ^^

2005-12-10 Thread Heiko Wundram
Brian Beck wrote: >> >> class D1(Base): >>def foo(self): >> print "D1" >> >> class D2(Base): >>def foo(self): >> print "D2" >> obj = Base() # I want a base class reference which is polymorphic >> if (): >>obj = D1() >> else: >>obj = D2() > > I have no idea what you'r

Re: OO in Python? ^^

2005-12-10 Thread Tony Nelson
In article <[EMAIL PROTECTED]>, Matthias Kaeppler <[EMAIL PROTECTED]> wrote: ... > obj = Base() # I want a base class reference which is polymorphic obj now refers to an instance of Base. > if (): > obj = D1() obj now refers to an instance of D1(). The Base instance is unreferenced. >

Re: OO in Python? ^^

2005-12-10 Thread Martin Christensen
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 > "Matthias" == Matthias Kaeppler <[EMAIL PROTECTED]> writes: Matthias> sorry for my ignorance, but after reading the Python Matthias> tutorial on python.org, I'm sort of, well surprised about Matthias> the lack of OOP capabilities in python. Hones

Re: OO in Python? ^^

2005-12-10 Thread Paul Boddie
Heiko Wundram wrote: > Matthias Kaeppler wrote: > > Well, unless you are (or he is) in with the GNOME crowd, C probably isn't really the object-oriented language acting as inspiration here. [Zen of Python] Of course the ZoP (Zen of Python) is deep guidance for those languishing in some design d

Re: ANN: Dao Language v.0.9.6-beta is release!

2005-12-10 Thread Rick Wotnaz
Zeljko Vrba <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > On 2005-12-10, Tom Anderson <[EMAIL PROTECTED]> wrote: >> >> ED IS THE STANDARD TEXT EDITOR. >> > And: > INDENTATION > SUCKS >BIG > TIME. > > Using indentation without block termination markers

Re: OO in Python? ^^

2005-12-10 Thread Leif K-Brooks
Heiko Wundram wrote: > Fredrik Lundh wrote: >>Matthias Kaeppler wrote: >>>polymorphism seems to be missing in Python >> >>QOTW! > > Let's have some UQOTW: the un-quote of the week! ;-) +1 -- http://mail.python.org/mailman/listinfo/python-list

Re: Another newbie question

2005-12-10 Thread Paul Rubin
[EMAIL PROTECTED] (Alex Martelli) writes: > You could make a case for a "2D coordinate" class being "sufficiently > primitive" to have immutable instances, of course (by analogy with > numbers and strings) -- in that design, you would provide no mutators, > and therefore neither would you provide s

  1   2   >