Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #21991

Re: class checking its own module for an attribute

References <20120321112503.00006eb5@unknown>
Date 2012-03-21 09:56 -0700
Subject Re: class checking its own module for an attribute
From Chris Rebert <clp2@rebertia.com>
Newsgroups comp.lang.python
Message-ID <mailman.864.1332349021.3037.python-list@python.org> (permalink)

Show all headers | View raw


On Wed, Mar 21, 2012 at 8:25 AM, Rod Person <rodperson@rodperson.com> wrote:
<snip>
> The question is there a way I can do this with out having to import
> constants when what it's doing is importing itself. It would seem to me
> that there should be a way for a module to reference itself. In that
> thinking I have tried
>
>  if not(hasattr(__file__, value):
>  if not(hasattr(__name__, value):
>
> and even:
>
>  this = sys.argv[0]
>  if not(hasattr(this, value):
>
> None of which works.

http://stackoverflow.com/questions/2933470/how-do-i-call-setattr-on-the-current-module

Cheers,
Chris

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: class checking its own module for an attribute Chris Rebert <clp2@rebertia.com> - 2012-03-21 09:56 -0700

csiph-web