new python syntax: concatenation of functions

F. Petitjean littlejohn.75 at news.noos.fr
Thu Mar 11 17:36:44 EST 2004


On 11 Mar 2004 10:24:14 -0800, Bob Lancaster <boblancaster at zxmail.com> wrote:
> Uwe Mayer <merkosh at hadiko.de> wrote in message news:<c2pj49$ej3$1 at news.rz.uni-karlsruhe.de>...
>> 
> 
> (4) For my personal style, I don't like to use constructs that are too
> esoteric.  I tend to avoid the tertiary operator in C++, and I tend
> not to get fancy with the 'and' and 'or' operators in Python.  It
> makes code more readable and maintainable, IMO.  Any programmer who
> writes code without any thought to code maintainance is doing the
> employer or client a disservice.
> 
Like this ?
(extract from a direct translation of C code into python
Nore also this snippet is nested into three while conditions of a method)
                  while charNo < self._cols:
                        charNo += 1
                        ch = self._ifs.read(1)
                        cond = ((ch != '\n') and not(ch==FF and
self._doFFs) and (ch != ''))
                        if not cond:
                            break

                        if ord(ch) >= 32 and ord(ch) <= 127:
                            if ch == '(' or ch == ')' or ch == '\\':
                                ws("\\")
                            ws(ch)
    
How to understand the deep nested, mostly negative parts of condition
cond ? and the test is   if not cond:  which will be equivalent to ...
So, hmmm,.. I need some sleep...

Regards

-- 
Ce qui se conçoit bien s'énonce clairement,
Et les mots pour le dire viennent aisément.
      Boileau Despréaux  (l'Art Poétique)



More information about the Python-list mailing list