Re: Custom string joining

2011-05-09 Thread Claudiu Popa
Hello Terry, Thanks, I understand now. Tuesday, May 10, 2011, 2:16:24 AM, you wrote: > On 5/9/2011 4:25 PM, Claudiu Popa wrote: >> I already told in the first post that I've implemented __str__ function, >> but it doesn't seems to be automatically called. > No, Python does not auto-coerce to

Re: Custom string joining

2011-05-09 Thread Terry Reedy
On 5/9/2011 4:25 PM, Claudiu Popa wrote: I already told in the first post that I've implemented __str__ function, > but it doesn't seems to be automatically called. No, Python does not auto-coerce to strings (only between numbers). You have to be explicit by calling str. Karim's statement "Yo

Re: Custom string joining

2011-05-09 Thread Martineau
On May 9, 1:25 pm, Claudiu Popa wrote: > Hello Karim, > > > You just have to implement __str__() python special method for your > > "custom_objects". > > Regards > > Karim > >> Cheers, > >> Chris > >> -- > >>http://rebertia.com > > I  already told in the first post that I've implemented __str__ fu

Re: Custom string joining

2011-05-09 Thread Claudiu Popa
Hello Karim, > You just have to implement __str__() python special method for your > "custom_objects". > Regards > Karim >> Cheers, >> Chris >> -- >> http://rebertia.com I already told in the first post that I've implemented __str__ function, but it doesn't seems to be automatically called.

Re: Custom string joining

2011-05-09 Thread Karim
On 05/07/11 16:25, Chris Rebert wrote: On Sat, May 7, 2011 at 5:31 AM, Claudiu Popa wrote: Hello Python-list, I have an object which defines some methods. I want to join a list or an iterable of those objects like this: new_string = "|".join(iterable_of_custom_objects) What is the __

Re: Custom string joining

2011-05-09 Thread Ian Kelly
On Mon, May 9, 2011 at 1:26 PM, Martineau wrote: > Instead of join() here's a function that does something similar to > what the string join() method does. The first argument can be a list > of any type of objects and the second separator argument can likewise > be any type. The result is list of

Re: Custom string joining

2011-05-09 Thread Martineau
On May 7, 5:31 am, Claudiu Popa wrote: > Hello Python-list, > > I  have  an object which defines some methods. I want to join a list or > an iterable of those objects like this: > > new_string = "|".join(iterable_of_custom_objects) > > What   is   the   __magic__  function that needs to be impleme

Re: Custom string joining

2011-05-07 Thread Chris Rebert
On Sat, May 7, 2011 at 5:31 AM, Claudiu Popa wrote: > Hello Python-list, > > I  have  an object which defines some methods. I want to join a list or > an iterable of those objects like this: > > new_string = "|".join(iterable_of_custom_objects) > > What   is   the   __magic__  function that needs

Custom string joining

2011-05-07 Thread Claudiu Popa
Hello Python-list, I have an object which defines some methods. I want to join a list or an iterable of those objects like this: new_string = "|".join(iterable_of_custom_objects) What is the __magic__ function that needs to be implemented for this case to work? I though that __str__