Attributions getting confusing, so I have snipped and rewritten: Dave Storrs writes: > > Actually, this would be a good reason to have a function called > > "literal" -- if it went both ways. So, I could do this: > > > > print literal(200+55):hex; # == print "0xff"; > > print literal("0xff)); # == print 255; >
[EMAIL PROTECTED] wrote: > why not str ? > > > print str( 200+55 :"format"=>"hex"); # == print "0xff"; > > print str("0xff"); # == print 255; It's just a cognitive difference--in my example, literal() would return a string if given a number and return a number if given a string (in each case, the output would be precisely what you would get had you written the input as a literal in the other format, hence the 'literal' name). In your example, str() does the same thing--but I would suggest that a function named 'str' should always return a string. --Dks