Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #37961
| Path | csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <d@davea.name> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.003 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'python,': 0.02; 'alias': 0.07; 'subject:2.7': 0.09; 'def': 0.10; 'subject:python': 0.11; 'b()': 0.16; 'old-style': 0.16; 'subject:class': 0.16; 'wrote:': 0.17; 'instance': 0.17; 'bit': 0.21; '2.x': 0.22; 'object.': 0.22; 'class.': 0.23; 'pass': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'creating': 0.26; 'subject:/': 0.28; 'skip:_ 10': 0.29; 'class': 0.29; 'basic': 0.30; 'print': 0.32; 'getting': 0.33; 'to:addr:python-list': 0.33; 'pm,': 0.35; 'but': 0.36; 'should': 0.36; 'execute': 0.37; 'why': 0.37; 'quite': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'help': 0.40; 'received:74.208': 0.71 |
| Date | Wed, 30 Jan 2013 15:20:33 -0500 |
| From | Dave Angel <d@davea.name> |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130106 Thunderbird/17.0.2 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: derived class name in python 2.6/2.7 |
| References | <DCD75728F460F14586086EA606E8308273BD623C@ACEVXCHMBX1001.ADVENTISTCORP.NET> |
| In-Reply-To | <DCD75728F460F14586086EA606E8308273BD623C@ACEVXCHMBX1001.ADVENTISTCORP.NET> |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Provags-ID | V02:K0:NBBl7R7tSydtduOGS6Wk+gcPj52tsfbAVUnTMzEp+ny /tDFGLM0OjsgUIHC7lS3vTT8ElKzI8G6ldO4Oq3xSoBecH9Dtn beS/FqD+BajUTg4cFMgV5UD+QlBf1bROU9BkxgIYSvJc+KX02O Z8CMIQxFqFmZdV7RYwlkc+NrIsI8oJTxm8ylDFTzoW9SDjkEu5 5vQamWWdpZGdBK2aBu8LMiIA/2DlSHJ2dmh2uNiGFAdC5sP1p5 fok2r9TPxvIsO3yVhzUAhJwXXHgADlfzBpr0bRY8E3E0RZshEl FjVxAvnEtWMlj6cMB2cbw9ilPrZ5MOLAu3+gqfoaBdTD3cO5A= = |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| 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.1229.1359577261.2939.python-list@python.org> (permalink) |
| Lines | 29 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1359577261 news.xs4all.nl 6867 [2001:888:2000:d::a6]:42103 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:37961 |
Show key headers only | View raw
On 01/30/2013 03:05 PM, Sells, Fred wrote: > This is simple, but I just cannot find it after quite a bit of searching > > I have this basic design > > class A: > def __init__(self): > print 'I am an instance of ', self.__class__.name > > class B(A): > pass > > > X = B > I would like this to print "I am an instance of B" but I keep getting A. Can someone help me out here. > Why would creating an alias for class B execute the initializer for either class? perhaps you meant: x = B() BTW, since you're on 2.x python, you should derive A from object. Otherwise it's an old-style class. -- DaveA
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: derived class name in python 2.6/2.7 Dave Angel <d@davea.name> - 2013-01-30 15:20 -0500
csiph-web