How to install python3.7 and create a virtualenv with pip on Ubuntu 18.04?

I don’t know if it’s best practices or not, but if I also install python3-venv and python3.7-venv then everything works (this is tested on a fresh stock Debian buster docker image): % sudo apt install python3.7 python3-venv python3.7-venv % python3.7 -m venv py37-venv % . py37-venv/bin/activate (py37-venv) % Note that it also installs all of … Read more

Dataclasses and property decorator

It sure does work: from dataclasses import dataclass @dataclass class Test: _name: str=”schbell” @property def name(self) -> str: return self._name @name.setter def name(self, v: str) -> None: self._name = v t = Test() print(t.name) # schbell t.name = “flirp” print(t.name) # flirp print(t) # Test(_name=”flirp”) In fact, why should it not? In the end, what … Read more

How can I get Python 3.7 new dataclass field types?

Inspecting __annotations__ gives you the raw annotations, but those don’t necessarily correspond to a dataclass’s field types. Things like ClassVar and InitVar show up in __annotations__, even though they’re not fields, and inherited fields don’t show up. Instead, call dataclasses.fields on the dataclass, and inspect the field objects: field_types = {field.name: field.type for field in … Read more

Can’t install Tensorflow Mac

Update: version 1.13 introduces Python 3.7 support The recent release candidate for the 1.13 version brings Python 3.7 support, in particular precompiled CPU wheels are also available for MacOS 10.11 and newer (link to 1.13.1). Install as usual: $ pip install tensorflow>=1.13 Original answer (outdated) tensorflow does not support Python 3.7 at the moment. The … Read more

How to move a no frame pygame windows when user clicks 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]: # […]

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