[Tutor] Getting import to use a variable name
Jim Mooney Py3.4.3winXP
cybervigilante at gmail.com
Wed May 20 01:45:07 CEST 2015
I use python help() a good deal but get tired of paging through the
__object__ stuff to get to what I use at my level, so I wrote the following
to omit it. The problem is, I want to import it then use it as shorthelp.py
for different modules so I could just type shorthelp(modulename). Only the
import mechanism won't let me rename. I can only use the hardcoded imported
module name, shutil in this case. If I try x = anothermodule, then import
x, it doesn't work. import sys.argv[1] also doesn't work. Is there any way
to get around this? I'm mostly interested in doing this from the repl
rather than running from the console.
Py3.4 win32
import shutil #this works to print non __xxx helpstrings for a module,
but I can't substitute it.
useful_helps = []
helps = dir(shutil)
for helper in helps:
if helper[0] == '_':
continue
useful_helps.append(helper)
for helper in useful_helps:
print(helper.upper() + ':', helper.__doc__, '\n')
--
Jim
After not doing dishes for a week and washing spoon after spoon, fork after
fork, knife after knife - I suddenly understand the mathematical concept of
infinity, which is just one more damn thing after another.
More information about the Tutor
mailing list