thanks for the help Andreas, i dont really need that much a const so i wont do anything like that to have a const like data. I am very used to java and c++, thats why i always used acess modifier, but i think i can live without it now i know that it dont exist in python :P.<br>
<br><br><br><div class="gmail_quote">On Thu, Mar 6, 2008 at 6:39 AM, Andreas Kostyrka &lt;<a href="mailto:andreas@kostyrka.org">andreas@kostyrka.org</a>&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
The answer is slightly more complex.<br>
<br>
1.) objects are either mutable or immutable. E.g. tuples and strings are<br>
per definition immutable and &quot;constant&quot;. Lists and dictionaries are an<br>
example of the mutable kind.<br>
<br>
2.) &quot;variables&quot;, &quot;instance members&quot; are all only references to objects.<br>
<br>
Examples:<br>
<br>
# lists are mutable<br>
a = [1, 2]<br>
b = a<br>
b.append(3)<br>
assert a == [1, 2, 3]<br>
<br>
Now coming back to your question, that you want a non-changeable name,<br>
well, one can create such a beast, e.g.:<br>
<br>
def constant(value):<br>
 &nbsp; &nbsp;def _get(*_dummy):<br>
 &nbsp; &nbsp; &nbsp; &nbsp;return value<br>
 &nbsp; &nbsp;return property(_get)<br>
<br>
class Test(object):<br>
 &nbsp; &nbsp;const_a = constant(123)<br>
<br>
This creates a member that can only be fetched, but not set or deleted.<br>
<br>
But in practice, I personally never have seen a need for something like<br>
this. You can always overcome the above constant. Btw, you can do that<br>
in C++ privates too, worst case by casting around and ending up with a<br>
pointer that points to the private element ;)<br>
<br>
Andreas<br>
<br>
<br>
Am Mittwoch, den 05.03.2008, 21:07 -0300 schrieb Tiago Katcipis:<br>
&gt; Its a simple question but i have found some trouble to find a good<br>
&gt; answer to it, maybe i just dont searched enough but it wont cost<br>
&gt; anything to ask here, and it will not cost to much to answer :-). I have<br>
&gt; started do develop on python and i really liked it, but im still<br>
&gt; learning. Im used to develop on c++ and java and i wanted to know if<br>
&gt; there is any way to create a final or const member, a member that after<br>
&gt; assigned cant be reassigned. Thanks to anyone who tries to help me and<br>
&gt; sorry to bother with a so silly question. i hope someday i can be able<br>
&gt; to help :-)<br>
&gt;<br>
&gt; best regards<br>
&gt;<br>
&gt; katcipis<br>
&gt; _______________________________________________<br>
&gt; Tutor maillist &nbsp;- &nbsp;<a href="mailto:Tutor@python.org">Tutor@python.org</a><br>
&gt; <a href="http://mail.python.org/mailman/listinfo/tutor" target="_blank">http://mail.python.org/mailman/listinfo/tutor</a><br>
</blockquote></div><br>