re.search when used within an if/else fails

Duncan Booth duncan.booth at invalid.invalid
Thu Nov 29 10:34:14 CET 2012


Dennis Lee Bieber <wlfraed at ix.netcom.com> wrote:

>      Unless there has been a major change in the parser... (I still don't
> have Python 3.x installed)
> 
>      I believe <tab> is expanded to 8-spaces -- NOT TO NEXT MULTIPLE OF
> 8...
> 

Certainly in Python 2.7 that's not the case: the tab expands to the next 
multiple of 8 spaces.

>>> if 1:
...     print "yes" # space + tab
...         print "no" # eight spaces
...
yes
no

If tab expanded to exactly 8 spaces the leading space would have forced an 
indentation error, but it didn't.

-- 
Duncan Booth http://kupuguy.blogspot.com



More information about the Python-list mailing list