<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
ryles wrote:
<blockquote
cite="mid:4eab6e76-833a-4cc7-a21d-c3d8ed344f8e@a7g2000yqk.googlegroups.com"
type="cite">
<pre wrap="">On Jul 2, 1:25 am, Terry Reedy <a class="moz-txt-link-rfc2396E" href="mailto:tjre...@udel.edu"><tjre...@udel.edu></a> wrote:
</pre>
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">The next statement works,
but I'm not sure if it will have any dramatical side effects,
other than overruling a possible object with the name A
</pre>
</blockquote>
<blockquote type="cite">
<pre wrap="">def some_function ( ...) :
A = object ( ...)
sys._getframe(1).f_globals [ Name ] = A
</pre>
</blockquote>
<pre wrap="">global name
name = A
or is name is a string var
globals()[name] = A
</pre>
</blockquote>
<pre wrap=""><!---->
It wasn't explicit, but I think Stef meant that the global should be
added to the caller's environment, which was the reason for
sys._getframe().
Is this environment only intended for interactive use? I wonder if you
might just set things up
in a PYTHONSTARTUP script instead.
</pre>
</blockquote>
the idea is to get a simple environment where you can do interactive 3D
geometry,<br>
without knowing anything about Python.<br>
So to create a triangle e.g., the whole program will look like this:<br>
<br>
<tt>Point ( 'A', (1,1,0) )<br>
Point ( 'B', (5,5,0) )<br>
Point ( 'C', (1,5,0) )<br>
Line_Segment ( 'AB' ) <br>
Line_Segment ( 'BC' ) <br>
Line_Segment ( 'AC' ) <br>
</tt><br>
<img src="cid:part1.03050802.03060801@gmail.com" alt=""><br>
<br>
And now the points A,B,C and the line segments AB,BC,AC also exists as
variables in the namespace of the above environment.<br>
So now you can add a point "D" in the middle of the line-segment AB, by
giving the formula of that point:<br>
<br>
<tt>Point ( 'D', ' ( A + B ) / 2 ' )<br>
</tt><br>
Or display the properties of point A, with :<br>
<br>
<tt>Print A<br>
</tt><br>
which (for the moment) will result in:<br>
<br>
<tt>Point Instance: A<br>
Childs : AB(Line-Segment), AC(Line-Segment), <br>
Parents: <br>
</tt><br>
The graphics above is done in VPython, which gives you an easy way to
make all objects dragable,<br>
and if objects are defined by formulas, the will stick together
according to that formula.<br>
<br>
And now it's obvious I can't use the solution of Terry,<br>
because I don't know what names will to become global.<br>
<br>
thanks,<br>
Stef<br>
<br>
<br>
</body>
</html>