[Tutor] Getting import to use a variable name

Alan Gauld alan.gauld at btinternet.com
Wed May 20 11:15:58 CEST 2015


On 20/05/15 09:02, Peter Otten wrote:

> $ python3 -i shorthelp.py
>>>> shorthelp("whatever")
> No module named 'whatever'
>>>> shorthelp(42)
> int(x=0) -> integer
> -------------------
> bit_length   int.bit_length() -> int
> conjugate    Returns self, the complex conjugate of any int.
> denominator  int(x=0) -> integer
...
>>>> shorthelp("pwd")
> This module provides access to the Unix password database.
> ----------------------------------------------------------
> getpwall       getpwall() -> list_of_entries
> getpwnam       getpwnam(name) -> (pw_name,pw_passwd,pw_uid,
> getpwuid       getpwuid(uid) -> (pw_name,pw_passwd,pw_uid,


Thats pretty cool Peter. I can see me using that pretty often.
I think I'll be stealing that for my collection of useful tools. :-)

Kudos to Jim for the concept too.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list