Pulling numbers from ASCII filename not working

Steven D'Aprano steve at REMOVETHIScyber.com.au
Wed Jan 25 20:18:39 EST 2006


On Wed, 25 Jan 2006 16:57:47 -0800, IamIan wrote:

>>Dude. You're trying to add a string to an int. What did you think would
>>happen?
> 
> Dude. I thought it would concatenate the value for LatInt with the rest
> of the sentence; I wasn't literally trying to add them. Apparently you
> can only concatenate strings like this in Python.

No. An interactive session is your friend. You can concatenate all sorts
of things, not just strings:

>>> [2, 3, 4] + [5]
[2, 3, 4, 5]
>>> (2, 3, 4,) + (5,)
(2, 3, 4, 5)

What should 4 + "5" give you? 9 or "45"?

Your description of the problem was *utterly* wrong. You said you get an
error when you try to print LatInt; but that's not true, is it? print
LatInt works fine, I bet. If you had actually posted the traceback, rather
than trying to describe it in your own words, your problem would have been
solved after one post. In other words, you sent us all on a wild goose
chase.

But the main thing is, the traceback was telling you exactly what was
wrong. Listen to it, it knows.



-- 
Steven.




More information about the Python-list mailing list