What does "::" mean?

Jim Sizelove sizelji at insightbb.com
Thu Jul 21 17:28:08 EDT 2005


Robert Kern wrote:
> Michael Hoffman wrote:
> 
>> Robert Kern wrote:
> 
> 
>>> Well, that part's easy at least:
>>>
>>>  live[::-1]
>>>
>>> :-)  And so the circle is complete ...
>>
>>
>> What about reversed(live)? Or if you want a list instead of an 
>> iterator, list(reversed(live))?
> 
> 
> That's fine if you want to iterate over it. Often, especially with 
> strings, you just want an object of the same type back again.
> 
Then you could use:
     ''.join(reversed(live))

though, I think that live[::-1] is the most obvious way to do it.  :-)

Regards,
Jim Sizelove



More information about the Python-list mailing list