Printing modules contents
Dale Strickland-Clark
dale at out-think.NOSPAMco.uk
Thu Dec 7 10:27:29 EST 2000
joonas <keisari_ at hotmail.com> wrote:
>I tried this but it didnt worked.
>
><clip>
>import sys
>list = dir(sys)
>for x in list:
> print x," = ",sys.x
></clip>
>
>Joonas.
>
>
>Michael Hudson wrote:
>>
>> joonas <keisari_ at hotmail.com> writes:
>>
>> > How can I make a script that would print modules contents like below,
>> >
>> > sys
>> > sys.__name__ = "sys"
>> > sys.stdout = "<PyShell.PseudoFile instance at 7fd530>"
>> > sys.winver = "1.5"
>> > sys.etc = "spam"
>>
>> Think "dir" & "repr". Shouldn't be hard.
>>
>> Cheers,
>> M.
>>
>> --
>> 39. Re graphics: A picture is worth 10K words - but only those
>> to describe the picture. Hardly any sets of 10K words can be
>> adequately described with pictures.
>> -- Alan Perlis, http://www.cs.yale.edu/homes/perlis-alan/quotes.html
Try this:
for x in list:
... print 'sys.' + x, '=', sys.__dict__[x]
--
Dale Strickland-Clark
Out-Think Ltd
Business Technology Consultants
More information about the Python-list
mailing list