print dir(XXX) gives out blank attributes
<p>In short, I work with an xlsx file and while checking some list with <code>print dir(alist)</code> get blank attributes.</p>

<pre><code>neglist = neglist.tolist()
</code></pre>

<p>At this point I want to check whether evth is Ok:  </p>

<pre><code>def check_variab (variab):
    print "The type is %s" % type(variab)
    print "Its length = %i" % len(variab)
    print "Its attributes are:" % dir(variab)

print 'neglist'
check_variab(neglist)
</code></pre>

<p>But what I get is:</p>

<pre><code>type: list
length: 19
attributes: 
</code></pre>

<p>No attributes are printed though the type is list all right, its length and content is ok.</p>

<p>Could anyone explain why this happens?</p>

<p>You forgot to use a <code>%s</code> placeholder, so <em>nothing</em> will be interpolated. Add <code>%s</code> or <code>%r</code>:     </p>

<pre><code>print "Its attributes are %s:" % dir(variab)
#                         ^^ A placeholder for the value
</code></pre>

<p>Without that placeholder, you won't see anything, indeed:</p>

<pre><code>&gt;&gt;&gt; variab = ['foo', 'bar']
&gt;&gt;&gt; dir(variab)
['__add__', '__class__', '__contains__', '__delattr__', '__delitem__', '__delslice__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getslice__', '__gt__', '__hash__', '__iadd__', '__imul__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__rmul__', '__setattr__', '__setitem__', '__setslice__', '__sizeof__', '__str__', '__subclasshook__', 'append', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort']
&gt;&gt;&gt; print "Its attributes are:" % dir(variab)
Its attributes are:
&gt;&gt;&gt; print "Its attributes are %s:" % dir(variab)
Its attributes are ['__add__', '__class__', '__contains__', '__delattr__', '__delitem__', '__delslice__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getslice__', '__gt__', '__hash__', '__iadd__', '__imul__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__rmul__', '__setattr__', '__setitem__', '__setslice__', '__sizeof__', '__str__', '__subclasshook__', 'append', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort']:
</code></pre>

<p>You want to use <a href="https://docs.python.org/2/library/stdtypes.html#sequence-types-str-unicode-list-tuple-bytearray-buffer-xrange" rel="nofollow">standard sequence operations</a> on lists.</p>

python list xlsx