identifier

How can I check if an identifier is dunder or class-private (i.e. will be mangled)?

How can I check if an identifier is dunder or class-private (i.e. will be mangled)? Question: I’m writing a project that gives advice about variable names, and I want it to tell if a name matches any of the reserved classes of identifiers. The first one ("private") is pretty straightforward, just name.startswith(‘_’), but dunder and …

Total answers: 1

Issue in character identifier for abs() in map() Python

Issue in character identifier for abs() in map() Python Question: Here the only one problem: list(map(abs, [−1, −2, 0, 1, 2])) ^ invalid character in identifier abs should do it in right way, but map had a problem. So, how to solve this problem? Asked By: whoami || Source Answers: You’ve got the Unicode minus …

Total answers: 2

Fixed identifier for a machine (uuid.getnode)

Fixed identifier for a machine (uuid.getnode) Question: I’m trying to find something I can use as a unique string/number for my script that is fixed in a machine and easily obtainable(cross-platform). I presume a machine would have a network card. I don’t need it to be really unique, but the necessary is it should be …

Total answers: 4

Identifier normalization: Why is the micro sign converted into the Greek letter mu?

Identifier normalization: Why is the micro sign converted into the Greek letter mu? Question: I just stumbled upon the following odd situation: >>> class Test: µ = ‘foo’ >>> Test.µ ‘foo’ >>> getattr(Test, ‘µ’) Traceback (most recent call last): File “<pyshell#4>”, line 1, in <module> getattr(Test, ‘µ’) AttributeError: type object ‘Test’ has no attribute ‘µ’ …

Total answers: 2

Are Python variables pointers? Or else, what are they?

Are Python variables pointers? Or else, what are they? Question: Variables in Python are just pointers, as far as I know. Based on this rule, I can assume that the result for this code snippet: i = 5 j = i j = 3 print(i) would be 3. But I got an unexpected result for …

Total answers: 9

Unicode identifiers in Python?

Unicode identifiers in Python? Question: I want to build a Python function that calculates, and would like to name my summation function Σ. In a similar fashion, would like to use Π for product, and so on. I was wondering if there was a way to name a python function in this fashion? def Σ …

Total answers: 5

What is the meaning of single and double underscore before an object name?

What is the meaning of single and double underscore before an object name? Question: What do single and double leading underscores before an object’s name represent in Python? Asked By: Ram Rachum || Source Answers: Single Underscore In a class, names with a leading underscore indicate to other programmers that the attribute or method is …

Total answers: 18