Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #34032
| Date | 2012-11-28 14:08 -0600 |
|---|---|
| From | Evan Driscoll <driscoll@cs.wisc.edu> |
| Subject | Re: Re: re.search when used within an if/else fails |
| References | (4 earlier) <mailman.82.1353440253.29569.python-list@python.org> <2930dc36-9d8f-411d-aa7a-272fe4885ec5@i5g2000yqh.googlegroups.com> <mailman.192.1353560449.29569.python-list@python.org> <11835b30-3448-45cc-9ae5-46d651f93429@googlegroups.com> <CALwzid=MW+c2F_Z_2=npC=Z41FJuFOXYMBJ0N-fGxycJE53t4A@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.346.1354133357.29569.python-list@python.org> (permalink) |
[Multipart message — attachments visible in raw view] - view raw
On 11/28/2012 01:57 PM, Ian Kelly wrote: > 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. I'm only entering this thread now so I'm not really in context, but you're correct; in Python 3, -tt is set by default, which makes illegal mixing an error. However, not all mixing is illegal: what it means by "code that illegally mixes tabs and spaces" is "code whose interpretation differs depending upon the interpretation of the tab width". While I'm not going to go test it, I think that if you, say, indent from the first to the second level with tabs (consistently), indent from the second to third level with spaces (consistently), and indent from the third to fourth level with tabs (consistently), it should not complain. Or perhaps I should say "it should complain that you're a bad person and should feel bad, but it won't." :-) (In fact, you could indent one block at the second level with tabs and another with spaces.) Evan
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
re.search when used within an if/else fails Kevin T <kevinintx@gmail.com> - 2012-11-19 15:43 -0800
Re: re.search when used within an if/else fails MRAB <python@mrabarnett.plus.com> - 2012-11-20 01:21 +0000
Re: re.search when used within an if/else fails Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-20 01:24 +0000
Re: re.search when used within an if/else fails Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-20 01:29 +0000
Re: re.search when used within an if/else fails Kevin T <kevinintx@gmail.com> - 2012-11-20 11:09 -0800
Re: re.search when used within an if/else fails Ian Kelly <ian.g.kelly@gmail.com> - 2012-11-20 12:37 -0700
Re: re.search when used within an if/else fails Kevin T <kevinintx@gmail.com> - 2012-11-21 08:41 -0800
Re: re.search when used within an if/else fails Chris Angelico <rosuav@gmail.com> - 2012-11-22 16:00 +1100
Re: re.search when used within an if/else fails Kevin T <kevinintx@gmail.com> - 2012-11-28 11:39 -0800
Re: Re: re.search when used within an if/else fails Evan Driscoll <driscoll@cs.wisc.edu> - 2012-11-28 14:08 -0600
Re: re.search when used within an if/else fails Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-28 21:39 +0000
Re: re.search when used within an if/else fails Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-11-28 19:20 -0500
Re: re.search when used within an if/else fails Duncan Booth <duncan.booth@invalid.invalid> - 2012-11-29 09:34 +0000
Re: re.search when used within an if/else fails Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-11-29 13:38 -0500
RE: re.search when used within an if/else fails "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-11-29 22:57 +0000
RE: re.search when used within an if/else fails "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-11-29 22:53 +0000
Re: re.search when used within an if/else fails Kevin T <kevinintx@gmail.com> - 2012-11-28 11:39 -0800
Re: re.search when used within an if/else fails Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-28 20:50 +0000
Re: re.search when used within an if/else fails Ian Kelly <ian.g.kelly@gmail.com> - 2012-11-20 12:39 -0700
csiph-web