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
0 votes

More Posts

Dashboard Operasional Armada Rental Mobil dengan Python + FastAPI

Masbadar - Mar 12

What Is an Availability Zone Explained Simply

Ijay - Feb 12

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

LegendsDaD - Feb 11

Advanced Python Concepts - Metaprogramming

Abdul Daim - Oct 10, 2024

Advanced Python Concepts - Networking with Python

Abdul Daim - Oct 8, 2024
chevron_left

Related Jobs

View all jobs →

Commenters (This Week)

4 comments
3 comments
1 comment

Contribute meaningful comments to climb the leaderboard and earn badges!