-__doc__ = u"""
- >>> class test(object): a = 1
- >>> t = test()
- >>> f(t, 'a')
+class test(object):
+ a = 1
+t = test()
+
+def getattr2_literal_unicode(a):
+ """
+ >>> getattr2_literal_unicode(t)
1
- >>> f(t, 'b')
+ >>> getattr2_literal_unicode(object())
Traceback (most recent call last):
- AttributeError: 'test' object has no attribute 'b'
+ AttributeError: 'object' object has no attribute 'a'
+ """
+ return getattr(a, u"a")
- >>> g(t, 'a', 2)
- 1
- >>> g(t, 'b', 2)
- 2
+def getattr3_literal_unicode(a, b):
+ """
+ >>> getattr3_literal_unicode(t, 2)
+ (1, 2)
+ """
+ return getattr(a, u"a", b), getattr(a, u"b", b)
- >>> h(t, 'a', 2)
+def getattr2_simple(a, b):
+ """
+ >>> getattr2_simple(t, 'a')
1
- >>> h(t, 'b', 2)
- 2
-"""
-
-def f(a, b):
+ >>> getattr2_simple(t, 'b')
+ Traceback (most recent call last):
+ AttributeError: 'test' object has no attribute 'b'
+ """
return getattr(a, b)
-def g(a, b, c):
+def getattr3_explicit(a, b, c):
+ """
+ >>> getattr3_explicit(t, 'a', 2)
+ 1
+ >>> getattr3_explicit(t, 'b', 2)
+ 2
+ """
return getattr3(a, b, c)
-def h(a, b, c):
+def getattr3_args(a, b, c):
+ """
+ >>> getattr3_args(t, 'a', 2)
+ 1
+ >>> getattr3_args(t, 'b', 2)
+ 2
+ """
return getattr(a, b, c)