Re: pythonic way

Discussion in 'Python' started by jack, Nov 2, 2012.

  1. jack

    jack Guest

    Sometimes, I need to alter the element as traverse a list like this
    (it's a sample):
    c = range(10)
    i = 0
    for ele in c:
    # do something
    # branch:
    c = # value
    i += 1

    How to be pythonic?

    2012/11/2 0:54, Zero Piraeus :
    > :
    >
    > On 1 November 2012 11:32, inshu chauhan <> wrote:
    >> what is the most pythonic way to do this :
    >>
    >> if 0 < ix < 10 and 0 < iy < 10 ???

    > As everyone else has said, it's perfectly pythonic once you stick the
    > colon on the end. You might find it more instantly readable with some
    > extra parentheses:
    >
    > if (0 < ix < 10) and (0 < iy < 10):
    > # do something
    >
    > ... but that's really just down to taste.
    >
    > -[]z.
    jack, Nov 2, 2012
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Doug Rosser

    What's the Pythonic way to do this?

    Doug Rosser, Sep 10, 2004, in forum: Python
    Replies:
    4
    Views:
    320
    Phillip J. Eby
    Sep 12, 2004
  2. Charles Krug
    Replies:
    11
    Views:
    548
    Bengt Richter
    Apr 27, 2005
  3. Thomas Lotze

    Controlling a generator the pythonic way

    Thomas Lotze, Jun 11, 2005, in forum: Python
    Replies:
    12
    Views:
    440
    Thomas Lotze
    Jun 14, 2005
  4. Sean Berry
    Replies:
    6
    Views:
    318
    George Sakkis
    Oct 10, 2005
  5. Carl J. Van Arsdall
    Replies:
    4
    Views:
    480
    Bruno Desthuilliers
    Feb 7, 2006
Loading...

Share This Page