Enhanced dir() function

Ethan Furman ethan at stoneleaf.us
Fri Jul 1 14:40:17 EDT 2011


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<-----------------------------------------------


~Ethan~



More information about the Python-list mailing list