Alternate indent proposal for python 3000

George Sakkis george.sakkis at gmail.com
Sun Apr 20 19:02:26 EDT 2008


On Apr 20, 6:54 pm, Dan Bishop <danb... at yahoo.com> wrote:
> On Apr 20, 11:42 am, Matthew Woodcraft
>
>
>
> <matth... at chiark.greenend.org.uk> wrote:
> > Christian Heimes  <li... at cheimes.de> wrote:
>
> > >> I feel that including some optional means to block code would be a big
> > >> step in getting wider adoption of the language in web development and
> > >> in general.  I do understand though, that the current strict indenting
> > >> is part of the core of the language, so... thoughts?
> > > Why should Python repeat the mistakes other languages did with SSI or
> > > <?php ?> inline code? Python favors the MVC separation of code and layout.
>
> > An alternative scheme for describing the block structure could be
> > useful in other cases, though. For example, if you wanted to support
> > putting snippets of Python in configuration files, or spreadsheet
> > cells.
>
> > There's no need to support the new scheme in .py files, so it seems to
> > me that this doesn't have to be done in the core language. All that's
> > needed is a variant of 'eval' which expects the alternate scheme, and
> > that could be prototyped just using text manipulation and the normal
> > 'eval'.
>
> We wouldn't even need that.  Just a new source encoding.  Then we
> could write:
>
> # -*- coding: end-block -*-
>
> def _itoa(num, base):
> """Return the string representation of a number in the given base."""
> if num == 0:
> return DIGITS[0]
> end if
> negative = num < 0
> if negative:
> num = -num
> end if
> digits = []
> while num:
> num, last_digit = divmod(num, base)
> digits.append(DIGITS[last_digit])
> end while
> if negative:
> digits.append('-')
> end if
> return ''.join(reversed(digits))
> end def

A great example of why something like this would never fly in standard
Python.



More information about the Python-list mailing list