I have a simple question. As everything is an object in python, can I access the inner attributes of a builtin object.
e.g. a='some String'
I want to access in the inner attributes of the string object a
.
Here is what I'have tried:-
for x in dir(a):
if not callable(eval('a.' + x)):
print x
But, I get output as:
__doc__
But, I want to access other attributes from this object, which the object will be using for itself.
Is there a way through which I can access the abstract attributes of this object ?
Just to elaborate:
class Some(object):
def __init__(self, initialiser):
self.initialiser = initialiser
s = Some('Any object can be put here, I am using a string')
print s.initialiser ## This is how I'm accessing the attribute of the class Some. Similarly, can I ##access the attributes of the string object `a` defined above?
print s
# gives me: <__main__.Some object at 0x02371AF0>
So, why does print a
not give me such an output. Because, some method is called when I print a
and which accesses the memory where the actual string sequence is stored and prints it. But, this does not happen when I print s