#1
  1. No Profile Picture
    guest
    Guest
    Devshed Newbie (0 - 499 posts)

    python


    I WANT MORE : things like executing commands from the script
  2. #2
  3. No Profile Picture
    guest
    Guest
    Devshed Newbie (0 - 499 posts)
    Careful, the text talks (in an aside) about the print() function. This is _wrong_, there is a print _statement_, but no print() function.
  4. #3
  5. No Profile Picture
    guest
    Guest
    Devshed Newbie (0 - 499 posts)

    Statements and expressions


    Once more, a slight confusion over statements and expressions leads me to point out that, although the article says, "Well, comparison operators come in very useful when building conditional expressions - and conditional expressions come in very useful when adding control routines to your code," Python does not have conditional expressions, only conditional staements.

    In this, Python is unlike Perl or C. Pythonistas claim this makes the resulting code more readable.
  6. #4
  7. No Profile Picture
    guest
    Guest
    Devshed Newbie (0 - 499 posts)

    switch/case


    Very good tutorial. Just a comment on:

    > Since Python does not support PHP-or
    > JSP-style "switch/case" conditional
    > statements, the "if-elif-else" construct
    > is the only way to route program
    > control to multiple code blocks.

    Python provide simple enough function pointers to implement switch/case in a
    more elegant way than a long if/else.
    But maybe this is advanced code:

    def work():
    print "Ahiho"

    def fun():
    print "Yuk"

    >>> tasks = {'monday':work,'tuesday':work,'sunday':fun}
    >>> tasks['monday']()
    AhiHo

  8. #5
  9. No Profile Picture
    guest
    Guest
    Devshed Newbie (0 - 499 posts)

    Error with code


    Why doesn't python allow wrapping around of text when there is an if block indented. It gives an error.
  10. #6
  11. No Profile Picture
    guest
    Guest
    Devshed Newbie (0 - 499 posts)

    Re: Error with code


    whitespace is significant. try the line continuation \
  12. #7
  13. No Profile Picture
    guest
    Guest
    Devshed Newbie (0 - 499 posts)

    Thank you


    Thank you for the inro to Python.
    I enjoyed it. Please keep these type
    of tutorials coming.

    Abe Almonte
  14. #8
  15. No Profile Picture
    guest
    Guest
    Devshed Newbie (0 - 499 posts)

    Good stuff


    InktomiSearch uses python as its scripting language. I've been trying to hack that up a bit but not being familiar wtih python, I was breaking stuff constantly. This series is a great quick intro to the language. Much appreciated!
  16. #9
  17. No Profile Picture
    guest
    Guest
    Devshed Newbie (0 - 499 posts)

    Python Who?


    Python is like one of those languages that you don't hear of until you get deep into Geekdom. I've been working in the IT industry for a long time, and I've never actually seen it being used. Is this like a cult language (The Black Sabbath of 'puter languages)??
  18. #10
  19. No Profile Picture
    guest
    Guest
    Devshed Newbie (0 - 499 posts)
  20. #11
  21. No Profile Picture
    guest
    Guest
    Devshed Newbie (0 - 499 posts)

    semi-colon


    Vikram,

    Presumably the semicolon at the end of:-

    else:
    print ("Finally! A user with active brain cells!");

    is a mistake?

  22. #12
  23. No Profile Picture
    guest
    Guest
    Devshed Newbie (0 - 499 posts)

    strange slices


    So,

    >>> str='hobgoblin'
    >>> str[:7]
    'hobgobl'

    Since str[0] is 'h', either the second value of the slice is a counter or the slice means from the first value up to [but not including] the second.

    >>> str[3:3]
    ''
    >>> str[3:4]
    'g'

    Ok, so the slice is:-
    [from:to but not including]

    Not a problem, but it's certainly different from what I expected.
  24. #13
  25. No Profile Picture
    guest
    Guest
    Devshed Newbie (0 - 499 posts)
  26. #14
  27. No Profile Picture
    Ducani
    Guest
    Devshed Newbie (0 - 499 posts)

    Python 101 (part 2): If Wishes Were Pythons


    Python 101 \(part 2\): If Wishes Were Pythons

    Begin your tour of Python with a look at its number and string types, together with examples of how they can be used in simple Python programs. Along the way, you'll also learn how to build conditional expressions, slice and dice strings, and accept user input from the command line.

    Please discuss this article in this thread. You can read the article here .

IMN logo majestic logo threadwatch logo seochat tools logo