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


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

Re: class checking its own module for an attribute

Started byRod Person <rodperson@rodperson.com>
First post2012-03-21 13:06 -0400
Last post2012-03-21 13:06 -0400
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 Rod Person <rodperson@rodperson.com> - 2012-03-21 13:06 -0400

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

FromRod Person <rodperson@rodperson.com>
Date2012-03-21 13:06 -0400
SubjectRe: class checking its own module for an attribute
Message-ID<mailman.866.1332349617.3037.python-list@python.org>
On Wed, 21 Mar 2012 09:56:57 -0700
Chris Rebert <clp2@rebertia.com> wrote:

> 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

Thank you!

-- 

Rod Person  http://www.rodperson.com  rodperson@rodperson.com

'Silence is a fence around wisdom'

[toc] | [standalone]


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


csiph-web