There have been a couple of very interesting Python recipes added to the Python Cookbook recently.
I love Michele Simionato's Parsing the command line. Parsing the module's docstring for the command line options is a brilliant idea. It feels really pythonic; most other languages, for example, treat indentation as purely documentary, and require you to repeat your code block delimitation using delimitation characters and using indentation, whereas Python treats the indentation as definitive, and doesn't require you to repeat yourself - DRY! Similarly, this recipe treats the docstring's definition of the supported command line options as definitive, and doesn't require you to repeat yourself.
Raymond Hettinger's Bind Globals into Constants at compile time is a lovely example of the kind of thing that Python 2.4's method decorators are designed to support.
I have to say, I'm not that keen on the current decorator syntax; a list of decorators on the line preceding the function/method definition looks ugly to me. I'd prefer the decorators in the def statement somewhere, or inside the function somewhere, like the docstring. But what do I know; Guido's the world-class language designer, after all!
Regarding the def syntax, there's a PEP that covers what you're looking for:
http://mail.python.org/pipermail/python-dev/2004-February/042851.html
Aaron
Posted by: Aaron Brady on April 19, 2004 04:47 PMI know. But if Guido likes the "list of decorators on the line preceding the function/method definition" syntax, that's what we'll get.
I'm not worried. It looks wrong to me at the moment, but I find that I almost always end up coming around to Guido's way of seeing things in the end. He has an irritating habit of being right all the time. Well, *almost* all the time, anyway.
Posted by: Simon Brunning on April 19, 2004 04:58 PMI found "a list on the line before" to be very disconcerting at first. But the more I play with it, the better I like it. And the fact that it looks quite similar to what C# has is a convenient coincidence.
Posted by: Michael Chermside on April 19, 2004 05:28 PMwell, delimiters does not need to be useless.
If the language is expression oriented you may see code added in the end just logically, say, with statement modifiers:
def f
...
end if NEED_F_REDEFINED
Sorry, Gabriele, but I have *no* idea what that's all about. Conditioned ends? The mind boggles!
Posted by: Simon Brunning on April 20, 2004 10:45 AMWRT Michele Simionato's command-line Parsing recipe, I've seen the same trick used in shell scripts. You just put a nice header comment at the start, ending with "##", and add two lines that look somewhat like this:
me=$0
function usage { sed -n '2,/^##$/s/^# //p' $me ; exit 1; }
(This works in zsh, haven't tried other shells, but most of them could do similar stuff.)
simon: if you enter the 'everything is an expression' mood you'll understand that that code mean
'define method "f" if you need it'.
Actually, I have to agree, that was not a so good example.
And Actually I can't think of any ATM :)
Apart from allowing just the existence of eval() over eval()+exec() in languages that does not separate statements and expressions.
maybe this:
[1,2,3].map do |i|
i**2
end.reject do |i|
i%2 == 2
end
(yes I know that a list comprehension does this cleaner it's just an example of using delimiters to concatenate syntax)
I really believe a mixed significant-space/optional delimeters syntax would be the best thing, haskell does like this IIRC
Posted by: gabriele on April 21, 2004 04:17 PMThat's easy enough, Gabriele:
if some_condition:
def some_function(argument):
pass
Significant spaces *and* delimiters? Thanks, but no thanks. TOOWTDI.
Posted by: Simon Brunning on April 21, 2004 04:28 PMswingers megaupload - pakisthansex com pakisthansex - free video passionUK - lolitapussy - www oldfartsyoungtarts com password -
Posted by: balabo3_ym on May 19, 2009 10:14 PMswingers megaupload - pakisthansex com pakisthansex - free video passionUK - lolitapussy - www oldfartsyoungtarts com password -
Posted by: balabo3_ym on May 19, 2009 10:14 PMswingers megaupload - pakisthansex com pakisthansex - free video passionUK - lolitapussy - www oldfartsyoungtarts com password -
Posted by: balabo3_ym on May 19, 2009 10:14 PMmFkY98 comment3 ,
Posted by: Ardemnnq on June 29, 2009 12:27 AMGreat site. Good info.
Posted by: tramadol contraindications on July 2, 2009 08:23 PMPerfect work!
Posted by: new drug cialis on July 2, 2009 11:31 PM