diff --git a/doc/conf.py b/doc/conf.py index 2b706db..b4bf7b1 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -23,7 +23,7 @@ source_suffix = ['.rst', '.md'] -extensions = ['myst_parser','sphinx.ext.autodoc', 'sphinx.ext.autosummary','sphinx_copybutton'] +extensions = ['myst_parser','sphinx.ext.autodoc', 'sphinx.ext.autosummary','sphinx_copybutton','sphinx_contributors'] templates_path = ['_templates'] exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] diff --git a/doc/contributors.rst b/doc/contributors.rst new file mode 100644 index 0000000..2fef78f --- /dev/null +++ b/doc/contributors.rst @@ -0,0 +1,15 @@ +Contributors +============ + +We would like to express our sincere gratitude to the following +contributors who have made valuable contributions + + +.. contributors:: python-world/Newsletter + :avatars: + :contributions: + :order: DESC + +Thank you for your dedication and for enriching the Python community +with your valuable insights, code snippets, and contributions! Happy +coding! ๐Ÿโœจ \ No newline at end of file diff --git a/doc/index.rst b/doc/index.rst index fcccbfb..271c69f 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -9,4 +9,8 @@ Python-world Newsletter .. toctree:: :maxdepth: 2 - modules \ No newline at end of file + contributors + modules + + + diff --git a/doc/modules.rst b/doc/modules.rst index a1e8653..dceb258 100644 --- a/doc/modules.rst +++ b/doc/modules.rst @@ -3,4 +3,6 @@ :maxdepth: 4 newsletters/index.2023 - newsletters/index.2022 \ No newline at end of file + newsletters/index.2022 + +.. contributors:: sphinx-doc/sphinx \ No newline at end of file diff --git a/doc/newsletters/2023/WEEK_29.md b/doc/newsletters/2023/WEEK_29.md new file mode 100644 index 0000000..aad0bb4 --- /dev/null +++ b/doc/newsletters/2023/WEEK_29.md @@ -0,0 +1,270 @@ + +# Week 29 - Jully 2023 + +## Introduction and Highlights + + +Welcome to the latest edition of the Python-World Newsletter! We bring +you the most exciting updates and insightful content from the Python +community. In this weekโ€™s edition, we have some incredible code +snippets, community spotlights, upcoming events, useful resources, and +more. Letโ€™s dive in! + +## Code Snippets + +### 1. ๐Ÿ’ผ Simplifying Python Classes with Dataclasses. + +Python dataclasses are a fantastic addition to the Python standard library that simplifies the creation of classes for storing data. ๐Ÿฐ๐Ÿ’พ With just a few lines of code, you can define classes that come with built-in methods for easy attribute initialization, comparison, and more. ๐ŸŽ๐Ÿ’ป + +**๐ŸŒŸ Key Features of Python Dataclasses:** + +โœ… Automatic attribute initialization - Say goodbye to writing tedious `__init__` methods! + +โœ… Concise and clean class definitions using decorators. + +โœ… Built-in methods for equality comparison, representation, and more. + +โœ… Customizable field defaults and ordering. + +โœ… Full integration with Python's standard library. + + +**๐Ÿ“ Simple Examples to Get Started:** + +```python +from dataclasses import dataclass + +@dataclass +class Point: + x: int + y: int + +# Creating instances +p1 = Point(1, 2) +p2 = Point(3, 4) + +# Accessing attributes +print(f"Point 1: x={p1.x}, y={p1.y}") +print(f"Point 2: x={p2.x}, y={p2.y}") +``` + +**๐Ÿš€ Use Cases for Python Dataclasses:** +1. **Configuration Objects**: Use dataclasses to create clean and straightforward configuration objects for your applications. ๐Ÿ› ๏ธ๐Ÿ”ง +2. **Data Containers**: Dataclasses are perfect for holding and manipulating structured data, such as CSV records or JSON data. ๐Ÿ“‚๐Ÿ—ƒ๏ธ +3. **API Responses**: Parse API responses into dataclass instances, making the data easy to work with and comprehend. ๐Ÿ“ก๐Ÿ’ผ +4. **Immutable Objects**: By default, dataclasses are immutable, making them suitable for representing read-only data. ๐Ÿ”’๐Ÿ” +5. **Testing**: Dataclasses can be incredibly useful when writing test cases with complex input data. ๐Ÿงช๐Ÿงพ + +**๐Ÿ’ก Pro Tip:** +Don't forget to explore advanced dataclass features like default values, ordering, and post-init processing. Dataclasses are highly customizable to fit your specific needs! ๐Ÿ”๐Ÿ”ง + + + +### 2. ๐Ÿ”ฆ Exploring Python's Hidden Secrets: The inspect Module + +The `inspect` module is your backstage pass to Python's internals. ๐ŸŽญ๐ŸŽซ It provides functions for introspecting live objects like modules, classes, functions, and more. With `inspect`, you can retrieve information about code objects, inspect callables' signatures, and even perform source code analysis. ๐Ÿ•ต๏ธโ€โ™€๏ธ๐Ÿ“ + +**๐Ÿ” Key Features of `inspect`:** + +โœ… Retrieving information about objects and modules at runtime. + +โœ… Accessing source code and analyzing the structure of Python functions and classes. + +โœ… Inspecting and manipulating the call signature of functions. + +โœ… Extracting and examining documentation strings. + +โœ… Finding the source file and line number of code objects. + +**๐Ÿ“ Examples to Get Started:** +```python +import inspect + +# Get the source code of a function +def greet(name,age): + return f"Hello, {name}!" + +source_code = inspect.getsource(greet) +print('Source code:\n',source_code) + +# Inspect a function's signature +signature = inspect.signature(greet) +print("Signature:",signature) + + + +''' +Output +Source code: + def greet(name,age): + return f"Hello, {name}!" + +Signature: (name, age) +''' + +``` + +**๐Ÿš€ Use Cases for `inspect`:** +1. **Debugging and Logging**: Use `inspect` to gather information about the calling frames for powerful debugging and logging capabilities. ๐Ÿž๐Ÿ“ +2. **Documentation Generation**: Automate the generation of documentation by extracting docstrings and function signatures with `inspect`. ๐Ÿ“š๐Ÿ“œ +3. **Dynamic Function Invocation**: Dynamically call functions with the correct arguments using `inspect` to inspect their signatures. ๐Ÿ“ž๐Ÿ”ง +4. **Code Analysis**: Perform static code analysis and gather insights about your codebase using `inspect` functions. ๐Ÿ“Š๐Ÿ“‹ +5. **Custom Decorators**: Create custom decorators that can automatically introspect and modify the behavior of decorated functions. ๐ŸŽญ๐Ÿ”ฎ + +**๐Ÿ’ก Pro Tip:** +Experiment with `inspect` interactively in a Python REPL to get a better feel for its capabilities. ๐Ÿ”„๐Ÿ”ฌ + + + + +### 3. ๐Ÿ”ง The Python Package Manager: Unleashing the Power of pip + + +`pip` is your go-to tool for installing, managing, and distributing Python packages. ๐Ÿ› ๏ธ๐Ÿ“š With a vast repository of open-source libraries available on the Python Package Index (PyPI), `pip` makes it a breeze to enhance your Python projects with external functionality. ๐ŸŒŸ๐Ÿ“ฆ + +**๐ŸŒŸ Key Features of `pip`:** + +โœ… Installing packages with a simple command - `pip install package-name`. + +โœ… Managing package versions and dependencies effortlessly. + +โœ… Listing installed packages - `pip list`. + +โœ… Upgrading packages to the latest versions - `pip install --upgrade package-name`. + +โœ… Creating virtual environments for isolated package installations. + +**๐Ÿ“ Examples to Get Started:** + +```python +# Install a package +# Example: Installing the popular requests library +# pip install requests + +# Listing installed packages +# pip list + +# Upgrading a package +# Example: Upgrading requests to the latest version +# pip install --upgrade requests +``` + +**๐Ÿš€ Use Cases for `pip`:** + +1. **Library Installation**: Use `pip` to easily install third-party libraries like NumPy, pandas, Django, and more, saving you time and effort. ๐Ÿ“š๐Ÿ’ก +2. **Package Management**: Keep your project's dependencies organized and up to date with `pip`, ensuring smooth collaboration. ๐Ÿ“ฆ๐Ÿ”„ +3. **Virtual Environments**: Create virtual environments to isolate package installations and avoid version conflicts. ๐ŸŒ๐Ÿงช +4. **Continuous Integration**: Utilize `pip` to install project dependencies in CI/CD pipelines for automated testing and deployment. ๐Ÿš€๐Ÿ”ง +5. **Package Distribution**: Share your Python projects with others by distributing them as packages on PyPI using `pip`. ๐Ÿš€๐ŸŒŸ + +**๐Ÿ’ก Pro Tip:** +Explore `pip`'s extensive options like installing packages from version control repositories or installing specific package versions to suit your project's requirements. ๐Ÿ”„๐ŸŽ›๏ธ + + +### 4. ๐ŸŽ Unpacking the Magic of Tuples + +Tuples are one of Python's versatile data structures, and unpacking allows you to extract individual elements from a tuple effortlessly. ๐ŸŽฉ๐ŸŒŸ It's like unwrapping a present and discovering the treasures within! ๐ŸŽ๐Ÿ’Ž + +**๐Ÿงณ Packing Tuples for Efficiency:** +Packing, on the other hand, involves creating tuples by grouping elements together. ๐ŸŽ’๐ŸŒ It's like packing your essentials for a journey, ensuring everything stays organized and accessible. ๐Ÿงณ๐Ÿ—บ๏ธ + +**๐Ÿ“ Examples to Get Started:** +```python +# Tuple Unpacking +point = (10, 20) +x, y = point +print(f"x: {x}, y: {y}") + +# Extended Unpacking +numbers = (1, 2, 3, 4, 5) +first, *middle, last = numbers +print(f"First: {first}, Middle: {middle}, Last: {last}") + +# Tuple Packing +person = "John", 30, "Engineer" +print(person) +``` + +**๐Ÿš€ Use Cases for Tuple Unpacking and Packing:** +1. **Multiple Return Values**: Unpack tuples to receive multiple return values from functions in one assignment. ๐Ÿ“ค๐Ÿ” +2. **Swapping Values**: Swap variable values without using a temporary variable using tuple unpacking. โ†”๏ธ๐Ÿ”„ +3. **Iterating over Multiple Elements**: Unpack tuples while iterating over lists or other iterable data structures. ๐Ÿ”„๐Ÿ“‘ +4. **Function Arguments**: Use tuple packing to pass multiple arguments to a function in a single parameter. ๐Ÿ“‹๐ŸŽ›๏ธ +5. **Namedtuples**: Unpack namedtuples for concise access to individual attributes. ๐Ÿท๏ธ๐Ÿ—ƒ๏ธ + +**๐Ÿ’ก Pro Tip:** +Remember that both tuple unpacking and packing support extended syntax, allowing you to handle multiple elements at once! ๐ŸŽฏ๐ŸŽฏ + + + +### 5. โž— Divmod - Dividing and Modulo Together + +`divmod` is a Python built-in function that takes two numbers and returns a pair of values - the result of integer division and the remainder (modulo). ๐Ÿงฎ๐Ÿ”ข It's like getting two for the price of one! ๐Ÿ’ฒ๐ŸŽ + +**๐Ÿ“ Examples to Get Started:** +```python +# Using divmod +result = divmod(20, 3) +print(f"Result of divmod(20, 3): {result}") + +# Using divmod in a loop +quotients = [] +remainders = [] +for num in range(1, 6): + q, r = divmod(20, num) + quotients.append(q) + remainders.append(r) +print(f"Quotients: {quotients}") +print(f"Remainders: {remainders}") +``` + +**๐Ÿš€ Use Cases for `divmod`:** +1. **Time Conversion**: Convert seconds into hours, minutes, and remaining seconds using `divmod`. ๐Ÿ•๐Ÿ•’ +2. **Loop Iterations**: Use `divmod` in loops to efficiently calculate quotients and remainders for a range of numbers. ๐Ÿ”ƒ๐Ÿ”ข +3. **Formatting**: Combine `divmod` results to display complex numerical data elegantly. ๐ŸŽจ๐Ÿ”  +4. **Resource Allocation**: Distribute resources evenly among a given number of entities using `divmod`. ๐Ÿ’ป๐Ÿ“Š +5. **Currency Handling**: Calculate the number of denominations needed when making change with `divmod`. ๐Ÿ’ฒ๐Ÿ’ธ + +**๐Ÿ’ก Pro Tip:** +Remember that `divmod` can be a powerful tool to optimize certain mathematical operations and simplify your code. ๐Ÿงฎ๐Ÿš€ + + +## Upcoming Events + + +| Event Name | Date | Location | URL | +|------------------|---------|-----------|---------------------------| +| North Bay Python 2023 | July 29th & 30th | Petaluma, California | [Website](https://dev.events/conferences/north-bay-python-petaluma-6-2023) | +| PyDelhi Conference 2023 | Aug 19th & 20th | Delhi | [Website](https://conference.pydelhi.org/) | +| PyCon 2023 | Sept 29 To Oct 2 | HYDRABAD | [Website](https://in.pycon.org/2023/) | + + +Stay updated with the latest events and conferences in the Python +community. Mark your calendars and donโ€™t miss out on these exciting +opportunities to learn, network, and engage with fellow Python +enthusiasts! + + + +Contact +------- + +Sure! Here's the text formatted in proper Markdown format: + +If you have any questions or need further assistance, feel free to reach out to us at [pythonworldhelp@gmail.com](mailto:pythonworldhelp@gmail.com) or join the discussion on our [GitHub Discussions](https://github.com/Python-World/newsletter/discussions) board. + + +## Contributors + + +We would like to express our sincere gratitude to the following +contributors who have made valuable contributions to this edition of the +Python-World Newsletter: + +- [Ravishankar Chavare](https://github.com/chavarera/) +- [Aahnik Daw](https://github.com/aahnik/) + + +Thank you for your dedication and for enriching the Python community +with your valuable insights, code snippets, and contributions! Happy +coding! ๐Ÿโœจ diff --git a/doc/newsletters/index.2023.rst b/doc/newsletters/index.2023.rst index c959100..c94d462 100644 --- a/doc/newsletters/index.2023.rst +++ b/doc/newsletters/index.2023.rst @@ -2,7 +2,8 @@ ========== .. toctree:: :maxdepth: 4 - + + 2023 Jully - Week 29 <2023/WEEK_29.md> 2023 Jully - Week 28 <2023/WEEK_28.md> 2023 Jully - Week 27 <2023/WEEK_27.md> 2023 June - Week 26 <2023/WEEK_26.rst> diff --git a/requirements.txt b/requirements.txt index 0322066..49a0993 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,6 @@ -sphinx_copybutton -ghp-import furo sphinx -myst-parser \ No newline at end of file +ghp-import +myst-parser +sphinx_copybutton +sphinx-contributors \ No newline at end of file