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
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.
>
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
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
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
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.
>
%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
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'
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