python-dev summary 2001-02-01 - 2001-02-15

Cliff Crawford cjc26 at nospam.cornell.edu
Mon Feb 19 13:12:44 EST 2001


* Marcin 'Qrczak' Kowalczyk <qrczak at knm.org.pl> menulis:
| 
| What about introducing a "black hole" or "wildcard pattern" for
| assignments?
|     e0, e1, _, _ = some_4_tuple
|     for k:_ in mapping:
|     for _:v in mapping:
| If there is code using _ as a variable name, maybe some different name.
| But it's _ in some other languages (ML, Haskell, Prolog, Clean).

You can already do stuff like

    e0, e1, _, _ = (10, 20, 40, 30)
    print e0  => 10
    print e1  => 20
    print _   => 30

You can use whatever variable name you want for the dummy variable.

As for dict iteration, I don't like the idea of inventing new syntax for
it; I would prefer having dict.items() return a lazy list, or maybe add
a xitems() method to return a lazy list.  (Actually, if there were some
way to signal to a method that it's being called in an iteration
context, then we wouldn't need all these x-methods...)


-- 
Cliff Crawford                 http://www.people.cornell.edu/pages/cjc26/
"huh?  Are you all there?  You missing some key parts up there?  Becoming  
a English major or an minor?   Do you need a annual report?  Are you slow
today, eh?  Did someone sever you parietal lobe?" - Mark



More information about the Python-list mailing list