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


Groups > comp.lang.python > #53082

RE: Can a child access parent attributes if that child added post-hoc as an attribute to the parent?

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <ramit.prasad@jpmorgan.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.004
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'talks': 0.03; 'anyway.': 0.05; 'completeness': 0.07; '22,': 0.09; 'received:155': 0.09; 'def': 0.12; 'class:': 0.16; 'disclaimers': 0.16; 'disclaimers,': 0.16; 'from:addr:jpmorgan.com': 0.16; 'inheritance': 0.16; 'name)': 0.16; "name=''):": 0.16; 'received:155.180': 0.16; 'received:159': 0.16; 'received:159.53': 0.16; 'received:exchad.jpmchase.net': 0.16; 'received:jpmchase.com': 0.16; 'received:jpmchase.net': 0.16; 'securities,': 0.16; 'subject: \n ': 0.16; 'subject:access': 0.16; 'subject:post': 0.16; 'url:disclosures': 0.16; 'url:jpmorgan': 0.16; 'wrote:': 0.18; 'thu,': 0.19; 'aug': 0.22; 'rules': 0.22; 'header:In-Reply- To:1': 0.27; 'names.': 0.31; 'subject:that': 0.31; 'class': 0.32; 'received:169.254': 0.32; 'supposed': 0.32; 'sense': 0.34; 'skip:_ 10': 0.34; 'subject:the': 0.34; 'no,': 0.35; 'point.': 0.35; 'accuracy': 0.36; 'charset:us-ascii': 0.36; 'subject:?': 0.36; 'should': 0.36; 'received:169': 0.37; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'ian': 0.60; 'subject:Can': 0.60; 'information,': 0.61; 'first': 0.61; 'name': 0.63; 'skip:n 10': 0.64; 'map': 0.64; 'more': 0.64; 'purchase': 0.65; 'subject': 0.69; 'legal': 0.71; 'sale': 0.75; 'number):': 0.84; 'received:169.254.8': 0.84; '2013': 0.98
X-DKIM OpenDKIM Filter v2.1.3 sz1.jpmchase.com r7RIcVFO023288
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpmorgan.com; s=smtpout; t=1377628711; bh=pxb5FzcY8oZ6jtvXAbJnD3I0bDUMQ2EhnKQICV2B9xc=; h=From:To:Subject:Date:Message-ID:References:In-Reply-To: Content-Type:content-transfer-encoding:MIME-Version; b=kliwKyIC5NVqXOI6IgCWqctU+k96/juCpsSuorUX1UQzZEJDUlKPwwk3aWSHo5GBr bU5WpkSynslOAREs1KfwKB82lRE9hO1RXONC8BOgvozJgXv2ejmNhEplOi7NGpy/Xg bqu4+hK3JoGtCX6E/tVKwSaDldwtbJ64scfvcxbg=
X-AuditID a97c8566-b7f628e000000303-73-521cf2262c81
From "Prasad, Ramit" <ramit.prasad@jpmorgan.com.dmarc.invalid>
To Python <python-list@python.org>
Subject RE: Can a child access parent attributes if that child added post-hoc as an attribute to the parent?
Thread-Topic Can a child access parent attributes if that child added post-hoc as an attribute to the parent?
Thread-Index AQHOn3tOhFqwvbYDS0+kAqnYoqz0KpmhuL5QgABRCoCAB1/MEA==
Date Tue, 27 Aug 2013 18:38:27 +0000
References <14d50efb-e88b-4259-960a-97ef58e345d8@googlegroups.com> <5B80DD153D7D744689F57F4FB69AF47418683AD8@SCACMX008.exchad.jpmchase.net> <CALwzidk1jS3ZNWV9bEcojJF-mvxtU-E7hSoNe1K9QXzgY21N1w@mail.gmail.com>
In-Reply-To <CALwzidk1jS3ZNWV9bEcojJF-mvxtU-E7hSoNe1K9QXzgY21N1w@mail.gmail.com>
Accept-Language en-US
Content-Language en-US
X-MS-Has-Attach
X-MS-TNEF-Correlator
x-originating-ip [10.67.79.47]
Content-Type text/plain; charset="us-ascii"
content-transfer-encoding quoted-printable
MIME-Version 1.0
X-DLP-FWD Yes
X-Brightmail-Tracker H4sIAAAAAAAAA+NgFvrEKsWRmVeSWpSXmKPExsWyMlDCWVftk0yQwbJr8hZHWq+xOjB6vJj/ hi2AMaqB0SYxLy+/JLEkVSEltTjZVsklszg5JzEzN7VIQVfBqyA3vyg9MU8vOT9XSSEzxVbJ REmhICcxOTU3Na/EVimxoCA1L0XJjksBA9gAlWXmKaTmJeenZOal2yp5BvvrWliYWuoaKtmF ZGQWK6TmJmbmKCRsZM84Pus0Y8FEjop/j1ezNDD+Ze1i5OSQEDCR+LBsJjuELSZx4d56ti5G Lg4hgcOMEpP+bEBwjk6+zwrhbGaUeHi8gwWkhU3AUOL42Sdg7SICyhKHfj9kArGFBfIlFnd/ YoWIF0gsu/qAGcJ2krh38iAbiM0ioCrx++8usBpegRCJQ6u+M0IsuMoo8eXSB7AEp0CgxIxb i8CWMQLd9/3UGrAFzALiEreezGeCuFtAYsme88wQtqjEy8f/oH6Tl3gx5SUbRL2OxILdn6Bs bYllC18zQywWlDg58wnQfA6gxWoS+9bbgpgSAnwS29uqJzBKzEKybBaSQbOQDJqFZNACRpZV jJLFuekZhnrFZUV6pcV6WQW5yRmJxal6eaklmxhBSaWmNW0H492ltocYBTgYlXh4J2yVCRJi TSwrrsw9xCjBwawkwvso+HCgEG9KYmVValF+fFFpTmrxIcYqYKBNZJYSTc4HJry8knhDYzML A1NTQwMLQyMTqggrifPO6pIOEhJIB6bV7NTUgtQimOVMHJxSDYxeZ3z7pwif77x0oOSLvYWh +9zE0KQ/xoLpHw/3VD0r3Xr9WMCN4EPy7oucJqnxRFlbqP+ZzC2nuK1wquO5O9oPPjFtFzU7 ou6yI35dMXupopVjXvndjOSduRM17tyfHjHZ48hNm40zVycfmny2tc07pfGkydr/c/9kFmt7 yK1XFPu32bJk2jYlluKMREMt5qLiRABq0xH5hQMAAA==
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.277.1377628719.19984.python-list@python.org> (permalink)
Lines 41
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1377628719 news.xs4all.nl 15953 [2001:888:2000:d::a6]:42802
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:53082

Show key headers only | View raw


Ian Kelly wrote:
> On Thu, Aug 22, 2013 at 3:26 PM, Prasad, Ramit
> <ramit.prasad@jpmorgan.com.dmarc.invalid> wrote:
> > Bitswapper wrote:
> >>
> >> So I have a parent and child class:
> >>
> >>
> >> class Map(object):
> >>     def __init__(self, name=''):
> >>         self.mapName = name
> >>         self.rules = {}
> >>
> >> class Rule(Map):
> >>     def __init__(self, number):
> >>         Map.__init__(self)
> >>         self.number = number
> >
> > This means that rules will never have a name. I think you need
> >       def __init__(self, name='', number=None):
> >           Map.__init__(self, name)
> >           self.number = number
> 
> No, that's still wrong.  The OP talks abut maps having names, not
> rules having names.  Unless a Rule is-a Map, which sounds unlikely,
> Rule should not be inheriting from Map in the first place.
> 

Good point. Composition definitely makes more sense as I was
confused by how the inheritance was supposed to work anyway. :)


~Ramit



This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email.  

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


Thread

Can a child access parent attributes if that child added post-hoc as an attribute to the parent? Bitswapper <bithead0101@gmail.com> - 2013-08-22 14:03 -0700
  RE: Can a child access parent attributes if that child added post-hoc as an attribute to the parent? "Prasad, Ramit" <ramit.prasad@jpmorgan.com.dmarc.invalid> - 2013-08-22 21:26 +0000
    Re: Can a child access parent attributes if that child added post-hoc as an attribute to the parent? Bitswapper <bithead0101@gmail.com> - 2013-08-22 15:00 -0700
      Re: Can a child access parent attributes if that child added post-hoc as an attribute to the parent? Bitswapper <bithead0101@gmail.com> - 2013-08-23 07:11 -0700
  Re: Can a child access parent attributes if that child added post-hoc as an attribute to the parent? Ian Kelly <ian.g.kelly@gmail.com> - 2013-08-22 15:59 -0600
    Re: Can a child access parent attributes if that child added post-hoc as an attribute to the parent? Bitswapper <bithead0101@gmail.com> - 2013-08-23 12:39 -0700
  RE: Can a child access parent attributes if that child added post-hoc as an attribute to the parent? "Prasad, Ramit" <ramit.prasad@jpmorgan.com.dmarc.invalid> - 2013-08-27 18:38 +0000

csiph-web