An Abridged Python Tutorial

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Michael Spencer

    #1

    An Abridged Python Tutorial

    An Abridged Python Tutorial

    There are tips for the novice and tricks
    that will add to your programming kicks.
    But the cardinal rule
    that you must learn at school
    is that spaces and tabs never mix.

    If there's syntax you don't understand,
    assistance is always at hand:
    a glance at the cookbook,
    or even a quick look
    at the manual should meet the demand.

    If you code without reading this doc,
    you may find yourself in for a shock,
    due to Python's aversion
    to boundless recursion
    or the global interpreter lock.

    The immutable types, such as int,
    can be subclassed, but follow this hint:
    you must override __new__
    'cause __init__ does not do -
    if you try it you'll find that it didn't.

    Now that functional style is passe,
    filter, map and reduce go away.
    Better use comprehensions
    to convey your intentions
    (or itertools.chain is OK).

    If today's Python code doesn't suit ya,
    don't despair or attack your computer.
    If the time machine's on,
    then your problem's soon gone:
    just import what you need from the __future__.

    When you harbour a yen to invent,
    then a PEP should ideally be sent.
    But know this in advance
    your idea has no chance
    should the BDFL not consent

    If you find this account is amiss,
    please avoid the temptation to hiss.
    Simply offer a patch,
    to apply with dispatch
    and if you seek Zen, import this!


    Michael

  • George Sakkis

    #2
    Re: An Abridged Python Tutorial

    "Michael Spencer" <mahs@telcopart ners.com> wrote in message
    news:mailman.82 6.1111682380.17 99.python-list@python.org ...[color=blue]
    > An Abridged Python Tutorial
    >
    > There are tips for the novice and tricks
    > that will add to your programming kicks.
    > But the cardinal rule
    > that you must learn at school
    > is that spaces and tabs never mix.
    >
    > If there's syntax you don't understand,
    > assistance is always at hand:
    > a glance at the cookbook,
    > or even a quick look
    > at the manual should meet the demand.
    >
    > If you code without reading this doc,
    > you may find yourself in for a shock,
    > due to Python's aversion
    > to boundless recursion
    > or the global interpreter lock.
    >
    > The immutable types, such as int,
    > can be subclassed, but follow this hint:
    > you must override __new__
    > 'cause __init__ does not do -
    > if you try it you'll find that it didn't.
    >
    > Now that functional style is passe,
    > filter, map and reduce go away.
    > Better use comprehensions
    > to convey your intentions
    > (or itertools.chain is OK).
    >
    > If today's Python code doesn't suit ya,
    > don't despair or attack your computer.
    > If the time machine's on,
    > then your problem's soon gone:
    > just import what you need from the __future__.
    >
    > When you harbour a yen to invent,
    > then a PEP should ideally be sent.
    > But know this in advance
    > your idea has no chance
    > should the BDFL not consent
    >
    > If you find this account is amiss,
    > please avoid the temptation to hiss.
    > Simply offer a patch,
    > to apply with dispatch
    > and if you seek Zen, import this!
    >
    >
    > Michael[/color]


    Outstanding ! Great piece Michael :-)

    George


    Comment

    • Paul McGuire

      #3
      Re: An Abridged Python Tutorial

      This will be tough to beat! (and not a single rhyme of "brace" and
      "space"!)

      -- Paul

      Comment

      • Bengt Richter

        #4
        Re: An Abridged Python Tutorial

        On Thu, 24 Mar 2005 08:37:29 -0800, Michael Spencer <mahs@telcopart ners.com> wrote:
        [color=blue]
        >An Abridged Python Tutorial
        >[/color]
        very nice !

        Regards,
        Bengt Richter

        Comment

        • bruno modulix

          #5
          Re: An Abridged Python Tutorial

          Michael Spencer wrote:[color=blue]
          > An Abridged Python Tutorial
          >[/color]
          (snip fine piece of art)[color=blue]
          >
          >[/color]
          <applaude>

          --
          bruno desthuilliers
          python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
          p in 'onurb@xiludom. gro'.split('@')])"

          Comment

          Working...