[Tutor] What's the difference between %s and %r?

2011-07-23 Thread amt
Hello! I'm having troubles understanding what is the difference between %s and %r(format characters). I did google and found something on StackOverflow but I don't understand the explanation as it's not beginner orientated. Also, I have this code from learn python the hard way. Why at line 9 doe

Re: [Tutor] What's the difference between %s and %r?

2011-07-23 Thread Wayne Werner
On Sat, Jul 23, 2011 at 7:48 AM, amt <0101...@gmail.com> wrote: > Hello! I'm having troubles understanding what is the difference between %s > and %r(format characters). I did google and found something on > StackOverflow but I don't understand the explanation as it's not beginner > orientated. >

Re: [Tutor] What's the difference between %s and %r?

2011-07-23 Thread Lisi
On Saturday 23 July 2011 13:48:03 amt wrote: > Hello! I'm having troubles understanding what is the difference between %s > and %r(format characters). I did google and found something on > StackOverflow but I don't understand the explanation as it's not beginner > orientated. > > > Also, I have th

Re: [Tutor] What's the difference between %s and %r?

2011-07-23 Thread Martin A. Brown
Hello everybody, : > Hello! I'm having troubles understanding what is the difference between %s : > and %r(format characters). I did google and found something on : > StackOverflow but I don't understand the explanation as it's not beginner : > orientated. : > : > : > Also, I have this co

Re: [Tutor] What's the difference between %s and %r?

2011-07-23 Thread James Reynolds
I just use string{0}.format(arg) format and that solves needing to memorize % whatevers. On Sat, Jul 23, 2011 at 11:08 AM, Martin A. Brown wrote: > > Hello everybody, > > : > Hello! I'm having troubles understanding what is the difference > between %s > : > and %r(format characters). I did goog

Re: [Tutor] What's the difference between %s and %r?

2011-07-23 Thread Joel Goldstick
On Sat, Jul 23, 2011 at 8:48 AM, amt <0101...@gmail.com> wrote: > Hello! I'm having troubles understanding what is the difference between %s > and %r(format characters). I did google and found something on > StackOverflow but I don't understand the explanation as it's not beginner > orientated. >

Re: [Tutor] What's the difference between %s and %r?

2011-07-23 Thread wesley chun
%s = send object to str() first then drop it into the string %r = send object to repr() first then drop it into the string pretty straightforward: >>> x = 'foo' >>> str(x) 'foo' >>> repr(x) "'foo'" why do people do %r at all? to get the quotes for free: :-) >>> x = 'Python' >>> print "What is t

Re: [Tutor] What's the difference between %s and %r?

2011-07-23 Thread wesley chun
i forgot to define these: str() - printable/human-readable string representation of an object repr() - evaluatable string representation of an object (can "eval()" it, meaning it is a string representation that evaluates to a Python object) in other words: x = 'foo' str(x) > 'foo'

Re: [Tutor] What's the difference between %s and %r?

2011-07-26 Thread amt
Hello! Thank you all for writing and helping me out. I now understand the difference between the two format characters. -amt ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo