thank you guys.
On 11.12.2013 10:36, Chris Angelico wrote:
2013/12/11 Johannes Schneider :
can somebody explain me the difference between accessing attributes via
obj.attribute and getattr(obj, "attribute")?
Is there a special reason or advantage when using getattr?
You use getatt
On Wed, Dec 11, 2013 at 8:30 PM, Jurko Gospodnetić
wrote:
> Also, you can not test whether an object has an attribute when using the
> object.attribute access method without raising/catching an exception and
> then it can be hard to make sure no other code caused the exception.
It's pretty easy
2013/12/11 Johannes Schneider :
> can somebody explain me the difference between accessing attributes via
> obj.attribute and getattr(obj, "attribute")?
>
> Is there a special reason or advantage when using getattr?
You use getattr when the attribute name comes from a
Hi.
On 11.12.2013. 9:23, Johannes Schneider wrote:
can somebody explain me the difference between accessing attributes via
obj.attribute and getattr(obj, "attribute")?
Is there a special reason or advantage when using getattr?
You can not use obj.attribute if you have the word
Hi list,
can somebody explain me the difference between accessing attributes via
obj.attribute and getattr(obj, "attribute")?
Is there a special reason or advantage when using getattr?
bg,
Johannes
--
Johannes Schneider
Webentwicklung
johannes.schnei...@galileo-press.de
Tel.: +49.228
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,
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
On Fri, 22 Nov 2013 00:52:21 +, MRAB
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
>
On Thursday, November 21, 2013 6:12:10 PM UTC-5, Catherine M Moroney wrote:
> Hello,
>
> 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 a
On 21/11/2013 23:12, Catherine M Moroney wrote:
Hello,
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
Hello,
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?
Obviously there's no need to do this fo
ackageSocketBindError sure beats IOError when it comes to trying to
figure out what went wrong.
2) As much as possible, keep your try blocks short. In the original
example, we've got:
try:
functionstring = args[2]
callfunction = getattr(self, functionstring.split
On 10/02/2011 05:24 PM, Kevin Walzer wrote:
Turns out the error was a typo in the actual method being
called...*faceinhands*
Sorry for the noise.
But this is a great example of why you should not use a naked except
clause. As stated, your code will execute the except clause for *any*
kin
Turns out the error was a typo in the actual method being
called...*faceinhands*
Sorry for the noise.
--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
--
http://mail.python.org/mailman/listinfo/python-list
On Sun, 02 Oct 2011 18:02:05 -0400, Kevin Walzer wrote:
> I'm seeing a very odd error in an application I'm developing using
> Python 2.7.2, on Mac OS 10.7.
>
> This application uses a wrapper method to look up other method names via
> getattr and then call those metho
On 10/2/2011 6:02 PM, Kevin Walzer wrote:
I'm seeing a very odd error in an application I'm developing using
Python 2.7.2, on Mac OS 10.7.
This application uses a wrapper method to look up other method names via
getattr and then call those methods. I have not previously had an issue
On Sun, Oct 2, 2011 at 3:02 PM, Kevin Walzer wrote:
> I'm seeing a very odd error in an application I'm developing using Python
> 2.7.2, on Mac OS 10.7.
>
> This application uses a wrapper method to look up other method names via
> getattr and then call those methods. I h
I'm seeing a very odd error in an application I'm developing using
Python 2.7.2, on Mac OS 10.7.
This application uses a wrapper method to look up other method names via
getattr and then call those methods. I have not previously had an issue
with this name, but for some r
Please reply inline; top posting is harder to read.
On Fri, Mar 12, 2010 at 12:15 AM, Gabriel Genellina
wrote:
En Thu, 11 Mar 2010 01:47:30 -0300, Radhakrishna Bhat
escribió:
I am using getattr to get a method instance from a class. But it also
returns methods from the superclass. How to
Thu, 11 Mar 2010 01:47:30 -0300, Radhakrishna Bhat
> escribió:
>
>
> I am using getattr to get a method instance from a class. But it also
>> returns methods from the superclass. How to detect if an attribute is from
>> superclass?
>>
>
> You may look it up dir
En Thu, 11 Mar 2010 01:47:30 -0300, Radhakrishna Bhat
escribió:
I am using getattr to get a method instance from a class. But it also
returns methods from the superclass. How to detect if an attribute is
from
superclass?
You may look it up directly in the class dictionary (__dict__
oblem.
-Radhakrishna
On Thu, Mar 11, 2010 at 6:12 PM, Steve Holden wrote:
> Radhakrishna Bhat wrote:
> > I am using getattr to get a method instance from a class. But it also
> > returns methods from the superclass. How to detect if an attribute is
> > from superclass?
>
Radhakrishna Bhat wrote:
> I am using getattr to get a method instance from a class. But it also
> returns methods from the superclass. How to detect if an attribute is
> from superclass?
>
You could try, if x is in instance, looking to see whether the name is
defined in x.__clas
I am using getattr to get a method instance from a class. But it also
returns methods from the superclass. How to detect if an attribute is from
superclass?
-Radhakrishna
--
http://mail.python.org/mailman/listinfo/python-list
Red Forks, 15.12.2009 13:19:
> I don't know it is a feature, or implement detail:
>
> >>> class C(object): pass
> ...
> >>> c = C()
> >>> setattr(c, ' ', 3)
> >>> getattr(c, ' ')
> 3
> >>> setattr(c,
I don't know it is a feature, or implement detail:
>>> class C(object): pass
...
>>> c = C()
>>> setattr(c, ' ', 3)
>>> getattr(c, ' ')
3
>>> setattr(c, 'with blank', 4)
>>> getattr(c, 'with blank'
foo = ("bar", "baaz, back")
>>> "bar" in foo
True
>>> "baaz" in foo
False
>>>
"""
storesTables.append(table)
for table in storesTables:
You don't need two loops here - you could as well proceed as you go,
mport options
>> storesTables = []
>> junkStores = string.join(addStore(), ', ')
>> for table in optionsTables():
>> if table not in ('particulars', junkStores):
>>storesTables.append(table)
>> for table in storesTables:
>> try:
>>fn
rs', junkStores):
storesTables.append(table)
for table in storesTables:
try:
fn = getattr(options, table)
print fn()
except:
pass
I need to change the obvious line to this or something similar (that
actually works):
fn = getattr(options, '%s("names")' % table)
Tha
es.append(table)
for table in storesTables:
try:
fn = getattr(options, table)
print fn()
except:
pass
I need to change the obvious line to this or something similar (that
actually works):
fn = getattr(options, '%s("names")' % table)
That is, I need to pass the
NMarcu wrote:
> Hello all,
> I need some help to understand a getattr syntax. The syntax is:
>
> try:
> getattr(self, command)(cursor, row)
> except Exception, e:
> print "Action failed : '%s'" % command
> raise e
>
> I don
Hello all,
I need some help to understand a getattr syntax. The syntax is:
try:
getattr(self, command)(cursor, row)
except Exception, e:
print "Action failed : '%s'" % command
raise e
I don't understand why is not like this: a = getattr(), and what ar
Mr SZ wrote:
Hi all,
Is it possible to call functions using getattr. I have written a simple script
with functions that call either SSL, TLS or plain functionality.
something like:
def func():
...
def funcSSL():
...
def funcTLS():
funcs = {'none':func, 'SSL':fu
On Apr 28, 2:30 am, Mr SZ wrote:
> Hi all,
>
> Is it possible to call functions using getattr. I have written a simple
> script with functions that call either SSL, TLS or plain functionality.
>
> something like:
> def func():
> ...
>
> def funcSSL():
> ...
&
Mr SZ wrote:
> Is it possible to call functions using getattr. I have written a simple
> script with functions that call either SSL, TLS or plain functionality.
>
> something like:
> def func():
> ...
>
> def funcSSL():
> ...
>
> def funcTLS():
> ..
Hi all,
Is it possible to call functions using getattr. I have written a simple script
with functions that call either SSL, TLS or plain functionality.
something like:
def func():
...
def funcSSL():
...
def funcTLS():
...
Now, based on my args I would like to call either one of them
Jason Scheirer a écrit :
(snip)
The 5%
of your time when you are doing metaprogramming or other abuses of the
object system are when you use get/setattr.
What makes you label "metaprogramming" and get/setattr as "abuses" ???
--
http://mail.python.org/mailman/listinfo/python-list
On Fri, 22 Aug 2008 20:50:17 -0700, maestro wrote:
> Why are these functions there? Is it somehow more idiomatic to use than
> to do obj.field ?
Heavens no!!! Using setattr and getattr is *less* idiomatic.
> Is there something you can with them that you can't by obj.fie
ith them that you can't by obj.field
> > reference?
>
> You can generate them dynamically from strings. In some cases you
> don't know until runtime what attributes you want to pull:
>
> def show_insides(obj):
> for attr in dir(obj):
> print "Attribute %r: %
ings. In some cases you
don't know until runtime what attributes you want to pull:
def show_insides(obj):
for attr in dir(obj):
print "Attribute %r: %r" % (attr, getattr(obj, attr))
class hello(object):
a = 1
b = 2
class goodbye(object):
c = 1
d = 500
pri
Why are these functions there? Is it somehow more idiomatic to use
than to do obj.field ?
Is there something you can with them that you can't by obj.field
reference?
--
http://mail.python.org/mailman/listinfo/python-list
func):
> dispatch = func()
> def _task(action, *args):
> return resultToXml(dispatch[action](*args))
> _task.__name__ = _task.func_name = func.__name__
> return _task
>
> @_make_task
> def _task1():
> def request(params):
> pass
>
Gabriel Rossetti a écrit :
Bruno Desthuilliers wrote:
Gabriel Rossetti a écrit :
Terry Reedy wrote:
(snip)
Unlike the class approach, this requires recreating the constant
functions and dict with each call to _test. Quick to write but a
bit 'dirty', in my opinion. Another standard idiom is
Bruno Desthuilliers wrote:
Gabriel Rossetti a écrit :
Terry Reedy wrote:
(snip)
Unlike the class approach, this requires recreating the constant
functions and dict with each call to _test. Quick to write but a
bit 'dirty', in my opinion. Another standard idiom is to set up the
constants ou
Gabriel Rossetti a écrit :
Terry Reedy wrote:
(snip)
Unlike the class approach, this requires recreating the constant
functions and dict with each call to _test. Quick to write but a bit
'dirty', in my opinion. Another standard idiom is to set up the
constants outside the function:
def re
s):
pass
def update(self, params, values):
pass
def delete(self, params):
pass
def __call__(self, action, *args):
return resultToXml(getattr(self, action)(*args))
_test = _Test()
Yes, very hackish :-)
No, not at all hackish, but one standard way to do what you want.
s):
pass
def delete(self, params):
pass
def __call__(self, action, *args):
return resultToXml(getattr(self, action)(*args))
_test = _Test()
Yes, very hackish :-)
No, not at all hackish, but one standard way to do what you want.
locals() is your friend.
def _test(self, ac
Bruno Desthuilliers wrote:
Gabriel Rossetti a écrit :
Hello,
I can't get getattr() to return nested functions,
Of course. Nested functions are not attributes of their container
function.
Ok
I tried this :
>>> def toto():
... def titi():
... pass
...
Gabriel Genellina wrote:
En Wed, 20 Aug 2008 05:34:38 -0300, Gabriel Rossetti
<[EMAIL PROTECTED]> escribi�:
I can't get getattr() to return nested functions, I tried this :
>>> def toto():
... def titi():
... pass
... f = getattr(toto, "t
Gabriel Rossetti a écrit :
Hello,
I can't get getattr() to return nested functions,
Of course. Nested functions are not attributes of their container function.
I tried this :
>>> def toto():
... def titi():
... pass
... f = getattr(toto, "titi&qu
En Wed, 20 Aug 2008 05:34:38 -0300, Gabriel Rossetti
<[EMAIL PROTECTED]> escribi�:
I can't get getattr() to return nested functions, I tried this :
>>> def toto():
... def titi():
... pass
... f = getattr(toto, "titi")
... print str(f)
.
Gabriel Rossetti <[EMAIL PROTECTED]> writes:
> I can't get getattr() to return nested functions, I tried this :
>
>>>> def toto():
> ... def titi():
> ... pass
> ... f = getattr(toto, "titi")
> ... print str(f)
> ...
&g
Hello,
I can't get getattr() to return nested functions, I tried this :
>>> def toto():
... def titi():
... pass
... f = getattr(toto, "titi")
... print str(f)
...
>>> toto()
Traceback (most recent call last):
File "&q
Gregor Horvath wrote:
Thank's, but this does not work for this case:
class A(object):
test = "test"
class B(object):
a = [A(),]
In [70]: reduce(getattr, "a[0].test".split("."), B)
On 15 Aug, 10:35, Gregor Horvath <[EMAIL PROTECTED]> wrote:
>
> : type object 'B' has no attribute
> 'a.test'
You have to realise that attributes can have names beyond those
supported by the usual attribute access syntax. For example:
class C: pass
setat
On Fri, 15 Aug 2008 11:12:04 +0200, Gregor Horvath wrote:
> Peter Otten schrieb:
>
>> make your own function that loops over the attributes, or spell it
>>
>>>>> reduce(getattr, "a.test".split("."), B)
>> 'test'
>>
On Fri, 15 Aug 2008 11:12:04 +0200, Gregor Horvath wrote:
> Thank's, but this does not work for this case:
>
> class A(object):
> test = "test"
>
> class B(object):
> a = [A(),]
>
> In [70]:
Gregor Horvath wrote:
> Peter Otten schrieb:
>
>> make your own function that loops over the attributes, or spell it
>>
>>>>> reduce(getattr, "a.test".split("."), B)
>> 'test'
>>
>
> Thank's, but this does
Peter Otten schrieb:
make your own function that loops over the attributes, or spell it
reduce(getattr, "a.test".split("."), B)
'test'
Thank's, but this does not work for this case:
class A(object):
test = "test"
class B(object):
a
Gregor Horvath wrote:
> Hi,
>
> class A(object):
> test = "test"
>
> class B(object):
> a = A()
>
>
> In [36]: B.a.test
> Out[36]: 'test'
>
> In [37]: getattr(B, "a.test")
>
Gregor Horvath wrote:
any help?
I guess you missunderstood the sentence "For example, getattr(x,
'foobar') is equivalent to x.foobar.". getattr(x, "foo.bar") is not
equivalant to x.foo.bar.
--
http://mail.python.org/mailman/listinfo/python-list
Hi,
class A(object):
test = "test"
class B(object):
a = A()
In [36]: B.a.test
Out[36]: 'test'
In [37]: getattr(B, "a.test")
---
Traceback (most recent call last)
/ i
Error:
if '.' in name:
attrs = name.split('.')
first = object.__getattribute__(self, attrs[0])
return getattr(first, '.'.join(attrs[1:]))
raise
>>> a = A()
>>> a.b = A()
>>> a.b.c = A()
>>&
>
> > class B(object):
> > def __init__(self):
> > c = C()
>
> note you're just defining some local variables here, should be self.b = B()
> and self.c = C().
>
> > class C(object):
> > def __init__(self):
> > pass
>
e just defining some local variables here, should be self.b = B()
and self.c = C().
> class C(object):
> def __init__(self):
> pass
>
> and now i wanna do something like this:
>
> a=A()
> c=getattr(a, 'b.c')
>
> I know this doesn't work, but wha
Rotlaus wrote:
Hello,
lets assume i have some classes:
[...]
a=A()
c=getattr(a, 'b.c')
I know this doesn't work, but what can i do to get this or a similar
functionality to get it work for this sample and for even more nested
classes?
Just recursively apply the getattr(), li
Hello,
lets assume i have some classes:
class A(object):
def __init__(self):
b = B()
class B(object):
def __init__(self):
c = C()
class C(object):
def __init__(self):
pass
and now i wanna do something like this:
a=A()
c=getattr(a, 'b.c')
I
Erik Max Francis a écrit :
> Dave Kuhlman wrote:
>
>> Basically, the above code is saying that foo.foobar is not the same as
>> getattr(foo, 'foobar').
>
> Python promises that the behavior is the same. It does not promise that
> the _objects_ will be th
Mel a écrit :
(snip)
> (What Diez said.) From what I've seen, f.bar creates a bound method
> object by taking the unbound method Foo.bar and binding its first
> parameter with f.
Nope. it's Foo.__dict__['bar'] (that is, the function bar defined in the
namespace of class Foo) that creates a bo
Dave Kuhlman a écrit :
> Arnaud Delobelle wrote:
>
>> 4. Both points above follow from the fact that foo.bar is really a
>> function call that returns a (potentially) new object: in fact what
>> really happens is something like
>
> Arnaud and Imri, too -
>
> No. foo.bar is *not* really a funct
unt
... count = -1
...
>>> class Foo(object):
... bar = Bar()
... def __repr__(self): return "foo"
...
>>> foo = Foo()
>>> foo.bar
__get__(foo, )
0
>>> foo.bar
__get__(foo, )
1
>>> foo.bar
__get__(foo, )
2
>>> getattr(foo, "bar")
__get__(foo, )
3
Peter
--
http://mail.python.org/mailman/listinfo/python-list
On Mar 14, 1:53 am, John Nagle <[EMAIL PROTECTED]> wrote:
> John Machin wrote:
> > On Mar 14, 5:38 am, John Nagle <[EMAIL PROTECTED]> wrote:
> >>Just noticed, again, that getattr/setattr are ASCII-only, and don't
> >> support
> >> Unicode.
John Machin wrote:
> On Mar 14, 5:38 am, John Nagle <[EMAIL PROTECTED]> wrote:
>>Just noticed, again, that getattr/setattr are ASCII-only, and don't
>> support
>> Unicode.
>>
>>SGMLlib blows up because of this when faced with a Unicode end tag:
On Mar 13, 8:15 pm, [EMAIL PROTECTED] wrote:
> On Mar 13, 7:45 pm, [EMAIL PROTECTED] wrote:
>
>
>
>
>
> > On Mar 13, 7:18 pm, Mel <[EMAIL PROTECTED]> wrote:
>
> > > Diez B. Roggisch wrote:
> > > >> My understanding is that foo.bar does *not* create a new object.
>
> > > > Your understanding is not
On Mar 13, 7:45 pm, [EMAIL PROTECTED] wrote:
> On Mar 13, 7:18 pm, Mel <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > Diez B. Roggisch wrote:
> > >> My understanding is that foo.bar does *not* create a new object.
>
> > > Your understanding is not correct.
>
> > >> All it
> > >> does is return the value
On Mar 13, 7:18 pm, Mel <[EMAIL PROTECTED]> wrote:
> Diez B. Roggisch wrote:
> >> My understanding is that foo.bar does *not* create a new object.
>
> > Your understanding is not correct.
>
> >> All it
> >> does is return the value of the bar attribute of object foo. What new
> >> object is being
Diez B. Roggisch wrote:
>> My understanding is that foo.bar does *not* create a new object.
>
> Your understanding is not correct.
>
>> All it
>> does is return the value of the bar attribute of object foo. What new
>> object is being created?
>
> A bound method. This happens through the descr
On Mar 13, 11:29 pm, Dave Kuhlman <[EMAIL PROTECTED]> wrote:
> Arnaud Delobelle wrote:
>
> > 4. Both points above follow from the fact that foo.bar is really a
> > function call that returns a (potentially) new object: in fact what
> > really happens is something like
>
> Arnaud and Imri, too -
>
> > Basically, the above code is saying that foo.foobar is not the same as
> > getattr(foo, 'foobar').
>
> > What gives? This breaks my understanding of id(), the is operator, and
> > getattr().
>
> 4. Both points above follow from the fact that foo.bar
> My understanding is that foo.bar does *not* create a new object.
Your understanding is not correct.
> All it
> does is return the value of the bar attribute of object foo. What new
> object is being created?
A bound method. This happens through the descriptor-protocol. Please see
this examp
Dave Kuhlman wrote:
> Basically, the above code is saying that foo.foobar is not the same as
> getattr(foo, 'foobar').
Python promises that the behavior is the same. It does not promise that
the _objects_ will be the same, which is what `is` determines. That is,
you'
Arnaud Delobelle wrote:
>
> 4. Both points above follow from the fact that foo.bar is really a
> function call that returns a (potentially) new object: in fact what
> really happens is something like
Arnaud and Imri, too -
No. foo.bar is *not* really a function/method call.
>
> Foo.__di
On Mar 13, 10:06 pm, Dave Kuhlman <[EMAIL PROTECTED]> wrote:
> The following code has me mystified:
>
> In [4]: class A(object):
> ...: def show(self):
> ...: print 'hello'
> ...:
> ...:
> In [5]: a = A()
> In [6]:
> In [7]: x
Dave Kuhlman wrote:
> The following code has me mystified:
>
> In [4]: class A(object):
>...: def show(self):
>...: print 'hello'
>...:
>...:
> In [5]: a = A()
> In [6]:
> In [7]: x = a.show
> In [8]: y = getattr(a, 's
The following code has me mystified:
In [4]: class A(object):
...: def show(self):
...: print 'hello'
...:
...:
In [5]: a = A()
In [6]:
In [7]: x = a.show
In [8]: y = getattr(a, 'show')
In [9]: x
Out[9]: >
In [10]: y
Out[10]: >
In [11]:
In [12]:
On Mar 14, 5:38 am, John Nagle <[EMAIL PROTECTED]> wrote:
>Just noticed, again, that getattr/setattr are ASCII-only, and don't support
> Unicode.
>
>SGMLlib blows up because of this when faced with a Unicode end tag:
>
> File "/usr/local/lib/p
"John Nagle" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
| Just noticed, again, that getattr/setattr are ASCII-only, and don't
support
| Unicode.
|
| SGMLlib blows up because of this when faced with a Unicode end tag:
|
| File "/usr/local/lib/pytho
Just noticed, again, that getattr/setattr are ASCII-only, and don't support
Unicode.
SGMLlib blows up because of this when faced with a Unicode end tag:
File "/usr/local/lib/python2.5/sgmllib.py", line 353, in finish_endtag
method = getattr(sel
ed until run time. I have it
> > loading the module correctly, but when I use getattr to access the
> > class and its attributes everything works except that I get additional
> > unwanted output. The code
>
> > testclass.py:
>
> > #!/usr/bin/python
>
> >
On Dec 23, 10:39 am, Sledge <[EMAIL PROTECTED]> wrote:
> Hi.
>
> I am trying to dynamically load a class and attributes at run time. I
> do not know what classes will be referenced until run time. I have it
> loading the module correctly, but when I use getattr to acces
Hi.
I am trying to dynamically load a class and attributes at run time. I
do not know what classes will be referenced until run time. I have it
loading the module correctly, but when I use getattr to access the
class and its attributes everything works except that I get additional
unwanted
Thanks Bruno, I had to keep coding, so I used the long form
[Object.subobject.property = blah] anyway. It's long-winded, but
unambiguous.
\d
--
http://mail.python.org/mailman/listinfo/python-list
Donn Ingle a écrit :
>>class Key(object):
>>def __init__self):
>>self.__dict__['props'] = KeyProps()
>
> Okay - that's weird.
No, that's coherent. The default behavior (I mean, when there's no
descriptor involved etc) of __setattr__ is to store attributes in
instance.__dict__. So as long a you
> class Key(object):
> def __init__self):
> self.__dict__['props'] = KeyProps()
Okay - that's weird. Is there another way to spin this?
> def __setattr__(self,var,val):
> setattr(self.props,var,val)
Perhaps by changing this one?
\d
--
http://mail.python.org/mailman/listinfo/python-list
On Sat, 08 Dec 2007 14:26:00 +0200, Donn Ingle wrote:
>> So you might want to describe your use-case.
> Um.. I wanted an object with Key to hold other data. I wanted a way to
> set that *other* data within Key without having to specify the "object
> in-between" everytime.
That's called "automatic
On Dec 8, 6:06 am, Donn Ingle <[EMAIL PROTECTED]> wrote:
> Hi,
> Here's some code, it's broken:
>
> class Key( object ):
> def __init__(self):
> self.props = KeyProps()
> def __getattr__(self, v):
> return getattr( self.prop
> So you might want to describe your use-case.
Um.. I wanted an object with Key to hold other data. I wanted a way to set
that *other* data within Key without having to specify the "object
in-between" everytime.
k1.x = "ni!"
should perform:
k1.props.x = "ni!"
and
print k1.x
should perform:
print
Donn Ingle wrote:
> Hi,
> Here's some code, it's broken:
>
>
> class Key( object ):
> def __init__(self):
> self.props = KeyProps()
> def __getattr__(self, v):
> return getattr( self.props,v )
> def __setattr__(self,var,val):
Hi,
Here's some code, it's broken:
class Key( object ):
def __init__(self):
self.props = KeyProps()
def __getattr__(self, v):
return getattr( self.props,v )
def __setattr__(self,var,val):
object.__setattr__(self.props,var,val)
class KeyPr
Alex, Gabriel,
Thanks for the reply. Works great!
On 9/3/07, Gabriel Genellina <[EMAIL PROTECTED]> wrote:
> En Mon, 03 Sep 2007 20:13:43 -0300, Sergio Correia
> <[EMAIL PROTECTED]> escribi�:
>
> > # Module spam.py
> >
> > import eggs
> >
> > pr
1 - 100 of 197 matches
Mail list logo