From: aq <aquynh@gmail.com>
To: Christian.Limpach@cl.cam.ac.uk
Cc: Ian Pratt <m+Ian.Pratt@cl.cam.ac.uk>,
xen-devel <xen-devel@lists.xensource.com>
Subject: Re: [PATCH] replace tabs with spaces of Python code
Date: Thu, 19 May 2005 20:49:12 +0900 [thread overview]
Message-ID: <9cde8bff05051904496f35283c@mail.gmail.com> (raw)
In-Reply-To: <3d8eece205051902171282fa2e@mail.gmail.com>
On 5/19/05, Christian Limpach <christian.limpach@gmail.com> wrote:
> On 5/19/05, aq <aquynh@gmail.com> wrote:
> > > The script from python.org that Anthony posted seems to fit the bill.
> >
> > no, that script doesnt work very well, because:
> > 1. almost all the code indented by 4 spaces, but his script convert
> > tab to 8 spaces
> > 2. some code consider tab as 4 and 8 spaces in the same file, so it is
> > hard to use this script.
> > 3. that script doesnt see how python deal with the code. for example,
> > lines the python code is aligned with the previous line, but the
> > script doesnt take that into account. that is a problem.
> >
> > a small example: file tools/python/xen/xm/main.py has few tabs inside,
> > and here is how Anthony's script converts the code, and it does it
> > wrongly. i have 3 files to compare here, so you can make a conclusion:
> > the main.org.py (copy from original main.py), main-t2s.py (converted
> > with Anthony's script, with tabsize=4) and main-aq.py (my script,
> > coverted manually)
> >
> > now to see the problem, here is a hunk taken from the diffs. see the
> > commented i put next to the broken line:
>
> That's because you broke the script by changing tabsize to 4. As
> Anthony wrote, the python manual describes the algorithm used to
> expand tabs and how tabs get expanded has nothing to with how you have
> indented your program. Whether your indention levels are 4 character
> wide or 8 doesn't matter, a tab always means go to the next 8
> character column. The original main.py looks visually incorrect at
> the args.append line (it's indented by 8 characters instead of 4) but
> that's not a bug.
Yes, I agree. Actually Anthony's script (with tabsize=8) can be used
to convert all related Python files, and the result code would work
like before.But since all the code originally indented with 4 spaces,
then we should still readjust some code a little bit.
If you want to play safely, I would rather use that script to remove
tabs completely, than leave them as they are now (not buggy but
*evil*).
regards,
aq
next prev parent reply other threads:[~2005-05-19 11:49 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-05-19 1:28 [PATCH] replace tabs with spaces of Python code Ian Pratt
2005-05-19 2:40 ` aq
2005-05-19 9:17 ` Christian Limpach
2005-05-19 11:49 ` aq [this message]
2005-05-19 17:53 ` David Hopwood
-- strict thread matches above, loose matches on Subject: below --
2005-05-18 20:06 Ian Pratt
2005-05-18 20:21 ` Vincent Hanquez
2005-05-18 20:43 ` Anthony Liguori
2005-05-19 1:09 ` aq
2005-05-18 18:58 aq
2005-05-18 19:59 ` Jacob Gorm Hansen
2005-05-19 0:48 ` aq
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9cde8bff05051904496f35283c@mail.gmail.com \
--to=aquynh@gmail.com \
--cc=Christian.Limpach@cl.cam.ac.uk \
--cc=m+Ian.Pratt@cl.cam.ac.uk \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.