Skip to content

Commit 8b78bb5

Browse files
committed
enh: added __bool__ dunder method
1 parent c3c4617 commit 8b78bb5

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

rocketpy/Function.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,17 @@ def __len__(self):
944944
"""
945945
return len(self.source)
946946

947+
def __bool__(self):
948+
"""Returns true if self exists. This is to avoid getting into __len__
949+
method in boolean statements.
950+
951+
Returns
952+
-------
953+
bool : bool
954+
Always True.
955+
"""
956+
return True
957+
947958
# Define all presentation methods
948959
def __call__(self, *args):
949960
"""Plot the Function if no argument is given. If an

0 commit comments

Comments
 (0)