diff --git a/examples/README.md b/examples/README.md new file mode 100644 index 0000000..44f3ca6 --- /dev/null +++ b/examples/README.md @@ -0,0 +1,3 @@ +# Python Examples + +// to do diff --git a/examples/date.py b/examples/date.py new file mode 100644 index 0000000..8f19800 --- /dev/null +++ b/examples/date.py @@ -0,0 +1,40 @@ +from datetime import datetime, timedelta + +now = datetime.now() + +first_day_week = now - timedelta(days=now.weekday()) + +currently_day = int(now.strftime("%d")) +currently_month = int(now.strftime("%m")) +currently_year = int(now.strftime("%Y")) + +current_date = datetime(currently_year, currently_month, currently_day) + +_date = now.strftime("%d-%m-%Y") +_time = now.strftime("%H:%M:%S") +week_number_iso = current_date.isocalendar()[1] +week_number_sunday = current_date.strftime("%U") +week_number_monday = current_date.strftime("%W") +year = current_date.strftime("%Y") +month = current_date.strftime("%m") +day = current_date.strftime("%j") +week = current_date.strftime("%A") +satuday = first_day_week + timedelta(days=5) +sunday = first_day_week + timedelta(days=6) + +print() +print() +print(f"Currenty date: {_date}") +print(f"Currenty time: {_time}") +print(f"Week number [ISO format]: {week_number_iso}") +print(f"Week number [starts on Sunday]: {week_number_sunday}") +print(f"Week number [starts on Monday]: {week_number_monday}") +print(f"Year: {year}") +print(f"Month: {month}") +print(f"Day of the year: {day}") +print(f"Currently day of the week: {week}") +print(f"Saturday of the currently week: {satuday.strftime('%Y-%m-%d')}") +print(f"Sunday of the currently week: {sunday.strftime('%Y-%m-%d')}") +print() +print() + diff --git a/python-blogs/README.md b/python-blogs/README.md index 0f7edf2..363ec18 100644 --- a/python-blogs/README.md +++ b/python-blogs/README.md @@ -23,6 +23,8 @@ - [Duck Typing in Python: Writing Flexible and Decoupled Code](https://realpython.com/duck-typing-python/) - [Python's pathlib Module: Taming the File System](https://realpython.com/python-pathlib/) - [What Are Python Wheels and Why Should You Care?](https://realpython.com/python-wheels/) +- [Python Closures: Common Use Cases and Examples](https://realpython.com/python-closure/) +- [Python '!=' Is Not 'is not': Comparing Objects in Python](https://realpython.com/python-is-identity-vs-equality/) ## Mathspp > Website: https://mathspp.com @@ -49,6 +51,7 @@ - [`bytes`: The Lesser-Known Python Built-In Sequence • And Understanding UTF-8 Encoding](https://www.thepythoncodingstack.com/p/bytes-python-built-in-unicode-utf-8-encoding) +- [After You. No, I Insist, You Go First • Python's Operator Precedence](https://www.thepythoncodingstack.com/p/python-operator-precedence-after-you-no-i-insist) ## Python Engineer > Website: https://www.python-engineer.com @@ -67,6 +70,7 @@ - [Data structures contain pointers](https://www.pythonmorsels.com/data-structures-contain-pointers/) - [Converting a string to a datetime](https://www.pythonmorsels.com/converting-a-string-to-a-datetime/) - [Find your strptime/strftime format](https://www.pythonmorsels.com/strptime/#formats) +- [Python's pathlib module](https://www.pythonmorsels.com/pathlib-module/) ## Test Driven > Website: https://testdriven.io/ diff --git a/python-packaging/uv.md b/python-packaging/uv.md index c344b83..3aa0b81 100644 --- a/python-packaging/uv.md +++ b/python-packaging/uv.md @@ -22,6 +22,11 @@ Install a specific Python version: uv python install 3.12 ``` +Update uv to the latest version: +```shell +uv self update +``` + ### Source - Website: https://docs.astral.sh/uv/ @@ -36,3 +41,4 @@ uv python install 3.12 - [Docker images using uv's python](https://mkennedy.codes/posts/python-docker-images-using-uv-s-new-python-features/) - [Production-ready Docker Containers with uv](https://hynek.me/articles/docker-uv/) - [Switching from virtualenvwrapper to direnv, Starship, and uv](https://treyhunner.com/2024/10/switching-from-virtualenvwrapper-to-direnv-starship-and-uv/) +- [A comprehensive guide to python project management and packaging concepts illustrated with uv part 1](https://reinforcedknowledge.com/a-comprehensive-guide-to-python-project-management-and-packaging-concepts-illustrated-with-uv-part-i/)