[Tutor] Fwd: The why

Kent Johnson kent37 at tds.net
Thu Jul 16 12:45:45 CEST 2009

> From: chris Hynes <cjhynes36 at hotmail.com>
> Date: 2009/7/15
> Subject: The why
> To: roadierich at googlemail.com
> Well, I'm trying to create an interactive program, let's say I'm
> running the program, I ask the user to give the array a name, I then
> do some computations and store the results in that array. While I'm
> still running the program I might decide to create several more arrays
> of the same type/dimension with names of my choosing same types of
> computation. When I'm done, I might have several arrays created, all
> with different names that I have given them. In the ipython mode I
> could call up any of these arrays off and on again as I want to
> visually compare them to each other.

You could write your program as a library with functions that create
your arrays. For example in myfuncs.py put:
def make_zeros():
  return zeros((3,3))

Then in ipython:
from myfuncs import * # usually import * is discouraged but this is a
reasonable use
chris = make_zeros()
bob = make_zeros()



Please Reply All to reply to the list.

More information about the Tutor mailing list