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


Groups > comp.lang.python > #21993

Re: class checking its own module for an attribute

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rodperson@rodperson.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.008
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'subject:module': 0.04; 'rod': 0.07; '21,': 0.09; 'am,': 0.12; 'constants': 0.16; 'sys.argv[0]': 0.16; '\xa0this': 0.16; 'cc:addr:python-list': 0.16; 'wed,': 0.17; 'wrote:': 0.18; 'cheers,': 0.20; 'header:In- Reply-To:1': 0.22; '-0700': 0.23; 'works.': 0.23; '\xa0if': 0.23; 'cc:2**0': 0.26; 'module': 0.26; 'import': 0.27; 'tried': 0.27; 'importing': 0.29; 'cc:addr:python.org': 0.29; 'seem': 0.29; 'chris': 0.30; 'there': 0.33; 'thank': 0.35; 'none': 0.35; 'question': 0.36; 'reference': 0.37; 'received:128': 0.38; 'doing': 0.38; 'should': 0.38; 'itself.': 0.39; 'subject:its': 0.84; 'value):': 0.84; 'subject:own': 0.91
Date Wed, 21 Mar 2012 13:06:55 -0400
From Rod Person <rodperson@rodperson.com>
To Chris Rebert <clp2@rebertia.com>
Subject Re: class checking its own module for an attribute
In-Reply-To <CAMZYqRS5YC9xBFfynEVpLDwzOhJwFm4bdj3NdLuat4=C5UApQA@mail.gmail.com>
References <20120321112503.00006eb5@unknown> <CAMZYqRS5YC9xBFfynEVpLDwzOhJwFm4bdj3NdLuat4=C5UApQA@mail.gmail.com>
X-Mailer Claws Mail 3.7.10cvs7 (GTK+ 2.16.6; i586-pc-mingw32msvc)
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
Cc "python-list@python.org" <python-list@python.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.866.1332349617.3037.python-list@python.org> (permalink)
Lines 33
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1332349617 news.xs4all.nl 6899 [2001:888:2000:d::a6]:49432
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:21993

Show key headers only | View raw


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'

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


Thread

Re: class checking its own module for an attribute Rod Person <rodperson@rodperson.com> - 2012-03-21 13:06 -0400

csiph-web