I made a class like this (I shortened it just to show the point), what do you think about it, do you think it is the python way of subclassing str (or unicode in this case)<div><br></div><div><span class="Apple-style-span" style="color: rgb(5, 10, 15); font-family: 'Trebuchet MS', Trebuchet, Arial, sans-serif; font-size: medium; "><pre class="prettyprint" style="padding-top: 2px; padding-right: 2px; padding-bottom: 2px; padding-left: 2px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(136, 136, 136); border-right-color: rgb(136, 136, 136); border-bottom-color: rgb(136, 136, 136); border-left-color: rgb(136, 136, 136); ">
<span class="com" style="color: rgb(136, 0, 0); "># -*- coding:utf-8 -*-</span><span class="pln" style="color: rgb(0, 0, 0); ">
</span><span class="pln" style="color: rgb(0, 0, 0); ">
</span><span class="kwd" style="color: rgb(0, 0, 136); ">class</span><span class="pln" style="color: rgb(0, 0, 0); "> kelime</span><span class="pun" style="color: rgb(102, 102, 0); ">(</span><span class="pln" style="color: rgb(0, 0, 0); ">unicode</span><span class="pun" style="color: rgb(102, 102, 0); ">):</span><span class="pln" style="color: rgb(0, 0, 0); ">
</span><span class="kwd" style="color: rgb(0, 0, 136); ">def</span><span class="pln" style="color: rgb(0, 0, 0); "> __init__</span><span class="pun" style="color: rgb(102, 102, 0); ">(</span><span class="kwd" style="color: rgb(0, 0, 136); ">self</span><span class="pun" style="color: rgb(102, 102, 0); ">,</span><span class="pln" style="color: rgb(0, 0, 0); ">sozcuk</span><span class="pun" style="color: rgb(102, 102, 0); ">):</span><span class="pln" style="color: rgb(0, 0, 0); ">
</span><span class="kwd" style="color: rgb(0, 0, 136); ">self</span><span class="pun" style="color: rgb(102, 102, 0); ">.</span><span class="pln" style="color: rgb(0, 0, 0); ">_sozcuk </span><span class="pun" style="color: rgb(102, 102, 0); ">=</span><span class="pln" style="color: rgb(0, 0, 0); "> sozcuk
</span><span class="kwd" style="color: rgb(0, 0, 136); ">def</span><span class="pln" style="color: rgb(0, 0, 0); "> __getattribute__</span><span class="pun" style="color: rgb(102, 102, 0); ">(</span><span class="kwd" style="color: rgb(0, 0, 136); ">self</span><span class="pun" style="color: rgb(102, 102, 0); ">,</span><span class="pln" style="color: rgb(0, 0, 0); "> isim</span><span class="pun" style="color: rgb(102, 102, 0); ">):</span><span class="pln" style="color: rgb(0, 0, 0); ">
att </span><span class="pun" style="color: rgb(102, 102, 0); ">=</span><span class="pln" style="color: rgb(0, 0, 0); "> </span><span class="kwd" style="color: rgb(0, 0, 136); ">super</span><span class="pun" style="color: rgb(102, 102, 0); ">(</span><span class="pln" style="color: rgb(0, 0, 0); ">kelime</span><span class="pun" style="color: rgb(102, 102, 0); ">,</span><span class="pln" style="color: rgb(0, 0, 0); "> </span><span class="kwd" style="color: rgb(0, 0, 136); ">self</span><span class="pun" style="color: rgb(102, 102, 0); ">).</span><span class="pln" style="color: rgb(0, 0, 0); ">__getattribute__</span><span class="pun" style="color: rgb(102, 102, 0); ">(</span><span class="pln" style="color: rgb(0, 0, 0); ">isim</span><span class="pun" style="color: rgb(102, 102, 0); ">)</span><span class="pln" style="color: rgb(0, 0, 0); ">
</span><span class="kwd" style="color: rgb(0, 0, 136); ">if</span><span class="pln" style="color: rgb(0, 0, 0); "> </span><span class="kwd" style="color: rgb(0, 0, 136); ">not</span><span class="pln" style="color: rgb(0, 0, 0); "> callable</span><span class="pun" style="color: rgb(102, 102, 0); ">(</span><span class="pln" style="color: rgb(0, 0, 0); ">att</span><span class="pun" style="color: rgb(102, 102, 0); ">):</span><span class="pln" style="color: rgb(0, 0, 0); ">
</span><span class="kwd" style="color: rgb(0, 0, 136); ">return</span><span class="pln" style="color: rgb(0, 0, 0); "> att
</span><span class="kwd" style="color: rgb(0, 0, 136); ">def</span><span class="pln" style="color: rgb(0, 0, 0); "> sonra_cagir</span><span class="pun" style="color: rgb(102, 102, 0); ">(*</span><span class="pln" style="color: rgb(0, 0, 0); ">args</span><span class="pun" style="color: rgb(102, 102, 0); ">,</span><span class="pln" style="color: rgb(0, 0, 0); "> </span><span class="pun" style="color: rgb(102, 102, 0); ">**</span><span class="pln" style="color: rgb(0, 0, 0); ">kwargs</span><span class="pun" style="color: rgb(102, 102, 0); ">):</span><span class="pln" style="color: rgb(0, 0, 0); ">
sonuc </span><span class="pun" style="color: rgb(102, 102, 0); ">=</span><span class="pln" style="color: rgb(0, 0, 0); "> att</span><span class="pun" style="color: rgb(102, 102, 0); ">(*</span><span class="pln" style="color: rgb(0, 0, 0); ">args</span><span class="pun" style="color: rgb(102, 102, 0); ">,</span><span class="pln" style="color: rgb(0, 0, 0); "> </span><span class="pun" style="color: rgb(102, 102, 0); ">**</span><span class="pln" style="color: rgb(0, 0, 0); ">kwargs</span><span class="pun" style="color: rgb(102, 102, 0); ">)</span><span class="pln" style="color: rgb(0, 0, 0); ">
</span><span class="kwd" style="color: rgb(0, 0, 136); ">if</span><span class="pln" style="color: rgb(0, 0, 0); "> isinstance</span><span class="pun" style="color: rgb(102, 102, 0); ">(</span><span class="pln" style="color: rgb(0, 0, 0); ">sonuc</span><span class="pun" style="color: rgb(102, 102, 0); ">,</span><span class="pln" style="color: rgb(0, 0, 0); "> basestring</span><span class="pun" style="color: rgb(102, 102, 0); ">):</span><span class="pln" style="color: rgb(0, 0, 0); ">
</span><span class="kwd" style="color: rgb(0, 0, 136); ">return</span><span class="pln" style="color: rgb(0, 0, 0); "> kelime</span><span class="pun" style="color: rgb(102, 102, 0); ">(</span><span class="pln" style="color: rgb(0, 0, 0); ">sonuc</span><span class="pun" style="color: rgb(102, 102, 0); ">)</span><span class="pln" style="color: rgb(0, 0, 0); ">
</span><span class="kwd" style="color: rgb(0, 0, 136); ">return</span><span class="pln" style="color: rgb(0, 0, 0); "> sonuc
</span><span class="kwd" style="color: rgb(0, 0, 136); ">return</span><span class="pln" style="color: rgb(0, 0, 0); "> sonra_cagir
</span><span class="kwd" style="color: rgb(0, 0, 136); ">def</span><span class="pln" style="color: rgb(0, 0, 0); "> cogul</span><span class="pun" style="color: rgb(102, 102, 0); ">(</span><span class="kwd" style="color: rgb(0, 0, 136); ">self</span><span class="pun" style="color: rgb(102, 102, 0); ">):</span><span class="pln" style="color: rgb(0, 0, 0); ">
</span><span class="kwd" style="color: rgb(0, 0, 136); ">for</span><span class="pln" style="color: rgb(0, 0, 0); "> harf </span><span class="kwd" style="color: rgb(0, 0, 136); ">in</span><span class="pln" style="color: rgb(0, 0, 0); "> reversed</span><span class="pun" style="color: rgb(102, 102, 0); ">(</span><span class="kwd" style="color: rgb(0, 0, 136); ">self</span><span class="pun" style="color: rgb(102, 102, 0); ">.</span><span class="pln" style="color: rgb(0, 0, 0); ">_sozcuk</span><span class="pun" style="color: rgb(102, 102, 0); ">):</span><span class="pln" style="color: rgb(0, 0, 0); ">
</span><span class="kwd" style="color: rgb(0, 0, 136); ">if</span><span class="pln" style="color: rgb(0, 0, 0); "> harf </span><span class="kwd" style="color: rgb(0, 0, 136); ">in</span><span class="pln" style="color: rgb(0, 0, 0); "> kalin</span><span class="pun" style="color: rgb(102, 102, 0); ">:</span><span class="pln" style="color: rgb(0, 0, 0); ">
</span><span class="kwd" style="color: rgb(0, 0, 136); ">return</span><span class="pln" style="color: rgb(0, 0, 0); "> kelime</span><span class="pun" style="color: rgb(102, 102, 0); ">(</span><span class="kwd" style="color: rgb(0, 0, 136); ">self</span><span class="pun" style="color: rgb(102, 102, 0); ">.</span><span class="pln" style="color: rgb(0, 0, 0); ">_sozcuk </span><span class="pun" style="color: rgb(102, 102, 0); ">+</span><span class="pln" style="color: rgb(0, 0, 0); "> u</span><span class="str" style="color: rgb(0, 136, 0); ">"lar"</span><span class="pun" style="color: rgb(102, 102, 0); ">)</span><span class="pln" style="color: rgb(0, 0, 0); ">
</span><span class="kwd" style="color: rgb(0, 0, 136); ">elif</span><span class="pln" style="color: rgb(0, 0, 0); "> harf </span><span class="kwd" style="color: rgb(0, 0, 136); ">in</span><span class="pln" style="color: rgb(0, 0, 0); "> ince</span><span class="pun" style="color: rgb(102, 102, 0); ">:</span><span class="pln" style="color: rgb(0, 0, 0); ">
</span><span class="kwd" style="color: rgb(0, 0, 136); ">return</span><span class="pln" style="color: rgb(0, 0, 0); "> kelime</span><span class="pun" style="color: rgb(102, 102, 0); ">(</span><span class="kwd" style="color: rgb(0, 0, 136); ">self</span><span class="pun" style="color: rgb(102, 102, 0); ">.</span><span class="pln" style="color: rgb(0, 0, 0); ">_sozcuk </span><span class="pun" style="color: rgb(102, 102, 0); ">+</span><span class="pln" style="color: rgb(0, 0, 0); "> u</span><span class="str" style="color: rgb(0, 136, 0); ">"ler"</span><span class="pun" style="color: rgb(102, 102, 0); ">)</span><span class="pln" style="color: rgb(0, 0, 0); ">
</span><span class="kwd" style="color: rgb(0, 0, 136); ">return</span><span class="pln" style="color: rgb(0, 0, 0); "> kelime</span><span class="pun" style="color: rgb(102, 102, 0); ">(</span><span class="kwd" style="color: rgb(0, 0, 136); ">self</span><span class="pun" style="color: rgb(102, 102, 0); ">.</span><span class="pln" style="color: rgb(0, 0, 0); ">_sozcuk </span><span class="pun" style="color: rgb(102, 102, 0); ">+</span><span class="pln" style="color: rgb(0, 0, 0); "> u</span><span class="str" style="color: rgb(0, 136, 0); ">"lar"</span><span class="pun" style="color: rgb(102, 102, 0); ">)</span><span class="pln" style="color: rgb(0, 0, 0); "><br>
</span></pre></span><div><br><div class="gmail_quote">31 Ağustos 2011 14:43 tarihinde Yaşar Arabacı <span dir="ltr"><<a href="mailto:yasar11732@gmail.com">yasar11732@gmail.com</a>></span> yazdı:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hİ,<div><br></div><div>I originally posted my question to here: <a href="http://stackoverflow.com/q/7255655/886669" target="_blank">http://stackoverflow.com/q/7255655/886669</a> Could you people please look at it and enlighten me a little bit? I would appreciate an answer either from here or at stackoverflow. Thanks in advance.<br clear="all">
<font color="#888888">
<div><br></div>-- <br><a href="http://yasar.serveblog.net/" target="_blank">http://yasar.serveblog.net/</a><br><br>
</font></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><a href="http://yasar.serveblog.net/" target="_blank">http://yasar.serveblog.net/</a><br><br>
</div></div>