This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Funkness with issubset
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.8
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Justin Hodder, rhettinger
Priority: normal Keywords:

Created on 2020-01-01 01:11 by Justin Hodder, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
PythonDoesntWorks.py Justin Hodder, 2020-01-01 01:11 Reproduces bug
Messages (5)
msg359137 - (view) Author: Justin Hodder (Justin Hodder) Date: 2020-01-01 01:11
line 59,"print(x2,"avalMana",set(avalMana.keys()))" prints:"{('A', 'B')} avalMana {'A', ('A', 'B'), ('A', 'C')}"

line 60,"        if x2.issubset(set(avalMana.keys())):" is False 
change line 60 to "        if x2.issubset(set(list(avalMana.keys()))):" and it works as expected.
msg359140 - (view) Author: Justin Hodder (Justin Hodder) Date: 2020-01-01 01:54
This works:
$ diff PythonDoesntWorks.py HowCanYouPayMana.v3.py
60c60
<         if x2.issubset(set(avalMana.keys())):
---
>         if x2.issubset(set(list(avalMana.keys()))):
62a63
>

this doesn't work:
$ diff PythonDoesntWorks.py HowCanYouPayMana.v3.py
60c60
<         if x2.issubset(set(avalMana.keys())):
---
>         if x2.issubset(set(list(avalMana.keys()))):
62a63
>                 print("cost",cost)
msg359141 - (view) Author: Justin Hodder (Justin Hodder) Date: 2020-01-01 02:25
oh I'm using Python 3.8.1 (32-bit)
3.8.1150.0
on win10
msg359142 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2020-01-01 02:38
The error is in line 51 which should be:  x3=tuple(sorted(x))
That will make sure you always get {('A', 'B')} instead of {('B', 'A')}.
msg359152 - (view) Author: Justin Hodder (Justin Hodder) Date: 2020-01-01 12:12
AttributeError: 'tuple' object has no attribute 'issubset'

And it doesn't explain why it works as expected in Brython.
History
Date User Action Args
2022-04-11 14:59:24adminsetgithub: 83356
2020-01-01 12:12:42Justin Hoddersetmessages: + msg359152
2020-01-01 02:38:03rhettingersetstatus: open -> closed

nosy: + rhettinger
messages: + msg359142

resolution: not a bug
stage: resolved
2020-01-01 02:25:10Justin Hoddersetmessages: + msg359141
2020-01-01 01:54:55Justin Hoddersetmessages: + msg359140
2020-01-01 01:11:33Justin Hoddercreate