Skip to content

Conversation

altbrace
Copy link

@altbrace altbrace commented Mar 5, 2024

for easy object comparison by image URL.

Usable for removing duplicates using Python builtin methods and many more.

Copy link

@Jesse-jude Jesse-jude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strengths

Equality and Hashing Consistency

Implementing eq and hash ensures that instances of this class can be used in sets and as dictionary keys, which is good.

Both methods are based on self.url, so equality and hashing are consistent.

Property Usage

Using @Property for url makes it clear that url is meant to be accessed like an attribute, not a method.

Issues / Areas to Improve

Initialization of url Missing

There’s no init method in the snippet, so it’s unclear how self.url is set. If url isn’t properly initialized, eq and hash will fail with AttributeError.

Suggestion: Explicitly define init to accept ur

def __init__(self, url: str): self._url = url self.resized = False

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 this pull request may close these issues.

2 participants