Skip to content

Instantly share code, notes, and snippets.

View rolika's full-sized avatar

Weisz Roland rolika

View GitHub Profile
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)
@rolika
rolika / num2word.py
Created March 13, 2022 17:37
Convert a number into hungarian words - Számok szavakká konvertálása
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
@rolika
rolika / python_decorator_guide.md
Created March 2, 2020 12:29 — forked from Zearin/python_decorator_guide.md
The best explanation of Python decorators I’ve ever seen. (An archived answer from StackOverflow.)

NOTE: This is a question I found on StackOverflow which I’ve archived here, because the answer is so effing phenomenal.


Q: How can I make a chain of function decorators in Python?


If you are not into long explanations, see [Paolo Bergantino’s answer][2].