Language Selection

English French German Italian Portuguese Spanish

Semantics of Python variable names from a C++ perspective

Filed under

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

Leftovers: Software

  • Kafka and syslog-ng
    First of all, let me introduce Kafka, a high-throughput distributed messaging system. It was originally developed by LinkedIn as a backbone of a website activity tracking infrastructure. Once open source, it was developed further under the umbrella of the Apache Foundation. In 2014 Confluent was founded to provide enterprise level support to Kafka users. Kafka is now used by major companies, including Netflix, Twitter and PayPal. There are now many more uses for Kafka: message queuing, log aggregation, stream processing or as a commit log.
  • Nmap 7.00 Has Been Released
    As you may know, Nmap is a command-line network exploration tool that supports ping scanning to determine the online hosts, port scanning techniques and TCP/IP fingerprinting for remote device identification.
  • Atom 1.2.4 Has Been Released
  • Vuze 5.7 (Open-Source BitTorrent Client) Has Been Released
  • Aptik 1.6.6 (Backup Software) Has Been Released
    As you may know, Aptik is an open-source application that enables the users to easily perform and restore backups of PPAs, aplications and packages in Ubuntu, Linux Mint, Elementary OS and other Ubuntu derivates.
  • Linphone 3.9.1 Brings Only Bug-Fixes
    As you may know, Linphone is an open-source VoIP service that allows the users to perform voice calls, video calls and text conversations with friends and other Linphone users.
  • Install QGifer 0.2.3 RC2 on Ubuntu
    Up to date packages are available via some third party PPA, so installing the software on Ubuntu 15.10 Wily Werewolf, Ubuntu 14.04 Trusty Tahr, Linux Mint 17.x, Elementary OS 0.3 Freya and other Ubuntu derivative systems is easy.
  • Wireshark 2.0 Has Been Released
    As you already know, Wireshark is an open-source protocol analyzer software, very used for monitoring the network traffic.
  • Kodi 16.0 Beta 2 “Jarvis” Brings Changes

today's howtos

Leftovers: Gaming

Krita 2.9