Steven D'Aprano wrote: > Why? What benefit do you gain? > >> Define function objects as "function"s, let users put them where they >> want to. Get rid of lambda, get rid of def, only use = for assignments. > > So you remove two keywords. That's a plus. But then you have to create a > WHOLE lot more syntax to support it, and that's about a thousand minuses. > Python has very little syntax, and the designers are (rightly) very > resistant to adding more.
You answered your own question. There is less syntax. > > It's also not clear how you expect this to work with anything more > complex than a single expression. How do you handle statements and > multiple returns? > > def foo(x, y): > L = [] > try: > if x[y] % 2: > print x, y > return y > return x[y] > except: > return None Huh? This is trivial. I don't see why this is so hard to grasp. foo= function(x, y): L = [] try: if x[y] % 2: print x, y return y return x[y] except: return None >> >>> s[x] # Simpler, clearer, more productive > > It's certainly smaller. > > But the fatal objection to this is that it is a special case for a very > limited benefit: saving half a dozen characters. It sounds like you are describing slices here. It is interesting how python people don't like specific case syntax, unless it applies to their already existing specific cases. Lists and tuples represent any sequence that slices can. Why slices? > > But can't you see that the suggestion to use sequences as replacements > for slices is completely incompatible with your suggestion above? > > seq = range(10) > > Would you expect seq[[2,6]] to do an index lookup, as you suggested > originally, or a slice? In the first case, it would return [2, 6], but in > the second, it would return [2, 3, 4, 5]. > > If sequence indices are slices, what does an index of [1, 2, 3, 4] mean? It means whatever you decide it to mean. Make a definition and stick with it. -- http://mail.python.org/mailman/listinfo/python-list