<br><br><div class="gmail_quote">On Sat, Jan 24, 2009 at 20:43, bob gailer <span dir="ltr">&lt;<a href="mailto:bgailer@gmail.com">bgailer@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">



  

<div bgcolor="#ffffff" text="#000000"><div><div></div><div class="Wj3C7c">
Vicent wrote:<blockquote type="cite"><div class="gmail_quote"><div><br>
It would be great if&nbsp;&nbsp; &quot;b.value = 0&quot; &nbsp; could be just written as &quot;b = 0&quot;
without changing type as a result.<br>
  </div>
  </div>
</blockquote>
<br></div></div>
Assignment in effect does a del b, then creates a new b based on the
expression. There is no way in Python right now to do that. The closest
I can come is to support the syntax b(0) and b(1) to emulate
assignment. That would require that I add to the Bit class:<br>
<br>
&nbsp; def __call__(self, value):<br>
&nbsp;&nbsp;&nbsp; self.value = value<div class="Ih2E3d"></div></div></blockquote><div><br>OK, I think I understand...<br>&nbsp;<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div bgcolor="#ffffff" text="#000000"><div class="Ih2E3d"><br>
<blockquote type="cite">
  <div class="gmail_quote">
  <div><br>
What happens if every time I want to update the value of &quot;b&quot;, I use &quot;b=
Bit(0)&quot; , &quot;b=Bit(1)&quot;, and so on?? Is like &quot;building&quot; the object each
time? It is less efficient, isn&#39;t it?<br>
  </div>
  </div>
</blockquote>
<br></div>
Yes and yes.<div class="Ih2E3d"></div></div></blockquote><div><br>Ok...<br>&nbsp;<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div bgcolor="#ffffff" text="#000000">
<div class="Ih2E3d"><br>
<blockquote type="cite">
  <div class="gmail_quote">
  <div><br>
You are going to kill me</div>
  </div>
</blockquote>
<br></div>
Are you saying that to prepare your self for a negative response from
me, or in hopes that I would not have such? I view everything we do
here as incremental improvement. I am glad you are thinking of
alternatives.</div></blockquote><div><br>Thank you...<br>&nbsp;<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div bgcolor="#ffffff" text="#000000">
<div class="Ih2E3d"><br>
<br>
<blockquote type="cite">
  <div class="gmail_quote">
  <div>, but... Maybe the solution is not to re-define what already
exists —boolean data type, but just using it, as suggested at the
beginning of the thread...<br>
  <br>
b = bool(1)<br>
b = bool(0)<br>
  <br>
After all, it&#39;s not so bad...<br>
  </div>
  </div>
</blockquote>
<br></div>
It really depends on your goals for having this new type. <br><div class="Ih2E3d">
</div></div></blockquote><div><br><br>I was thinking about this during this night (sometimes, it is near to sleep or when having a shower when new ideas come out!, isn&#39;t it?).<br><br>Maybe, all I need to do is this:<br>
<br>&gt;&gt;&gt; bit = bool<br><br>And then, I can do this:<br><br>&gt;&gt;&gt; b = bit(0) <br></div></div><br>I mean, just using &quot;bit&quot; as an &quot;alias&quot; for &quot;bool&quot; [, and forget about any new class or whatever]. In fact, type for &quot;b&quot; is &quot;bool&quot;:<br>
<br>&gt;&gt;&gt; type(b)<br>&lt;type &#39;bool&#39;&gt;<br clear="all"><br><br><br><div class="gmail_quote">On Sat, Jan 24, 2009 at 22:46, Kent Johnson <span dir="ltr">&lt;<a href="mailto:kent37@tds.net">kent37@tds.net</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d"><br>
<br>
</div>You have an incorrect idea about how variables and assignment work in<br>
Python. Type is associated with a value, not a name. You might want to<br>
read this:<br>
<a href="http://personalpages.tds.net/%7Ekent37/kk/00012.html" target="_blank">http://personalpages.tds.net/~kent37/kk/00012.html</a><br>
<br>
and this classic:<br>
<a href="http://effbot.org/zone/python-objects.htm" target="_blank">http://effbot.org/zone/python-objects.htm</a><br>
<font color="#888888"><br>
</font></blockquote></div><br><br>Yes, I was a bit confused, although I&#39;ve already read those links you provide (I think you gave them to me in another recent post). They are very good explanations.<br><br>I think I hadn&#39;t get that &quot;0&quot; is always integer, but now I get it. If I want to make it boolean (bit-like), it should be referred as &quot;bool(0)&quot;.&nbsp;&nbsp; [It is like that, isn&#39;t it????]<br>
<br>-- <br>Vicent<br>