<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>Le 22 sept. 2012 à 14:42, klo uo a écrit :</div><br class="Apple-interchange-newline"><blockquote type="cite">I'll try to explain through example:<br><span style="font-family:courier new,monospace"><br></span><span style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">==========<span style="font-family:courier new,monospace">==========<span style="font-family:courier new,monospace">==========</span></span></span></span><span style="font-family:courier new,monospace">==========<br>
</span><span style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"></span>In [1]: from lxml import etree<br><br></span><span style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">In [2]: </span>tree = etree.fromstring('<foo><bar></bar></foo>')<br>
</span><span style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">In [3]: </span>xp = tree.xpath('/foo/bar')</span><br><span style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">==========<span style="font-family:courier new,monospace">==========<span style="font-family:courier new,monospace">==========</span></span></span></span><span style="font-family:courier new,monospace">==========</span><br>
<br>Now "xp" is a list of objects, in above example list of just one object:<br><br><span style="font-family:courier new,monospace">[<Element bar at 0x1aa4aa8>]</span><br><br>So if I want to access variable "xp", I must access list item, and IPython treats it as a list without exposing underlying object.<br>
<br>As in:<br><br><span style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">In [4]: </span>xp[0].<tab></span><br><br>it won't let me inspect the object, while if I type:<br>
<br><font face="courier new,monospace">In [5]: xp0 = xp[0]<br>In [6]: xp0.<tab><br></font></blockquote><div><br></div>This is the greedy completer, it is an option, because [] can actually be a methods that have side effects… </div><div>Introspecting would trigger this methods, like querying over the web, or change the state of an oscilloscope…</div><div><br></div><div>So it is disabled by default.</div><div><br></div><div>You can opt-in with --IPcompleter.greedy=True </div><div>or </div><div>%config IPconmpleter.greedy=True</div><div><br></div><div>and do </div><div>'mystring'.u<tab></div><div>to completer to uppercase().</div><div><br></div><div>-- </div><div>Matthias</div><div><br></div></body></html>