Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #98925

Which type should be used when testing static structure appartenance

From Nicolas Évrard <nicoe@altern.org>
Newsgroups comp.lang.python
Subject Which type should be used when testing static structure appartenance
Date 2015-11-17 11:27 -0300
Message-ID <mailman.388.1447770859.16136.python-list@python.org> (permalink)

Show all headers | View raw


Hello,

I saw the following retweet by Raymond Hettinger in this morning:

    https://twitter.com/sanityinc/status/666485814214287360

    Programming tip: many of those arrays and hashes in your code
    should actually be sets. Match data structures to data
    constraints!

I saw just in time because in a review I wrote something like this:

    if operator not in ('where', 'not where')

and my colleague proposed that I should use a list instead of a tuple.
But reading the mentioned tweet I tend to think that a set would be a
better choice.

What are your opinion on this issue (I realize it's not something of
the utmost importance but rather a "philosophical" question).

-- 
Nicolas Évrard - B2CK SPRL
E-mail/Jabber: nicolas.evrard@b2ck.com
Tel: +32 472 54 46 59
Website: http://www.b2ck.com/

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Which type should be used when testing static structure appartenance Nicolas Évrard <nicoe@altern.org> - 2015-11-17 11:27 -0300
  Re: Which type should be used when testing static structure appartenance Steven D'Aprano <steve@pearwood.info> - 2015-11-18 22:37 +1100
    Re: Which type should be used when testing static structure appartenance Chris Angelico <rosuav@gmail.com> - 2015-11-18 23:40 +1100
      Re: Which type should be used when testing static structure appartenance Steven D'Aprano <steve@pearwood.info> - 2015-11-19 00:30 +1100
        Re: Which type should be used when testing static structure appartenance Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2015-11-18 13:32 +0000
        Re: Which type should be used when testing static structure appartenance Chris Angelico <rosuav@gmail.com> - 2015-11-19 00:42 +1100

csiph-web