I am using a built-in function name as a method identifier and sometimes as an attribute in Python, is this bad?

0 votes

Hi all, I am completely aware of the fact that I know I shouldn't be using built-in function names as the variable identifiers in my code. 

My question is simple: Are there any specific methodologies or reasons that stop us from not making use of them as the identifier or the attribute?

Here's an example for better understanding. How safe is it to write my_object.id = 5?

Or let's say defining the instance method dict in a class of my own?

All help appreciated!

Jan 23 in Python by Anirudh
• 2,060 points
19 views

1 answer to this question.

0 votes
Hi, good question. The thing is that it might end up confusing the programmer more than the interpreter.

The interpreter can figure it out but the decreased readability will add a bit of confusion to the user reading it. It is always a strong recommendation that the usage of built-in names for the use of methods and attributes should be avoided just for this purpose.

There is another negative side to this. There are many Python editors and using this obviously changes the syntax heightening property and thereby again confusing the user or even ending up with an error message.
answered Jan 23 by Nymeria
• 3,500 points

Related Questions In Python

0 votes
1 answer

Is there a foreach function in python and is there a way to implement it if there isnt any

Every occurence of "foreach" I've seen (PHP, ...READ MORE

answered Aug 31, 2018 in Python by charlie_brown
• 7,710 points
64 views
0 votes
1 answer

How to correctly return an a dictionary as an output in zappier code using python?

David here, from the Zapier Platform team. ...READ MORE

answered Dec 3, 2018 in Python by charlie_brown
• 7,710 points
88 views
0 votes
1 answer

Is there a way to list out in-built variables and functions of Python?

The in-built variables and functions are defined ...READ MORE

answered May 14 in Python by Junaid
26 views
0 votes
1 answer

Is it possible to run a function in Python using the command line?

Suppose your file name is demo.py and ...READ MORE

answered Jun 26 in Python by Neel
• 1,610 points
30 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 128 views
+4 votes
6 answers
0 votes
1 answer

Shortest path from source to and from a negative cycle using Bellman Ford in Python

class NegativeWeightFinder: def __init__(self, graph: nx.Graph): ...READ MORE

answered Nov 13, 2018 in Python by Nymeria
• 3,500 points
78 views
0 votes
1 answer

Is multi-threading supported in Python and can it speed up execution time as well?

The GIL does not prevent threading. All ...READ MORE

answered Nov 22, 2018 in Python by Nymeria
• 3,500 points
112 views