forcing a definition to be called on attribute change

Rob Williscroft rtw at freenet.co.uk
Tue Oct 24 17:24:32 CEST 2006


Bruno Desthuilliers wrote in news:453dec91$0$23269$426a34cc at news.free.fr in 
comp.lang.python:

>> class cSphere() :
> 
> OT : prefixing classes names with 'c' is totally unpythonic.

My understanding of "pythonic" is that its about how you use the 
language not what style you code in.

Here's a variation of the usual example of pythonic:

use:

  for i in some_list:
    pass

not:

  i = 0
  while i < len( some_list ):
    i += 1

IOW, pythonic code is code that uses the features of the language
for the purpose they are intended, not code that ignores python's
features and tries to adapt features or idiom's from other languages.

I guess we could claim that one-liners are unpythonic (because 
indentation is a language feature), but claiming a all PEP 8 
violating styles are unpyhonic seems to me to be devaluing the 
term.

Rob.
-- 
http://www.victim-prime.dsl.pipex.com/



More information about the Python-list mailing list