How can an int be '+' with a tuple?

Ben Finney ben+python at benfinney.id.au
Sun Jun 3 03:18:45 EDT 2018


Jach Fong <jfong at ms4.hinet.net> writes:

> Yes, (I think) I know the *any usage, but don't know their type will be
> changed after unpack?

You are exhibiting a (very common! this is not a criticism)
misunderstanding of how Python's data model and assignment work.

An object in Python never changes type. Any name can be bound to any
object, which may be why you are seeing changes in type; instead, follow
the object, not the name.

Leave behind anything you have brought from other languages about
“variables” or passing parameters to function parameters. Instead,
understand how Python does them.

You should work through the Python tutorial, from beginning to end,
<URL:https://docs.python.org/3/tutorial/>. “Work through” means do the
work of experimenting with the exercises until you understand them.

To better understand names, type of an object, and binding a name to an
object, see Ned Batchelder's presentation “Facts and myths about Python
names and values” <URL:http://nedbatchelder.com/text/names.html>.

-- 
 \         “Our urge to trust our senses overpowers what our measuring |
  `\         devices tell us about the actual nature of reality.” —Ann |
_o__)                                           Druyan, _Cosmos_, 2014 |
Ben Finney




More information about the Python-list mailing list