Re: A Python 3000 Question

2007-11-02 Thread Bruno Desthuilliers
Steven D'Aprano a écrit : > On Fri, 02 Nov 2007 03:40:59 +, Tim Roberts wrote: > >> Steven D'Aprano <[EMAIL PROTECTED]> wrote: >> >>> On Wed, 31 Oct 2007 22:48:12 -0700, Carl Banks wrote: >>> > I hope you're not serious that $# would make a good operator. If you happen to know where I

Re: A Python 3000 Question

2007-11-02 Thread Paul Rubin
Steven D'Aprano <[EMAIL PROTECTED]> writes: > > Seriously? You didn't know that $#x in perl returns the length of the > > array @x, minus 1? > I don't speak Perl. You know there are million of us who have managed to > avoid it. I used to use perl (though I was never an expert) and I didn't know

Re: A Python 3000 Question

2007-11-01 Thread Steven D'Aprano
On Fri, 02 Nov 2007 03:40:59 +, Tim Roberts wrote: > Steven D'Aprano <[EMAIL PROTECTED]> wrote: > >>On Wed, 31 Oct 2007 22:48:12 -0700, Carl Banks wrote: >> I hope you're not serious that $# would make a good operator. >>> >>> If you happen to know where I borrowed it from, it would be

Re: A Python 3000 Question

2007-11-01 Thread Tim Roberts
Steven D'Aprano <[EMAIL PROTECTED]> wrote: >On Wed, 31 Oct 2007 22:48:12 -0700, Carl Banks wrote: > >>> I hope you're not serious that $# would make a good operator. >> >> If you happen to know where I borrowed it from, it would be pretty >> evident that I wasn't being serious. > >Ooh, now I'm cu

Re: A Python 3000 Question

2007-11-01 Thread J. Cliff Dyer
Steven D'Aprano wrote: > On Wed, 31 Oct 2007 22:48:12 -0700, Carl Banks wrote: > > >>> I hope you're not serious that $# would make a good operator. >>> >> If you happen to know where I borrowed it from, it would be pretty >> evident that I wasn't being serious. >> > > Ooh, now I'm c

Re: A Python 3000 Question

2007-11-01 Thread Steven D'Aprano
On Wed, 31 Oct 2007 22:48:12 -0700, Carl Banks wrote: >> I hope you're not serious that $# would make a good operator. > > If you happen to know where I borrowed it from, it would be pretty > evident that I wasn't being serious. Ooh, now I'm curious. -- Steven. -- http://mail.python.org/mail

Re: A Python 3000 Question

2007-10-31 Thread Carl Banks
On Oct 30, 1:30 am, George Sakkis <[EMAIL PROTECTED]> wrote: > Having a builtin len() that calls the method __len__ > seems (using your words) "not only foolish but wasteful". But what about (for instance) having the bitwise not operator (^) calling __bitwise_not__. Is that foolish and wasteful?

Re: A Python 3000 Question

2007-10-31 Thread Carl Banks
On Oct 31, 6:29 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Wed, 31 Oct 2007 07:59:58 -0700, Carl Banks wrote: > > Python considers len to be an operator for all intents and purposes. > > Python chose to spell this operator like a regular function, but it > > could easily

Re: A Python 3000 Question

2007-10-31 Thread Chris Mellon
On Oct 31, 2007 6:02 PM, George Sakkis <[EMAIL PROTECTED]> wrote: > On Oct 31, 6:13 pm, Steven D'Aprano > > > What you have measured is a local optimization that is only useful when > > you have a tight loop with lots of calls to the same len(): > > > > Len = sequence.__len__ > > while Len() < 1000

Re: A Python 3000 Question

2007-10-31 Thread George Sakkis
On Oct 31, 6:13 pm, Steven D'Aprano > What you have measured is a local optimization that is only useful when > you have a tight loop with lots of calls to the same len(): > > Len = sequence.__len__ > while Len() < 10: > foo(sequence) Exactly what timeit() does, a tight loop. > But what

Re: A Python 3000 Question

2007-10-31 Thread Steven D'Aprano
On Wed, 31 Oct 2007 07:59:58 -0700, Carl Banks wrote: > Python considers len to be an operator for all intents and purposes. > Python chose to spell this operator like a regular function, but it > could easily have given a special syntax to the length operation (for > instance, $#x). I hope you'r

Re: A Python 3000 Question

2007-10-31 Thread Steven D'Aprano
On Wed, 31 Oct 2007 13:14:41 +, George Sakkis wrote: > On Oct 31, 8:44 am, Neil Cerutti <[EMAIL PROTECTED]> wrote: >> On 2007-10-30, George Sakkis <[EMAIL PROTECTED]> wrote: >> >> >> >> > On Oct 30, 11:25 am, Neil Cerutti <[EMAIL PROTECTED]> wrote: >> >> On 2007-10-30, Eduardo O. Padoan <[EMAI

Re: A Python 3000 Question

2007-10-31 Thread Steven D'Aprano
On Wed, 31 Oct 2007 14:45:59 +, Duncan Booth wrote: >> Thanks for the interesting note. I didn't know that tuples originally >> had no methods. That made len mandatory, I suppose. >> > Only if you think tuples are a sequence rather than a record. Even records have a length. The length of a r

Re: A Python 3000 Question

2007-10-31 Thread Carl Banks
On Oct 31, 8:44 am, Neil Cerutti <[EMAIL PROTECTED]> wrote: > On 2007-10-30, George Sakkis <[EMAIL PROTECTED]> wrote: > > > > > On Oct 30, 11:25 am, Neil Cerutti <[EMAIL PROTECTED]> wrote: > >> On 2007-10-30, Eduardo O. Padoan <[EMAIL PROTECTED]> wrote: > > >> > This is a FAQ: > >> >http://effbot.o

Re: A Python 3000 Question

2007-10-31 Thread Duncan Booth
Neil Cerutti <[EMAIL PROTECTED]> wrote: > On 2007-10-31, Duncan Booth <[EMAIL PROTECTED]> wrote: >> Obviously it isn't an absolute thing: lists and dictionaries do >> have other methods in the user namespace, so the decision to >> keep len out of that namespace is partly a judgement call, and >> p

Re: A Python 3000 Question

2007-10-31 Thread Neil Cerutti
On 2007-10-31, Duncan Booth <[EMAIL PROTECTED]> wrote: > Obviously it isn't an absolute thing: lists and dictionaries do > have other methods in the user namespace, so the decision to > keep len out of that namespace is partly a judgement call, and > partly historical (I think tuples didn't used to

Re: A Python 3000 Question

2007-10-31 Thread Duncan Booth
Neil Cerutti <[EMAIL PROTECTED]> wrote: > But if I'm wrong about the performance benefits then I guess I'm > still in the dark about why len is a builtin. The only compelling > thing in the linked explation was the signatures of the guys who > wrote the artible. (Guido does admit he would, "hate t

Re: A Python 3000 Question

2007-10-31 Thread Neil Cerutti
On 2007-10-31, George Sakkis <[EMAIL PROTECTED]> wrote: > On Oct 31, 8:44 am, Neil Cerutti <[EMAIL PROTECTED]> wrote: >> On 2007-10-30, George Sakkis <[EMAIL PROTECTED]> wrote: >> >> >> >> > On Oct 30, 11:25 am, Neil Cerutti <[EMAIL PROTECTED]> wrote: >> >> On 2007-10-30, Eduardo O. Padoan <[EMAIL

Re: A Python 3000 Question

2007-10-31 Thread George Sakkis
On Oct 31, 8:44 am, Neil Cerutti <[EMAIL PROTECTED]> wrote: > On 2007-10-30, George Sakkis <[EMAIL PROTECTED]> wrote: > > > > > On Oct 30, 11:25 am, Neil Cerutti <[EMAIL PROTECTED]> wrote: > >> On 2007-10-30, Eduardo O. Padoan <[EMAIL PROTECTED]> wrote: > > >> > This is a FAQ: > >> >http://effbot.o

Re: A Python 3000 Question

2007-10-31 Thread Neil Cerutti
On 2007-10-30, George Sakkis <[EMAIL PROTECTED]> wrote: > On Oct 30, 11:25 am, Neil Cerutti <[EMAIL PROTECTED]> wrote: >> On 2007-10-30, Eduardo O. Padoan <[EMAIL PROTECTED]> wrote: >> >> > This is a FAQ: >> >http://effbot.org/pyfaq/why-does-python-use-methods-for-some-function... >> >> Holy Airy P

Re: A Python 3000 Question

2007-10-31 Thread Neil Cerutti
On 2007-10-30, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote: > On Tue, 30 Oct 2007 15:25:54 GMT, Neil Cerutti <[EMAIL PROTECTED]> wrote: >>On 2007-10-30, Eduardo O. Padoan <[EMAIL PROTECTED]> wrote: >>> This is a FAQ: >>> http://effbot.org/pyfaq/why-does-python-use-methods-for-some-functionality-e

Re: A Python 3000 Question

2007-10-30 Thread Paul Boddie
On 30 Okt, 15:09, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > [Language "OOness", hand-waving] > I disagree. I think they *do* take away from the overall Object-Oriented > nature of the language, and that is A Very Good Thing Indeed. But everything is an object in Python: not

Re: A Python 3000 Question

2007-10-30 Thread George Sakkis
On Oct 30, 11:25 am, Neil Cerutti <[EMAIL PROTECTED]> wrote: > On 2007-10-30, Eduardo O. Padoan <[EMAIL PROTECTED]> wrote: > > > This is a FAQ: > >http://effbot.org/pyfaq/why-does-python-use-methods-for-some-function... > > Holy Airy Persiflage Batman! > > Python 2.5.1 (r251:54863, Apr 18 2007, 08:

Re: A Python 3000 Question

2007-10-30 Thread Jean-Paul Calderone
On Tue, 30 Oct 2007 15:25:54 GMT, Neil Cerutti <[EMAIL PROTECTED]> wrote: >On 2007-10-30, Eduardo O. Padoan <[EMAIL PROTECTED]> wrote: >> This is a FAQ: >> http://effbot.org/pyfaq/why-does-python-use-methods-for-some-functionality-e-g-list-index-but-functions-for-other-e-g-len-list.htm > >Holy Airy

Re: A Python 3000 Question

2007-10-30 Thread Neil Cerutti
On 2007-10-30, Eduardo O. Padoan <[EMAIL PROTECTED]> wrote: > This is a FAQ: > http://effbot.org/pyfaq/why-does-python-use-methods-for-some-functionality-e-g-list-index-but-functions-for-other-e-g-len-list.htm Holy Airy Persiflage Batman! Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.13

Re: A Python 3000 Question

2007-10-30 Thread Steven D'Aprano
On Tue, 30 Oct 2007 00:11:58 +, Marc 'BlackJack' Rintsch wrote: >>> And to answer the question. In OO programming generic functions are no >>> less important than classes and objects. >> >> Do they not take away from the OOness of the overall language and >> introduce inconsistencies? > > No

Re: A Python 3000 Question

2007-10-30 Thread brad
Eduardo O. Padoan wrote: > This is a FAQ: > http://effbot.org/pyfaq/why-does-python-use-methods-for-some-functionality-e-g-list-index-but-functions-for-other-e-g-len-list.htm Thanks to all for the feedback. I'm no language designer. I just see and hear these criticisms and I wanted to think thro

Re: A Python 3000 Question

2007-10-30 Thread Dustan
On Oct 29, 7:59 pm, Wildemar Wildenburger <[EMAIL PROTECTED]> wrote: > Bjoern Schliessmann wrote: > > The inconsistencies arise, IMHO, if an OO language introduces > > non-object types for performance reasons, after that gets wrapper > > classes to wrap those primitives, and even later gets the abi

Re: A Python 3000 Question

2007-10-30 Thread Eduardo O. Padoan
On 10/29/07, brad <[EMAIL PROTECTED]> wrote: > Will len(a_string) become a_string.len()? I was just reading > > http://docs.python.org/dev/3.0/whatsnew/3.0.html > > One of the criticisms of Python compared to other OO languages is that > it isn't OO enough or as OO as others or that it is inconsist

Re: A Python 3000 Question

2007-10-30 Thread Bruno Desthuilliers
brad a écrit : > Rob Wolfe wrote: > >> I wonder why people always complain about `len` function but never >> about `iter` or `pprint.pprint`? :) > > Not complaining. len is simple and understandable and IMO fits nicely > with split(), strip(), etc... that's why I used it as an example, but > li

Re: A Python 3000 Question

2007-10-30 Thread Bruno Desthuilliers
brad a écrit : > Will len(a_string) become a_string.len()? I was just reading > > http://docs.python.org/dev/3.0/whatsnew/3.0.html > > One of the criticisms of Python compared to other OO languages is that > it isn't OO enough Really ? IIRC, Python doesn't have primitive types, functions are o

Re: A Python 3000 Question

2007-10-30 Thread Thomas Wittek
Bjoern Schliessmann: > Is there any particular reason why it should be a method? > > [..] > > To make a long story short: Most methods do specific things with > objects; but len is a common function to get a simple property of > an object. You said it. IMHO it really could be a *property*, say `

Re: A Python 3000 Question

2007-10-30 Thread Marc 'BlackJack' Rintsch
On Mon, 29 Oct 2007 19:50:14 -0700, George Sakkis wrote: > On Oct 29, 5:49 pm, "Terry Reedy" <[EMAIL PROTECTED]> wrote: > >> | why not a_string.len()? >> >> You are free to bypass builtins and call methods directly if you like: >> a_string.__len__(). >> >> But consider rewriting the following: >>

Re: A Python 3000 Question

2007-10-29 Thread George Sakkis
On Oct 29, 9:35 pm, Michael L Torrie <[EMAIL PROTECTED]> wrote: > brad wrote: > > Not complaining. len is simple and understandable and IMO fits nicely > > with split(), strip(), etc... that's why I used it as an example, but > > list(), etc. could be used as examples as well: > > > a_string.list()

Re: A Python 3000 Question

2007-10-29 Thread George Sakkis
On Oct 29, 5:49 pm, "Terry Reedy" <[EMAIL PROTECTED]> wrote: > I was just reading > |http://docs.python.org/dev/3.0/whatsnew/3.0.html > > which says nothing about such a change, except for one in the opposite > direction: o.next() changes to next(o) which in turn calls o.__next__(), > just as len

Re: A Python 3000 Question

2007-10-29 Thread Michael L Torrie
brad wrote: > Not complaining. len is simple and understandable and IMO fits nicely > with split(), strip(), etc... that's why I used it as an example, but > list(), etc. could be used as examples as well: > > a_string.list() instead of list(a_string) This is a great example of why list() needs

Re: A Python 3000 Question

2007-10-29 Thread Wildemar Wildenburger
Bjoern Schliessmann wrote: > The inconsistencies arise, IMHO, if an OO language introduces > non-object types for performance reasons, after that gets wrapper > classes to wrap those primitives, and even later gets the ability > to automatically cast a primitive into a wrapper class instance. > Tha

Re: A Python 3000 Question

2007-10-29 Thread Marc 'BlackJack' Rintsch
On Mon, 29 Oct 2007 17:26:06 -0400, brad wrote: > Rob Wolfe wrote: > >> I wonder why people always complain about `len` function but never >> about `iter` or `pprint.pprint`? :) > > Not complaining. len is simple and understandable and IMO fits nicely > with split(), strip(), etc... that's why

Re: A Python 3000 Question

2007-10-29 Thread Carl Banks
On Oct 29, 4:25 pm, brad <[EMAIL PROTECTED]> wrote: > One of the criticisms of Python compared to other OO languages is that > it isn't OO enough or as OO as others or that it is inconsistent. Python is less thoroughly OO than some other languages, yes. The underlying assumption, that being thoro

Re: A Python 3000 Question

2007-10-29 Thread Bjoern Schliessmann
brad wrote: > a_string.list() instead of list(a_string) A string can be stripped, "lowercased" or split, but why should it be able to be "listed"? IMHO, list is a conversion function to make a list from something. >> And to answer the question. In OO programming generic functions >> are no less

Re: A Python 3000 Question

2007-10-29 Thread Bjoern Schliessmann
brad wrote: > One of the criticisms of Python compared to other OO languages is > that it isn't OO enough or as OO as others or that it is > inconsistent. If OO meant "everything must be a method" then yes, Python wasn't OO. > And little things such as this seem to support those > arguments. No

Re: A Python 3000 Question

2007-10-29 Thread Terry Reedy
"brad" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | Will len(a_string) become a_string.len()? No. I was just reading | http://docs.python.org/dev/3.0/whatsnew/3.0.html which says nothing about such a change, except for one in the opposite direction: o.next() changes to next(

Re: A Python 3000 Question

2007-10-29 Thread brad
Rob Wolfe wrote: > I wonder why people always complain about `len` function but never > about `iter` or `pprint.pprint`? :) Not complaining. len is simple and understandable and IMO fits nicely with split(), strip(), etc... that's why I used it as an example, but list(), etc. could be used as e

Re: A Python 3000 Question

2007-10-29 Thread Rob Wolfe
brad <[EMAIL PROTECTED]> writes: > Will len(a_string) become a_string.len()? I was just reading > > http://docs.python.org/dev/3.0/whatsnew/3.0.html > > One of the criticisms of Python compared to other OO languages is that > it isn't OO enough or as OO as others or that it is inconsistent. And >

A Python 3000 Question

2007-10-29 Thread brad
Will len(a_string) become a_string.len()? I was just reading http://docs.python.org/dev/3.0/whatsnew/3.0.html One of the criticisms of Python compared to other OO languages is that it isn't OO enough or as OO as others or that it is inconsistent. And little things such as this seem to support t