Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #60198

Re: using getattr/setattr for local variables in a member function

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!feeder.erje.net!eu.feeder.erje.net!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From Gregory Ewing <greg.ewing@canterbury.ac.nz>
Newsgroups comp.lang.python
Subject Re: using getattr/setattr for local variables in a member function
Date Fri, 22 Nov 2013 17:07:49 +1300
Lines 18
Message-ID <bf83knFu0s8U1@mid.individual.net> (permalink)
References <l6m40a$9vd$1@news.jpl.nasa.gov>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Trace individual.net 6BY9owKmWICxNimCPoWHuwa5x0aNtC3kGV1SUBy6zTkU1d3hvy
Cancel-Lock sha1:CRHrOVeUx1lwfVrhTx9y7HeTi8M=
User-Agent Mozilla Thunderbird 1.0.5 (Macintosh/20050711)
X-Accept-Language en-us, en
In-Reply-To <l6m40a$9vd$1@news.jpl.nasa.gov>
Xref csiph.com comp.lang.python:60198

Show key headers only | View raw


Catherine M Moroney wrote:
> is there
> some way to use getattr/setattr to access the local variables specific 
> to a given function?

No, because those variables don't even exist when there
isn't a call to the function in progress.

Your example suggests that, instead of local variables,
you really want them to be attributes of your object
somehow. The best way to go about that will depend on
how you want to use them.

If you explain more about the problem you're trying
to solve, we may be able to suggest a solution.

-- 
Greg

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

using getattr/setattr for local variables in a member function Catherine M Moroney <Catherine.M.Moroney@jpl.nasa.gov> - 2013-11-21 15:12 -0800
  Re: using getattr/setattr for local variables in a member function MRAB <python@mrabarnett.plus.com> - 2013-11-22 00:52 +0000
  Re: using getattr/setattr for local variables in a member function Ned Batchelder <ned@nedbatchelder.com> - 2013-11-21 17:58 -0800
  Re: using getattr/setattr for local variables in a member function Dave Angel <davea@davea.name> - 2013-11-21 21:02 -0500
  Re: using getattr/setattr for local variables in a member function Ethan Furman <ethan@stoneleaf.us> - 2013-11-21 19:18 -0800
  Re: using getattr/setattr for local variables in a member function Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2013-11-22 17:07 +1300

csiph-web