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


Groups > comp.lang.python > #32154

RE: Appending a list using list obtained from a class

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.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.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; "'',": 0.07; 'append': 0.07; 'completeness': 0.07; 'main()': 0.07; 'python': 0.09; 'lst': 0.09; 'objects.': 0.09; 'received:155': 0.09; 'repr': 0.09; 'subject:using': 0.09; 'def': 0.10; 'blocks': 0.16; 'disclaimers': 0.16; 'disclaimers,': 0.16; 'from:addr:jpmorgan.com': 0.16; 'received:155.180': 0.16; 'received:159.53': 0.16; 'received:159.53.110': 0.16; 'received:bankone.net': 0.16; 'received:exchad.jpmchase.net': 0.16; 'received:jpmchase.com': 0.16; 'received:jpmchase.net': 0.16; 'received:svr.bankone.net': 0.16; 'securities,': 0.16; 'subject:class': 0.16; 'type:': 0.16; 'url:disclosures': 0.16; 'url:jpmorgan': 0.16; 'wrote:': 0.17; 'version.': 0.17; '>>>': 0.18; 'code.': 0.20; 'to:name:python- list@python.org': 0.20; 'trying': 0.21; 'smallest': 0.22; 'this:': 0.23; 'seems': 0.23; 'received:169.254': 0.24; 'header:In-Reply- To:1': 0.25; 'am,': 0.27; 'guess': 0.27; 'accuracy': 0.27; 'subject:list': 0.28; 'post': 0.28; 'appending': 0.29; 'prints': 0.29; 'str': 0.29; 'received:169': 0.29; 'skip:_ 10': 0.29; 'class': 0.29; 'usually': 0.30; 'returned': 0.30; 'version,': 0.30; 'helpful': 0.30; 'code': 0.31; 'point': 0.31; 'problem.': 0.32; 'addresses': 0.32; 'print': 0.32; 'getting': 0.33; 'problem': 0.33; 'to:addr:python-list': 0.33; 'likely': 0.33; 'themselves': 0.33; 'another': 0.33; 'text': 0.34; 'list': 0.35; 'whatever': 0.35; 'expected': 0.35; 'posting': 0.35; 'something': 0.35; 'list.': 0.35; 'but': 0.36; 'method': 0.36; 'charset:us- ascii': 0.36; 'being': 0.37; 'why': 0.37; 'subject:: ': 0.38; 'object': 0.38; 'shows': 0.38; 'instead': 0.39; 'to:addr:python.org': 0.39; 'help': 0.40; 'your': 0.60; 'skip:a 30': 0.60; 'most': 0.61; 'you.': 0.61; 'containing': 0.61; '(that': 0.62; 'provide': 0.62; 'helps': 0.63; 'p.s.': 0.63; 'information': 0.63; 'information,': 0.63; 'url:email': 0.63; 'dont': 0.64; 'legal': 0.65; 'subject': 0.66; 'purchase': 0.67; 'sale': 0.76; 'received:169.254.8': 0.84; 'subject:Appending': 0.84; 'suspicion': 0.84
X-DKIM OpenDKIM Filter v2.1.3 sj3.jpmchase.com q9PJ75HS024058
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpmorgan.com; s=smtpout; t=1351192025; bh=xtUfVva2WIDsjK05BrFw0lkIwId0Z0jLI41bCn9pdAI=; h=From:To:Subject:Date:Message-ID:References:In-Reply-To: Content-Transfer-Encoding:MIME-Version:Content-Type; b=rVf26rWrjGrVWUtcoCnUaCzCS4rRTfEsS+wq+1xTsvsppkKGHnyw3YSNhSLJS8QnN 2GhPMZjKiK6EOK5FMUs+38ddFrIbPTmVzK93FFKF8yYJTxwHh/MtllZq221oAvz0M6 L0nSqktwaddhoMquQZ3mXzDGwYfpt8Kq2s6jfMDY=
From "Prasad, Ramit" <ramit.prasad@jpmorgan.com>
To "python-list@python.org" <python-list@python.org>
Subject RE: Appending a list using list obtained from a class
Thread-Topic Appending a list using list obtained from a class
Thread-Index AQHNsfUTgRThgLzQNECBK6tDGWLKppfIyoyAgAAA5gCAAAGJAIAAAs2AgAABKACAAY5tAA==
Date Thu, 25 Oct 2012 19:06:54 +0000
References <CAFqGZRGcM+kuW3zf85mcBfvBG=FBd2CCm5o-zBu9mVYp-ehkvQ@mail.gmail.com> <1BA49B0B-47E0-4683-9A49-FC2DFCC5C7C2@gmail.com> <CAFqGZRHxfmmWXjBxU2YixaJN6PQhqgMrqc5k-m-ujV_Mxn_2=g@mail.gmail.com> <E6ED38F6-63F9-4330-A5D5-EB5656D8D6FB@gmail.com> <CAFqGZRFHdsJ6w2kKaS_6xyKL0ddCYJbsjm1kjTghx0ukQH-hVw@mail.gmail.com> <65ED09AC-A4A5-4502-BF39-F665F25F96A8@gmail.com>
In-Reply-To <65ED09AC-A4A5-4502-BF39-F665F25F96A8@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-Transfer-Encoding quoted-printable
MIME-Version 1.0
X-DLP-FWD Yes
Content-Type text/plain; charset="us-ascii"
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.2860.1351192034.27098.python-list@python.org> (permalink)
Lines 35
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1351192034 news.xs4all.nl 6890 [2001:888:2000:d::a6]:53938
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:32154

Show key headers only | View raw


Demian Brecht wrote:
> On 2012-10-24, at 8:00 AM, inshu chauhan <insideshoes@gmail.com> wrote:
> 
> > Yes, a Class method returns a list. I am trying to append this in main() to make another list.
> > But the list i am getting after appending i showing addresses like this '<__main__.Point object at
> 0x0254FAB0>' but if i print the same in the same loop its showing me numbers which i want. Why I dont know ??
> 
> If you can, please post the relevant blocks of code. That'll be a tremendous help in figuring out your problem.
> 

I would like to re-iterate that posting the relevant code is very
helpful and the best way for us to help you. Everything below is an
educated guess based on the information you provided.


Based on the text '<__main__.Point object at 0x0254FAB0>', it seems
like the object being returned is most likely NOT a list but instead a 
Point class that is iterable. Either that or it is a list of Point 
objects. To find out exactly, try something like this:

lst = # whatever your class is returning.
print 'LIST - type : ', type(lst) '\trepr: ', repr(lst), '\tstr :', str(lst)
for p in lst[-1:]:
    print 'POINT - type: ', type(p) '\trepr: ', repr(p), '\tstr :', str(p)

My suspicion is that when you print the list containing
points/addresses it prints the repr version. When you print the 
points/addresses themselves it prints the str version.

>>> class t(object):
...     def __str__(self):
...         return 'str'
...     def __repr__(self):
...         return 'repr'
...     
>>> a = t()
>>> print [a] 
[repr]
>>> print a
str
>>> print a.__class__.__base__.__repr__(a)
<__pieshell__.t object at 0x11B28F10>

Hope that helps you to understand what is going on.

Ramit Prasad

P.S. Usually it is best to specify, Python version, OS version,
expected input/output, and the smallest code sample you can provide
that shows the problem (that any reader of your message can run).
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 | Next | Find similar | Unroll thread


Thread

RE: Appending a list using list obtained from a class "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-10-25 19:06 +0000

csiph-web