Python Forum
Thread Rating:
  • 1 Vote(s) - 2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Code Review?
#10
Quote:
if currentl_line[:2]
-- I do not understand the syntax -- what the colon 2 is doing here.   Is that the following _2 items_ need to be in before the 3rd item(position 2) ? or is it those items need to be before _position 2_ ?  what is :2 representi
Its a slice

the : represents its a slice and not getting index [2]
Its more like current_line[X:2:X]  [start:stop:step] but you dont need to specify the beginning index of 0, you just leave it empty.

In this case there is a 2 at stop which means it will get indexes 0 and 1
Recommended Tutorials:
Reply


Messages In This Thread
Code Review? - by PappaBear - Apr-18-2017, 06:06 AM
RE: Code Review? - by micseydel - Apr-18-2017, 06:24 AM
RE: Code Review? - by PappaBear - Apr-18-2017, 02:03 PM
RE: Code Review? - by micseydel - Apr-18-2017, 08:14 PM
RE: Code Review? - by PappaBear - Apr-18-2017, 10:25 PM
RE: Code Review? - by metulburr - Apr-18-2017, 10:43 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python best library for Excel reports & review of existing code MasterOfDestr 4 1,103 Feb-14-2024, 03:39 PM
Last Post: MasterOfDestr
  Review my code: convert a HTTP date header to a datetime object stevendaprano 1 2,189 Dec-17-2022, 12:24 AM
Last Post: snippsat
  Code review for S3 object creation beherap 0 2,222 Mar-29-2018, 01:31 PM
Last Post: beherap

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020