[Tutor] For - if - else loop; print selective output

eryksun eryksun at gmail.com
Wed Oct 24 19:49:44 CEST 2012


On Wed, Oct 24, 2012 at 1:30 PM, Joel Goldstick
<joel.goldstick at gmail.com> wrote:
>
>>>      if (i[1] == '25' or i[1] == '26'):
>
> like this
>          if i[1] in ('25', '26'):

Using "in ['25', '26']" also checks a compiled tuple constant:

    >>> compile("x in ['25', '26']", '', 'eval').co_consts
    ('25', '26', ('25', '26'))

3.x adds frozenset support:

    >>> compile("x in {'25', '26'}", '', 'eval').co_consts
    ('25', '26', frozenset({'25', '26'}))


More information about the Tutor mailing list