I am trying to add a frozenset to an already existing set of frozensets however when i try to use the add() function to add it the return is None. I tried using the update() function instead but to no avail. I am forced to use frozensets because I need a set of sets and this seems like the only solution in Python. The literal is just a list of one element of type String.
print(literal)
print(clauses)
clauses = clauses.add(frozenset(literal))
print(clauses)
The output looks like this:
['!y']
{frozenset({'!y', 'z', 'x'})}
None
The general rule ( https://docs.python.org/3/library/stdtypes.html )
The methods that add, subtract, or rearrange their members in place, and don't return a specific item, never return the collection instance itself but None.
That's why:
clauses = clauses.add(frozenset(literal))
means:
clauses.add(frozenset(literal))
clauses = None
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.