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().

posted 1 min read
class AlwaysFive:
    def __len__(self):
        return 5

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

1 Comment

0 votes

More Posts

Dashboard Operasional Armada Rental Mobil dengan Python + FastAPI

Masbadar - Mar 12

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

snapsynapse - Apr 20

What Is an Availability Zone Explained Simply

Ijay - Feb 12

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

vitalicset - Apr 13

Python: An Expert-Level Deep Dive into Design, Internals, and Ecosystem

LegendsDaD - Feb 11
chevron_left

Related Jobs

View all jobs →

Commenters (This Week)

5 comments
2 comments
1 comment

Contribute meaningful comments to climb the leaderboard and earn badges!