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,050 points
17 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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
53 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
70 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
16 views
+2 votes
3 answers

How can I play an audio file in the background using Python?

down voteacceptedFor windows: you could use  winsound.SND_ASYNC to play them ...READ MORE

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

how can i count the items in a list?

suppose you have a list a = [0,1,2,3,4,5,6,7,8,9,10] now ...READ MORE

answered May 2 in Python by Mohammad
• 1,400 points
56 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
62 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
82 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.