
Dear Pythonistas, It's my first post in the list, so let me introduce myself. My name is Jan Kaliszewski, I am a composer (studied in Frederic Chopin Academy of Music in Warsaw) and a programmer (currently working in Record System company on Anakonda -- ERP system being programmed in Python). Comming to the matter... 13-07-2009 Chris Perkins <chrisperkins99@gmail.com>:
In other words, I think code that puts things in the opposite order from the way you think of them is harder to read.
Another example: if I'm thinking that what I want to do is "substitute some stuff in a string", then I want to start by typing/reading "re.sub(...)", and not "def some_made_up_name(...):"
re.sub(pat, &, s) do(m): # several lines of code
vs.
def temp(m): # several lines of code re.sub(pat, temp, s)
The latter relegates the key line of code to the very last line, making it harder to see at a glance what it does.
So yes, the point of this really is just to allow you to write code "in the right order".
I like the idea of '&' (or another character/word in that role) -- but maybe it'd be enough to extend an existing feature: decorators with it, and to add possibility to use that special character/word as a function name after 'def'? E.g.: ################### # Networking dfr = twisted.whatever(...) # @dfr.addCallback(&) could be equivalent @dfr.addCallback def &(result): handle(result) @dfr.addErrback def &(err): handle_err(err) ################### # GUI (for some hypothetical library) @my_widget.add_button('Go').on('click', &) def &(evt): if evt.ctrl_key: do_something() else: do_other_stuff() # or, if we want to keep the result: @my_widget.add_button('Go').on('click', &) def button_clicked(evt): if evt.ctrl_key: do_something() else: do_other_stuff() ################### # Threads @thread.start_new: def &(): do_some_work() Best regards, Jan Kaliszewski