Always Five Trick → Class always returns 5 no matter what when you use len().

Always Five Trick → Class always returns 5 no matter what when you use len().

3 9 15
calendar_todayschedule1 min read
class AlwaysFive:
    def __len__(self):
        return 5

a = AlwaysFive()
print(len(a))  # Always prints 5

1 Comment

0 votes
🔥 Join developers growing publicly
Share your knowledge, build in public, and grow your developer presence with a global community.

More Posts

Dashboard Operasional Armada Rental Mobil dengan Python + FastAPI

Masbadar - Mar 12

Cisco's Amy Chang: A Model's "Passport" Doesn't Tell You Where It Actually Came From

Tom Smithverified - Aug 27

I Wrote a Script to Fix Audible's Unreadable PDF Filenames

snapsynapseverified - Apr 20

Cyera: Non-Human Identities Grew 480% in Six Months. Most Companies Have No Idea What They're Doing.

Tom Smithverified - Aug 3

5 Things This Playwright SQL Fixture Does So You Don't Have To

vitalicset - Apr 13
chevron_left
2.2k Points27 Badges
Indiaclcoding.com
5Posts
2Comments
Let's learn Python on a daily basis. Free resources for students only for educational purposes. Auto... Show more

Related Jobs

View all jobs →

Commenters (This Week)

10 comments
3 comments
2 comments

Contribute meaningful comments to climb the leaderboard and earn badges!