Skip to content

Instantly share code, notes, and snippets.

View scandiumby's full-sized avatar

Egor N. Kostyuk scandiumby

View GitHub Profile
# Операции, операторы и инструкции
## Пример кода
Инструкция импортирует переменную pi из модуля math.
from math import pi
Позиционное присваивание значений глобальным переменным.
x, y, z = [1, 2, 3]
## 1. Python - высокоуровневый язык программирования общего назначения с динамической строгой типизацией и
автоматическим управлением памятью.
## 2. Python поддерживает следующие парадигмы программирования:
- императивное,
- процедурное,
- структурное,
- объектно-ориентированное,
- метапрограммированиe
- функциональное программирование
@scandiumby
scandiumby / fix.py
Created May 15, 2022 08:45
Gurtam's task in PyCon By 2020
import asyncio
import string
class CharIterator:
def __init__(self):
self.pos = 0
def __aiter__(self):
return self
@scandiumby
scandiumby / IT English example
Created May 12, 2022 13:40
Python example for IT English course
import random
english_goals = {
"a": "Free communication with colleagues and customers",
"b": "I want to become an IT specialist",
"c": "Easy to read documentation in English",
"d": "I don't need to learn English",
"e": "Make a choice instead of me",
}
@scandiumby
scandiumby / mutable_immutable.py
Last active January 21, 2020 14:37
Mutable and immutable args for functions in Python3
class AutoInc:
current_index = 0
def __call__(self):
self.current_index += 1
return self.current_index
def append_to_list(alist: list):
alist.append(7)
@scandiumby
scandiumby / gist:23b45dffd424d302632534d215461624
Last active September 24, 2019 09:48
Example for Class counter in Python3
class EJCounter:
counter = 0
def __init__(self):
EJCounter.counter += 1
def __str__(self):
return f'{self.__class__.__name__} was called {self.counter} time'
@scandiumby
scandiumby / map_lambda_bad_example.py
Last active February 21, 2019 16:32
Bad example for use map/lambda in Python3
in_list = [1, 2, 3, 4, 5]
out_list = list(map(lambda x: (x + 1) if x % 2 == 0 else x, in_list))
print(out_list)
@scandiumby
scandiumby / gist:8c67a17dfa4c60c5377309c348330338
Last active September 19, 2018 17:11
Private data were changed in the code.
<?php
/**
* Author: Egor N. Kostyuk
* Date: 06.02.2018
* Time: 15:35
*/
if (!defined('ABSPATH')) {
exit;
}
@scandiumby
scandiumby / class-falbar-ssbf-core.php
Created October 26, 2017 07:59
Fix for "Simple SEO by falbar" wordpress plugins (checking to blank metatags).
protected function get_meta_template($params){
$tmp = "\n\r";
$tmp .= '<!-- '.$this->plugin_name.' v '.$this->plugin_version.' -->';
$tmp .= "\n";
if ($params['description']){
$tmp .= '<meta name="description" content="'.$params['description'].'" />';
$tmp .= "\n";
}