Loading ...
Sorry, an error occurred while loading the content.

60Re: [python-iter] Colon syntax: We barely knew thee...

Expand Messages
  • Clark C. Evans
    Mar 2, 2001
    • 0 Attachment
      Hello. I am very new to python and find this discussion
      interesting as "iterators and generic functions" were the
      first thing that I marked as notably absent. I'd like to
      comment, but I don't really have much of a context so if
      I blunder badly, please forgive me.

      On Sat, 3 Mar 2001 n8spam@... wrote:
      > for thing in dict:
      > for key: in dict:
      > for :item in list:
      > If we're giving up on key:value, what's the proposed
      > alternative? Why is it better?

      This syntax has potential. What if the colon could be
      used for filtering operations as well? For instance,
      in these examples, let _ be a wild card.

      for key:_ in dict: # loops through each key
      for _:value in dict: # loops through each value
      for key:value in dict: # loops thorugh each key and value

      for key:'value' in dict: # loops through keys having value = 'value'

      I don't particularly like ":x" or "x:" since the former
      reminds me of SQL binding variables, and the latter
      reminds me of a subordate clause. However, "_:x" and "x:_"
      make perfect sense to me.

      There is a likely problem: _ is a valid identifier, right?
      Well, could "*:value" and "key:*" be used instead then?

      Sorry if this is _way_ out in left field...

      Kind Regards,

    • Show all 27 messages in this topic