Some language proposals.

Anton Vredegoor anton at vredegoor.doge.nl
Tue Feb 24 18:06:49 CET 2004


Antoon Pardon <apardon at forel.vub.ac.be> wrote:

>I'm rather new at this, so I don't know how I should
>introduce this, nor whether these ideas are worth much
>but here goes.

I'm rather new at criticizing new language proposals so forgive me for
not fighting new ideas ferociously enough :-) But seriously, I think
it's better to keep an eye open to new proposals. Even if things have
been discussed before, the fact that the same ideas come up again and
again should mean something in itself. Also a lot of proposals come in
the company of new ideas that have not yet been evaluated.

>Now my idea would be to look at the local variables in
>a function like member variables of an object so that
>you could write
>
>
>def fun_1():
>
>  a = some_value
>  b = a_value_too
>
>  def fun_2():
>
>    fun_1.a = new_value
>    fun_1.b = next_value
>
>
>This could maybe even extended further is seeing functions
>like some kind of module which would allow something like
>the following
>
>
>def fun_1():
>
>  a = some_value
>  b = a_value_too
>      
>  def fun_2():
>
>    from fun_1 import a, b
>
>    a = new_value
>    b = next_value
>
>
>What do people think about this?
>As far as I know the proposal doesn't break existing
>code and seems in the spirit of python.

I don't see much merit in this, since functions are designed to go out
of scope once they are executed. Having sub-scopes change names higher
up is considered a no-no in Python, although new developments like
"properties" are already nibbling little chunks away from this
concept.

However, in the case of *generator functions* this situation changes
dramatically, so you might score some points there. The road to take
would be something along the lines of "practicality beats purity".

>On a side note, what would people think about the idea of
>a from ... import ... statement usable on any object? So
>that we could do:
>
>class A:
>  pass
>
>A.a = ...
>A.b = ...
>
>from A import a, b
>
># from here a and be refer to A.a and A.b

This raises the question of why not to use a class to begin with even
for your earlier proposals. Anyway, this can be accomplished easily
with:

  a,b = A.a,A.b

If you still want to go through with this, have a look at this link:

http://us.st5.yimg.com/store4.yimg.com/I/demotivators_1780_2263455

Anton






More information about the Python-list mailing list