I am reading Thinking in Python, by Bruce Eckel, which I find fascinating.
However, I came across the folowing line:
Code:
return ´self´ + self.val
which got the following interpreter complaint:
Code:
File "SingletonPattern.py", line 11
return ´self´ + self.val
^
SyntaxError: invalid syntax
Ok, so I removed the ticks:
Code:
Traceback (most recent call last):
File "SingletonPattern.py", line 22, in <module>
print x
File "SingletonPattern.py", line 11, in __str__
return self + self.val
TypeError: unsupported operand type(s) for +: 'instance' and 'str'
Then I used ordinary single quotes, which produced a string combining self with self.val. Not good.
Finally I dug up the solution in the code folder that comes with the html book and found the following:
Code:
return `self` + self.val
I didn't know python had backticks, like bash.
When I google ticks in python, the search comes up with timer ticks.
Can someone explain ticks to me or point me to a good doc?