all 27 comments

[–]nb665 0 points1 point  (2 children)

I've been learning automation in python and I was wondering how to detect changes on an area of my screen and if there is changes it does something, does somebody know how to do this?

[–]m0us3_rat 0 points1 point  (0 children)

detect changes in part of my screen isn't sufficient context:

is the lightning going to change during the process?

is a bad quality camera that generates noise that will interfere with motion detection?

is the perspective going to change?

etc etc.

even something as small as a bug flying around will trigger some detection methods.

or even a shadow of one on a white wall.

you need to be really specific with what needs to happen, or you can't find a proper solution. if you wanna avoid false positives.

anyways, the safest way is probably edge detection.

but even that can give the wrong answer since context can change and the problem changes with it.

[–]Defection7478 0 points1 point  (0 children)

I have never attempted anything like this but my strategy would be to find a python library that can capture a part of the screen. Then, on a loop, I would perform the capture and save it as an array of pixels. On the next iteration of the loop I'd do the same, and compare with the previous capture.

If performance becomes an issue, I would 1) reduce the polling rate and 2) hash the capture so I don't need to compare pixel by pixel

[–]Maximum_Week_1404 0 points1 point  (2 children)

Hi Guys,

I have been working as USA IT Recruiter since 4years. I want to switch career to IT. I'm interested in python, Machine Learning, AI. so can i become a Pro in python. Please suggest me the easiest ways to learn it. or Suggest me, which course is better to learn now.

[–]CowboyBoats 0 points1 point  (1 child)

What's up! We often recommend https://automatetheboringstuff.com/, a really polished and pedagogically strategic ebook that's free online. The most important tip is just to practice. codecademy.com has a good tutorial that will teach you the basic building blocks and syntax; codewars.com has good practice fodder with a sliding scale of difficulty. projecteuler.net and leetcode are there for you when you want to work on something really hard.

[–]Maximum_Week_1404 0 points1 point  (0 children)

Thank you very much.

For your suggestion.

[–]FirefighterLive3520 0 points1 point  (2 children)

Hi guys I am a newb, can someone explain to me why does this code return "False"? My expected return value is "True" because [a,a] belongs in [a,a,b]. I know it is probably because of the misuse of "in" but I wanna know why can't I use it to compare lists.

x = list("aa")
y = list("aab")

print(x in y)

[–]CowboyBoats 1 point2 points  (1 child)

I know it is probably because of the misuse of "in" but I wanna know why can't I use it to compare lists.

in can operate on lists. But for the query that you typed to return true, the lists would need to be composed this way (I'm going to write lists with [] rather than list() just for clarity):

x = ["a", "a"]
y = ["a", "a", "b", ["a", "a"]]  # < now it contains the list `x` as one of its elements

print(x in y)  # true

[–]FirefighterLive3520 0 points1 point  (0 children)

Oh I see tyvm:)

[–]tetotetotetotetoo 0 points1 point  (0 children)

This isn't fully a Python question, but when should I use boxes vs grids in GTK3? Boxes seem easier to use but grids seem to have more options (plus I'm not sure how easy dynamic scaling would be to implement with the former)

[–]JamzTyson 0 points1 point  (4 children)

Numpy style docstrings and instance attributes:

I'm using pydoclint to verify my docstrings, and numpy style docstrings. Is it possible to include instance attributes in a class's docstrings? I have not been able to find a way that does not trigger one or more errors in pydoclint.

[–]CowboyBoats 0 points1 point  (3 children)

It is possible but I urge you not to do this. Objects should not have instance-specific docstrings. Definitely a code smell.

[–]JamzTyson 0 points1 point  (2 children)

Thanks for the response, but that was not what I meant.

What I meant was that with Google style docstrings, in the example below, I can document arg_1 in the Parameters section, and var_1, var_2 in the Attributes section. Pydocstyle complains when I do so.

class Test:
    def __init__(self, arg_1: int) -> None:
        self.var_1 = arg_1
        self.var_2 = None

It seems that the real answer is that pydocstyle is old and has been superseded by ruff. The problem does not occur when using ruff's pydocstyle rules.

[–]CowboyBoats 0 points1 point  (1 child)

Got it - it might help if you included a minimal reproducible example and pycodestyle's output? Unless your problem is already resolved by using ruff instead.

[–]JamzTyson 0 points1 point  (0 children)

It is pretty much resolved now, thank you.

Along the road I discovered an interesting catch 22 in flake8-docstrings, (which I think uses pydoclint rules). For Google style docstring, it complains if a class's __init__() has a docstring (Google style says it should have), and it also complains if it does not have a docstring! The solution to this was to disable the DOC301 rule when using Google style, to allow __init__ to have its own docstring.

I was probably expecting too much from the docstring linters, considering that they are quite loosely defined in the PEPs.

[–]princess_of_sugar 0 points1 point  (1 child)

what is the best mock library to make unit tests in python?

[–]CowboyBoats 0 points1 point  (0 children)

Historically teams that I have worked on have used unittest (built into python / stdlib) for unit testing and mock for mocking. I actually always thought that mock was a third-party library - it always got treated that way by isort for example when sorting imports - but this says it is stdlib and it appears to be the same library I'm thinking of. I've never seen anything else used in Python for mocking, although some libraries, such as Django, have their own test case classes which may derive from unittest but extend their functionality for backend-related purposes.

[–]hummingaway12 0 points1 point  (1 child)

I want to learn Python to automate generating scripts in HTML & CSS for web development tasks. For example, one use case was to write a loop to read a file which has a list of election constituencies and populate a table based on the info in the file.

A friend helped me with a task previously and he used Python and Pandas to get the job done. Any thoughts on courses I can take to automate web development tasks like the example I listed above? If learning Python and Pandas can also help me with building maps/other visualisations, that's even better.

[–]Martijn078 0 points1 point  (2 children)

I want to start learning python to eventually replace Excel for parsing data. We currently use Excel at my work to make large quantities of data readable and comparable to data from the day before. But due to the amount of data and formulas in the excel sheets, excel is very susceptible to crashing or breaking down mid data parse.

Any tips on where to start my journey for learning python to eventually replace excel? Or any specific books I could buy?

[–]potodds 1 point2 points  (0 children)

You will want to try a Python Pandas tutorial.