Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #60195
| Date | 2013-11-21 19:18 -0800 |
|---|---|
| From | Ethan Furman <ethan@stoneleaf.us> |
| Subject | Re: using getattr/setattr for local variables in a member function |
| References | <l6m40a$9vd$1@news.jpl.nasa.gov> <528EAAC5.7070402@mrabarnett.plus.com> <almarsoft.1584750865369778100@news.gmane.org> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3024.1385092281.18130.python-list@python.org> (permalink) |
On 11/21/2013 06:02 PM, Dave Angel wrote: > Catherine Moroney wrote: >> >> If I have a class that has some member functions, and all the >> functions define a local variable of the same name (but >> different type), is there some way to use getattr/setattr to >> access the local variables specific to a given function? > > If you mean to access them from within the same method, someone > else has already shown it using locals(). But you cannot access > locals from a method that's already terminated. They no longer exist. Also, accessing is fine, but not all pythons support changing them. -- ~Ethan~
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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