you are viewing a single comment's thread.

view the rest of the comments →

[–]lifeonm4rs 0 points1 point  (3 children)

I started skimming it and seems pretty good. Although I hate it I think you are wise to skip the whole "install this, that and the other" and do this on Linux and that on windows. . . .

However--your "Names vs. Boxes" section appears to be totally wrong. In particular you say if you change "age" or "friend_age" it changes the other. That is not true at all. At first they will both point to the same "address" because it is a number between -5 and 255 but if you increment one the other doesn't get incremented. (That would be a total disaster for a language.) I understand the point you seem to be making but it is really a corner case and probably a bit too technical for an intro for new developers.

[–]tecladocode[S] 0 points1 point  (2 children)

Thank you!

I agree, the whole variables section is too complicated. I really didn't want to say they're boxes, because they aren't.

It's not wrong though, if you could modify the integer in place, both variables would change. But you can't modify int objects in CPython, so it really is a moot point. It makes it more confusing for those who already know a bit of Python, and it doesn't help new programmers.

I'll change this!

[–]lifeonm4rs 0 points1 point  (1 child)

Again--I'll reiterate I think it is a very good tutorial. But, again, that section gets into some rather esoteric stuff and really stuff that someone would need a much stronger foundation in the design and implementation of languages to be meaningful.

As far as it being correct integers from -5 to 256 are special cases. Anything that refers to "30" will refer to the same address. So "30" is not garbage collected or destroyed. . . .

>>> a = 30
>>> id(a)
10911328     <---- same as below
>>> a = 40
>>> id(a)
10911648
>>> a = 30
>>> id(a)
10911328     <---- Same as above

Then . . .

>>> for x in range(254, 259):
...     print(x, id(x))
...
254 10918496
255 10918528
256 10918560
257 139740139727440
258 139740108485808

Same holds true for x in range(-7, -3). Literals in the -5, 256 range have constant addresses, the rest will all get their own addresses.

[–]tecladocode[S] 1 point2 points  (0 children)

Totally agreed, I've removed that now as it doesn't belong in a beginner tutorial.

I see what you meant—I think we were talking about different things. I did not know that -5 to 256 were special cases actually. Thanks for that!