On Monday, 6 October 2014 21:07:24 UTC+11, roro codeath  wrote:
> in ruby:
> 
> 
> module M
> def ins_var
> @ins_var ||= nil
> end
> 
> 
> def m
> @ins_var = 'val'
> end
> 
> 
> def m2
> m
> ins_var # => 'val'
> end
> end
> 
> 
> in py:
> 
> 
> # m.py
> 
> 
> # how to def ins_var
> 
> 
> def m:
>     # how to set ins_var
> 
> 
> def m2:
>     m()
>     # how to get ins var

I took || to be a ternary. So I assumed your code just sets ins_var to nil and 
then  is called in module m and supplied a val. Could be wrong.

if ins_var is None:
    ins_var = 'val'
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to