[Python-ideas] stealing "var" from javascript

Arne Babenhauserheide arne_bab at web.de
Mon Apr 14 21:59:10 CEST 2008


El Monday, 14 de April de 2008 02:04:32 Jim Jewett escribió:
> "var" by itself won't shove much off the screen.  But changing from:
>
> """
> def fn(a=4):
>     x=5
>     ...
> """
> to:
> """
> def fn(a=4):
>
>     var x
>     var y
>     var z
>
>     x=5
>     ...
> """

This looks kinda bloated to me. 

If I just want to do

def f(b=2): 
  # First assign x  
  x=2*b

  # Now define function we'll use again later
  def fn(a=4): 
      x=5
      return a+x

  # and use x again. 
  y = fn(x)

Your idea would needlessly fill up lines here, because I'd have to declare x 
as local in the inner function (as I understand it). 

"When any function is defined, it's variables are local" is a nice and simple 
rule for me. 

(I'm sure there are some cases I miss, though... )

Best wishes, 
Arne
-- 
Unpolitisch sein
Heißt politisch sein
Ohne es zu merken. 
- Arne Babenhauserheide ( http://draketo.de )
-- Weblog: http://blog.draketo.de

-- Mein öffentlicher Schlüssel (PGP/GnuPG): 
http://draketo.de/inhalt/ich/pubkey.txt
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20080414/d32c241c/attachment.pgp>


More information about the Python-ideas mailing list