Path: csiph.com!x330-a1.tempe.blueboxinc.net!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'instance,': 0.05; 'function,': 0.07; 'python': 0.07; 'called.': 0.09; 'str': 0.09; 'subject:string': 0.09; '>>>': 0.12; 'def': 0.13; 'subject:joining': 0.16; 'traceback': 0.16; '(most': 0.16; 'cheers,': 0.20; 'seems': 0.21; 'header:In-Reply-To:1': 0.22; 'last):': 0.23; 'example': 0.24; 'chris': 0.27; "doesn't": 0.28; 'skip:" 30': 0.29; 'class': 0.29; 'work:': 0.29; 'implement': 0.30; "won't": 0.30; 'typeerror:': 0.31; "skip:' 10": 0.32; 'to:addr:python-list': 0.32; "i've": 0.33; 'implemented': 0.33; 'skip:" 10': 0.34; 'post': 0.34; 'file': 0.35; '"",': 0.35; 'sequence': 0.38; 'but': 0.38; 'to:addr:python.org': 0.39; 'best': 0.60; 'special': 0.66; 'received:(helo localhost)': 0.73; 'subject:Custom': 0.84; 'received:ro': 0.91 Date: Mon, 9 May 2011 23:25:27 +0300 From: Claudiu Popa X-Priority: 3 (Normal) To: python-list@python.org Subject: Re: Custom string joining In-Reply-To: <4DC84B2E.9090209@free.fr> References: <254518825.20110507153133@bitdefender.com> <4DC84B2E.9090209@free.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BitDefender-Spam: No (0) X-BitDefender-SpamStamp: v1, build 2.8.97.149134, SQMD Hits: InvalidIPBytes34 97.192.25.0, rbl score: 0(0), bayes score: 500(0), pbayes score: 500(0), neunet score: 0(0), flags: [NN_LEGIT_BITDEFENDER; NN_LAST_COLON; NN_LEGIT_MAILING_LIST_TO], SQMD: 4082bbd4468955e41033a8a5cadf3c08.fuzzy.fzrbl.org, total: 0(775) X-BitDefender-Scanner: Clean, Agent: BitDefender qmail 3.1.0 on elfie.dsd.hq, sigver: 7.37419 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 36 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1304972738 news.xs4all.nl 81484 [::ffff:82.94.164.166]:39324 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:5024 Hello Karim, > You just have to implement __str__() python special method for your=20 > "custom_objects". > Regards > Karim >> Cheers, >> Chris >> -- >> http://rebertia.com I already told in the first post that I've implemented __str__ function, b= ut it doesn't seems to be automatically called. For instance, the following example won't work: >>> class a: def __init__(self, i): self.i =3D i def __str__(self): return "magic_function_{}".format(self.i) >>> t =3D a(0) >>> str(t) 'magic_function_0' >>> "".join([t]) Traceback (most recent call last): File "", line 1, in "".join([t]) TypeError: sequence item 0: expected str instance, a found --=20 Best regards, Claudiu