Solution fork python call it python-1.<div><br><br><div class="gmail_quote">On Sat, Sep 10, 2011 at 11:40 AM, Massimo Di Pierro <span dir="ltr">&lt;<a href="mailto:mdipierro@cs.depaul.edu" target="_blank">mdipierro@cs.depaul.edu</a>&gt;</span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
class List(list):<br>
    &quot;&quot;&quot;<br>
    &gt;&gt;&gt; a=List()<br>
    &gt;&gt;&gt; for i in range(100000): a.append(i)<br>
    &gt;&gt;&gt; print a.first<br>
    0<br>
    &gt;&gt;&gt; print a.second<br>
    1<br>
    &gt;&gt;&gt; print a.third<br>
    2<br>
    &gt;&gt;&gt; print a.twentieth<br>
    19<br>
    &gt;&gt;&gt; print a.twentysecond<br>
    21<br>
    &gt;&gt;&gt; print a.onehundredthirtyfifth<br>
    134<br>
    &gt;&gt;&gt; print a.onethousandfivehundredthirtyeighth<br>
    1537<br>
    &quot;&quot;&quot;<br>
    def __getattr__(self,name):<br>
        import re<br>
        if name.endswith(&#39;first&#39;): name = name[:-5]+&#39;one&#39;<br>
        elif name.endswith(&#39;second&#39;): name = name[:-6]+&#39;two&#39;<br>
        elif name.endswith(&#39;third&#39;): name = name[:-5]+&#39;three&#39;<br>
        elif name.endswith(&#39;fth&#39;): name = name[:-3]+&#39;ve&#39;<br>
        elif name.endswith(&#39;hth&#39;): name = name[:-3]+&#39;th&#39;<br>
        elif name.endswith(&#39;ieth&#39;): name = name[:-4]+&#39;y&#39;<br>
        elif name.endswith(&#39;th&#39;): name = name[:-2]<br>
        subs = [<br>
            (&quot;eleven&quot;,&quot;+11&quot;),<br>
            (&quot;twelve&quot;,&quot;+12&quot;),<br>
            (&quot;thirteen&quot;,&quot;+13&quot;),<br>
            (&quot;fourteen&quot;,&quot;+14&quot;),<br>
            (&quot;fiftheen&quot;,&quot;+15&quot;),<br>
            (&quot;sixteen&quot;,&quot;+16&quot;),<br>
            (&quot;seventeen&quot;,&quot;+17&quot;),<br>
            (&quot;eighteen&quot;,&quot;+18&quot;),<br>
            (&quot;nineteen&quot;,&quot;+19&quot;),<br>
            (&quot;ten&quot;,&quot;+10&quot;),<br>
            (&quot;twenty&quot;,&quot;+20&quot;),<br>
            (&quot;thirty&quot;,&quot;+30&quot;),<br>
            (&quot;fourty&quot;,&quot;+40&quot;),<br>
            (&quot;fifthy&quot;,&quot;+50&quot;),<br>
            (&quot;sixty&quot;,&quot;+60&quot;),<br>
            (&quot;seventy&quot;,&quot;+70&quot;),<br>
            (&quot;eighty&quot;,&quot;+80&quot;),<br>
            (&quot;ninety&quot;,&quot;+90&quot;),<br>
            (&quot;one&quot;,&quot;+1&quot;),<br>
            (&quot;two&quot;,&quot;+2&quot;),<br>
            (&quot;three&quot;,&quot;+3&quot;),<br>
            (&quot;four&quot;,&quot;+4&quot;),<br>
            (&quot;five&quot;,&quot;+5&quot;),<br>
            (&quot;six&quot;,&quot;+6&quot;),<br>
            (&quot;seven&quot;,&quot;+7&quot;),<br>
            (&quot;eigth&quot;,&quot;+8&quot;),<br>
            (&quot;nine&quot;,&quot;+9&quot;),<br>
            (&quot;ten&quot;,&quot;+10&quot;),<br>
            (&quot;hundred&quot;,&quot;)*100+(&quot;),<br>
            (&quot;thousand&quot;,&quot;)*1000+(&quot;),<br>
            (&quot;million&quot;,&quot;)*1000000+(&quot;),<br>
            (&quot;billion&quot;,&quot;)*1000000000+(&quot;),<br>
            (&quot;trillion&quot;,&quot;)*100000000000+(&quot;),<br>
            (&quot;and&quot;,&quot;&quot;)]<br>
        for key,value in subs:<br>
            name = name.replace(key,value)<br>
        if &#39;(&#39; in name: name=&#39;(&#39;+name+&#39;)&#39;<br>
        name.replace(&#39;()&#39;,&#39;1&#39;)<br>
        if not re.compile(&#39;[\d\+\*\(\)]+&#39;).match(name): return AttributeError<br>
        try: return self[eval(name)-1]<br>
        except: raise AttributeError<br>
<br>
_______________________________________________<br>
Chicago mailing list<br>
<a href="mailto:Chicago@python.org" target="_blank">Chicago@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/chicago" target="_blank">http://mail.python.org/mailman/listinfo/chicago</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Thanks,<br>Brian Herman<br><br><a href="http://brianjherman.com" style="color:rgb(153, 153, 153)" target="_blank">brianjherman.com</a><br><font color="#999999">Research Assistant</font><br>


<font color="#999999">University Of Illinois at Chicago</font><br><a href="mailto:brianherman@acm.org" style="color:rgb(153, 153, 153)" target="_blank">brianherman@acm.org</a><br><br>
</div>