Cookbook for beginners?
Bruno Desthuilliers
bdesth.quelquechose at free.quelquepart.fr
Sun Mar 26 16:46:22 EST 2006
Aahz a écrit :
> If you were going to name three or five essential recipes from the
> Python Cookbook suitable for beginners, what would you pick?
>
> Yes, this is for _Python for Dummies_, so idioms that aren't in the
> Cookbook are also fine.
1/ tuple- and dict-based dispatch, ie:
x = (result_if_false, result_if_true)[boolexpr]
y = {key1: result1, key2:result2, ...}[keyexpr]
2/ functions (and methods etc) as first-class objects (two main obvious
uses : callbacks and decorators)
+ (bonus) the combination of 1/ and 2/ !-)
3/ name-based lookups and affectations (getattr() / setattr()) and their
implementation ( __getattr__ / __setattr__)
More information about the Python-list
mailing list