What does "::" mean?

C

could ildg

I know that ":" can do slice works.
But I saw "::" today and it puzzled me much,
I can't find it in the python doc,
so I raise this question here.
The code is as below:
----------------------------------------------------------
Jython 2.2a1 on java1.5.0_03 (JIT: null)
Type "copyright", "credits" or "license" for more information.
live='live';print live live
live=live[::-1];print live evil
 
P

Paul Villani

I'm very new to Python, but....

I think it's really ':' and ':' side-by-side with no values, not a single
"::".

In V2.3 and higher, slicing supports an optional third index which works as
a step, e.g.,

X[2:9:2]

fetches every other item in indexes 2-8. The useage you cite is really
defaulting the start and end indexes, and decrementing the step index.

Regards,

I know that ":" can do slice works.
But I saw "::" today and it puzzled me much,
I can't find it in the python doc,
so I raise this question here.
The code is as below:
----------------------------------------------------------
Jython 2.2a1 on java1.5.0_03 (JIT: null)
Type "copyright", "credits" or "license" for more information.
live='live';print live live
live=live[::-1];print live evil
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
474,262
Messages
2,571,310
Members
47,979
Latest member
konoha

Latest Threads

Top