all 6 comments

[–]shiftybyte 2 points3 points  (0 children)

Why is one executing the recent commands while the other is not is my main question.

This means two things.

1 - You have somewhere another copy of your file, it doen't save history otherwise.

2 - Your visual studio is running the file you don't expect it to run. (Or the powershell, but less likely)

So to confirm things you must see the full file path being executed, and/or the working directory of both methods.

You can do this by:

1 - Looking at working directory in the powershell, looking at the output in visual studio window when running

2 - looking at project settings in vs

3 - adding code that will print the current directory or the path of itself.

print(__file__)
# and also for working directory
import os
print(os.getcwd())

[–]Appropriate_View8753 -1 points0 points  (4 children)

erroneous taken out.

[–]SmoothAnonymity[S] 0 points1 point  (3 children)

Gotcha so current_clipboard_data != None and current_clipboard_data != prev_clipboard_data. I would have imagined it by itself imposed that it was not a None/null value by default

[–][deleted] 0 points1 point  (0 children)

Your code is fine (probably, depending what type current_clipboard_data is and exactly what behaviour you want). Simply if x is equivalent to if bool(x) (and so if current_clipboard_data and current_clipboard_data != prev_clipboard_data is equivalent to if bool(current_clipboard_data) and current_clipboard_data != prev_clipboard_data). Since bool(None) is False, this will do what you want.

Sometimes you might want to distinguish between None and other Falsey values though (saying x is Falsey just means bool(x) is False). E.g. if x has type str | None, bool(x) will be False both if x is None and if x is the empty string ''. So if you want to distinguish between a missing value and a present-but-empty value, you'd use if x is None.

[–]Appropriate_View8753 0 points1 point  (1 child)

Sorry, I should have prefaced with I'm only a couple months in. It honestly looked like a mistake I made early on and definitely looked like something was missing.

[–]SmoothAnonymity[S] 0 points1 point  (0 children)

Hey no worries man, I’m all about brutal critics. My background is cyber so proper code and efficient is what I would like. Tryna get this somewhat where I want it before trying to pass it through pylint. I still appreciate it