[Edu-sig] Fw: Python sequences by reference - how to make

Guido van Rossum guido@python.org
Sat, 21 Sep 2002 21:13:26 -0400


> What I'd like help with is understanding the implications of loading
> libraries vs. built_ins vs. smarter IDLE prompts.
> 
> For developers and students worknig at the Python shell, it is
> tedious and often often frustrating to have to load functionality
> repeatedly from libraries, ones which we feel should already be
> available.

Would a custom startup file that imports a bunch of stuff into your
interactive prompt whenever you start IDLE work?

All you need to do is set the shell environment variable PYTHONSTARTUP
or IDLESTARTUP to point to a file that you want loaded.

> From a script pov perspective, the assumption is rely 'assume
> nothing' so scripts should all start with a healthy block of import
> statements. Python does this well. 'Import' behaves transparently
> when a module is already loaded. Nice feature and thank you Python!
> 
> But also introduces a little Novice gotcha we ALL learn on Day One Lesson#1:
> 
> reload()
> 
> I assume reload() is used 99% of the time at the shell and not in
> scripts.[?]

I think it's closer to 100%.

reload() is a crock -- it's just the best we've got.  Except...

The new version of IDLE that's now under development in the
idlefork.sf.net project will address this better (hopefully) by
providing a way to say "run my script in a fresh interpreter".

> If so, then that confirms slightly my point there are
> two use contexts we need to be discussing:
> 
> A. people working interactively
> B. script and system defaults
> 
> My recent Top 5' rants have been trying to focus more on use context
> A.  [people] and how Python meets Novice users. But we are all
> novices about something, with expectations about Python behaves.
> 
> So what strategy can be applied when Python boots and in the IDLE
> shell to handle these expectation better:
> - loading modules
> - visible feedback and prompts about them
> - ??

Can you explain this more?

--Guido van Rossum (home page: http://www.python.org/~guido/)