Arithmetic sequences in Python

Steve Holden steve at holdenweb.com
Sun Jan 22 06:07:33 EST 2006


Paul Rubin wrote:
> Tom Anderson <twic at urchin.earth.li> writes:
> 
>>>listx/dictx/setx would be the display forms as well as the constructor forms.
>>
>>Could these even replace the current forms? If you want the equivalent
>>of list(sometuple), write list(*sometuple). 
> 
> 
> The current list function is supposed to be something like a typecast:
> 
list() isn't a function, it's a type.

  >>> type(list)
<type 'type'>

  I'm not happy about the way the documentation represents types as 
functions, as this obscures the whole essence of Python's object 
orientation.


> list() = []
> xlist() = []   # ok
> 
> list(list()) = []   # casting a list to a list does nothing
> xlist(xlist()) = [[]]  # make a new list, not the same
> 
> list(xrange(4)) = [0,1,2,3]
> xlist(xrange(4)) = [xrange(4)]   # not the same
> 
> list((1,2)) = [1,2]
> xlist((1,2)) = [(1,2)]
> 
> etc.

I presume that here "=" means "evaluates to"?

regards
  Steve
-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC                     www.holdenweb.com
PyCon TX 2006                  www.python.org/pycon/




More information about the Python-list mailing list