<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2654.45">
<TITLE>RE: [Python-Dev] Decimal - context manipulation</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=2>[Paul Moore]</FONT>
</P>

<P><FONT SIZE=2>#- One thing I couldn't find an obvious way of doing with Decimal is to</FONT>
<BR><FONT SIZE=2>#- obtain a copy of the current context, with a different (say)</FONT>
<BR><FONT SIZE=2>#- precision. The Context constructor defaults from </FONT>
<BR><FONT SIZE=2>#- DefaultContext rather</FONT>
<BR><FONT SIZE=2>#- than from the current context, and I can't see a way of modifying the</FONT>
<BR><FONT SIZE=2>#- precision of a Context object (is the &quot;prec&quot; attribute intended to be</FONT>
<BR><FONT SIZE=2>#- publicly writeable?) I assume that copy.copy works to copy a context,</FONT>
<BR><FONT SIZE=2>#- although maybe an explicit copy method would be useful?</FONT>
</P>

<P><FONT SIZE=2>&gt;&gt;&gt; from Decimal import *</FONT>
<BR><FONT SIZE=2>&gt;&gt;&gt; actual_context = getcontext()</FONT>
<BR><FONT SIZE=2>&gt;&gt;&gt; copied_context = copy.copy(actual_context)</FONT>
<BR><FONT SIZE=2>&gt;&gt;&gt; copied_context.prec = 5</FONT>
<BR><FONT SIZE=2>&gt;&gt;&gt; +Decimal('123456789')</FONT>
<BR><FONT SIZE=2>Decimal( (0, (1, 2, 3, 4, 5, 6, 7, 8, 9), 0) )</FONT>
<BR><FONT SIZE=2>&gt;&gt;&gt; actual_context.prec = 5</FONT>
<BR><FONT SIZE=2>&gt;&gt;&gt; +Decimal('123456789')</FONT>
<BR><FONT SIZE=2>Decimal( (0, (1, 2, 3, 4, 6), 4L) )</FONT>
</P>

<P><FONT SIZE=2>Note the + in front of the creation of Decimal: that implies an operation and that's why the context get involved.</FONT>
</P>

<P><FONT SIZE=2>Regarding a copy() method in Context class, don't know. It's really easy to implement, but don't know if the standard preference is to get a copy method inside each data type (I'm confused about dictionaries having a copy method and lists, for example, not having it).</FONT></P>

<P><FONT SIZE=2>.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Facundo</FONT>
</P>
<BR>
<BR>
<BR>
<BR>

<P><B><FONT SIZE=2>. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .</FONT></B></P>

<P><B><U><FONT SIZE=2>ADVERTENCIA&nbsp;</FONT></U> </B>
</P>

<P><B><FONT SIZE=2>La información contenida en este mensaje y cualquier archivo anexo al mismo, son para uso exclusivo del destinatario y pueden contener información confidencial o propietaria, cuya divulgación es sancionada por la ley. </FONT></B></P>

<P><B><FONT SIZE=2>Si Ud. No es uno de los destinatarios consignados o la persona responsable de hacer llegar este mensaje a los destinatarios consignados, no está autorizado a divulgar, copiar, distribuir o retener información (o parte de ella) contenida en este mensaje. Por favor notifíquenos respondiendo al remitente, borre el mensaje original y borre las copias (impresas o grabadas en cualquier medio magnético) que pueda haber realizado del mismo. </FONT></B></P>

<P><B><FONT SIZE=2>Todas las opiniones contenidas en este mail son propias del autor del mensaje y no necesariamente coinciden con las de Telefónica Comunicaciones Personales S.A. o alguna empresa asociada. </FONT></B></P>

<P><B><FONT SIZE=2>Los mensajes electrónicos pueden ser alterados, motivo por el cual Telefónica Comunicaciones Personales S.A. no aceptará ninguna obligación cualquiera sea el resultante de este mensaje. </FONT></B></P>

<P><B><FONT SIZE=2>Muchas Gracias.</FONT></B>
</P>

</BODY>
</HTML>