Skip to content

Same name for an attribute and a function #1926

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mrcloma opened this issue May 1, 2020 · 2 comments · Fixed by #1943
Closed

Same name for an attribute and a function #1926

mrcloma opened this issue May 1, 2020 · 2 comments · Fixed by #1943

Comments

@mrcloma
Copy link

mrcloma commented May 1, 2020

Hi, I'm new to programming and I'm not sure if it's a problem, but the code(
Python/data_structures/queue/queue_on_list.py) have the same name for an attribute and a function.

class Queue:
    def __init__(self):
        self.entries = []
        self.length = 0
        self.front = 0

    def front(self):
        return self.entries[0]

When executed it gives me the error:
TypeError: 'int' object is not callable

@cclauss
Copy link
Member

cclauss commented May 1, 2020

You are correct. It is an anti-pattern to have the same name for both an attribute and a method of the same class.

@scriptdruid
Copy link
Contributor

@cclauss , can I work on this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants