Is PEP-8 a Code or More of a Guideline?

Hendrik van Rooyen mail at microcorp.co.za
Fri Jun 1 10:14:08 CEST 2007


 "Tim Roberts" <timr at probo.com> wrote:
> Carl Banks <pavlovevidence at gmail.com> wrote:
> >
> >Identifiers should just allow spaces.
> >
> >first element.get item(selected value)
> >
> >This is not a joke.  I don't mean Python should necessarily do this
> >(though it could be done without any ambiguity or backward
> >incompatibility: there is currently nowhere in Python where two
> >identifiers can be separated by only a space), but new languages
> >should be designed to allow it.
>
> That's an interesting idea.  It would, perhaps, allow you to write programs
> that read more like prose.
>
> However, it would certainly make the parser more complicated, because it
> could no longer be context-insensitive.  For example, if I had identifiers
> called "mine" and "not mine", how would it parse this:
>
>     if not mine:

The rules would have to change - currently you cannot use a reserved
word (or keyword) as an identifier.  It would have to be legislated that
you cannot use a keyword as part of a space linked identifier - this should
not be a train smash to implement, and if it makes it easier for people with
disabilities, its probably not too much to ask.

Hey, it could lead to self documenting code such as:

That which will be returned = []
for The current element from the iterator in My iterable thingy:
    My temporary variable called x = The current element from the iterator
    if My temporary variable called x == None:
        break
    else:
        Temporary variable  = Complicated function(My temporary variable called
x)
        That which will be returned.append(Temporary variable)

and so forth - kind of verbose, but clear...

Note that I have also just invented a rule - I shall call it
The German Noun Copycat Readability Style and Parser
Simplification Capitalisation Rule for short.  It reads:

Space linked identifiers must start with a capital letter.

- Hendrik






More information about the Python-list mailing list