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

Openwashing

Games for GNU/Linux

  • Achieve Global Domination in Agenda, Coming to PC, Mac, Linux on September 21
    Agenda, a strategy simulation from Exordium Games where players control an evil organization seeking world domination, will come to Windows, Mac, and Linux on Sept. 21st, 2016. Players will direct covert operations to increase their control over countries' economies, political parties, militaries, science institutions and media outlets. Operations will entail everything from low key kickbacks to military leaders to the brazen assassination of political rivals.
  • Vendetta Online 1.8.385 MMORPG Drastically Improves Chat and Effect Delays
    Guild Software announced the release of a new maintenance update for their popular and cross-platform Vendetta Online MMORPG (Massively Multiplayer Online Role-Playing Game) 3D space combat title. According to the release notes, Vendetta Online 1.8.385 is an important milestone, and it's here to drastically improve the chat and effect delays reported by users during larger capship battles by implementing a new dynamic server packet-queuing and priority change system, which was tested internally with 200 close-proximity capships per battle.
  • Looks like Subnautica from the Natural Selection 2 developers won't get Linux support
    This is quite sad, it seems we have been left wondering for a while (years) about Subnautica, but a developer has now confirmed a Linux version is not being worked on.

Leftovers: Software

  • GNOME Music 3.22 to Offer Better Sorting of Songs in Albums and Artists Views
    GNOME Music 3.22 is on its way, as well as the GNOME 3.22 desktop environment, due for release next month on September 21, and it looks like we're now able to get an early taste of what's coming in GNOME's default music playback app. GNOME Music 3.22 Beta has been released, distributed as part of the first Beta development milestone of the upcoming GNOME 3.22 desktop environment, and it promises to offer better sorting of tracks in the Artists and Albums views, a "new playlist" entry to the Playlist dialog, and new keyboard shortcuts.
  • bitmath-1.3.1 released
    bitmath is a Python module I wrote which simplifies many facets of interacting with file sizes in various units as python objects. A few weeks ago version 1.3.1 was released with a few small updates.
  • NetworkManager 1.4 Released
  • NetworkManager 1.4: with better privacy and easier to use
    After we released version 1.0 of NetworkManager, it took us sixteen months to reach the 1.2 milestone. This means that it took over a year for some newly added features to reach the user base. Now we are releasing the next major release after just four months.

More on Linux 'Birthday'

  • Linux celebrates its 25th birthday today
    Today marks 25 years since Linus Torvalds sent out his industry-changing message, asking for help testing a new operating system he had devised. On 25 August, 1991, he wrote: “I'm doing a (free) operating system (just a hobby, won't be big and professional like gnu) for 386(486) AT clones. This has been brewing since april, and is starting to get ready. I'd like any feedback on things people like/dislike in minix, as my OS resembles it somewhat (same physical layout of the file-system (due to practical reasons) among other things).”
  • Linux, the world's most widespread OS, turns 25 years old
    While Linux may not be the first operating system you think of, it is one of the most significant computing platforms ever developed. Linux powers everything from the world's largest supercomputers to Android phones. Today, it turns 25 years old.
  • Fedora project leader Matthew Miller talks world domination on Linux's 25th birthday
    Linux is now a quarter-century old. August 25, 2016 marks 25 years since the day Linus Torvalds posted a message announcing Linux to the world. “I’m doing a (free) operating system (just a hobby, won’t be big and professional like gnu),” he wrote. Since then, Linux has taken the world by storm, powering millions of servers, a countless number of embedded devices, and most of the smartphones in the world—by way of Android.
  • Linux Turns 25 Years Old
  • The Queue: How did you discover Linux?