[Tutor] Help with building bytearray arrays
Alan Gauld
alan.gauld at yahoo.co.uk
Sat Sep 8 06:13:19 EDT 2018
On 08/09/18 04:57, Chip Wachob wrote:
> was my attempt at 'setting' the type of the variable.
A variable in Python is just a name. It has no type.
Only values have types. So you can set (or change)
the type of a value but not of a variable.
> Coming from a 'C' background, I find the lack of typing in Python to
> be confusing.
There is no shortage of typing in Python its just
applied to the values(objects) not to their labels.
> I'm used to working with bytes / words signed and
> unsigned for a reason.
The same applies in Python. You just have to separate
the concepts of variable name and variable value.
In C those two concepts get kind of squished together
but in Python the name/value duality is strong.
You can always check the type of an object by using
the type() function or if you think a type error is
likely catch it when it happens with:
try:...
except TypeError:....
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list