Enhanced dir() function

Ethan Furman ethan at stoneleaf.us
Tue Jul 12 17:19:17 EDT 2011


Ethan Furman wrote:
> Tim Chase wrote:
>> If it came in as an effortless (i.e. O(1) where I do it once and never 
>> again; not an O(n) where n=the number of times I invoke Python) 
>> default replacement for dir(), I'd reach for it a lot more readily.  I 
>> seem to recall there's some environment-var or magic file-name that 
>> gets sourced on every startup.
> 
> interact.py
> 8<-----------------------------------------------
> import os, sys
> sys.ps1 = '--> '
> 
> from cookbook.utils import dir  # or whereever you keep your copy
> sys.modules['__builtin__'].dir = dir
> 8<-----------------------------------------------


Imagine my amusement when I went to change an environment variable today 
and found:

PYTHONSTARTUP=c:\python25\interact.py

~Ethan~



More information about the Python-list mailing list