New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ PySimpleGUIWeb ] Python warning #3663
Comments
There are at least 3 of these special kinds of constants in Python where you are encouraged / instructed to use I'm surprised Wing would complain about this. I would expect it to warn if a comparison against PEP8 explicitly mentions They mentioned one instance that you've suggested:
This is exactly the opposite of what you're suggesting I think you are correct in the primary example of (None, None). The tuple if image_size is not (None, None): It could be a problem and I'll make some tests and the appropriate changes. But comparisons against |
OK, all fixed up in 0.39.0.6. Also fixed the type comparisons. I wasn't using |
Rolled back to 0.39.0.5 due to evidently bad fixes. Will readdress later. |
@PySimpleGUI The reason that >>> x = (None, None)
>>> y = (None, None)
# they have the same value, so this will return true
>>> x == y
True
# but they're not in the same place in memory, so they are not the same object
>>> x is y
False
# if you link another variable to the same object in memory...
>>> z = x
# ...it will return True for an `is` call.
>>> x is z
True
>>> x == z
True
# To show that, the unique ID of the objects for X and Z are the same, but the ID for Y is
# different -- even though they all have the same value.
>>> id(x)
139760977201088
>>> id(z)
139760977201088
>>> id(y)
139760977202176
>>> |
Joe, thanks for this. I fear, though, I've wasted your time through not
knowing how to raise issues on PySimpleGUI !!
The warnings came from Wing, and my purpose in mentioning it was to draw
Mike's attention to the problem, and later to explain it more fully in
another issue.
He did fix my first issue, made a new version, but then withdrew it when I
raised another issue with more detail .
He would appreciate your more detailed exposition, but might not find time.
John
…On Tue, 1 Dec 2020 at 04:56, Joe Kaufeld ***@***.***> wrote:
@PySimpleGUI <https://github.com/PySimpleGUI> The reason that if
image_size is not (None, None): has a warning is because you're not
comparing against None -- you're comparing against a *tuple containing
two Nones*. When you apply is against an object, then you're checking
that it's the *same object* that you're pointing at, not whether the
values are the same. See here:
>>> x = (None, None)>>> y = (None, None)# they have the same value, so this will return true>>> x == yTrue# but they're not in the same place in memory, so they are not the same object>>> x is yFalse# if you link another variable to the same object in memory...>>> z = x# ...it will return True for an `is` call.>>> x is zTrue>>> x == zTrue# To show that, the unique ID of the objects for X and Z are the same, but the ID for Y is# different -- even though they all have the same value.>>> id(x)139760977201088>>> id(z)139760977201088>>> id(y)139760977202176>>>
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#3663 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AARNLWLBHRFNWBYTAYGISOLSSRZONANCNFSM4UCXFFNQ>
.
|
Type of Issues (Enhancement, Error, Bug, Question)
[ Question] I noticed an important syntax warning in PySimpleGuiWeb.py
Operating System
MacOS Catalina 10.15,3
Python version
3.8
PySimpleGUI Port and Versio
Ports = Web
PySimpleGUIWeb Version: 0.39.0.5
Your Experience Levels In Months or Years
10_______ Python programming experience
20_____ Programming experience overall
yes___ Have used another Python GUI Framework (tkinter, Qt, etc) previously (yes/no is fine)?
You have completed these steps:
Description of Problem / Question / Details
I've got a very simple program that works well with PySimpleGui tkinter, but works only partly in PySimpleGUIWeb.
That's not actually the problem! It's not urgent, but I'll raise it as a new issue sometime maybe. I mention it because I loaded the latest version as a file into my project. It gave no improvement, but when it was compiled, Wing IDE gave the following warnings:
Line 1362: SyntaxWarning: "is not" with a literal. Did you mean "!="?
Line 1368: same
I looked at the code, and it does in fact do the opposite of what you want.
(1362: if image_size is not (None, None):
I notice it's been put right elsewhere, e.g.
(3859: if element.ReturnValues[0] is not None)
although "if not element.ReturnValues[0]" is better,
and maybe
(ParmGiven = parm[0] and parm[1])
and later:
(if not ParmGiven)
would be even better
Code To Duplicate
Paste your code here
The text was updated successfully, but these errors were encountered: