SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    Keep it simple, stupid! bokehman's Avatar
    Join Date
    Jul 2005
    Posts
    1,935
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Can you explain some syntax to a non-python person?

    Not a python coder here. Can someone please explain (or even better link to something that explains) the bit in red.

    Code:
    MyVar = line.split()[3][4:-1]

  2. #2
    SitePoint Zealot
    Join Date
    Apr 2005
    Location
    London
    Posts
    163
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It is the slice operation (or substring) of a String.
    The red bit will return the 5th char to the to 2nd last char. (as everything is indexed from 0).

    You can read through http://docs.python.org/2/tutorial/introduction.html


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •