Re: Parsing Indented Text (like parsing Python)

2007-03-13 Thread alisonken1
On Mar 11, 2:34 am, "Mike Schinkel" <[EMAIL PROTECTED]> wrote: > Hi, > > I'm relatively new to Python but have lots of prior programming experience > as a developer, instructor, and author (ASP/VBScript/SQL Server and > Clipper.) > > -- > -Mike > Schinkelhttp://www.mikeschinkel.com/blogs/http:/

Re: Parsing Indented Text (like parsing Python)

2007-03-11 Thread Gabriel Genellina
En Sun, 11 Mar 2007 13:12:20 -0300, Paul McGuire <[EMAIL PROTECTED]> escribió: > On Mar 11, 8:37 am, "Gabriel Genellina" <[EMAIL PROTECTED]> > wrote: >> If you mix tabs+spaces, Python simple replaces each tab by 8 spaces. > As I recall, the number of spaces to replace a tab by is something > l

Re: Parsing Indented Text (like parsing Python)

2007-03-11 Thread John Nagle
Mike Schinkel wrote: > Gabriel Genellina wrote: >>That's why all people always say >>"never mix tabs and spaces" That's the one rule in this area Python ought to enforce. If you've got that, you can convert tabs to spaces, or vice versa, safely. John Nagle --

Re: Parsing Indented Text (like parsing Python)

2007-03-11 Thread Paul McGuire
On Mar 11, 8:37 am, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > > If you mix tabs+spaces, Python simple replaces each tab by 8 spaces. > Are you sure about this? This is not the tab problem I am familiar with in the past. In the following sample, the columnar text labeled 'col2' should al

RE: Parsing Indented Text (like parsing Python)

2007-03-11 Thread Mike Schinkel
Gabriel Genellina wrote: > > The problem is, how do I figure out how > > many spaces represent a tab? > > You can't, unless you have more context. How does Python do it? > > one case, someone could have their editor configured to > > allow tabs to use 3 spaces and the user could > > intermingl

Re: Parsing Indented Text (like parsing Python)

2007-03-11 Thread Gabriel Genellina
En Sun, 11 Mar 2007 10:09:57 -0300, Mike Schinkel <[EMAIL PROTECTED]> escribió: > The problem is, how do I figure out how many spaces represent a tab? In You can't, unless you have more context. > one > case, someone could have their editor configured to allow tabs to use 3 > spaces and the us

Re: Parsing Indented Text (like parsing Python)

2007-03-11 Thread Stef Mientki
> > The problem is, how do I figure out how many spaces represent a tab? In one > case, someone could have their editor configured to allow tabs to use 3 > spaces and the user could intermingle tabs and spaces. In other cases, a > user might have their editor configured to have a tab equal 8 space

RE: Parsing Indented Text (like parsing Python)

2007-03-11 Thread Mike Schinkel
Gabriel Genellina wrote: > Start with IC = Previous IC = 0, and a stack with a single 0 > element For each line in the file: >compute the indentation column IC (that is, count the > number of leading whitespace characters; perhaps replacing > tabs as 8 spaces) >compare IC with the Previo

Re: Parsing Indented Text (like parsing Python)

2007-03-11 Thread Gabriel Genellina
En Sun, 11 Mar 2007 06:34:03 -0300, Mike Schinkel <[EMAIL PROTECTED]> escribió: > I'm trying to write an app that parses a text file containing an outline > useing essentially the same indentation rules as Python source code, i.e. > the first level has no indent, the second level has one indent,