[Python-3000] Stackable Blocks

Talin talin at acm.org
Mon Apr 24 04:17:09 CEST 2006


Crutcher Dunnavant <crutcher <at> gmail.com> writes:

> 
> On 4/23/06, Jay Parlar <jparlar <at> cogeco.ca> wrote:
> >
> > What's the use case for doing this with method and class defs?
> 
> They're blocks, what would be the use case for having the
> for/while/with/if stuff be treated different from class/def ? Besides,
> it comes up in platform handling code.
> 
> if sys.platform == 'foo': class Bar:
>   ...
> 
> class Foo:
>   if sys.platform == 'foo': def bar(self):
>     ...
> 
>   else: def bar(self):
>     ...

It seems to me that the end result of what you are trying to accomplish here is
to save a level of indentation.

I know that it might seem logical to say "Well, if the 'for' keyword in a list
comprehension has an 'if' clause, why shouldn't the regular 'for' keyword have
an 'if' clause? The answer is that it already does. But because they are
statements, rather than simply expressions, they need a little more 'elbow
room' instead of trying to cram everything on one line.

>From what I can see, the change that you propose doesn't allow you to do
anything you can't do already, it just saves a few characters of typing. From
what I have seen on these lists, proposals like that generally don't go over
well. (Although if you can figure out a way to save a *whole lot* of typing,
that might be a different story.)

-- Talin




More information about the Python-3000 mailing list