Skip to content

Commit 3b6333e

Browse files
committed
Refactor Set class __str__ method to handle dangling sets and improve readability
1 parent f666d4f commit 3b6333e

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/fuzzylogic/classes.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -403,19 +403,18 @@ def create_function_closure():
403403
closure = create_function_closure.__closure__
404404
func = types.FunctionType(*args[:-1] + [closure])
405405
return func
406+
407+
probably best realized by AST-analysis and code generation...
406408
"""
407409
if self.domain is not None:
408-
return f"{self.domain._name}."
410+
return f"{self.domain._name}.{self.name}"
409411
return f"Set({__name__}({self.func.__qualname__})"
410412

411413
def __str__(self) -> str:
412414
"""Return a string for print()."""
413415
if self.domain is not None:
414416
return f"{self.domain._name}.{self.name}"
415-
if self.name is None:
416-
return f"dangling Set({self.func})"
417-
else:
418-
return f"dangling Set({self.name}"
417+
return f"dangling Set({self.func.__name__}"
419418

420419
def normalized(self) -> T:
421420
"""Return a set that is normalized *for this domain* with 1 as max."""

0 commit comments

Comments
 (0)