What does "::" mean?
Robert Kern
rkern at ucsd.edu
Wed Jul 20 11:53:16 EDT 2005
qwweeeit at yahoo.it wrote:
> Hi Robert,
> I didn't succeed in reversing a string with the "full form" you
> proposed:
> live[len(live)-1:-1:-1] # where live="live"
> The result is an empty string.
> To reverse "live" (in a "full form"), I have to put a char in front of
> the string and...:
> ('x'+live)[len(live)+1:0:-1] # --> "evil"
> Is it due to the Python's version (I still have 2.3.4)?
No, it's because I am stupid. There isn't a full form.
live[len(live)::-1] is the closest expansion.
--
Robert Kern
rkern at ucsd.edu
"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
More information about the Python-list
mailing list