Language Selection

English French German Italian Portuguese Spanish

Semantics of Python variable names from a C++ perspective

Filed under
HowTos

If you are going to start programming in Python and come from languages like C or C++, there are a couple of things you should know about variable names. In Python, variable names do not have the same behaviour as in C++. Part of this is clarified in the Python documentation, but I’ll try to give specific examples of things that work and don’t work as you may expect, and why.

All variables are references

Yes, that’s right. In Python, all variables are references. In C++, a reference is a type of data that behaves like a pointer but that has “normal” variable syntax. Other languages coined the name alias for this type of data. In other words:

int foo = 3;
int &bar = foo;

When creating the reference to int named bar, both foo and bar are names for the same variable or object.

Full Story.

More in Tux Machines

Linux 4.9-rc8

So if anybody has been following the git tree, it should come as no surprise that I ended up doing an rc8 after all: things haven't been bad, but it also hasn't been the complete quiet that would have made me go "no point in doing another week". Extra kudos to Arnd, who actually root-caused the incredibly annoying "modversions do not work with new versions of binutils", bisecting it to a particular change to symbol handling in binutils, and then adding a small one-liner patch to the kernel to work around the issue. We already had other workarounds in place, but it's always good to know exactly what in the tool chain changed to cause things like this. Read more Also: Linux Kernel 4.9 Slated for December 11 Release as Linus Torvalds Outs RC8 Linux 4.9-rc8 Kernel Released