[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Re: How to get current module object

Gabriel Genellina

2/18/2008 7:56:00 AM

En Sun, 17 Feb 2008 16:25:44 -0200, Alex <noname9968@gmail.com> escribi�:

> Can I get reference to module object of current module (from which the
> code is currently executed)? I know __import__('filename') should
> probably do that, but the call contains redundant information (filename,
> which needs to be updated), and it'll perform unnecessary search in
> loaded modules list.
>
> It shouldn't be a real problem (filename can probably be extracted from
> the traceback anyway), but I wonder if there is more direct and less
> verbose way.

sys.modules[__name__]

Why do you want to get the module object? globals() returns the module
namespace, its __dict__, perhaps its only useful attribute...

--
Gabriel Genellina

3 Answers

mm

6/9/2014 12:52:00 AM

0

On Mon, 9 Jun 2014 00:31:25 +0000 (UTC),
"henry.dot.goodman.at.virgin.net" <henry.p.goodman@gmail.com> wrote:

>On Sunday, June 8, 2014 11:12:50 PM UTC+1, googy wrote:
>> On Sun, 8 Jun 2014 21:51:32 +0000 (UTC), "Evertjan."
>>
>> <exxjxw.hannivoort@inter.nl.net> wrote:
>>
>>
>>
>> >topazgalaxy <topazgalaxy@gmail.com> wrote on 08 jun 2014 in
>>
>> >soc.culture.jewish.moderated:
>>
>> >
>>
>> >>> > they may not have been there to
>>
>> >>> > swap at all for our soldier.
>>
>> >>>
>>
>> >>> Why is he "your" soldier?
>>
>> >
>>
>> >> My use of the word "our" is referring to an American soldier
>>
>> >
>>
>> >How strange imply that in an NG.
>>
>> >How were we to know that?
>>
>>
>>
>> FWIW, I knew what she meant. She didn't mean the newsgroup's
>>
>> solider, or the Jews' solider, or her county's soldier, and probably not
>>
>> the soldier of her and her parents, and all that was left was her
>>
>> country's solider. As an American, I'd call him "our soldier" too.
>>
>>
>As an Englishman he's not my soldier
>Henry Goodman

I figured that. If you had said "our soldier", I would have been
confused.
--

Meir
It is better to eat an onion in Jerusalem than a cockerel in Egypt. 1055CE

mirjam

6/9/2014 3:24:00 AM

0

On Monday, June 9, 2014 12:51:32 AM UTC+3, Evertjan. wrote:
> topazgalaxy <topazgalaxy@gmail.com> wrote on 08 jun 2014 in
>
> soc.culture.jewish.moderated:
>
>
>
> >> > they may not have been there to
>
> >> > swap at all for our soldier.
>
> >>
>
> >> Why is he "your" soldier?
>
>
>
> > My use of the word "our" is referring to an American soldier
>
>
>
> How strange imply that in an NG.

Because the discussion was about that event ,,,,
mirjam
>
> How were we to know that?
>
>
>
> --
>
> Evertjan.
>
> The Netherlands.
>
> (Please change the x'es to dots in my emailaddress)

Evertjan.

6/9/2014 9:40:00 AM

0

"henry.dot.goodman.at.virgin.net" <henry.p.goodman@gmail.com> wrote on 09
jun 2014 in soc.culture.jewish.moderated:

>> country's solider. As an American, I'd call him "our soldier" too.
>>
>>
> As an Englishman he's not my soldier
> Henry Goodman

Indeed. Not mine either.

This is a NG available on usenet,
so private conversations, where the "group" members
are expected to know eachother and their allegiances,
are not acceptable. At least not to me.

When saying "our" and not meaning the NG,
one should specify the context.

Even then, not being the military type,
a soldier of "my" country is not neccessarily "my" soldier.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)