Please hear my plea: print without softspace

kosh kosh at aesaeion.com
Sat Feb 28 13:15:21 EST 2004


On Saturday 28 February 2004 10:26 am, Valentino Volonghi aka Dialtone wrote:
> In data Sat, 28 Feb 2004 09:44:57 -0700, kosh ha scritto:
> > why not?
> >
> > def pprint(*args):
> >     print ''.join(args)
> >
> > if you want it to be more robust you could do
> >
> > def pprint(*args):
> >     print ''.join(map(str,args))
> >
> > That would try and convert all the items to a string first before joining
> > them.
>
> I would have used the list comprehension solution that Mel Wilson posted
> but I was in a hurry and wrote wrong code...
>
> Actually I don't like map() and I always try to use LC as much as
> possible, I think they are a lot more readable.

I use map, reduce, filter etc pretty rarely but I think in this case it is a 
very simple way to say what I mean there. I just want str called on every 
element in args and have a list returned with that result. 

I use list comps a lot in other places but things like map do have their 
place.




More information about the Python-list mailing list