Re: Built-in functions and keyword arguments

2007-10-30 Thread Gabriel Genellina
En Tue, 30 Oct 2007 14:43:48 -0300, Duncan Booth <[EMAIL PROTECTED]> escribió: > "J. Clifford Dyer" <[EMAIL PROTECTED]> wrote: > >>> >>> help(int) >>> Help on class int in module __builtin__: >>> >>> class int(object) >>> | int(x[, base]) -> integer >>> ... >>> >> OK, good point. Perhaps it's

Re: Built-in functions and keyword arguments

2007-10-30 Thread Duncan Booth
"J. Clifford Dyer" <[EMAIL PROTECTED]> wrote: >> How do you interpret: >> >> >>> help(__import__) >> Help on built-in function __import__ in module __builtin__: >> >> __import__(...) >> __import__(name, globals={}, locals={}, fromlist=[], level=-1) -> >> module >> ... >> >>> help(int) >> Hel

Re: Built-in functions and keyword arguments

2007-10-30 Thread Marc 'BlackJack' Rintsch
On Tue, 30 Oct 2007 07:28:07 +0200, Hendrik van Rooyen wrote: > yes - the point I am trying to make is that the intention of the OP > was to use an assignment as an argument, and you can't do that, > as the interpreter thinks its a keyword. Hence the gotcha. Then you must have misunderstand his

Re: Built-in functions and keyword arguments

2007-10-29 Thread Hendrik van Rooyen
"Jean-Paul Calderone" <[EMAIL PROTECTED]> wrote: > On Mon, 29 Oct 2007 19:03:34 +0200, Hendrik van Rooyen <[EMAIL PROTECTED]> wrote: > >Looks like a gotcha to me - its the difference between a keyword > >(master = 42) and an assignment (s='I am a string') > > > > But it's not a keyword: > > >

Re: Built-in functions and keyword arguments

2007-10-29 Thread J. Clifford Dyer
On Mon, Oct 29, 2007 at 06:45:22PM +, Duncan Booth wrote regarding Re: Built-in functions and keyword arguments: > > "J. Clifford Dyer" <[EMAIL PROTECTED]> wrote: > > >> I think you are being a little bit unfair here: help(len) says: > >> &g

Re: Built-in functions and keyword arguments

2007-10-29 Thread Duncan Booth
"J. Clifford Dyer" <[EMAIL PROTECTED]> wrote: >> I think you are being a little bit unfair here: help(len) says: >> >> len(...) >> len(object) -> integer >> >> Return the number of items of a sequence or mapping. >> >> which implies that the argument to len has the name 'object' >>

Re: Built-in functions and keyword arguments

2007-10-29 Thread J. Clifford Dyer
On Mon, Oct 29, 2007 at 02:27:50PM +, Duncan Booth wrote regarding Re: Built-in functions and keyword arguments: > > Bruno Desthuilliers <[EMAIL PROTECTED]> > wrote: > > > In the second case, the name of the argument *is* 'object'. Which is not >

Re: Built-in functions and keyword arguments

2007-10-29 Thread Jean-Paul Calderone
On Mon, 29 Oct 2007 19:03:34 +0200, Hendrik van Rooyen <[EMAIL PROTECTED]> wrote: >"Tim Chase" <[EMAIL PROTECTED]> > >> > I think you are being a little bit unfair here: help(len) says: >> > >> > len(...) >> > len(object) -> integer >> > >> > Return the number of items of a sequence or map

Re: Built-in functions and keyword arguments

2007-10-29 Thread Bruno Desthuilliers
Armando Serrano Lombillo a écrit : > On Oct 29, 3:20 pm, Bruno Desthuilliers [EMAIL PROTECTED]> wrote: >> Armando Serrano Lombillo a écrit : >> >>> Why does Python give an error when I try to do this: >> len(object=[1,2]) >>> Traceback (most recent call last): >>> File "", line 1, in >>>

Re: Built-in functions and keyword arguments

2007-10-29 Thread Hendrik van Rooyen
"Tim Chase" <[EMAIL PROTECTED]> > > I think you are being a little bit unfair here: help(len) says: > > > > len(...) > > len(object) -> integer > > > > Return the number of items of a sequence or mapping. > > > > which implies that the argument to len has the name 'object' (although

Re: Built-in functions and keyword arguments

2007-10-29 Thread Marc 'BlackJack' Rintsch
On Mon, 29 Oct 2007 08:34:58 -0700, Armando Serrano Lombillo wrote: > On Oct 29, 3:10 pm, Duncan Booth <[EMAIL PROTECTED]> wrote: >> >> I don't know if the reason that most builtin functions don't accept >> keywords is just historical (someone would have to go through a lot of >> code and add keyw

Re: Built-in functions and keyword arguments

2007-10-29 Thread Armando Serrano Lombillo
On Oct 29, 3:20 pm, Bruno Desthuilliers wrote: > Armando Serrano Lombillo a écrit : > > > Why does Python give an error when I try to do this: > > len(object=[1,2]) > > Traceback (most recent call last): > > File "", line 1, in > > len(object=[1,2]) > > TypeError: len() takes no keywor

Re: Built-in functions and keyword arguments

2007-10-29 Thread Armando Serrano Lombillo
On Oct 29, 3:10 pm, Duncan Booth <[EMAIL PROTECTED]> wrote: > Armando Serrano Lombillo <[EMAIL PROTECTED]> wrote: > > > > > Why does Python give an error when I try to do this: > > len(object=[1,2]) > > Traceback (most recent call last): > > File "", line 1, in > > len(object=[1,2]) > >

Re: Built-in functions and keyword arguments

2007-10-29 Thread Tim Chase
>> >> While we're at it, you should avoid using builtin's names for >> identifiers - here, using 'object' as the arg name shadows the builtin >> 'object' class). >> > > I think you are being a little bit unfair here: help(len) says: > > len(...) > len(object) -> integer > > Retur

Re: Built-in functions and keyword arguments

2007-10-29 Thread Duncan Booth
Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > In the second case, the name of the argument *is* 'object'. Which is not > the case for the builtin len (which, fwiw, has type > 'builtin_function_or_method', not 'function', so inspect.getargspec > couldn't tell me more). > > > While we're at

Re: Built-in functions and keyword arguments

2007-10-29 Thread Steven D'Aprano
On Mon, 29 Oct 2007 13:52:04 +, Armando Serrano Lombillo wrote: > Why does Python give an error when I try to do this: > len(object=[1,2]) > Traceback (most recent call last): > File "", line 1, in > len(object=[1,2]) > TypeError: len() takes no keyword arguments > > but not when

Re: Built-in functions and keyword arguments

2007-10-29 Thread Bruno Desthuilliers
Armando Serrano Lombillo a écrit : > Why does Python give an error when I try to do this: > len(object=[1,2]) > Traceback (most recent call last): > File "", line 1, in > len(object=[1,2]) > TypeError: len() takes no keyword arguments > > but not when I use a "normal" function: > >>>

Re: Built-in functions and keyword arguments

2007-10-29 Thread Duncan Booth
Armando Serrano Lombillo <[EMAIL PROTECTED]> wrote: > Why does Python give an error when I try to do this: > len(object=[1,2]) > Traceback (most recent call last): > File "", line 1, in > len(object=[1,2]) > TypeError: len() takes no keyword arguments > > but not when I use a "normal

Built-in functions and keyword arguments

2007-10-29 Thread Armando Serrano Lombillo
Why does Python give an error when I try to do this: >>> len(object=[1,2]) Traceback (most recent call last): File "", line 1, in len(object=[1,2]) TypeError: len() takes no keyword arguments but not when I use a "normal" function: >>> def my_len(object): return len(object) >>> m