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

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

snapsynapseverified - Apr 20

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

Advanced Python Concepts - Metaprogramming

Abdul Daim - Oct 10, 2024
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)

16 comments
2 comments
2 comments

Contribute meaningful comments to climb the leaderboard and earn badges!