Does Python really follow its philosophy of "Readability counts"?

Brian Allen Vanderburg II BrianVanderburg2 at aim.com
Wed Jan 14 17:13:31 EST 2009


rt8396 at gmail.com wrote:
> Here is a piece of C code this same guy showed me saying Pythonic
> indention would make this hard to read -- Well lets see then!
>
> I swear, before god, this is the exact code he showed me. If you don't
> believe me i will post a link to the thread.
>
> //  Warning ugly C code ahead!
> if( is_opt_data() < sizeof( long double ) ) { // test for insufficient
> data
>     return TRUE; // indicate buffer empty
>   } // end test for insufficient data
>   if( is_circ() ) { // test for circular buffer
>     if( i < o ) { // test for data area divided
>       if( ( l - o ) > sizeof( long double ) ) { // test for data
> contiguous
>         *t = ( ( long double * ) f )[ o ]; // return data
>         o += sizeof( long double ); // adjust out
>         if( o >= l ) { // test for out wrap around
>           o = 0; // wrap out around limit
>         } // end test for out wrap around
>       } else { // data not contiguous in buffer
>         return load( ( char * ) t, sizeof( long double ) ); // return
> data
>       } // end test for data contiguous
>     } else { // data are not divided
>       *t = ( ( float * ) f )[ o ]; // return data
>       o += sizeof( long double ); // adjust out
>       if( o >= l ) { // test for out reached limit
>         o = 0; // wrap out around
>       } // end test for out reached limit
>     } // end test for data area divided
>   } else { // block buffer
>     *t = ( ( long double * ) f )[ o ]; // return data
>     o += sizeof( long double ); // adjust data pointer
>   } // end test for circular buffer
>
>   
I do a bit of C and C++ programming and even I think that is ugly and 
unreadable.  First of all there are 'way' to many comments.  Why does he 
comment every single line.  Second of all I've always found that 
brace/indent style to lead toward harder-to-read code IMHO.  I think the 
Allman style is the most readable followed by perhaps Whitesmiths style.

Brian Vanderburg II



More information about the Python-list mailing list