menu
CODER
LEGION
one community, more codes
GitHub Login
Twitter Login
Login
Register
search
Log In
account_circle
Welcome to
Coder Legion
Community
with 2,409 amazing developers
Connect with
Already have an account?
Log in
Email or Username
Password
Remember
Log In
I forgot my password
1
1
0
share
content_copy
Share on Facebook
Share on Twitter
Share on Reddit
Share on LinkedIn
Share on Pinterest
Share on HackerNews
Always Five Trick → Class always returns 5 no matter what when you use len().
advanced-python
python
pythonclcoding
Leader
posted
1 day
0 min read
class AlwaysFive: def __len__(self): return 5 a = AlwaysFive() print(len(a)) # Always prints 5
If you read this far, tweet to the author to show them you care.
Tweet a Thanks
comment
Please
log in
to add a comment.
0
Answers
More Posts
Advanced Python Concepts - Metaprogramming
Abdul Daim
- Oct 10, 2024
Advanced Python Concepts - Networking with Python
Abdul Daim
- Oct 8, 2024
Advanced Python Concepts - List Comprehensions
Abdul Daim
- May 30, 2024
Resolved: Attributeerror: 'dataframe' object has no attribute 'reshape'
Honey
- Jun 20, 2024
[Python Error] modulenotfounderror: no module named 'sklearn.cross_validation' [Solved]
Muzzamil Abbas
- Feb 15, 2024
chevron_left
More From
pythonclcoding
Remove Image Background in Python with rembg
Python for Absolute Beginners - 2025