re.search when used within an if/else fails

Ian Kelly ian.g.kelly at gmail.com
Wed Nov 28 14:57:08 EST 2012


On Wed, Nov 28, 2012 at 12:39 PM, Kevin T <kevinintx at gmail.com> wrote:
> with other languages i always expand tabs to spaces.  the vi plugin does
do this properly.  if i change all indents to be spaces only will python
behave?  i inherited a good deal of the code that i am using, which is tab
based.

Yes, it's best to use either tabs-only or spaces-only.  Quoting from PEP 8
on the subject:

Never mix tabs and spaces.
>
> The most popular way of indenting Python is with spaces only. The
> second-most popular way is with tabs only. Code indented with a mixture of
> tabs and spaces should be converted to using spaces exclusively. When
> invoking the Python command line interpreter with the -t option, it issues
> warnings about code that illegally mixes tabs and spaces. When using -tt
> these warnings become errors. These options are highly recommended!
>
> For new projects, spaces-only are strongly recommended over tabs. Most
> editors have features that make this easy to do.
>

I thought the prohibition against mixing tabs and spaces was made more
strict in Python 3, but I can't find any reference to that now.  Probably I
was mistaken.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20121128/07e619c5/attachment.html>


More information about the Python-list mailing list