Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #78797
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2014-10-07 05:29 -0700 |
| References | <mailman.14632.1412590002.18130.python-list@python.org> |
| Message-ID | <b22416b5-e3ed-4ece-aeba-65603fff1b3f@googlegroups.com> (permalink) |
| Subject | Re: ruby instance variable in python |
| From | flebber <flebber.crue@gmail.com> |
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'
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
ruby instance variable in python roro codeath <rorocodeath@gmail.com> - 2014-10-06 18:06 +0800
Re: ruby instance variable in python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-10-07 05:54 +1100
Re: ruby instance variable in python flebber <flebber.crue@gmail.com> - 2014-10-07 05:29 -0700
Re: ruby instance variable in python Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2014-10-07 15:46 +0300
Re: ruby instance variable in python flebber <flebber.crue@gmail.com> - 2014-10-07 17:59 -0700
Re: ruby instance variable in python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-10-08 12:32 +1100
Re: ruby instance variable in python flebber <flebber.crue@gmail.com> - 2014-10-08 03:12 -0700
csiph-web