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, 2019 in Python by Anirudh
• 2,090 points
805 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, 2019 by Nymeria
• 3,560 points

Related Questions In Python

+1 vote
1 answer
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,720 points
1,152 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,720 points
1,648 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, 2019 in Python by Junaid
2,220 views
0 votes
2 answers
+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 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,434 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
4,067 views
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,560 points
1,327 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,560 points
1,782 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP