diff --git a/src/practice_files/practice_image/practice_image_info_by_bits.py b/src/practice_files/practice_image/practice_image_info_by_bits.py deleted file mode 100644 index 13e6a88..0000000 --- a/src/practice_files/practice_image/practice_image_info_by_bits.py +++ /dev/null @@ -1,88 +0,0 @@ -from array import array - - -def main(): - """ - SOS array('B', [255, 218, 0, 12, 3, 0, 0, 1, 17, 2, 17, 0, 63, 0]) - length of segment depends on the number of components: array('B', [0, 12]) - number of components (1=monochrome, 3=colour): 3 - 0x01 = Y, 0x00 = Huffman table to use: array('B', [0, 0]) - 0x02 = Cb, 0x11 = Huffman table to use: array('B', [1, 17]) - 0x03 = Cr, 0x11 = Huffman table to use: array('B', [2, 17]) - start of spectral selection or predictor selection 0 - end of spectral selection 63 - successive approximation bit position or point transform 0 - SOF array('B', [255, 192, 0, 17, 8, 5, 85, 8, 0, 3, 0, 17, 0, 1, 17, 1, 2, 17, 1]) - SOF0 segement: array('B', [255, 192]) - length of segment depends on the number of components: array('B', [0, 17]) - bits per pixel: 8 - image height: array('B', [5, 85]) - image width: array('B', [8, 0]) - number of components (should be 1 or 3): 3 - 0x01=Y component, 0x22=sampling factor, quantization table number: array('B', [0, 17, 0]) - 0x02=Cb component, ...: array('B', [1, 17, 1]) - 0x03=Cr component, ...: array('B', [2, 17, 1]) - """ - with open("../../resources/35163667010_8bfcaef274_k.jpg", "rb") as fd: - content = array("B", fd.read()) - v_content = memoryview(content) - start_of_scan = [0xFF, 0xDA] - start_of_frame = [0xFF, 0xC0] - eof = [0xFF, 0xD9] - meta_scan_info = None - meta_frame_info = None - body = None - body_idx = 0 - - for idx in range(0, len(v_content) - 2): - if [v_content[idx], v_content[idx + 1]] == start_of_frame: - meta_frame_info = array("B", v_content[idx : idx + 19]) - if [v_content[idx], v_content[idx + 1]] == start_of_scan: - meta_scan_info = array("B", v_content[idx : idx + 14]) - body = array("B", v_content[idx + 14 :]) - break - - # if [body[-2], body[-1]] != eof: - # raise Exception("File not has valid end of file") - print("SOS", meta_scan_info) - print( - "length of segment depends on the number of components: ", - meta_scan_info[2:4], - ) - print( - "number of components (1=monochrome, 3=colour): ", - meta_scan_info[4], - ) - print("0x01 = Y, 0x00 = Huffman table to use: ", meta_scan_info[5:7]) - print("0x02 = Cb, 0x11 = Huffman table to use: ", meta_scan_info[7:9]) - print("0x03 = Cr, 0x11 = Huffman table to use: ", meta_scan_info[9:11]) - print( - "start of spectral selection or predictor selection", - meta_scan_info[11], - ) - print("end of spectral selection", meta_scan_info[12]) - print( - "successive approximation bit position or point transform", - meta_scan_info[13], - ) - - print("SOF", meta_frame_info) - print("SOF0 segement: ", meta_frame_info[0:2]) - print( - "length of segment depends on the number of components: ", - meta_frame_info[2:4], - ) - print("bits per pixel: ", meta_frame_info[4]) - print("image height: ", meta_frame_info[5:7]) - print("image width: ", meta_frame_info[7:9]) - print("number of components (should be 1 or 3): ", meta_frame_info[9]) - print( - "0x01=Y component, 0x22=sampling factor, quantization table number: ", - meta_frame_info[10:13], - ) - print("0x02=Cb component, ...: ", meta_frame_info[13:16]) - print("0x03=Cr component, ...: ", meta_frame_info[16:19]) - - -if __name__ == "__main__": - main() diff --git a/src/practice_files/practice_image/practice_pillow.py b/src/practice_files/practice_image/practice_pillow.py deleted file mode 100644 index ae01ab4..0000000 --- a/src/practice_files/practice_image/practice_pillow.py +++ /dev/null @@ -1,31 +0,0 @@ -from PIL import Image -from PIL.ExifTags import TAGS - - -def main(): - """ - {'version': b'GIF89a', 'background': 21, 'transparency': 21, 'duration': 120, 'extension': (b'NETSCAPE2.0', 795), 'loop': 0} - 24 - 360 360 - """ - img = Image.open("../../resources/266e9742dc0aa9230e6061710cad3a88.gif") - exifdata = img.getexif() - # iterating over all EXIF data fields - for tag_id in exifdata: - # get the tag name, instead of human unreadable tag id - tag = TAGS.get(tag_id, tag_id) - data = exifdata.get(tag_id) - # decode bytes - if isinstance(data, bytes): - data = data.decode() - print(f"{tag:25}: {data}") - print("=" * 32) - print(img.info) - # if img.format == "GIF": - if hasattr(img, "n_frames"): - print(img.n_frames) - print(img.width, img.height) - - -if __name__ == "__main__": - main() diff --git a/src/practice_files/practice_image/practice_pymediainfo.py b/src/practice_files/practice_image/practice_pymediainfo.py deleted file mode 100644 index 8e79376..0000000 --- a/src/practice_files/practice_image/practice_pymediainfo.py +++ /dev/null @@ -1,69 +0,0 @@ -import json -from pprint import pprint - -from pymediainfo import MediaInfo - - -def main(): - """ - {'tracks': [{'codecs_image': 'GIF', - 'commercial_name': 'GIF', - 'complete_name': '../../resources/266e9742dc0aa9230e6061710cad3a88.gif', - 'count': '331', - 'count_of_image_streams': '1', - 'count_of_stream_of_this_kind': '1', - 'file_extension': 'gif', - 'file_last_modification_date': 'UTC 2020-05-29 02:44:01', - 'file_last_modification_date__local': '2020-05-29 11:44:01', - 'file_name': '266e9742dc0aa9230e6061710cad3a88', - 'file_name_extension': '266e9742dc0aa9230e6061710cad3a88.gif', - 'file_size': 181078, - 'folder_name': '../../resources', - 'format': 'GIF', - 'format_extensions_usually_used': 'gif gis', - 'format_info': 'Graphics Interchange Format', - 'image_format_list': 'GIF', - 'image_format_withhint_list': 'GIF', - 'internet_media_type': 'image/gif', - 'kind_of_stream': 'General', - 'other_file_size': ['177 KiB', - '177 KiB', - '177 KiB', - '177 KiB', - '176.8 KiB'], - 'other_format': ['GIF'], - 'other_kind_of_stream': ['General'], - 'stream_identifier': '0', - 'track_type': 'General'}, - {'commercial_name': 'GIF', - 'compression_mode': 'Lossless', - 'count': '124', - 'count_of_stream_of_this_kind': '1', - 'format': 'GIF', - 'format_info': 'Graphics Interchange Format', - 'format_profile': '89a', - 'height': 360, - 'internet_media_type': 'image/gif', - 'kind_of_stream': 'Image', - 'other_compression_mode': ['Lossless'], - 'other_format': ['GIF'], - 'other_height': ['360 pixels'], - 'other_kind_of_stream': ['Image'], - 'other_width': ['360 pixels'], - 'stream_identifier': '0', - 'track_type': 'Image', - 'width': 360}]} - """ - info = MediaInfo.parse("../../resources/35163667010_8bfcaef274_k.jpg") - - attrs = dir(info) - - for k in attrs: - if k.startswith("_"): - continue - print(f"{k}: {getattr(info, k)}") - pprint(json.loads(info.to_json())) - - -if __name__ == "__main__": - main() diff --git a/src/practice_files/practice_media/practice_image_processing.py b/src/practice_files/practice_media/practice_image_processing.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/practice_files/practice_nlp/practice_kiwi.py b/src/practice_files/practice_nlp/practice_kiwi.py new file mode 100644 index 0000000..0a32e25 --- /dev/null +++ b/src/practice_files/practice_nlp/practice_kiwi.py @@ -0,0 +1,9 @@ +from kiwipiepy import Kiwi + +s = "염료, 조제 무기안료, 유연제 및 기타 착색제 제조업" +base = "[바이오USA] SK바이오팜, 피닉스랩과 생성형 AI 개발 MOU - 조선비즈" + +processor = Kiwi() + +print([(token.form, token.tag) for token in processor.tokenize(base)]) + diff --git a/src/practice_files/practice_redis/practice_get_keys.py b/src/practice_files/practice_redis/practice_get_keys.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/practice_files/practice_sqlalchemy/__init__.py b/src/practice_files/practice_sqlalchemy/__init__.py deleted file mode 100644 index 18cead5..0000000 --- a/src/practice_files/practice_sqlalchemy/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from . import model, practice_aliased_subquery - -__all__ = ['model', 'practice_aliased_subquery'] diff --git a/src/practice_files/practice_sqlalchemy/model.py b/src/practice_files/practice_sqlalchemy/model.py deleted file mode 100644 index 3aba35b..0000000 --- a/src/practice_files/practice_sqlalchemy/model.py +++ /dev/null @@ -1,246 +0,0 @@ -from __future__ import annotations - -import enum -import os - -from sqlalchemy import ( - Column, - Enum, - ForeignKey, - Integer, - PrimaryKeyConstraint, - Text, - create_engine, -) -from sqlalchemy.ext.declarative import declarative_base -from sqlalchemy.orm import relationship, sessionmaker - -Base = declarative_base() - - -""" - +-------+ +---+ +---------+ - |Company| --> |Car| ----+---> |Ownership| - +-------+ +---+ | +---------+ - +----------+ +-----+ | - |CreditCard| --> |Human| -+ - +----------+ +-----+ -""" - -class CreditCard(Base): - __tablename__ = "credit_card" - - card_id = Column(Integer, primary_key=True, autoincrement=True) - provider = Column(Text) - bounded = Column(Integer) - - user = relationship("Human") - - -class Company(Base): - __tablename__ = "company" - - company_id = Column(Integer, autoincrement=True, primary_key=True) - name = Column(Text) - location = Column(Text) - - -class CarType(str, enum.Enum): - gasoline = "gasoline" - electric = "electric" - hybrid_electric = "hybrid_electric" - - -class Car(Base): - __tablename__ = "car" - - car_id = Column(Integer, autoincrement=True, primary_key=True) - name = Column(Text) - drivetrain = Column(Enum(CarType)) - maker_id = Column(Integer, ForeignKey(Company.company_id)) - price = Column(Integer) - - -class Human(Base): - __tablename__ = "human" - - id_number = Column(Integer, primary_key=True, autoincrement=True) - name = Column(Text) - credit_card_id = Column(Integer, ForeignKey(CreditCard.card_id)) - - -class Ownership(Base): - __tablename__ = "ownership" - - human_id = Column(Integer, ForeignKey(Human.id_number)) - car_id = Column(Integer, ForeignKey(Car.car_id)) - register_num = Column(Text, unique=True) - - __table_args__ = (PrimaryKeyConstraint(human_id, car_id),) - - -def prepare_data(): - if os.path.exists("test.db"): - os.remove("test.db") - - engine = create_engine( - "sqlite:///db.sqlite3", - echo=True, - ) - - session_obj = sessionmaker() - sess = session_obj(bind=engine) - - try: - Base.metadata.create_all(engine) - - cards = [ - CreditCard(provider="samsung", bounded=100000), - CreditCard(provider="hyundai", bounded=20000), - CreditCard(provider="shinhan", bounded=3000000), - CreditCard(provider="kookmin", bounded=4000), - ] - sess.add_all(cards) - sess.flush() - - companies = [ - Company(name="porsche", location="German"), - Company(name="audi", location="German"), - Company(name="bmw", location="German"), - Company(name="jeep", location="USA"), - Company(name="tesla", location="USA"), - Company(name="ford", location="USA"), - Company(name="Lamborghini", location="Italy"), - ] - sess.add_all(companies) - sess.flush() - - cars = [ - Car( - name="911", - drivetrain=CarType.gasoline, - maker_id=0, - price=50000, - ), - Car( - name="356", - drivetrain=CarType.gasoline, - maker_id=0, - price=100000, - ), - Car( - name="R8", drivetrain=CarType.gasoline, maker_id=1, price=45000 - ), - Car( - name="A4", drivetrain=CarType.gasoline, maker_id=1, price=32000 - ), - Car( - name="A6", drivetrain=CarType.gasoline, maker_id=1, price=38000 - ), - Car( - name="M5", drivetrain=CarType.gasoline, maker_id=2, price=35000 - ), - Car( - name="X3", drivetrain=CarType.gasoline, maker_id=2, price=35000 - ), - Car( - name="Cherokee", - drivetrain=CarType.gasoline, - maker_id=3, - price=38000, - ), - Car( - name="Model 3", - drivetrain=CarType.gasoline, - maker_id=4, - price=48000, - ), - Car( - name="Model S", - drivetrain=CarType.gasoline, - maker_id=4, - price=48000, - ), - Car( - name="Model Y", - drivetrain=CarType.gasoline, - maker_id=4, - price=48000, - ), - Car( - name="mustang", - drivetrain=CarType.gasoline, - maker_id=5, - price=55000, - ), - ] - sess.add_all(cars) - sess.flush() - - humans = [ - Human( - name="ella", - credit_card_id=cards[0].card_id, - ), - Human( - name="scarlet", - credit_card_id=cards[1].card_id, - ), - Human( - name="wanda", - credit_card_id=cards[1].card_id, - ), - Human( - name="sally", - credit_card_id=cards[3].card_id, - ), - Human( - name="anastasia", - credit_card_id=cards[2].card_id, - ), - Human( - name="sandra", - credit_card_id=cards[2].card_id, - ), - Human( - name="penny", - credit_card_id=cards[3].card_id, - ), - ] - sess.add_all(humans) - sess.flush() - - owners = [ - Ownership( - human_id=humans[0].id_number, - car_id=cars[1].car_id, - register_num="abc1", - ), - Ownership( - human_id=humans[1].id_number, - car_id=cars[1].car_id, - register_num="abc2", - ), - Ownership( - human_id=humans[1].id_number, - car_id=cars[2].car_id, - register_num="abc3", - ), - Ownership( - human_id=humans[2].id_number, - car_id=cars[5].car_id, - register_num="abc4", - ), - Ownership( - human_id=humans[3].id_number, - car_id=cars[5].car_id, - register_num="abc5", - ), - ] - sess.add_all(owners) - sess.flush() - except Exception as e: - print(str(e)) - sess.rollback() - else: - sess.commit() diff --git a/src/practice_files/practice_sqlalchemy/practice_aliased_subquery.py b/src/practice_files/practice_sqlalchemy/practice_aliased_subquery.py deleted file mode 100644 index 44424be..0000000 --- a/src/practice_files/practice_sqlalchemy/practice_aliased_subquery.py +++ /dev/null @@ -1,82 +0,0 @@ -from operator import concat - -from sqlalchemy import create_engine, inspect, select -from sqlalchemy.orm import ( - Query, - aliased, - column_property, - sessionmaker, - subqueryload, -) - -from .model import ( - Base, - Company, - CreditCard, - Car, - Human, - Ownership, - prepare_data, -) - - -def practice_annotation_(sess): - """annotation은 django 프레임워크의 ORM 쿼리함수인데, SQLAlchemy로 어떻게 번역해야 하는지에 대한 테스트를 수행""" - inspection = inspect(Car) - - car_list_q = ( - Query(concat(inspection.columns, [Human.name.label("owner")])) - .join(Car, Car.car_id == Ownership.car_id) - .subquery() - ) - - print( - list( - getattr(type("TempModel", tuple(), dict(t._asdict())), "owner") - for t in sess.query(car_list_q).all() - ) - ) - print([t._asdict() for t in sess.query(car_list_q).all()]) - print(sess.query(Car).all()) - stmt = sess.query(Human.name).label("owner") - - print( - list( - map( - lambda c: c._asdict(), - sess.query(*inspection.columns, stmt).all(), - ) - ) - ) - - -def practice_prefetch_(sess): - humans = sess.query(Human).filter(Human.name == "wanda").subquery() - ownership = ( - sess.query(Ownership) - .join(humans, humans.c.id_number == Ownership.human_id) - .subquery() - ) - used_car = ( - sess.query(Car) - .join(ownership, ownership.c.car_id == Car.car_id) - .subquery() - ) - # makers = sess.query(Company).subquery() - car_list = sess.query(Company).join(used_car).first() - - print(car_list) - - -def main(): - engine = create_engine("sqlite:///db.sqlite3", echo=True) - - session_obj = sessionmaker(engine) - - sess = session_obj() - practice_prefetch_(sess) - - -if __name__ == "__main__": - # prepare_data() - main() diff --git a/src/practice_files/practice_sqlalchemy/practice_db.py b/src/practice_files/practice_sqlalchemy/practice_db.py deleted file mode 100644 index 1de93dc..0000000 --- a/src/practice_files/practice_sqlalchemy/practice_db.py +++ /dev/null @@ -1,46 +0,0 @@ -import sqlalchemy -from datetime import datetime - - -def main(): - meta = sqlalchemy.MetaData() - - engine = sqlalchemy.create_engine("sqlite://") - - table_1 = sqlalchemy.Table( - "table_1", - meta, - sqlalchemy.Column( - "col_11", sqlalchemy.Integer, primary_key=True, autoincrement=True - ), - sqlalchemy.Column("col_12", sqlalchemy.String), - sqlalchemy.Column("col_13", sqlalchemy.DateTime, default=datetime.now), - ) - - table_2 = sqlalchemy.Table( - "table_2", - meta, - sqlalchemy.Column( - "col_21", sqlalchemy.Integer, primary_key=True, autoincrement=True - ), - sqlalchemy.Column("col_22", sqlalchemy.String), - ) - - meta.create_all(engine) - - conn = engine.connect() - - q = sqlalchemy.insert(table_1).values(col_12="value_1") - conn.execute(q) - q = sqlalchemy.insert(table_2).values(col_22="value_22") - conn.execute(q) - - q = sqlalchemy.select([table_1, table_2]) - rows = conn.execute(q) - - for row in rows: - print(row) - - -if __name__ == "__main__": - main() diff --git a/src/practice_files/practice_sqlalchemy/practice_mocking_engine.py b/src/practice_files/practice_sqlalchemy/practice_mocking_engine.py deleted file mode 100644 index 20de80f..0000000 --- a/src/practice_files/practice_sqlalchemy/practice_mocking_engine.py +++ /dev/null @@ -1,159 +0,0 @@ -from __future__ import annotations - -from contextlib import contextmanager -import enum -import os -import logging - -from sqlalchemy import ( - Column, - Enum, - ForeignKey, - Integer, - PrimaryKeyConstraint, - Text, - create_engine, -) -from sqlalchemy.engine import create_engine -from sqlalchemy.ext.declarative import declarative_base -from sqlalchemy.orm import relationship, sessionmaker - -import factory - -Base = declarative_base() - - -""" - +-------+ +---+ +---------+ - |Company| --> |Car| ----+---> |Ownership| - +-------+ +---+ | +---------+ - +----------+ +-----+ | - |CreditCard| --> |Human| -+ - +----------+ +-----+ -""" - -class CreditCard(Base): - __tablename__ = "credit_card" - - card_id = Column(Integer, primary_key=True, autoincrement=True) - provider = Column(Text) - bounded = Column(Integer) - - user = relationship("Human") - - -class Company(Base): - __tablename__ = "company" - - company_id = Column(Integer, autoincrement=True, primary_key=True) - name = Column(Text) - location = Column(Text) - - -class CarType(str, enum.Enum): - gasoline = "gasoline" - electric = "electric" - hybrid_electric = "hybrid_electric" - - -class Car(Base): - __tablename__ = "car" - - car_id = Column(Integer, autoincrement=True, primary_key=True) - name = Column(Text) - drivetrain = Column(Enum(CarType)) - maker_id = Column(Integer, ForeignKey(Company.company_id)) - price = Column(Integer) - - -class Human(Base): - __tablename__ = "human" - - id_number = Column(Integer, primary_key=True, autoincrement=True) - name = Column(Text) - credit_card_id = Column(Integer, ForeignKey(CreditCard.card_id)) - - -class Ownership(Base): - __tablename__ = "ownership" - - human_id = Column(Integer, ForeignKey(Human.id_number)) - car_id = Column(Integer, ForeignKey(Car.car_id)) - register_num = Column(Text, unique=True) - - __table_args__ = (PrimaryKeyConstraint(human_id, car_id),) - -def dump(sql, *multiparams, **params): - print(sql.compile(dialect=engine.dialect)) - -engine = create_engine('mysql+mysqlconnector://', executor=dump, strategy="mock") -Base.metadata.create_all(engine, checkfirst=False) - -maker = sessionmaker(bind=engine) -session = maker() - -class FactoryCreditCard(factory.alchemy.SQLAlchemyModelFactory): - class Meta: - model = CreditCard - sqlalchemy_session = session - provider = "Samsung" - bounded = 500000 - -class FactoryCompany(factory.alchemy.SQLAlchemyModelFactory): - class Meta: - model = Company - sqlalchemy_session = session - name = "Volkswagen" - location = "Germany" - -class FactoryCar(factory.alchemy.SQLAlchemyModelFactory): - class Meta: - model = Car - sqlalchemy_session = session - name = "Beetle" - drivetrain = "FWD" - maker_id = factory.RelatedFactory(FactoryCompany, factory_related_name="company_id") - price=250000 - -class FactoryHuman(factory.alchemy.SQLAlchemyModelFactory): - class Meta: - model = Human - sqlalchemy_session = session - name = "Dick" - credit_card_id = factory.RelatedFactory(FactoryCreditCard, factory_related_name="card_id") - -class FactoryOwnership(factory.alchemy.SQLAlchemyModelFactory): - class Meta: - model = Ownership - sqlalchemy_session = session - human_id = factory.RelatedFactory(FactoryHuman, factory_related_name="id_number") - car_id = factory.RelatedFactory(FactoryCar, factory_related_name="car_id") - - -def query_example_model(engine): - pass - - -def main(): - logging.getLogger().setLevel(logging.DEBUG) - - FactoryCompany() - FactoryCar() - - print(session.query(Car).all()) - # print(session.query(CreditCard).all()) - # for m in dir(session): - # if m.startswith('_'): - # continue - # print(m, callable(getattr(session, m))) - - # print(dir(session.connection())) - # print(session.connection()) - - # with get_test_session() as test_session: - - # print(test_session) - # print(dir(test_session)) - -if __name__ == '__main__': - main() diff --git a/src/practice_files/practice_std_library/__init__.py b/src/practice_files/practice_std_library/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/practice_files/practice_algorithm/__init__.py b/src/practice_files/python/practice_algorithm/__init__.py similarity index 100% rename from src/practice_files/practice_algorithm/__init__.py rename to src/practice_files/python/practice_algorithm/__init__.py diff --git a/src/practice_files/practice_algorithm/combination.py b/src/practice_files/python/practice_algorithm/combination.py similarity index 100% rename from src/practice_files/practice_algorithm/combination.py rename to src/practice_files/python/practice_algorithm/combination.py diff --git a/src/practice_files/practice_algorithm/easy.py b/src/practice_files/python/practice_algorithm/easy.py similarity index 100% rename from src/practice_files/practice_algorithm/easy.py rename to src/practice_files/python/practice_algorithm/easy.py diff --git a/src/practice_files/practice_algorithm/graph.py b/src/practice_files/python/practice_algorithm/graph.py similarity index 100% rename from src/practice_files/practice_algorithm/graph.py rename to src/practice_files/python/practice_algorithm/graph.py diff --git a/src/practice_files/practice_algorithm/heap.py b/src/practice_files/python/practice_algorithm/heap.py similarity index 100% rename from src/practice_files/practice_algorithm/heap.py rename to src/practice_files/python/practice_algorithm/heap.py diff --git a/src/practice_files/practice_algorithm/make_crossword.py b/src/practice_files/python/practice_algorithm/make_crossword.py similarity index 100% rename from src/practice_files/practice_algorithm/make_crossword.py rename to src/practice_files/python/practice_algorithm/make_crossword.py diff --git a/src/practice_files/practice_algorithm/tree_avl.py b/src/practice_files/python/practice_algorithm/tree_avl.py similarity index 100% rename from src/practice_files/practice_algorithm/tree_avl.py rename to src/practice_files/python/practice_algorithm/tree_avl.py diff --git a/src/practice_files/practice_algorithm/tree_binary.py b/src/practice_files/python/practice_algorithm/tree_binary.py similarity index 100% rename from src/practice_files/practice_algorithm/tree_binary.py rename to src/practice_files/python/practice_algorithm/tree_binary.py diff --git a/src/practice_files/practice_builtins/__init__.py b/src/practice_files/python/practice_builtins/__init__.py similarity index 100% rename from src/practice_files/practice_builtins/__init__.py rename to src/practice_files/python/practice_builtins/__init__.py diff --git a/src/practice_files/practice_builtins/practice_args.py b/src/practice_files/python/practice_builtins/practice_args.py similarity index 100% rename from src/practice_files/practice_builtins/practice_args.py rename to src/practice_files/python/practice_builtins/practice_args.py diff --git a/src/practice_files/practice_builtins/practice_args_2.py b/src/practice_files/python/practice_builtins/practice_args_2.py similarity index 100% rename from src/practice_files/practice_builtins/practice_args_2.py rename to src/practice_files/python/practice_builtins/practice_args_2.py diff --git a/src/practice_files/practice_builtins/practice_asyncio.py b/src/practice_files/python/practice_builtins/practice_asyncio.py similarity index 100% rename from src/practice_files/practice_builtins/practice_asyncio.py rename to src/practice_files/python/practice_builtins/practice_asyncio.py diff --git a/src/practice_files/practice_builtins/practice_char.py b/src/practice_files/python/practice_builtins/practice_char.py similarity index 100% rename from src/practice_files/practice_builtins/practice_char.py rename to src/practice_files/python/practice_builtins/practice_char.py diff --git a/src/practice_files/practice_builtins/practice_dataclass.py b/src/practice_files/python/practice_builtins/practice_dataclass.py similarity index 100% rename from src/practice_files/practice_builtins/practice_dataclass.py rename to src/practice_files/python/practice_builtins/practice_dataclass.py diff --git a/src/practice_files/practice_builtins/practice_dataclass_conversion.py b/src/practice_files/python/practice_builtins/practice_dataclass_conversion.py similarity index 100% rename from src/practice_files/practice_builtins/practice_dataclass_conversion.py rename to src/practice_files/python/practice_builtins/practice_dataclass_conversion.py diff --git a/src/practice_files/practice_builtins/practice_dataclass_field.py b/src/practice_files/python/practice_builtins/practice_dataclass_field.py similarity index 100% rename from src/practice_files/practice_builtins/practice_dataclass_field.py rename to src/practice_files/python/practice_builtins/practice_dataclass_field.py diff --git a/src/practice_files/practice_builtins/practice_dataclass_from_dict.py b/src/practice_files/python/practice_builtins/practice_dataclass_from_dict.py similarity index 100% rename from src/practice_files/practice_builtins/practice_dataclass_from_dict.py rename to src/practice_files/python/practice_builtins/practice_dataclass_from_dict.py diff --git a/src/practice_files/practice_builtins/practice_dataclass_hierarchy.py b/src/practice_files/python/practice_builtins/practice_dataclass_hierarchy.py similarity index 100% rename from src/practice_files/practice_builtins/practice_dataclass_hierarchy.py rename to src/practice_files/python/practice_builtins/practice_dataclass_hierarchy.py diff --git a/src/practice_files/practice_builtins/practice_dataclass_kwargs.py b/src/practice_files/python/practice_builtins/practice_dataclass_kwargs.py similarity index 100% rename from src/practice_files/practice_builtins/practice_dataclass_kwargs.py rename to src/practice_files/python/practice_builtins/practice_dataclass_kwargs.py diff --git a/src/practice_files/practice_builtins/practice_enum.py b/src/practice_files/python/practice_builtins/practice_enum.py similarity index 100% rename from src/practice_files/practice_builtins/practice_enum.py rename to src/practice_files/python/practice_builtins/practice_enum.py diff --git a/src/practice_files/practice_builtins/practice_ex.py b/src/practice_files/python/practice_builtins/practice_ex.py similarity index 100% rename from src/practice_files/practice_builtins/practice_ex.py rename to src/practice_files/python/practice_builtins/practice_ex.py diff --git a/src/practice_files/practice_builtins/practice_exception.py b/src/practice_files/python/practice_builtins/practice_exception.py similarity index 100% rename from src/practice_files/practice_builtins/practice_exception.py rename to src/practice_files/python/practice_builtins/practice_exception.py diff --git a/src/practice_files/practice_builtins/practice_file.py b/src/practice_files/python/practice_builtins/practice_file.py similarity index 100% rename from src/practice_files/practice_builtins/practice_file.py rename to src/practice_files/python/practice_builtins/practice_file.py diff --git a/src/practice_files/practice_builtins/practice_file2.py b/src/practice_files/python/practice_builtins/practice_file2.py similarity index 100% rename from src/practice_files/practice_builtins/practice_file2.py rename to src/practice_files/python/practice_builtins/practice_file2.py diff --git a/src/practice_files/practice_builtins/practice_file_load.py b/src/practice_files/python/practice_builtins/practice_file_load.py similarity index 100% rename from src/practice_files/practice_builtins/practice_file_load.py rename to src/practice_files/python/practice_builtins/practice_file_load.py diff --git a/src/practice_files/practice_builtins/practice_inspect.py b/src/practice_files/python/practice_builtins/practice_inspect.py similarity index 100% rename from src/practice_files/practice_builtins/practice_inspect.py rename to src/practice_files/python/practice_builtins/practice_inspect.py diff --git a/src/practice_files/practice_builtins/practice_multiprocess.py b/src/practice_files/python/practice_builtins/practice_multiprocess.py similarity index 100% rename from src/practice_files/practice_builtins/practice_multiprocess.py rename to src/practice_files/python/practice_builtins/practice_multiprocess.py diff --git a/src/practice_files/practice_builtins/practice_namedtuple.py b/src/practice_files/python/practice_builtins/practice_namedtuple.py similarity index 100% rename from src/practice_files/practice_builtins/practice_namedtuple.py rename to src/practice_files/python/practice_builtins/practice_namedtuple.py diff --git a/src/practice_files/practice_builtins/practice_path.py b/src/practice_files/python/practice_builtins/practice_path.py similarity index 100% rename from src/practice_files/practice_builtins/practice_path.py rename to src/practice_files/python/practice_builtins/practice_path.py diff --git a/src/practice_files/practice_builtins/practice_type.py b/src/practice_files/python/practice_builtins/practice_type.py similarity index 100% rename from src/practice_files/practice_builtins/practice_type.py rename to src/practice_files/python/practice_builtins/practice_type.py diff --git a/src/practice_files/practice_builtins/practice_unicode.py b/src/practice_files/python/practice_builtins/practice_unicode.py similarity index 100% rename from src/practice_files/practice_builtins/practice_unicode.py rename to src/practice_files/python/practice_builtins/practice_unicode.py diff --git a/src/practice_files/practice_builtins/practice_urllib.py b/src/practice_files/python/practice_builtins/practice_urllib.py similarity index 100% rename from src/practice_files/practice_builtins/practice_urllib.py rename to src/practice_files/python/practice_builtins/practice_urllib.py diff --git a/src/practice_files/practice_builtins/practice_warning.py b/src/practice_files/python/practice_builtins/practice_warning.py similarity index 100% rename from src/practice_files/practice_builtins/practice_warning.py rename to src/practice_files/python/practice_builtins/practice_warning.py diff --git a/src/practice_files/practice_builtins/practice_weakref.py b/src/practice_files/python/practice_builtins/practice_weakref.py similarity index 100% rename from src/practice_files/practice_builtins/practice_weakref.py rename to src/practice_files/python/practice_builtins/practice_weakref.py diff --git a/src/practice_files/practice_builtins/practice_xml.py b/src/practice_files/python/practice_builtins/practice_xml.py similarity index 100% rename from src/practice_files/practice_builtins/practice_xml.py rename to src/practice_files/python/practice_builtins/practice_xml.py diff --git a/src/practice_files/practice_circular_import/__init__.py b/src/practice_files/python/practice_circular_import/__init__.py similarity index 100% rename from src/practice_files/practice_circular_import/__init__.py rename to src/practice_files/python/practice_circular_import/__init__.py diff --git a/src/practice_files/practice_circular_import/main.py b/src/practice_files/python/practice_circular_import/main.py similarity index 100% rename from src/practice_files/practice_circular_import/main.py rename to src/practice_files/python/practice_circular_import/main.py diff --git a/src/practice_files/practice_circular_import/package_a.py b/src/practice_files/python/practice_circular_import/package_a.py similarity index 100% rename from src/practice_files/practice_circular_import/package_a.py rename to src/practice_files/python/practice_circular_import/package_a.py diff --git a/src/practice_files/practice_circular_import/package_b.py b/src/practice_files/python/practice_circular_import/package_b.py similarity index 100% rename from src/practice_files/practice_circular_import/package_b.py rename to src/practice_files/python/practice_circular_import/package_b.py diff --git a/src/practice_files/practice_circular_import/package_c.py b/src/practice_files/python/practice_circular_import/package_c.py similarity index 100% rename from src/practice_files/practice_circular_import/package_c.py rename to src/practice_files/python/practice_circular_import/package_c.py diff --git a/src/practice_files/practice_cpython/CMakeLists.txt b/src/practice_files/python/practice_cpython/CMakeLists.txt similarity index 100% rename from src/practice_files/practice_cpython/CMakeLists.txt rename to src/practice_files/python/practice_cpython/CMakeLists.txt diff --git a/src/practice_files/practice_cpython/practice_types.c b/src/practice_files/python/practice_cpython/practice_types.c similarity index 100% rename from src/practice_files/practice_cpython/practice_types.c rename to src/practice_files/python/practice_cpython/practice_types.c diff --git a/src/practice_files/practice_cpython/practice_types.py b/src/practice_files/python/practice_cpython/practice_types.py similarity index 100% rename from src/practice_files/practice_cpython/practice_types.py rename to src/practice_files/python/practice_cpython/practice_types.py diff --git a/src/practice_files/practice_decorator/__init__.py b/src/practice_files/python/practice_decorator/__init__.py similarity index 100% rename from src/practice_files/practice_decorator/__init__.py rename to src/practice_files/python/practice_decorator/__init__.py diff --git a/src/practice_files/practice_decorator/practice_deco.py b/src/practice_files/python/practice_decorator/practice_deco.py similarity index 100% rename from src/practice_files/practice_decorator/practice_deco.py rename to src/practice_files/python/practice_decorator/practice_deco.py diff --git a/src/practice_files/practice_decorator/practice_deco2.py b/src/practice_files/python/practice_decorator/practice_deco2.py similarity index 100% rename from src/practice_files/practice_decorator/practice_deco2.py rename to src/practice_files/python/practice_decorator/practice_deco2.py diff --git a/src/practice_files/practice_decorator/practice_deco3.py b/src/practice_files/python/practice_decorator/practice_deco3.py similarity index 100% rename from src/practice_files/practice_decorator/practice_deco3.py rename to src/practice_files/python/practice_decorator/practice_deco3.py diff --git a/src/practice_files/practice_decorator/practice_deco4.py b/src/practice_files/python/practice_decorator/practice_deco4.py similarity index 100% rename from src/practice_files/practice_decorator/practice_deco4.py rename to src/practice_files/python/practice_decorator/practice_deco4.py diff --git a/src/practice_files/practice_decorator/practice_deco_args.py b/src/practice_files/python/practice_decorator/practice_deco_args.py similarity index 100% rename from src/practice_files/practice_decorator/practice_deco_args.py rename to src/practice_files/python/practice_decorator/practice_deco_args.py diff --git a/src/practice_files/practice_decorator/practice_decorator_using_html.py b/src/practice_files/python/practice_decorator/practice_decorator_using_html.py similarity index 100% rename from src/practice_files/practice_decorator/practice_decorator_using_html.py rename to src/practice_files/python/practice_decorator/practice_decorator_using_html.py diff --git a/src/practice_files/practice_func/__init__.py b/src/practice_files/python/practice_func/__init__.py similarity index 100% rename from src/practice_files/practice_func/__init__.py rename to src/practice_files/python/practice_func/__init__.py diff --git a/src/practice_files/practice_func/practice_attr.py b/src/practice_files/python/practice_func/practice_attr.py similarity index 100% rename from src/practice_files/practice_func/practice_attr.py rename to src/practice_files/python/practice_func/practice_attr.py diff --git a/src/practice_files/practice_func/practice_attr_2.py b/src/practice_files/python/practice_func/practice_attr_2.py similarity index 100% rename from src/practice_files/practice_func/practice_attr_2.py rename to src/practice_files/python/practice_func/practice_attr_2.py diff --git a/src/practice_files/practice_func/practice_compisite.py b/src/practice_files/python/practice_func/practice_compisite.py similarity index 98% rename from src/practice_files/practice_func/practice_compisite.py rename to src/practice_files/python/practice_func/practice_compisite.py index 993a14a..e53a7b4 100644 --- a/src/practice_files/practice_func/practice_compisite.py +++ b/src/practice_files/python/practice_func/practice_compisite.py @@ -19,8 +19,6 @@ def composite_funcs(*funcs: Callable) -> Callable: # return reduce(lambda f, g: (lambda x: f(g(x))), funcs) # msg = ",".join(["{}".format(func.__name__) for func in funcs]) # logging.debug(msg) - logging.debug(funcs[0].__name__) - # func = lambda x: funcs[0](composite_funcs(*funcs[1:])(x)) if len(funcs) > 1 else funcs[0] # return lambda x: funcs[0](composite_funcs(*funcs[1:])(x)) if len(funcs) > 1 else funcs[0] diff --git a/src/practice_files/practice_func/practice_yield.py b/src/practice_files/python/practice_func/practice_yield.py similarity index 100% rename from src/practice_files/practice_func/practice_yield.py rename to src/practice_files/python/practice_func/practice_yield.py diff --git a/src/practice_files/practice_image/__init__.py b/src/practice_files/python/practice_logging/__init__.py similarity index 100% rename from src/practice_files/practice_image/__init__.py rename to src/practice_files/python/practice_logging/__init__.py diff --git a/src/practice_files/practice_logging/config.py b/src/practice_files/python/practice_logging/config.py similarity index 100% rename from src/practice_files/practice_logging/config.py rename to src/practice_files/python/practice_logging/config.py diff --git a/src/practice_files/practice_logging/practice_accept_log_yaml.py b/src/practice_files/python/practice_logging/practice_accept_log_yaml.py similarity index 100% rename from src/practice_files/practice_logging/practice_accept_log_yaml.py rename to src/practice_files/python/practice_logging/practice_accept_log_yaml.py diff --git a/src/practice_files/practice_logging/practice_log_server.py b/src/practice_files/python/practice_logging/practice_log_server.py similarity index 100% rename from src/practice_files/practice_logging/practice_log_server.py rename to src/practice_files/python/practice_logging/practice_log_server.py diff --git a/src/practice_files/practice_logging/practice_logging.py b/src/practice_files/python/practice_logging/practice_logging.py similarity index 100% rename from src/practice_files/practice_logging/practice_logging.py rename to src/practice_files/python/practice_logging/practice_logging.py diff --git a/src/practice_files/practice_logging/python_log_conf.yml b/src/practice_files/python/practice_logging/python_log_conf.yml similarity index 100% rename from src/practice_files/practice_logging/python_log_conf.yml rename to src/practice_files/python/practice_logging/python_log_conf.yml diff --git a/src/practice_files/practice_module/__init__.py b/src/practice_files/python/practice_module/__init__.py similarity index 100% rename from src/practice_files/practice_module/__init__.py rename to src/practice_files/python/practice_module/__init__.py diff --git a/src/practice_files/practice_module/module1.py b/src/practice_files/python/practice_module/module1.py similarity index 100% rename from src/practice_files/practice_module/module1.py rename to src/practice_files/python/practice_module/module1.py diff --git a/src/practice_files/practice_module/practice_functional_import.py b/src/practice_files/python/practice_module/practice_functional_import.py similarity index 100% rename from src/practice_files/practice_module/practice_functional_import.py rename to src/practice_files/python/practice_module/practice_functional_import.py diff --git a/src/practice_files/practice_module/practice_import.py b/src/practice_files/python/practice_module/practice_import.py similarity index 100% rename from src/practice_files/practice_module/practice_import.py rename to src/practice_files/python/practice_module/practice_import.py diff --git a/src/practice_files/practice_module/practice_import2.py b/src/practice_files/python/practice_module/practice_import2.py similarity index 100% rename from src/practice_files/practice_module/practice_import2.py rename to src/practice_files/python/practice_module/practice_import2.py diff --git a/src/practice_files/practice_module/practice_import_loader_by_files.py b/src/practice_files/python/practice_module/practice_import_loader_by_files.py similarity index 100% rename from src/practice_files/practice_module/practice_import_loader_by_files.py rename to src/practice_files/python/practice_module/practice_import_loader_by_files.py diff --git a/src/practice_files/practice_module/practice_module_name.py b/src/practice_files/python/practice_module/practice_module_name.py similarity index 100% rename from src/practice_files/practice_module/practice_module_name.py rename to src/practice_files/python/practice_module/practice_module_name.py diff --git a/src/practice_files/practice_module/practice_module_test.py b/src/practice_files/python/practice_module/practice_module_test.py similarity index 100% rename from src/practice_files/practice_module/practice_module_test.py rename to src/practice_files/python/practice_module/practice_module_test.py diff --git a/src/practice_files/practice_module/practice_module_test2.py b/src/practice_files/python/practice_module/practice_module_test2.py similarity index 100% rename from src/practice_files/practice_module/practice_module_test2.py rename to src/practice_files/python/practice_module/practice_module_test2.py diff --git a/src/practice_files/practice_module/practice_pkg.py b/src/practice_files/python/practice_module/practice_pkg.py similarity index 100% rename from src/practice_files/practice_module/practice_pkg.py rename to src/practice_files/python/practice_module/practice_pkg.py diff --git a/src/practice_files/practice_module/practice_pkg_2.py b/src/practice_files/python/practice_module/practice_pkg_2.py similarity index 100% rename from src/practice_files/practice_module/practice_pkg_2.py rename to src/practice_files/python/practice_module/practice_pkg_2.py diff --git a/src/practice_files/practice_module/practice_runtime_code_load.py b/src/practice_files/python/practice_module/practice_runtime_code_load.py similarity index 100% rename from src/practice_files/practice_module/practice_runtime_code_load.py rename to src/practice_files/python/practice_module/practice_runtime_code_load.py diff --git a/src/practice_files/practice_logging/__init__.py b/src/practice_files/python/practice_pattern/__init__.py similarity index 100% rename from src/practice_files/practice_logging/__init__.py rename to src/practice_files/python/practice_pattern/__init__.py diff --git a/src/practice_files/practice_pattern/practice_singleton.py b/src/practice_files/python/practice_pattern/practice_singleton.py similarity index 100% rename from src/practice_files/practice_pattern/practice_singleton.py rename to src/practice_files/python/practice_pattern/practice_singleton.py diff --git a/src/practice_files/practice_pattern/practice_state_machine.py b/src/practice_files/python/practice_pattern/practice_state_machine.py similarity index 100% rename from src/practice_files/practice_pattern/practice_state_machine.py rename to src/practice_files/python/practice_pattern/practice_state_machine.py diff --git a/src/practice_files/practice_media/__init__.py b/src/practice_files/python/practice_python/__init__.py similarity index 100% rename from src/practice_files/practice_media/__init__.py rename to src/practice_files/python/practice_python/__init__.py diff --git a/src/practice_files/practice_python/practice_class.py b/src/practice_files/python/practice_python/practice_class.py similarity index 100% rename from src/practice_files/practice_python/practice_class.py rename to src/practice_files/python/practice_python/practice_class.py diff --git a/src/practice_files/practice_python/practice_class_hierarchy.py b/src/practice_files/python/practice_python/practice_class_hierarchy.py similarity index 100% rename from src/practice_files/practice_python/practice_class_hierarchy.py rename to src/practice_files/python/practice_python/practice_class_hierarchy.py diff --git a/src/practice_files/practice_python/practice_create_fn.py b/src/practice_files/python/practice_python/practice_create_fn.py similarity index 100% rename from src/practice_files/practice_python/practice_create_fn.py rename to src/practice_files/python/practice_python/practice_create_fn.py diff --git a/src/practice_files/practice_python/practice_csv.py b/src/practice_files/python/practice_python/practice_csv.py similarity index 100% rename from src/practice_files/practice_python/practice_csv.py rename to src/practice_files/python/practice_python/practice_csv.py diff --git a/src/practice_files/practice_python/practice_dict.py b/src/practice_files/python/practice_python/practice_dict.py similarity index 100% rename from src/practice_files/practice_python/practice_dict.py rename to src/practice_files/python/practice_python/practice_dict.py diff --git a/src/practice_files/practice_python/practice_enum.py b/src/practice_files/python/practice_python/practice_enum.py similarity index 100% rename from src/practice_files/practice_python/practice_enum.py rename to src/practice_files/python/practice_python/practice_enum.py diff --git a/src/practice_files/practice_python/practice_enum_class_hierarchy.py b/src/practice_files/python/practice_python/practice_enum_class_hierarchy.py similarity index 100% rename from src/practice_files/practice_python/practice_enum_class_hierarchy.py rename to src/practice_files/python/practice_python/practice_enum_class_hierarchy.py diff --git a/src/practice_files/practice_python/practice_func.py b/src/practice_files/python/practice_python/practice_func.py similarity index 100% rename from src/practice_files/practice_python/practice_func.py rename to src/practice_files/python/practice_python/practice_func.py diff --git a/src/practice_files/practice_python/practice_list.py b/src/practice_files/python/practice_python/practice_list.py similarity index 100% rename from src/practice_files/practice_python/practice_list.py rename to src/practice_files/python/practice_python/practice_list.py diff --git a/src/practice_files/practice_python/practice_loop.py b/src/practice_files/python/practice_python/practice_loop.py similarity index 100% rename from src/practice_files/practice_python/practice_loop.py rename to src/practice_files/python/practice_python/practice_loop.py diff --git a/src/practice_files/practice_python/practice_obj.py b/src/practice_files/python/practice_python/practice_obj.py similarity index 100% rename from src/practice_files/practice_python/practice_obj.py rename to src/practice_files/python/practice_python/practice_obj.py diff --git a/src/practice_files/practice_python/practice_set.py b/src/practice_files/python/practice_python/practice_set.py similarity index 100% rename from src/practice_files/practice_python/practice_set.py rename to src/practice_files/python/practice_python/practice_set.py diff --git a/src/practice_files/practice_python/practice_typehint.py b/src/practice_files/python/practice_python/practice_typehint.py similarity index 100% rename from src/practice_files/practice_python/practice_typehint.py rename to src/practice_files/python/practice_python/practice_typehint.py diff --git a/src/practice_files/practice_python/test.csv b/src/practice_files/python/practice_python/test.csv similarity index 100% rename from src/practice_files/practice_python/test.csv rename to src/practice_files/python/practice_python/test.csv diff --git a/src/practice_files/practice_serialize/practice_pickle.py b/src/practice_files/python/practice_serialize/practice_pickle.py similarity index 100% rename from src/practice_files/practice_serialize/practice_pickle.py rename to src/practice_files/python/practice_serialize/practice_pickle.py diff --git a/src/practice_files/practice_pattern/__init__.py b/src/practice_files/python/practice_std_library/__init__.py similarity index 100% rename from src/practice_files/practice_pattern/__init__.py rename to src/practice_files/python/practice_std_library/__init__.py diff --git a/src/practice_files/practice_std_library/practice_audithook.py b/src/practice_files/python/practice_std_library/practice_audithook.py similarity index 100% rename from src/practice_files/practice_std_library/practice_audithook.py rename to src/practice_files/python/practice_std_library/practice_audithook.py diff --git a/src/practice_files/practice_std_library/practice_fibo.py b/src/practice_files/python/practice_std_library/practice_fibo.py similarity index 100% rename from src/practice_files/practice_std_library/practice_fibo.py rename to src/practice_files/python/practice_std_library/practice_fibo.py diff --git a/src/practice_files/practice_std_library/practice_func.py b/src/practice_files/python/practice_std_library/practice_func.py similarity index 100% rename from src/practice_files/practice_std_library/practice_func.py rename to src/practice_files/python/practice_std_library/practice_func.py diff --git a/src/practice_files/practice_std_library/practice_named_enum.py b/src/practice_files/python/practice_std_library/practice_named_enum.py similarity index 100% rename from src/practice_files/practice_std_library/practice_named_enum.py rename to src/practice_files/python/practice_std_library/practice_named_enum.py diff --git a/src/practice_files/practice_string/practice_extract.py b/src/practice_files/python/practice_string/practice_extract.py similarity index 100% rename from src/practice_files/practice_string/practice_extract.py rename to src/practice_files/python/practice_string/practice_extract.py diff --git a/src/practice_files/practice_string/practice_unicode.py b/src/practice_files/python/practice_string/practice_unicode.py similarity index 100% rename from src/practice_files/practice_string/practice_unicode.py rename to src/practice_files/python/practice_string/practice_unicode.py diff --git a/src/practice_files/practice_string/text_output.txt b/src/practice_files/python/practice_string/text_output.txt similarity index 100% rename from src/practice_files/practice_string/text_output.txt rename to src/practice_files/python/practice_string/text_output.txt diff --git a/src/practice_files/practice_string/text_unicode.txt b/src/practice_files/python/practice_string/text_unicode.txt similarity index 100% rename from src/practice_files/practice_string/text_unicode.txt rename to src/practice_files/python/practice_string/text_unicode.txt diff --git a/src/practice_files/practice_subprocess/popen_runner.py b/src/practice_files/python/practice_subprocess/popen_runner.py similarity index 100% rename from src/practice_files/practice_subprocess/popen_runner.py rename to src/practice_files/python/practice_subprocess/popen_runner.py diff --git a/src/practice_files/practice_subprocess/practice_popen.py b/src/practice_files/python/practice_subprocess/practice_popen.py similarity index 100% rename from src/practice_files/practice_subprocess/practice_popen.py rename to src/practice_files/python/practice_subprocess/practice_popen.py diff --git a/src/practice_files/practice_python/__init__.py b/src/practice_files/python/practice_typing/__init__.py similarity index 100% rename from src/practice_files/practice_python/__init__.py rename to src/practice_files/python/practice_typing/__init__.py diff --git a/src/practice_files/python/practice_typing/practice_cast.py b/src/practice_files/python/practice_typing/practice_cast.py new file mode 100644 index 0000000..b7dd006 --- /dev/null +++ b/src/practice_files/python/practice_typing/practice_cast.py @@ -0,0 +1,46 @@ +""" +typing.cast + +Practice for typing.cast to try type casting for instance to child class. +Actually, it does not works. `cast` should be read for semantic word, declaration. +""" +from typing import cast + + +class ACls: + x: int + y: int + z: int + + def __init__(self, x=0, y=1, z=2) -> None: + self.x = x + self.y = y + self.z = z + + def __str__(self): + return f"" + +class BCls(ACls): + a: str + b: str + c: str + + def __init__(self, a="a", b="b", c="c", *, x=0, y=1, z=2): + super().__init__(x, y, z) + self.a = a + self.b = b + self.c = c + + +def runner(): + a = ACls(1,2,3) + + print(type(a), a) # + + b = cast(BCls, a) # Just declare type to BCls for variable `a`. It does not means of really converting to BCls. + + print(type(b), b) # + + +if __name__ == "__main__": + runner() diff --git a/src/practice_files/practice_typing/practice_protocol.py b/src/practice_files/python/practice_typing/practice_protocol.py similarity index 100% rename from src/practice_files/practice_typing/practice_protocol.py rename to src/practice_files/python/practice_typing/practice_protocol.py diff --git a/src/practice_files/practice_redis/__init__.py b/src/practice_files/python/weakref/__init__.py similarity index 100% rename from src/practice_files/practice_redis/__init__.py rename to src/practice_files/python/weakref/__init__.py diff --git a/src/practice_files/python/weakref/practice_weakref.py b/src/practice_files/python/weakref/practice_weakref.py new file mode 100644 index 0000000..e281e68 --- /dev/null +++ b/src/practice_files/python/weakref/practice_weakref.py @@ -0,0 +1,35 @@ +""" +weakref with dataclass + +Practice to add attribute for reference type. + - Not support the attribute type of ReferenceType for BaseModel, dataclass in pydantic + - Available to add the attribute type of ReferenceType for dataclass(basic library) +""" +from weakref import ref, ReferenceType +# from pydantic import BaseModel, Field +# from pydantic.dataclasses import dataclass +from dataclasses import dataclass, field, asdict +from typing import Optional, Any, ForwardRef + + +@dataclass +class Object: + field: str = field(default="", kw_only=True) + +@dataclass +class SuperObject: + obj: ReferenceType[Object] + +o = Object(field="abc") +r = ref(o) + +so = SuperObject(obj = ref(o)) + +print(so) +print(so.obj, so.obj()) +print(id(so.obj()), id(o)) + +print(o.field, so.obj().field) + +o.field = "xyz" +print(so.obj().field)