NOTE: This is a question I found on StackOverflow which I’ve archived here, because the answer is so effing phenomenal.
If you are not into long explanations, see [Paolo Bergantino’s answer][2].
| 1. Python virtuális környezet beállítása (projekt gyökérmappájában állva): | |
| python3 -m venv .venv (ez egy rejtett .venv nevű mappát hoz létre) | |
| Ha valami nem működik venv alatt, de amúgy igen, kell a végére a | |
| --system-site-packages kapcsoló | |
| 2. VS Code-ban átállítani a Python-interpretert | |
| Enter path: .venv/bin/python | |
| 3. virtuális környezet indítása | |
| source .venv/bin/activate |
| import pygame | |
| from pygame.locals import * | |
| from pygame import freetype, time, Surface # import freetype here to initialize it | |
| from enum import Enum | |
| from game import Game | |
| SCREEN_SIZE = (640, 480) | |
| FRAMERATE = 60 | |
| BLACK = (0, 0, 0) |
| import itertools | |
| ZERO = "nulla" | |
| ONES = ( "", "egy", "kettő", "három", "négy", "öt", "hat", "hét", "nyolc", "kilenc" ) | |
| TENS = ( "", "tizen", "huszon", "harminc", "negyven", "ötven", "hatvan", "hetven", "nyolcvan", | |
| "kilencven" ) | |
| ROUNDED_TENS = ( "", "tíz", "húsz" ) | |
| HUNDRED = "száz" | |
| NAMED = ( "", "", "ezer", "millió", "milliárd", "billió", "billiárd", "trillió", | |
| "trilliárd", "kvadrillió", "kvadrilliárd", "kvantillió", "kvantrilliárd", "szextillió" ) |
| ## A simple decorator | |
| def add_another_one(func): | |
| """This'll be the decorator. | |
| func: the function reference to be decorated""" | |
| def wrapper(num): | |
| """The wrapper does the useful thing. | |
| num: the decorated function's argument""" | |
| return func(num) + 1 | |
| return wrapper |
NOTE: This is a question I found on StackOverflow which I’ve archived here, because the answer is so effing phenomenal.
If you are not into long explanations, see [Paolo Bergantino’s answer][2].