<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Anandesh Sharma on Medium]]></title>
        <description><![CDATA[Stories by Anandesh Sharma on Medium]]></description>
        <link>https://medium.com/@anandeshsharma?source=rss-8e140108dcb3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*6DlVRVpC4dH3j7lhA1_uZA.png</url>
            <title>Stories by Anandesh Sharma on Medium</title>
            <link>https://medium.com/@anandeshsharma?source=rss-8e140108dcb3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 05:29:20 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@anandeshsharma/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[MCP Apps in 2026: Your Tools Just Got a UI (And It’s a Game-Changer)]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-snippet">You&#x2019;ve been pasting tool outputs into chat windows for months. What if your tools could render rich, interactive dashboards, forms, and&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/@anandeshsharma/mcp-apps-in-2026-your-tools-just-got-a-ui-and-its-a-game-changer-a2ec8a235146?source=rss-8e140108dcb3------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@anandeshsharma/mcp-apps-in-2026-your-tools-just-got-a-ui-and-its-a-game-changer-a2ec8a235146?source=rss-8e140108dcb3------2</link>
            <guid isPermaLink="false">https://medium.com/p/a2ec8a235146</guid>
            <dc:creator><![CDATA[Anandesh Sharma]]></dc:creator>
            <pubDate>Thu, 11 Jun 2026 10:23:02 GMT</pubDate>
            <atom:updated>2026-06-11T10:23:23.904Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Use crawl4ai with langchain RAG.]]></title>
            <link>https://medium.com/@anandeshsharma/use-crawl4ai-with-langchain-rag-4457fe42914a?source=rss-8e140108dcb3------2</link>
            <guid isPermaLink="false">https://medium.com/p/4457fe42914a</guid>
            <category><![CDATA[crawl4ai]]></category>
            <dc:creator><![CDATA[Anandesh Sharma]]></dc:creator>
            <pubDate>Thu, 06 Feb 2025 12:52:09 GMT</pubDate>
            <atom:updated>2025-02-09T08:50:00.410Z</atom:updated>
            <content:encoded><![CDATA[<p>In modern AI applications, accessing and processing real-time web data is increasingly important. Whether you’re building a smart search engine, a content aggregator, or an intelligent data pipeline, the ability to efficiently ingest dynamic content is crucial. In this article, we’ll explore how to extend LangChain’s Document Loader with the asynchronous capabilities of the [crawl4ai](https://pypi.org/project/crawl4ai/) library. By doing so, you can build a custom loader that not only crawls web pages efficiently but also integrates seamlessly with LangChain’s framework.</p><p><strong>Why Combine LangChain and crawl4ai?</strong></p><p>LangChain is renowned for its modular design that simplifies working with large language models (LLMs) by abstracting data ingestion through document loaders. While the built-in loaders serve many use cases, they sometimes lack the flexibility needed for dynamic web crawling and real-time content updates. This is where crawl4ai comes into play. Designed for asynchronous web crawling, crawl4ai allows for non-blocking operations that can dramatically improve performance when dealing with multiple requests or complex web pages.</p><p>By merging these two powerful tools, you create a robust system that can fetch, process, and convert web content into a structured format suitable for downstream processing with LangChain. The following sections dive into the design, code, and implementation details of this integration.</p><p><strong>Building the Custom Document Loader</strong></p><p>Our goal is to develop a custom document loader that extends LangChain’s `BaseLoader` class. This loader will employ crawl4ai to fetch web content asynchronously, process the content into markdown, and then encapsulate the data into a LangChain `Document` object. Let’s take a look at the code:</p><pre><br>from langchain.document_loaders.base import BaseLoader<br>from langchain.docstore.document import Document<br>from crawl4ai import AsyncWebCrawler, BrowserConfig<br>import asyncio<br><br>class Crawl4AILoader(BaseLoader):<br>    def __init__(self, start_url: str, browser_config: BrowserConfig = None):<br>        &quot;&quot;&quot;<br>        Initialize the Crawl4AI document loader.<br><br>        Args:<br>            start_url (str): The URL to start crawling from.<br>            browser_config (BrowserConfig, optional): Optional browser configuration for crawl4ai.<br>        &quot;&quot;&quot;<br>        self.start_url = start_url<br>        self.browser_config = browser_config<br>        self._crawler = AsyncWebCrawler(config=browser_config)<br><br>    async def aload(self) -&gt; list[Document]:<br>        &quot;&quot;&quot;<br>        Asynchronously load documents using crawl4ai.<br><br>        Returns:<br>            A list of Document objects containing the crawled content and metadata.<br>        &quot;&quot;&quot;<br>        # Start the asynchronous crawler.<br>        await self._crawler.start()<br><br>        # Crawl the provided URL to fetch content.<br>        results = await self._crawler.arun(self.start_url)<br>        metadata = {&quot;url&quot;: results.url}<br>        content = results.markdown<br><br>        # Close the crawler to free resources.<br>        await self._crawler.close()<br><br>        # Wrap the fetched content in a Document object.<br>        return [Document(page_content=content, metadata=metadata)]<br><br># Asynchronous main function to test the loader.<br>async def main():<br>    loader = Crawl4AILoader(&quot;https://www.example.com&quot;)<br>    docs = await loader.aload()<br>    for doc in docs:<br>        # Display the URL and a snippet of the content.<br>        print(f&quot;URL: {doc.metadata[&#39;url&#39;]}&quot;)<br>        print(f&quot;Content: {doc.page_content[:200]}...&quot;)  # Show first 200 characters for brevity.<br><br>if __name__ == &quot;__main__&quot;:<br>    asyncio.run(main())</pre><p><strong>Code Walkthrough</strong></p><p><strong>Initialization</strong></p><p>The custom loader, Crawl4AILoader, is initialized with a starting URL and an optional browser configuration. The constructor creates an instance of AsyncWebCrawler from crawl4ai, which will be used to perform the asynchronous crawl.</p><p><strong>Asynchronous Crawling</strong></p><p>The heart of our loader is the aload method, defined as an asynchronous function. Here’s how it works:</p><p>• <strong>Starting the Crawler:</strong></p><p>The method begins by calling await self._crawler.start(), ensuring the crawler is ready to fetch data.</p><p>• <strong>Fetching Data:</strong></p><p>It then uses await self._crawler.arun(self.start_url) to perform the crawl. This method returns a result object containing the URL and the markdown-formatted content.</p><p>• <strong>Processing the Results:</strong></p><p>The fetched content is wrapped into a LangChain Document object along with its metadata, which includes the URL from which the data was obtained.</p><p>• <strong>Resource Cleanup:</strong></p><p>Finally, the crawler is gracefully shut down using await self._crawler.close() to free up resources.</p><p><strong>Testing the Loader</strong></p><p>The asynchronous main function demonstrates how to utilize the loader. By calling asyncio.run(main()), we execute the loader and print a snippet of the retrieved content along with its source URL.</p><p><strong>Benefits of This Integration</strong></p><p>• <strong>Asynchronous Efficiency:</strong></p><p>The use of async/await ensures that your application can handle web requests without blocking, which is essential for high-performance applications.</p><p>• <strong>Modularity:</strong></p><p>Extending LangChain’s BaseLoader allows you to plug this custom loader into your existing LangChain-based projects with minimal changes.</p><p>• <strong>Real-time Data Processing:</strong></p><p>With crawl4ai’s capability to fetch and process live web content, your applications can work with up-to-date data, enabling more accurate and timely insights.</p><p><strong>Conclusion</strong></p><p>Integrating crawl4ai with LangChain’s Document Loader significantly enhances the data ingestion process by combining the best of both worlds — LangChain’s powerful data processing capabilities with crawl4ai’s efficient asynchronous web crawling. This integration is ideal for developers looking to build dynamic, real-time applications that require continuous web content updates. By following the steps outlined in this article, you can build a custom document loader that is both efficient and highly adaptable to a variety of use cases.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4457fe42914a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Evolution of Python: Embracing Type Safety with mypy]]></title>
            <link>https://medium.com/@anandeshsharma/the-evolution-of-python-embracing-type-safety-with-mypy-23b96d67494b?source=rss-8e140108dcb3------2</link>
            <guid isPermaLink="false">https://medium.com/p/23b96d67494b</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[python-types]]></category>
            <category><![CDATA[python-dynamic-typing]]></category>
            <category><![CDATA[mypy-type-checker]]></category>
            <dc:creator><![CDATA[Anandesh Sharma]]></dc:creator>
            <pubDate>Tue, 22 Oct 2024 07:26:14 GMT</pubDate>
            <atom:updated>2024-10-22T07:26:14.570Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F989rqiizQOHZN8TqMQFRA.png" /></figure><p><strong>Introduction:</strong> Python has long been a favorite among developers for its simplicity and flexibility, often labeled as beginner-friendly. However, some argue that Python’s dynamic typing can lead to pitfalls, especially when managing large-scale applications. But what if we could bring the benefits of static typing to Python? In this article, we explore how tools like mypy enhance Python&#39;s error-detection capabilities, providing a balance between dynamic and static typing for more robust code.</p><h3>Understanding Dynamic Typing</h3><p>Dynamic typing is one of Python’s core features. It allows variables to change types during runtime, which offers flexibility but can make large applications error-prone. Consider the following:</p><pre>x = &quot;Hello&quot;<br>x = 42  # No error</pre><p>This fluidity, while useful, can lead to bugs that are difficult to track in larger codebases. Languages like C# enforce static typing, where types are locked in, preventing such changes:</p><pre>string name = &quot;Alex&quot;;<br>name = 42;  // Error: Cannot convert &#39;int&#39; to &#39;string&#39;</pre><p>This difference divides the programming community into two camps: those who prefer the flexibility of dynamic typing and those who value the rigidity and safety of static typing.</p><h3>The Case for Static Typing</h3><p>As software projects scale, managing code becomes more complex. Static typing provides an extra layer of security by catching type-related errors early, during development. For many developers, this control over the code is essential, as it allows them to identify and fix bugs faster.</p><p>For example, in Python, without type checking:</p><pre>def greet(name):<br>    return &quot;Hello &quot; + name</pre><p>If you pass an integer by mistake, it could lead to runtime errors. By adding type hints and using a type checker like mypy, you can catch these errors before they occur:</p><pre>def greet(name: str) -&gt; str:<br>    return &quot;Hello &quot; + name</pre><pre># Incorrect usage caught early<br>print(greet(123))  # mypy will raise an error</pre><h3>Enter mypy: Bridging the Gap</h3><p>mypy is a type checker that gives Python some of the benefits of static typing without changing the language&#39;s nature. It acts as a linter, warning developers of potential issues in the code without stopping execution.</p><p>To get started with mypy:</p><pre>pip install mypy</pre><p>Incorporating it into your development environment is simple, especially if you use tools like VS Code, which supports mypy through extensions.</p><h3>Setting Up mypy</h3><p>Once installed, configuring mypy is straightforward. Add a configuration file (mypy.ini) in your project:</p><pre>[mypy]<br>strict = True<br>warn_unused_configs = True</pre><p>This enables strict mode, ensuring that missing type hints are flagged, and warns about incorrect configurations.</p><h3>Best Practices with mypy</h3><ul><li><strong>Enable strict mode</strong>: This ensures that mypy flags missing type hints.</li><li><strong>Use </strong><strong># type: ignore cautiously</strong>: While useful for silencing errors in complex cases, avoid overusing it as it can mask real issues.</li><li><strong>Suppress warnings when necessary</strong>: If mypy struggles with certain language features, you can suppress specific errors.</li></ul><h3>Recap and Conclusion</h3><p>Python’s dynamic typing can be both a blessing and a curse, especially for large projects. Tools like mypy offer a middle ground, allowing developers to enjoy Python&#39;s flexibility while reaping the benefits of static type checking. The result? Cleaner, more reliable code.</p><p>So, if you’re ready to elevate your Python coding, give mypy a try. It might just change the way you code!</p><p>I hope you found this article insightful. If so, show your appreciation by clapping below!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=23b96d67494b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Python 3.13 is now out, bringing a wealth of new features, improvements, and optimizations that aim…]]></title>
            <link>https://medium.com/@anandeshsharma/whats-new-in-python-3-13-a-comprehensive-guide-with-code-examples-7d89eb171a31?source=rss-8e140108dcb3------2</link>
            <guid isPermaLink="false">https://medium.com/p/7d89eb171a31</guid>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Anandesh Sharma]]></dc:creator>
            <pubDate>Tue, 22 Oct 2024 07:02:17 GMT</pubDate>
            <atom:updated>2024-10-22T07:13:23.273Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XiNLPcL4-7EoiRB8afqpRA.png" /></figure><p>Python 3.13 is now out, bringing a wealth of new features, improvements, and optimizations that aim to improve both performance and developer experience. From experimental threading capabilities to more user-friendly interactive shell improvements, Python continues to evolve into a powerful tool for programmers. In this article, we’ll explore the most exciting features and provide easy-to-understand code examples to help you get the most out of this latest release.</p><h3>1. Revamped Interactive Interpreter</h3><p>One of the most developer-friendly features introduced in Python 3.13 is the revamped interactive interpreter. Previous versions of Python’s REPL (Read-Eval-Print Loop) had limitations when editing multi-line code. You could only scroll back one line at a time, which made modifying functions or classes inconvenient.</p><h3>Key Features of the New REPL:</h3><ul><li><strong>Multi-line editing</strong>: Python 3.13 allows you to edit entire code blocks by pressing the up arrow. You can scroll through multiple lines of a function or class and make modifications more easily.</li><li><strong>New Commands</strong>: Typing commands like exit, quit, or help without parentheses now works directly, making the REPL simpler to use.</li><li><strong>Clear Command</strong>: You can now clear the screen by typing clear, which wasn’t available in earlier versions.</li><li><strong>Colorized Tracebacks</strong>: By default, tracebacks now appear in color, helping to visually parse errors more quickly.</li></ul><h3>Code Example:</h3><pre>&gt;&gt;&gt; def greet(name):<br>...     print(f&quot;Hello, {name}&quot;)<br>&gt;&gt;&gt; greet(&quot;Python 3.13&quot;)<br>Hello, Python 3.13</pre><p>With the new multi-line editing feature, if you press the up arrow, you’ll retrieve the entire function definition, making it easy to modify without retyping everything.</p><h3>2. Free-threaded Mode: Disabling the GIL (Experimental)</h3><p>The Global Interpreter Lock (GIL) has been a controversial feature in Python, limiting the ability to fully utilize multi-core processors. Python 3.13 introduces an <strong>experimental free-threaded mode</strong>, allowing the GIL to be disabled, which can greatly improve multi-threaded performance.</p><p>This mode is still experimental and requires compiling Python with the --with-free-threading flag to enable. It is a game-changer for applications requiring true multi-threading, like those involved in machine learning, high-performance networking, or parallel processing.</p><h3>Key Benefits:</h3><ul><li><strong>Better CPU Utilization</strong>: Full multi-threading capabilities for CPU-bound programs.</li><li><strong>Improved Performance</strong>: Programs that use multiple threads will see performance boosts by utilizing multiple CPU cores.</li></ul><h3>Code Example:</h3><pre>import threading</pre><pre>def thread_task(n):<br>    print(f&quot;Task {n} is running on thread {threading.current_thread().name}&quot;)</pre><pre># Run multiple threads<br>for i in range(5):<br>    t = threading.Thread(target=thread_task, args=(i,))<br>    t.start()</pre><p>In the above example, Python threads will run concurrently. With the free-threaded mode enabled, each thread will utilize separate cores for parallel execution.</p><h3>3. Experimental Just-In-Time (JIT) Compiler</h3><p>Python 3.13 also introduces an <strong>experimental Just-In-Time (JIT) compiler</strong>. JIT compilation can significantly speed up the execution of Python programs by compiling frequently used parts of the code into machine code at runtime. While this feature is experimental and not enabled by default, it lays the foundation for future performance improvements.</p><p>To enable the JIT compiler, you need to compile Python with the --enable-experimental-jit flag.</p><h3>Code Example:</h3><pre>def slow_function():<br>    total = 0<br>    for i in range(1_000_000):<br>        total += i<br>    return total</pre><pre># Call the function to see performance improvements with JIT enabled<br>print(slow_function())</pre><p>With JIT, the loop in the above function could run significantly faster by translating the repeated bytecode operations into native machine code.</p><h3>4. Improved locals() Behavior</h3><p>The locals() function, which returns a dictionary representing the current local symbol table, has a more well-defined behavior in Python 3.13. In previous versions, mutating the dictionary returned by locals() could lead to unpredictable results. Now, the behavior is more consistent, which makes debugging and modifying local variables more reliable.</p><h3>Code Example:</h3><pre>def modify_locals():<br>    x = 5<br>    locals_dict = locals()<br>    locals_dict[&#39;x&#39;] = 10<br>    print(x)  # In Python 3.13, this still prints 5 as expected</pre><pre>modify_locals()</pre><p>While you can access the local variables using locals(), modifying them within the returned dictionary does not affect the actual local variables, ensuring safer and more predictable behavior.</p><h3>5. Memory Optimizations for Docstrings</h3><p>In Python 3.13, docstrings have undergone a memory optimization. The leading whitespace in docstrings is now stripped, reducing the overall memory footprint. This may seem like a small change, but for projects with many large docstrings, it can save significant memory.</p><h3>Code Example:</h3><pre>def example_function():<br>    &quot;&quot;&quot;<br>    This function demonstrates the new memory optimizations for docstrings<br>    in Python 3.13. The leading whitespace is stripped, reducing memory use.<br>    &quot;&quot;&quot;<br>    pass</pre><pre>print(example_function.__doc__)</pre><p>The docstring output will be the same as before, but Python internally stores it more efficiently.</p><h3>6. Support for Android and WASM Platforms</h3><p>Python 3.13 expands platform support by officially adding Android as a <strong>Tier 3 platform</strong> and WebAssembly System Interface (WASI) as a <strong>Tier 2 platform</strong>. This broadens Python’s reach to mobile and embedded devices.</p><h3>Code Example:</h3><p>Although these changes primarily affect compilation and deployment environments, developers can now use Python on Android and WASM without worrying about platform-specific bugs or limitations.</p><h3>7. Deprecation and Removal of Legacy Modules</h3><p>Python continues to clean up its standard library by removing outdated modules that have long been deprecated. As of Python 3.13, the following modules are no longer available:</p><ul><li>cgi</li><li>crypt</li><li>imghdr</li><li>audioop</li><li>mailcap</li></ul><p>This is part of Python’s “Removing Dead Batteries” initiative (PEP 594) to keep the language modern and streamlined.</p><h3>Code Example:</h3><p>If your application still depends on any of these modules, it’s time to migrate to modern alternatives. For example, replace cgi with Flask or FastAPI for handling web requests.</p><pre>pip install flask</pre><h3>8. Typing Improvements</h3><p>Python 3.13 adds several new features to its typing system, including support for <strong>type defaults</strong> in type parameters and <strong>type narrowing annotations</strong>. These improvements make Python’s type-checking system more robust and expressive, especially for larger projects or teams using static analysis tools like mypy.</p><h3>Code Example:</h3><pre>from typing import TypeVar, List</pre><pre>T = TypeVar(&#39;T&#39;, bound=int)</pre><pre>def add_to_list(element: T, lst: List[T] = None) -&gt; List[T]:<br>    if lst is None:<br>        lst = []<br>    lst.append(element)<br>    return lst</pre><pre># Type checking will now catch type inconsistencies more effectively<br>print(add_to_list(5))  # Correct</pre><p>With better typing support, you can write more precise type hints, reducing bugs and making your code easier to maintain.</p><h3>Conclusion</h3><p>Python 3.13 is packed with new features and optimizations, ranging from user-friendly improvements in the REPL to experimental features like the JIT compiler and free-threaded mode. Whether you’re working on performance-critical applications or just looking for a smoother development experience, this release offers something for everyone.</p><p>Stay tuned for further updates as some of these experimental features, like JIT and GIL removal, mature in future Python versions. Ready to upgrade? Download Python 3.13 and start exploring these features today!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7d89eb171a31" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building High-Performance Applications with NestJS and Fastify]]></title>
            <link>https://medium.com/@anandeshsharma/building-high-performance-applications-with-nestjs-and-fastify-ac2546e44323?source=rss-8e140108dcb3------2</link>
            <guid isPermaLink="false">https://medium.com/p/ac2546e44323</guid>
            <category><![CDATA[node]]></category>
            <category><![CDATA[backend]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[scalability]]></category>
            <dc:creator><![CDATA[Anandesh Sharma]]></dc:creator>
            <pubDate>Sat, 22 Jul 2023 03:33:41 GMT</pubDate>
            <atom:updated>2023-07-22T03:33:41.744Z</atom:updated>
            <content:encoded><![CDATA[<p>In the realm of backend development, choosing the right framework can make all the difference. NestJS and Fastify are two powerful frameworks that have garnered significant attention for their ability to provide exceptional performance, scalability, and developer-friendly features. When combined, these frameworks unlock a potent combination that empowers developers to create high-performance applications that can outshine the competition. In this article, we’ll delve into the unique strengths of NestJS and Fastify, explore their differences, and demonstrate how to optimize performance through techniques like request validation and caching. By the end of this read, you’ll have a comprehensive understanding of how to leverage the power of NestJS and Fastify to build efficient and powerful applications.</p><h3>NestJS: The Backing of Strong Foundations</h3><p>NestJS is a progressive and versatile Node.js framework that embraces the concept of modularity. It leverages the power of TypeScript to provide a strongly-typed and structured approach to building server-side applications. By following the principles of Object-Oriented Programming (OOP) and Functional Programming (FP), NestJS promotes code maintainability and testability, making it an excellent choice for complex and large-scale projects.</p><h3>Scalability at Its Core</h3><p>One of NestJS’s standout features is its scalability. The framework encourages the division of applications into modules, each with its own specific functionality. This modularity allows developers to organize and scale their applications efficiently. As the project grows, developers can easily extend and adapt the application by adding or modifying modules without affecting the entire codebase. This scalability ensures that NestJS applications can handle increasing traffic and evolving requirements without sacrificing performance.</p><h3>Fastify: Unleashing Blazing Speed</h3><p>Fastify, on the other hand, is renowned for its incredible speed and low overhead. As a web framework specifically designed for speed, it boasts one of the fastest request processing times among Node.js frameworks. Its performance is further enhanced by leveraging modern JavaScript features and asynchronous programming techniques.</p><h3>Supercharging JSON Serialization</h3><p>In the world of backend development, efficient data serialization is crucial. Fastify’s fast-json-stringify library takes JSON serialization to new heights, providing a significant boost in speed compared to traditional JSON.stringify() methods. This optimization can have a substantial impact on the overall performance of your application, especially when dealing with large amounts of data.</p><h3>The Power of Synergy: NestJS and Fastify Integration</h3><p>Now that we’ve explored the strengths of NestJS and Fastify individually, let’s dive into the power of combining these two frameworks. The integration of NestJS with Fastify allows developers to harness the best of both worlds, creating high-performance applications that deliver exceptional user experiences.</p><h3>Middleware Logic Adjustments</h3><p>When transitioning code from Express to Fastify within a NestJS application, developers need to consider middleware logic adjustments. While the core principles of middleware usage remain consistent, some specific middleware implementations may require adaptations to ensure seamless compatibility with Fastify’s architecture. By making these adjustments thoughtfully, developers can fully leverage Fastify’s speed and performance within their NestJS application.</p><h3>Request Validation for Robust Applications</h3><p>Validation of incoming requests is crucial to ensure the security and integrity of your application. With NestJS and Fastify, developers can implement request validation techniques to thoroughly examine incoming data and reject any malformed or malicious requests. By using Fastify’s built-in validation capabilities and NestJS’s elegant decorators, developers can easily implement robust request validation and keep their applications secure.</p><h3>Caching for Lightning-Fast Responses</h3><p>Caching is a tried-and-true technique for optimizing application performance and response times. By integrating caching mechanisms into your NestJS and Fastify application, you can dramatically reduce the response time for frequently requested data. Fastify provides convenient plugins for caching, and by leveraging NestJS’s extensible architecture, developers can seamlessly integrate caching strategies that cater to their application’s specific needs.</p><h3>Real-World Examples: Unleashing the Potential</h3><p>To truly grasp the capabilities of NestJS and Fastify, let’s explore some real-world examples where developers have harnessed the power of these frameworks to build high-performance applications.</p><h3>Example 1: Real-Time Chat Application</h3><p>In this example, a development team creates a real-time chat application with NestJS and Fastify. By employing Fastify’s lightning-fast request processing, they ensure that chat messages are delivered instantaneously to users, providing a seamless and engaging user experience. Additionally, NestJS’s modularity allows the team to easily add features like user authentication, message history, and chat room management, all while maintaining exceptional performance.</p><h3>Example 2: E-Commerce Platform</h3><p>In this scenario, developers build an e-commerce platform using NestJS and Fastify. The combination of NestJS’s structured architecture and Fastify’s efficient JSON serialization results in rapid API responses and lightning-fast product browsing for customers. With the integration of caching mechanisms, product listings and search results load almost instantly, keeping potential buyers engaged and satisfied.</p><h3>Conclusion: Empowering Developers to Excel</h3><p>In conclusion, NestJS and Fastify are an unbeatable duo when it comes to building high-performance applications. Their unique strengths, when combined, create a powerhouse of scalability, speed, and developer-friendly features. By understanding the differences between the frameworks and optimizing performance through request validation and caching techniques, developers can unlock the full potential of NestJS and Fastify, delivering applications that surpass the competition and provide unparalleled user experiences.</p><p>Now that you’ve grasped the immense potential of NestJS and Fastify, it’s time to embark on your journey to create cutting-edge, high-performance applications that leave a lasting impression. So dive in, explore the possibilities, and let NestJS and Fastify elevate your backend development to new heights!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ac2546e44323" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Maximizing AI’s Potential for Positive Development: Balancing Progress and Mitigating Risks]]></title>
            <link>https://medium.com/@anandeshsharma/maximizing-ais-potential-for-positive-development-balancing-progress-and-mitigating-risks-cbb462682a82?source=rss-8e140108dcb3------2</link>
            <guid isPermaLink="false">https://medium.com/p/cbb462682a82</guid>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Anandesh Sharma]]></dc:creator>
            <pubDate>Fri, 21 Jul 2023 06:55:51 GMT</pubDate>
            <atom:updated>2023-07-21T06:55:51.438Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>At Neuron Square, we believe that artificial intelligence (AI) has the potential to revolutionize various industries and enhance human lives. However, with great power comes great responsibility. In this article, we delve into various aspects of AI, ranging from navigational instructions for web pages to the risks of AI-driven autonomous weapons. Our mission is to shed light on both the promising developments and the potential dangers of AI, emphasizing the importance of finding a balance between progress and mitigation.</p><h3>Navigational Instructions for a Seamless Web Experience</h3><p>To navigate a website efficiently, users need clear and intuitive instructions. At Neuron Square, we prioritize user experience, and our web designers create streamlined interfaces that guide visitors seamlessly through our website. By focusing on user-centered design and providing easily accessible menus, we ensure that users can find the information they seek effortlessly.</p><h3>The Global Newsletter: A Gateway to Worldwide Insights</h3><p>Our website proudly hosts a global newsletter, which serves as a hub for the latest industry insights and updates from around the world. Curated by experts in the field, our newsletter covers a wide range of topics, including technological advancements, innovative breakthroughs, and thought-provoking analyses. By offering a comprehensive newsletter, we aim to foster a community of knowledge-sharing and inspire impactful discussions.</p><h3>Futurist Bernard Marr: Pioneering AI Advancements</h3><p>As a prominent futurist, Bernard Marr’s contributions to the field of AI are invaluable. His latest book delves into the transformative potential of AI and its impact on society. At Neuron Square, we acknowledge and celebrate the work of visionaries like Bernard Marr, as they continue to pave the way for a future empowered by AI.</p><h3>Balancing the Pros and Cons of AI</h3><p>While AI brings numerous benefits, we cannot ignore the potential dangers it poses. Concerns about AI’s dangers, such as the misuse of data and the proliferation of autonomous weapons, need to be addressed proactively. As AI becomes more prevalent in our lives, it is essential to prioritize ethical considerations and accountability.</p><h3>The Risks of AI-Driven Autonomous Weapons</h3><p>The development of AI-driven autonomous weapons raises legitimate concerns about their potential misuse and the implications for international security. At Neuorn Square, we advocate for responsible AI development and stringent regulations to prevent any adverse consequences stemming from the use of autonomous weapons.</p><h3>Social Manipulation and Invasion of Privacy</h3><p>AI’s potential for social manipulation is another area of concern. With the ability to analyze vast amounts of data, AI can influence public opinion and behavior. To safeguard against these risks, we advocate for transparent AI algorithms and robust data protection measures that prioritize user privacy and data security.</p><h3>Social Grading and Misalignment of Human Goals</h3><p>AI’s capabilities to analyze human behavior and decision-making patterns have led to discussions about social grading and the potential misalignment of AI-driven goals with human values. At Neuron Square, we emphasize the importance of human oversight and ethical guidelines to ensure that AI remains a force for good and serves humanity’s best interests.</p><h3>Addressing Discrimination in AI-Driven Data Collection</h3><p>As AI relies heavily on data to make decisions, the risk of discrimination based on AI-collected data becomes a pressing concern. To combat bias and promote fairness, we advocate for diverse data sources and rigorous testing to ensure that AI algorithms are free from discriminatory tendencies.</p><h3>Conclusion</h3><p>In conclusion, at Neuron Square, we recognize the tremendous potential of AI to drive positive developments across various industries. However, we also acknowledge the importance of mitigating AI’s potential risks. By prioritizing ethical considerations, user privacy, and responsible AI development, we can ensure that AI continues to be a powerful tool for progress while safeguarding against potential pitfalls. Together, let us build a future where AI works hand in hand with humanity, creating a world that benefits all.</p><pre>graph LR<br>A[Maximizing AI&#39;s Potential for Positive Development] --&gt; B[Navigational Instructions for a Seamless Web Experience]<br>A --&gt; C[The Global Newsletter: A Gateway to Worldwide Insights]<br>A --&gt; D[Futurist Bernard Marr: Pioneering AI Advancements]<br>A --&gt; E[Balancing the Pros and Cons of AI]<br>E --&gt; F[The Risks of AI-Driven Autonomous Weapons]<br>E --&gt; G[Social Manipulation and Invasion of Privacy]<br>E --&gt; H[Social Grading and Misalignment of Human Goals]<br>E --&gt; I[Addressing Discrimination in AI-Driven Data Collection]</pre><p><em>Note: The above mermaid diagram illustrates the interconnectivity between different sections of the article, highlighting the comprehensive coverage of AI-related topics and their relevance in contemporary society.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cbb462682a82" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Explaining Even Loops in Detail (Node.js)]]></title>
            <link>https://medium.com/@anandeshsharma/explaining-even-loops-in-detail-node-js-4fff6e23f3ee?source=rss-8e140108dcb3------2</link>
            <guid isPermaLink="false">https://medium.com/p/4fff6e23f3ee</guid>
            <category><![CDATA[node-js-tutorial]]></category>
            <category><![CDATA[node]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[nodejs-event-loop]]></category>
            <dc:creator><![CDATA[Anandesh Sharma]]></dc:creator>
            <pubDate>Fri, 21 Jul 2023 06:49:19 GMT</pubDate>
            <atom:updated>2023-07-21T06:49:19.659Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>Hey there, fellow developers! 🖐️ Today, we’re diving into the fascinating world of even loops in Node.js. If you’ve ever found yourself grappling with managing asynchronous operations efficiently, even loops might just be your saving grace. But before we get into that, let’s quickly refresh our memory about loops and their significance in programming.</p><h3>Understanding Loops in JavaScript</h3><p>In the world of programming, loops are like trusty workhorses that help us repeat a set of instructions until a certain condition is met. In JavaScript, we have three primary types of loops: the classic for loop, the versatile while loop, and the less common do-while loop. These loops have been around for ages and are used extensively to iterate over arrays, perform iterative calculations, and more.</p><h3>Introducing the Concept of Even Loops</h3><p>Now, let’s turn our attention to the star of the show: even loops. You might be wondering what makes them special. Well, even loops are specifically designed to handle asynchronous operations in Node.js. In Node.js, where the event-driven, non-blocking architecture reigns supreme, even loops play a crucial role in managing asynchronous tasks efficiently.</p><h3>Using Even Loops in Node.js</h3><p>Node.js, for those unfamiliar, is a JavaScript runtime built on Chrome’s V8 engine. One of its core features is the event loop, which enables Node.js to handle numerous concurrent connections without blocking the execution of other tasks. Even loops fit right into this picture, allowing developers to juggle multiple asynchronous tasks with ease.</p><p>To truly appreciate even loops, let’s briefly talk about the event loop in Node.js. The event loop goes through several phases, including timers, I/O callbacks, and more. Even loops work harmoniously with this event loop to ensure that all tasks are executed promptly.</p><h3>The Basics of Node.js</h3><p>If you’re new to Node.js, fear not! Let’s take a moment to understand what makes this runtime so popular. Node.js allows developers to build scalable network applications, server-side applications, and real-time applications. Its non-blocking nature and event-driven architecture set it apart from traditional server-side platforms.</p><h3>Event Loop in Node.js</h3><p>The event loop is at the heart of Node.js, making it an excellent choice for handling concurrent operations. Unlike traditional blocking approaches, Node.js leverages a non-blocking event loop to ensure that no time is wasted waiting for tasks to complete. This results in impressive performance and scalability.</p><h3>Blocking vs. Non-Blocking Operations</h3><p>In the context of Node.js, the terms “blocking” and “non-blocking” are of paramount importance. Blocking operations halt the execution until the operation completes, while non-blocking operations allow the program to continue its execution without waiting. As you can imagine, non-blocking operations are ideal for performance-intensive tasks, and that’s where even loops shine.</p><h3>Implementing Even Loops in Node.js</h3><p>Enough theory! Let’s get our hands dirty and see how even loops are implemented in Node.js applications. We’ll take you through a step-by-step guide, and by the end, you’ll be a pro at harnessing the power of even loops. Suppose you have a task involving file I/O or network operations. In that case, even loops will make sure these tasks are efficiently managed, allowing other parts of your code to keep running smoothly.</p><h3>Avoiding Common Pitfalls</h3><p>As with any programming concept, even loops come with their share of challenges and pitfalls. It’s essential to be aware of these potential issues and know how to steer clear of them. Performance bottlenecks can be a concern, but fear not! We’ve got some tips up our sleeves to help you optimize your even loops and avoid those pesky bottlenecks.</p><h3>Event Emitters and Even Loops</h3><p>Ah, event emitters! The unsung heroes complement even loops perfectly. Event emitters are an integral part of Node.js, allowing you to emit custom events and handle them gracefully with even loops. They provide a streamlined way to manage complex asynchronous flows, and we’ll show you how to leverage them effectively.</p><h3>Real-World Use Cases</h3><p>It’s all well and good to talk about even loops, but how do they fare in the real world? Let’s explore some real-life scenarios where even loops truly shine. From handling multiple requests simultaneously to managing database operations, even loops prove to be a reliable companion for developers facing asynchronous challenges.</p><h3>Exploring Alternatives</h3><p>While even loops are fantastic for managing asynchronous tasks, it’s always good to know your options. We’ll discuss other approaches for handling asynchronous operations in Node.js, such as promises and async/await. It’s essential to choose the right tool for the job, and understanding these alternatives will make you a more well-rounded developer.</p><h3>Best Practices for Even Loops</h3><p>As with any coding practice, there are some best practices you should follow when implementing even loops. Writing clean, maintainable code is key to ensuring that your application runs smoothly and efficiently. We’ll share some golden rules that will elevate your event loop game and make your code a pleasure to work with.</p><h3>Conclusion</h3><p>Congratulations, dear developers! You’ve successfully journeyed through the world of even loops in Node.js. We’ve covered the basics, dived into their inner workings, and explored real-world use cases. Now, you possess a powerful tool to tackle asynchronous tasks like a pro. Embrace even loops in your Node.js applications, and you’ll witness the true magic of efficient asynchronous programming.</p><h3>FAQs</h3><ol><li><strong>What are the advantages of using even loops in Node.js?</strong> <br>Even loops excel at handling asynchronous tasks, making Node.js applications highly performant and scalable. They ensure that the event loop runs smoothly and efficiently manages concurrent operations.</li><li><strong>Can even loops replace other asynchronous programming methods? </strong>While even loops are excellent for many use cases, they aren’t always the best fit. Depending on the complexity of your application, you might find promises or async/await more suitable for certain tasks.</li><li><strong>Are there any performance concerns with even loops?</strong> <br>When implemented carelessly, even loops can suffer from performance bottlenecks. However, following best practices and optimizing your code will mitigate such concerns.</li><li><strong>How do even loops contribute to Node.js’ scalability?</strong> <br>Even loops are a fundamental part of Node.js’ non-blocking architecture, ensuring that the application can handle multiple concurrent connections efficiently. This scalability is crucial for high-performance applications.</li><li><strong>Can you provide an example of a complex use case for even loops in Node.js?</strong> <br>Picture a real-time chat application with hundreds of users sending messages simultaneously. Even loops would efficiently manage incoming messages and distribute them to the respective recipients without causing delays. Impressive, right?</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4fff6e23f3ee" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to install Python 3.7.x on Linux?]]></title>
            <link>https://medium.com/@anandeshsharma/how-to-install-python-3-7-x-on-linux-a8637d06f13f?source=rss-8e140108dcb3------2</link>
            <guid isPermaLink="false">https://medium.com/p/a8637d06f13f</guid>
            <dc:creator><![CDATA[Anandesh Sharma]]></dc:creator>
            <pubDate>Sat, 20 Oct 2018 09:12:08 GMT</pubDate>
            <atom:updated>2018-10-20T09:12:13.633Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KjKeBA-SbigyQFI0.jpg" /></figure><p>So after very long time I am writing something on my blog. Hell yeah! So this article is all about how to install latest python on <strong>Ubuntu, Debian, Linux Mint</strong>.</p><blockquote><strong><em>Why to install 3.7.x?<br> </em></strong>Upgrading is always good but sometimes it isn’t. All of you developers know why?<br> For more about the latest version 3.7.0. Read <a href="https://docs.python.org/3/">HERE</a><br> I know reading docs are way too boring but some of you noobs loves that, so here you go.</blockquote><p><strong><em>STEP 1:</em></strong> First we need to install some dependency packages which are required by python.</p><pre>sudo apt-get install build-essential checkinstall<br>sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev</pre><p><strong><em>STEP 2: </em></strong>Download the latest <a href="https://www.python.org/">Python</a> archived file.</p><pre>sudo tar xzf Python-3.7.0.tgz</pre><p>Extract the files.</p><p><strong><em>STEP 3: </em></strong>After extracting the source code, now its time to compile the source code. For compiling run these commands.</p><pre>cd Python-3.7.0<br>sudo ./configure --enable-optimizations<br>sudo make altinstall</pre><p>altinstall is used because we don&#39;t want the new install overwrites all binaries inside our /usr/bin.</p><p><strong><em>STEP 4:</em> </strong>Now check the version of python installed.</p><pre>python3.7 --version<br><br>Python 3.7.0</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a8637d06f13f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Python — Dictonary]]></title>
            <link>https://medium.com/@anandeshsharma/python-dictonary-da9ef498a69?source=rss-8e140108dcb3------2</link>
            <guid isPermaLink="false">https://medium.com/p/da9ef498a69</guid>
            <category><![CDATA[dictionary]]></category>
            <dc:creator><![CDATA[Anandesh Sharma]]></dc:creator>
            <pubDate>Sun, 22 Apr 2018 07:24:14 GMT</pubDate>
            <atom:updated>2018-04-22T07:25:19.548Z</atom:updated>
            <content:encoded><![CDATA[<h3>Python — Dictionary</h3><p>Dictionary is an unordered set of key and value pair. It is a container that contains data, enclosed within curly braces. the pair i.e., key and value is known as item. They key passed in the item must be unique.</p><p>The key and the value is separated by a colon(:). This pair is known as item. Items are separated from each other by a comma(,). Different items are enclosed within a curly braces and this forms Dictionary.</p><pre>dic = {1:&quot;A&quot;, 2:&quot;B&quot;, 3:&quot;C&quot;, 4:&quot;D&quot;}<br>print(dic) #Output : {1: &#39;A&#39;, 2: &#39;B&#39;, 3: &#39;C&#39;, 4: &#39;D&#39;}</pre><p>Dictionary is mutable i.e., value can be updated.</p><p>Key must be unique and immutable. Value is accessed by key. Value can be updated while key cannot be changed. Dictionary is known as Associative array since the Key works as index and they are decided by the user.</p><pre>Example:</pre><pre>Dic = {}<br><br>#Values in brackets are keys and Values on right side are data values<br>Dic[1] = &quot;A&quot;<br>Dic[2] = &quot;B&quot;<br>Dic[3] = &quot;C&quot;<br>Dic[&quot;a&quot;] = &quot;Louis&quot;<br>Dic[&quot;b&quot;] = &quot;Williams&quot;<br><br>print(Dic) #Output : {1: &#39;A&#39;, 2: &#39;B&#39;, 3: &#39;C&#39;, &#39;a&#39;: &#39;Louis&#39;, &#39;b&#39;: &#39;Williams&#39;}</pre><h4>ACCESSING DICTIONARY VALUES</h4><p>Since Index is not defined, a Dictionary values can be accessed by their keys only. It means, to access the dictionary elements we need to pass key, associated to the value.</p><pre>Std = {1:&quot;Andy&quot;, 2:&quot;Bash&quot;, 3:&quot;Cayle&quot;}<br><br>print(&quot;First Student : &quot;, Std[1])<br>print(&quot;Second Student : &quot;,Std[2])<br>print(&quot;Third Student : &quot;, Std[3])<br><br># Output : <br># First Student :  True<br># Second Student :  Bash<br># Third Student :  Cayle</pre><h4>UPDATING PYTHON DICTIONARY</h4><p>The item i.e., key-value pair can be updated. Updating means new item can be added to the dictionary. The values can be modified.</p><pre>Std = {1:&quot;Andy&quot;, 2:&quot;Bash&quot;, 3:&quot;Cayle&quot;}<br><br>Std[2] = &quot;Bob&quot;<br><br>print(Std) #Output : {1: &#39;Andy&#39;, 2: &#39;Bob&#39;, 3: &#39;Cayle&#39;}</pre><h4>DELETING ELEMENTS FROM PYTHON DICTIONARY</h4><p><strong>del </strong>statement can be used for performing deletion operation in dictionary. An element can be deleted using the key only.</p><pre>Std = {1:&quot;Andy&quot;, 2:&quot;Bash&quot;, 3:&quot;Cayle&quot;}<br><br>del(Std[2])<br><br>print(Std) #Output : {1: &#39;Andy&#39;, 3: &#39;Cayle&#39;}</pre><h4>PYTHON DICTIONARY FUNCTIONS</h4><p><strong>cmp(dict1, dict2)</strong> : No longer available in Python 3.</p><p><strong>len(dict)</strong> : Gives the total length of the dictionary. This would be equal to the number of items in the dictionary.</p><p><strong>str(dict)</strong> : Produces a printable string representation of a dictionary.</p><p><strong>type(variable)</strong> : Returns the type of the passed variable. If passed variable is dictionary, then it would return a dictionary type.</p><pre>Std = {1:&quot;Andy&quot;, 2:&quot;Bash&quot;, 3:&quot;Cayle&quot;}<br>#Returns all keys<br>print(Std.keys())<br>#Returns all values<br>print(Std.values())<br>#Returns all the items(key-value) pair<br>print(Std.items())<br>#Returns ordered copy of the data<br>print(Std.copy())<br>#Returns the data using key<br>print(Std.get(1))<br>#Used to add items of another dictonary<br>print(Std.update())<br><br>#Output : <br># dict_keys([1, 2, 3])<br># dict_values([&#39;Andy&#39;, &#39;Bash&#39;, &#39;Cayle&#39;])<br># dict_items([(1, &#39;Andy&#39;), (2, &#39;Bash&#39;), (3, &#39;Cayle&#39;)])<br># {1: &#39;Andy&#39;, 2: &#39;Bash&#39;, 3: &#39;Cayle&#39;}<br># Andy<br># None</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=da9ef498a69" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Python — Tuples]]></title>
            <link>https://medium.com/@anandeshsharma/python-tuples-9348ec8c2b64?source=rss-8e140108dcb3------2</link>
            <guid isPermaLink="false">https://medium.com/p/9348ec8c2b64</guid>
            <category><![CDATA[tuples]]></category>
            <dc:creator><![CDATA[Anandesh Sharma]]></dc:creator>
            <pubDate>Sun, 22 Apr 2018 05:02:34 GMT</pubDate>
            <atom:updated>2018-04-22T05:02:36.198Z</atom:updated>
            <content:encoded><![CDATA[<p>A tuple is a sequence of immutable Python objects. Tuples are sequences, just like lists. The differences between tuples and lists are, the tuples cannot be changed unlike lists and tuples use parentheses, whereas lists use square brackets.</p><p>Creating a tuple is as simple as putting different comm-separated values.</p><pre>Example:</pre><pre>tup = (1,2,3,4,5)<br>print(tup) #Output : (1, 2, 3, 4, 5)<br><br>#Empty tuple<br>tup = ()<br>print(tup) #Output : ()</pre><h4>ACCESSING VALUES IN TUPLES</h4><p>We can access the objects in tuple, using the square brackets and also can do slicing of the items with the help of indexing.</p><pre>Example:</pre><pre>tup = (1,2,3,4,5)<br><br>#print the object at index 3<br>print(tup[3]) #Output : 4<br><br>#print the objects from index 1 to index 5<br>print(tup[1:5]) #Output : (2, 3, 4, 5)</pre><h4>UPDATING VALUES IN A TUPLE</h4><p>Tuples are immutable i.e. we can’t change or delete the objects in a tuple. We can add elements in an existing tuple and create a new tuple as following:</p><pre>Example:</pre><pre>tup = (1,2,3,4,5)<br><br>another_tup = (&#39;a&#39;,&#39;b&#39;,&#39;c&#39;,&#39;d&#39;)<br><br>#concatenating the tuples<br>final_tup = tup + another_tup <br><br>print(final_tup) #Output : (1, 2, 3, 4, 5, &#39;a&#39;, &#39;b&#39;, &#39;c&#39;, &#39;d&#39;)</pre><h4>DELETE TUPLE ELEMENTS</h4><p>We can’t actually delete elements from a tuple, but we can delete the whole tuple.</p><pre>Example:</pre><pre>tup = (1,2,3,4,5)<br><br>del tup<br><br>print(tup) #Throws a NameError : &#39;tup&#39; is not defined</pre><h4>BASIC OPERATORS IN TUPLE</h4><p>We can actually use operators to manipulate tuple elements and that makes easier to do some redundant tasks. Like writing a tuple element 5 times.</p><pre>Example:</pre><pre>tup1 = (1,2,3,4,5)<br>tup2 = (&#39;a&#39;, &#39;b&#39;, &#39;c&#39;, &#39;d&#39;, &#39;e&#39;)<br><br>#prints the no.of elements in a tuple<br>print(len(tup1))<br><br>#concatenates two tuples <br>print(tup1 + tup2)<br><br>#print tup1 3 times<br>print(tup1*3)<br><br>#returns true or false if 1 is present in tup1<br>print(1 in tup1)</pre><h4>SOME BUILT IN FUNCTIONS</h4><p>Python include some built-in functions for tuples</p><pre>Example:</pre><pre>tup1 = (1,2,3,4,5)<br>tup2 = (&#39;a&#39;, &#39;b&#39;, &#39;c&#39;, &#39;d&#39;, &#39;e&#39;)<br>myList = [1,2,3,4,5]<br><br>#prints the no.of elements in a tuple<br>print(len(tup1))<br><br>#Returns the item with max value<br>print(max(tup1))<br><br>#returns the item with min value<br>print(min(tup2))<br><br>#Converts a list into a tuple<br>print(tuple(myList))</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9348ec8c2b64" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>