assigning in nested functions

2005-10-09 Thread jena
Hi
I have code

# BEGIN CODE
def test():
  def x():
print a
a=2 # ***
 
  a=1
  x()
  print a

test()
# END CODE

This code fails (on statement print a in def x), if I omit line marked 
***, it works (it prints 1\n1\n). It look like when I assign variable in 
nested function, I cannot access variable in container function.
I need to assign variable in container function, is any way to do this?

Thanks a lot for your help
Jena
-- 
http://mail.python.org/mailman/listinfo/python-list


list of lambda

2005-11-11 Thread jena
hello,
when i create list of lambdas:
l=[lambda:x.upper() for x in ['a','b','c']]
then l[0]() returns 'C', i think, it should be 'A'

my workaround is to define helper class with __call__ method:
class X:
def __init__(self,s): self.s=s
def __call__(self): return self.s.upper()
l=[X(x) for x in ['a','b','c']]

now it is correct, l[0]()=='A'

it is OK or it is bug?
can i do it correctly simplier than with helper X class?

thanks
Honza Prochazka
-- 
http://mail.python.org/mailman/listinfo/python-list


any body know how to use winlike

2008-11-25 Thread Anuradha Jena
Hi,
  Any body know how to use winlike.If yes.Can s/he give a simple example
of onEvent & onClose functionally.  Actually i am facing problem where.
  I have one page there if u click on a text Winlike window will
open.After opening i want to print text value,it is not printing.i am
calling by parent.document.forms['formname'].getElementById("Id").
  parent.document.forms is giving an object but
parent.document.forms['formname'] is giving undefined.I already tired all
the possibility like opener/parent.window .So can anybody give any solution?

Thanks
Anuradha

-- 
|| Anuradha ||
--
http://mail.python.org/mailman/listinfo/python-list