“RuntimeError: generator raised StopIteration” every time I try to run app

To judge from the file paths, it looks like you’re running Python 3.7. If so, you’re getting caught by new-in-3.7 behavior: PEP 479 is enabled for all code in Python 3.7, meaning that StopIteration exceptions raised directly or indirectly in coroutines and generators are transformed into RuntimeError exceptions. (Contributed by Yury Selivanov in bpo-32670.) Before … Read more

How to move a no frame pygame windows when user click on it?

Write a function, which moves the window from dependent on a previous mouse position (start_x, start_y) and a mouse position (new_x, new_y) def move_window(start_x, start_y, new_x, new_y): global window_size_x, window_size_y window_x, window_y = eval(environ[‘SDL_VIDEO_WINDOW_POS’]) dist_x, dist_y = new_x – start_x, new_y – start_y environ[‘SDL_VIDEO_WINDOW_POS’] = str(window_x + dist_x) + ‘,’ + str(window_y + dist_y) # … Read more

Will OrderedDict become redundant in Python 3.7?

No it won’t become redundant in Python 3.7 because OrderedDict is not just a dict that retains insertion order, it also offers an order dependent method, OrderedDict.move_to_end(), and supports reversed() iteration*. Moreover, equality comparisons with OrderedDict are order sensitive and this is still not the case for dict in Python 3.7, for example: >>> OrderedDict([(1,1), … Read more

How to hold a ‘key down’ in Pygame?

pygame.key.get_pressed() is a function form pygame.key module. It returns a list of boolean values representing the state of every key on the keyboard. If you want to test if the SPACE key is pressed the you have to get the state of K_SPACE by subscription: keys = pygame.key.get_pressed() if keys[pygame.K_SPACE]: # […]

Class inheritance in Python 3.7 dataclasses

The way dataclasses combines attributes prevents you from being able to use attributes with defaults in a base class and then use attributes without a default (positional attributes) in a subclass. That’s because the attributes are combined by starting from the bottom of the MRO, and building up an ordered list of the attributes in … Read more