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


Groups > comp.lang.python > #21991 > unrolled thread

Re: class checking its own module for an attribute

Started byChris Rebert <clp2@rebertia.com>
First post2012-03-21 09:56 -0700
Last post2012-03-21 09:56 -0700
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

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

#21991 — Re: class checking its own module for an attribute

FromChris Rebert <clp2@rebertia.com>
Date2012-03-21 09:56 -0700
SubjectRe: class checking its own module for an attribute
Message-ID<mailman.864.1332349021.3037.python-list@python.org>
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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web