Because your __new__
method returns None
for any word with no space in it. Probably you want to unindent the return
statement. You can even see this problem in your console output — when you try len(Word('zhiying'))
you get an error about NoneType
.
More Related Contents:
- Python Classes with methods [closed]
- How to avoid having class data shared among instances?
- What is the difference between old style and new style classes in Python?
- Why is the id of a Python class not unique when called quickly?
- How to create a custom string representation for a class object?
- How do I use method overloading in Python?
- What is the difference between class and instance variables?
- python class instance variables and class variables
- List attributes of an object [duplicate]
- How to return a value from __init__ in Python?
- How to create a read-only class property in Python? [duplicate]
- Attaching a decorator to all functions within a class
- Defining “boolness” of a class in python
- How do I access Class member variables in Python?
- Monkey patching a class in another module in Python
- class variables is shared across all instances in python? [duplicate]
- AttributeError: ‘datetime’ module has no attribute ‘strptime’
- How do you create an incremental ID in a Python Class
- assigning class variable as default value to class method argument
- Overloading Addition, Subtraction, and Multiplication Operators
- Python Class Members Initialization
- What are the parentheses for at the end of Python method names? [duplicate]
- “__init__” vs “__call__” in python class
- Class (Static) variables and methods in Python
- Does python `str()` function call `__str__()` function of a class?
- How do you change the value of one attribute by changing the value of another? (dependent attributes)
- Calling a class function inside of __init__
- Calling one method from another within same class in Python
- Is there a way to implement methods like __len__ or __eq__ as classmethods?
- Is it possible to do partial inheritance with Python?