<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ganesh Samarthyam</title>
    <description>The latest articles on DEV Community by Ganesh Samarthyam (@gsamarthyam).</description>
    <link>https://dev.to/gsamarthyam</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F429057%2F888d0872-118e-45f3-ad5d-fef498572025.jpg</url>
      <title>DEV Community: Ganesh Samarthyam</title>
      <link>https://dev.to/gsamarthyam</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/gsamarthyam"/>
    <language>en</language>
    <item>
      <title>Why You Should Use IntelliJ IDEA!</title>
      <dc:creator>Ganesh Samarthyam</dc:creator>
      <pubDate>Sat, 12 Sep 2020 07:32:07 +0000</pubDate>
      <link>https://dev.to/gsamarthyam/why-you-should-use-intellij-idea-1pe7</link>
      <guid>https://dev.to/gsamarthyam/why-you-should-use-intellij-idea-1pe7</guid>
      <description>&lt;h2&gt;
  
  
  An Uncomfortable Confession!
&lt;/h2&gt;

&lt;p&gt;I’ll start with a confession – I was a Vim (text editor) lover and disliked IDEs. As a power-user I loved the power &amp;amp; magic that powerful text editors like Vim and did not like the IDEs that made developers lazy! &lt;/p&gt;

&lt;p&gt;Perhaps that started with the buggy and pathetic Turbo C/C++ IDEs in the college days. I was surprised how most of my classmates were using them and (god-forbid!) even loved it. What bothered me was they didn’t even know how to invoke it from command-line (forget about using the powerful command-line options we can pass to control it). That’s how I also started using command-line tools and loved the power &amp;amp; magic of Unix command-line. &lt;/p&gt;

&lt;p&gt;20 years fast-forward, and I can see how much I have missed the power of developer friendly IDEs. Of course, I am talking about ergonomic IDEs like IntelliJ IDEA. The main reason where the power of text editors stop is that they are generic (max they understand is syntax highlighting, code completion, etc.) – not language-specific capabilities and in-depth ones that require deep understanding of language and semantics (like the deep static analysis and refactoring transformations that IDEs do). &lt;/p&gt;

&lt;p&gt;In this blog post, I am going to cover five reasons why you should consider using IntelliJ IDEA. &lt;/p&gt;

&lt;h2&gt;
  
  
  It’s not either powerful text editor or IDE – it’s BOTH!
&lt;/h2&gt;

&lt;p&gt;What I found interesting is we can have the power of text editors plus the power of IDEs. And IDEs can be super high-quality (and not like those buggy Borland/Turbo C/C++ IDEs).  For example, I can use IdeaVim  as a plugin and have the comfort of using my short keys. At the same time, I can do things like Alt + Enter and invoke powerful and convenient quick fixes, transformations and refactorings! &lt;/p&gt;

&lt;h2&gt;
  
  
  IntelliJ IDEA = Productivity
&lt;/h2&gt;

&lt;p&gt;What I love about IntelliJ is its keyboard shortcuts and features that boost our productivity. My five most favorite shortcuts (in Mac): quick-fixes (Alt + Enter), refactoring (Ctrl + T), search everywhere (Shift + Shift aka double Shift), generate code (Cmd + N), insert live template (Cmd + J). This is just a sampling of what you can do with this powerful editor. You can do many things “auto”-magically - automatically find potential bugs, fix them, transform code, generate code, reformat &amp;amp; rearrange, improve, … &lt;/p&gt;

&lt;h2&gt;
  
  
  Polyglot Language Support
&lt;/h2&gt;

&lt;p&gt;IntelliJ IDEA is synonymous with Java – but it is not the only language it supports: It has superb support for programming in Kotlin, Scala and Groovy. Wait, not just that, it also supports JavaScript, TypeScript, and SQL! This is possible mainly because of the rich plugins it supports.  &lt;/p&gt;

&lt;h2&gt;
  
  
  Rich Set of Built-in Tools
&lt;/h2&gt;

&lt;p&gt;Want to dig deeper and debug or performance tune applications? Decompiler, disassembler, and profilers are integrated. Want to pull changes or commit changes all from without leaving your IDE? Version control is integrated and supports Git, SVN and Mercurial. Using Spring, Java EE, Micronaut, Quarkus, Helidon? That’s tiny list, please add more including Grails, Play2 &amp;amp; Hibernate. Using SQL? Got you covered with the power of DataGrip integrated.  &lt;/p&gt;

&lt;h2&gt;
  
  
  Cloud, Mobile and Web Development
&lt;/h2&gt;

&lt;p&gt;IntelliJ IDEA is not just for developing desktop applications. You can use it for cloud (esp. with Azure and AWS plugins), mobile (with support for React Native, Cordova, and Ionic frameworks) and web development (supports JavaScript, TypeScript, HTML and CSS, Node.js, Angular), ...  &lt;/p&gt;

&lt;h2&gt;
  
  
  IntelliJ IDEA is for Learners, Professionals, and Students
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Community Edition
&lt;/h3&gt;

&lt;p&gt;This is the free and open source version, and yes it can be used for commercial development. It has all the important features required for regular development including code completion, static analysis and auto/quick-fixes, refactorings, and more. It also has support for multiple languages, mobile development (on Android), version control integration, profiling, and more. &lt;/p&gt;

&lt;h3&gt;
  
  
  Ultimate Edition
&lt;/h3&gt;

&lt;p&gt;The main reason for switching to Ultimate Edition is development for web and enterprise environment. It has powerful support for developing in different languages (through plugins for PHP, Go, SQL, Web – JavaScript and TypeScript), support for frameworks (Spring, Hibernate, React, Angular, Node, …), build tools (npm, grunt, gulp, …) and more. There is a 30 day free trial for you to give it a try. Interested in purchasing licenses/renewing for yourself or your company? Contact &lt;a href="mailto:reachus@codeops.tech"&gt;reachus@codeops.tech&lt;/a&gt; (CodeOps is an Authorized Reseller of JetBrains Tools for India &amp;amp; US). &lt;/p&gt;

&lt;h3&gt;
  
  
  Edu Version
&lt;/h3&gt;

&lt;p&gt;If you are a student, you can use the IntelliJ DEA Edu version (free). What I love about Edu is the helpful learning support provided for learning both Java in the form of assignments, programming tests – all that help learn programming in a fun and interactive way. &lt;/p&gt;

&lt;h2&gt;
  
  
  Give it a try now!
&lt;/h2&gt;

&lt;p&gt;If you are a LOTR (Lord Of The Rings) fan, you’ll relate to “one ring to rule them all” for IDE – and yes, “72% of Java developers choose IntelliJ IDEA”! No matter if you develop occasionally in Java (Community), professional developer using the IDE most of the day (Ultimate), or learning Java (Edu) – you can use IntelliJ IDEA. Give it a try and have fun coding! Download &lt;a href="https://www.jetbrains.com/idea/"&gt;here&lt;/a&gt;.  &lt;/p&gt;

</description>
      <category>java</category>
      <category>productivity</category>
      <category>codequality</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Auto-Refactoring Code Smells in C#.NET with Rider  </title>
      <dc:creator>Ganesh Samarthyam</dc:creator>
      <pubDate>Fri, 24 Jul 2020 13:57:31 +0000</pubDate>
      <link>https://dev.to/gsamarthyam/auto-refactoring-code-smells-in-c-net-with-rider-2457</link>
      <guid>https://dev.to/gsamarthyam/auto-refactoring-code-smells-in-c-net-with-rider-2457</guid>
      <description>&lt;p&gt;It is quite common to see bad and smelly code. Refactoring is all about clean code: identifying the bad smells in code and transforming the code to make it better. &lt;/p&gt;

&lt;p&gt;In this article, we discuss how to automate most of the refactoring tasks. For illustration we are using Rider (Rich IDE from JetBrains). Identifying smells and refactoring is made incredibly easy because most of it is automatic with Rider! Just point and click/select options to see the magic unfold! &lt;/p&gt;

&lt;p&gt;Rider often identifies / indicates bad smells in code. &lt;br&gt;
To refactor, you need to select appropriate refactoring action from one of:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;“Refactor” menu option&lt;/li&gt;
&lt;li&gt;“Refactor This” option with Shift + Cmd + R
&lt;/li&gt;
&lt;li&gt;Clicking the Yellow bulb &lt;/li&gt;
&lt;li&gt;Invoke "Context action" with Alt + Enter &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's jump in with smells examples and how to refactor them. &lt;/p&gt;
&lt;h2&gt;
  
  
  Extract from Large Methods to Smaller Helper Methods
&lt;/h2&gt;

&lt;p&gt;Large methods are one of the biggest enemies of readability. It is easy to end-up with excessively long methods with 100s of lines of code. &lt;/p&gt;

&lt;p&gt;A rule of thumb is that the entire method code should be visible within your screen (and reducing the font size of zooming out is not the right fix :-p) &lt;/p&gt;

&lt;p&gt;Methods should read like steps. So, extract code segments into separate private helper methods. Tip: Look out for new lines - they indicate logical breaks in the method and they blocks separated by newlines belong in separate methods! &lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/aLvjBUi4PRI"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Add Parameter Validation Code Automatically
&lt;/h2&gt;

&lt;p&gt;Applications can easily break with missing validation checks. Examples: null checks and check if collection is empty. &lt;/p&gt;

&lt;p&gt;Code defensively and add these validation code automatically. Just point on the parameter and click the hammer icon and add the checks! Or on the parameter press Alt + Enter to add these checks - just like magic! &lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/6JfgmGNQTZo"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Extract Variables From 'Magic Strings'
&lt;/h2&gt;

&lt;p&gt;You can refactor ‘Magic Strings’ with named variables or constants. &lt;/p&gt;

&lt;p&gt;"Magic strings" are hardcoded strings in the programs. Though its extremely convenient to just embed the required strings in the program, it is a bad practice &amp;amp; a smell. Refactor them to named constants or variables. If needed extract them into resource files for internationalization. It’s easy to extract variable or inline variable with just context actions&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/diqrJndCurc"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Extract Classes from Method(s)
&lt;/h2&gt;

&lt;p&gt;When you have large static methods in a class, it is often an indication that the method belongs to a class on its own. For example, consider a large method in a class named AirQualityReporter named ReadXLS - that reads pollution readings from an Excel file. &lt;/p&gt;

&lt;p&gt;Reading a XLS file should be handled by a separate abstraction. So the smell is "missing abstraction" and the refactoring is "extract class". &lt;/p&gt;

&lt;p&gt;This short video shows how. Note that the extracted class XLSReport need further refactoring since its a large method with more than one responsibilities. Of course, that's the topic of another video :-) &lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/wViAUc3FQUU"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Constructor to Factory Method
&lt;/h2&gt;

&lt;p&gt;To control object creation, we need to use factory methods. &lt;/p&gt;

&lt;p&gt;In many contexts, we want to control object creation. For example, reuse objects instead of creating them again and again (as in Flyweight pattern) or restrict the number of objects created (as in Singleton). With a publicly available constructor, that becomes not possible. Invoke refactor this by adding a factory method and make the constructor protected in a click or two! &lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/8r_Q33JCxdY"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Refactor "Data Clumps" and "Long Parameters" With "Transform Parameter"
&lt;/h2&gt;

&lt;p&gt;Large parameters and data clumps are common smells in large codebases. Rule of thumb - if &amp;gt;4 parameters, consider refactoring. &lt;/p&gt;

&lt;p&gt;'Data clumps' refer to related parameters that are always passed and used together - that indicates they belong in a separate data class. &lt;/p&gt;

&lt;p&gt;With “Transform Parameters” refactoring, extracting data clumps to data classes is as easy as blinking the eye! &lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/yzEvLvy-kro"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Converting Interface to Abstract Class (and vice versa)
&lt;/h2&gt;

&lt;p&gt;‪Think about UI widets. The base type Widet doesn't exist in the real-world and it abstracts various concrete widgets such as TextWidget, ScrollBar, Grid etc. So the base type Widget is best expressed as an abstract class.‬&lt;/p&gt;

&lt;p&gt;‪Consider 'Scrollable' - not all UI Widgets are scrollable. And Scrollable doesn't have concrete behavior - it just provides methods such as ScrollUp and ScrollDown. So its best expressed as an interface.‬&lt;/p&gt;

&lt;p&gt;‪If you have created an abstract class instead of an interface (and vice versa), you can do it automatically in Rider (Rich IDE for .NET). Just point at the abstract class or interface and press Shift + Cmd + R and you can change its form from one to another. ‬&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/Rbt5aA8D9I0"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Smells and Refactorings Covered
&lt;/h2&gt;

&lt;p&gt;This is a small article and we have just scratching the surface! Just as a quick summary, here is the list of smells and refactorings we have covered so far: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;“Large Methods” =&amp;gt; Extract “Helper Methods” &lt;/li&gt;
&lt;li&gt;“Unchecked Methods” =&amp;gt; Add Parameter Validation to Methods &lt;/li&gt;
&lt;li&gt;“Magic Strings” =&amp;gt; Extract constants / variables&lt;/li&gt;
&lt;li&gt;“Large static methods” =&amp;gt; Extract class&lt;/li&gt;
&lt;li&gt;Unconstrained constructors =&amp;gt; Factory Method &lt;/li&gt;
&lt;li&gt;“Data Clumps” &amp;amp; “Long Parameter Lists” =&amp;gt; Extract data classes &lt;/li&gt;
&lt;li&gt;Inappropriate abstract class =&amp;gt; Transform to interface &lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Summary &amp;amp; Key Takeaways
&lt;/h2&gt;

&lt;p&gt;Refactoring is all about repeatedly improving the existing code. When we get some code working and leave it there, it will be certainly be smelly. However, if we revisit the code and improve it, the code quality improves dramatically. &lt;/p&gt;

&lt;p&gt;Fortunately, such improvement can be done sort of "auto-magically" with the powerful IDEs like Rider. For example, consider renaming a variable/method/class/etc. Renaming manually is prone to errors and time consuming. And its so easy to rename with Rider - just point on the name and press Alt + Enter =&amp;gt; "Refactor This" =&amp;gt; "Rename" and boom, the refactoring is done! &lt;/p&gt;

&lt;p&gt;Also, there is no need to remember “too many” shortcuts! &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Select “Refactor” menu option &lt;/li&gt;
&lt;li&gt;Invoke “Refactor This” with Shift + Cmd + R&lt;/li&gt;
&lt;li&gt;Get “Context Actions” with Alt + Enter &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Hope you explore powerful refactoring features of Rider &amp;amp; ReSharper and make your code clean and higher quality. &lt;/p&gt;

</description>
    </item>
    <item>
      <title>Python Comprehensions &amp; Generators Made Easy (PyCharm)</title>
      <dc:creator>Ganesh Samarthyam</dc:creator>
      <pubDate>Sat, 11 Jul 2020 06:53:02 +0000</pubDate>
      <link>https://dev.to/gsamarthyam/python-comprehensions-generators-made-easy-pycharm-34nh</link>
      <guid>https://dev.to/gsamarthyam/python-comprehensions-generators-made-easy-pycharm-34nh</guid>
      <description>&lt;p&gt;One of the features I love is Live Templates in PyCharm: With it, you can code super fast! They are incredibly useful for speeding up common tasks such as looping over (or generating from) a collection object. &lt;/p&gt;

&lt;p&gt;In this brief blog, show how to use them in PyCharm (works for both Community or Professional editions)&lt;/p&gt;

&lt;h1&gt;
  
  
  Python Comprehensions &amp;amp; Generators 101
&lt;/h1&gt;

&lt;p&gt;Comprehensions and generators can help write concise yet expressive code. Consider this loop:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;small_words = []
for word in quip.split(" "):
    if(len(word.upper()) &amp;lt;= 4):
        small_words.append(word.upper())
print(small_words)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This is quite verbose. &lt;/p&gt;

&lt;p&gt;Here is how it could be expressed with a list comprehension - which is quite readable as well:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;small_words = [word.upper() for word in quip.split(" ") if len(word) &amp;lt;= 4]
print(small_words)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Here are the parts of the comprehension: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--iOE6nwn8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/aguwesnh5g5zf1ul7dud.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--iOE6nwn8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/aguwesnh5g5zf1ul7dud.png" alt="Alt Text"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;That's easy and nice, isn't it! &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8NuTtSCd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/frp9e02tan2rrygq6eop.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8NuTtSCd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/frp9e02tan2rrygq6eop.gif" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Live Templates in PyCharm
&lt;/h1&gt;

&lt;p&gt;You can use Live Templates - the template code segments that you can fill - in PyCharm. &lt;/p&gt;

&lt;p&gt;Here is the list of live templates. You can access it as &lt;code&gt;PyCharm -&amp;gt; Preferences -&amp;gt; Editor -&amp;gt; Live Templates&lt;/code&gt;.  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0xTsuVxZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/so1ssl6azmtp6o4l1fxp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0xTsuVxZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/so1ssl6azmtp6o4l1fxp.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Getting Started - Easy and Simple Live Templates
&lt;/h1&gt;

&lt;p&gt;The live templates &lt;code&gt;main&lt;/code&gt;, &lt;code&gt;iter&lt;/code&gt; and &lt;code&gt;itere&lt;/code&gt; are easy and simple ones to get started with. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bY_Kkq7C--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/pdhvwxqu5m6ppy4lmr7b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bY_Kkq7C--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/pdhvwxqu5m6ppy4lmr7b.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In live action in this YouTube Video. &lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/qtPTPAIvG4s"&gt;
&lt;/iframe&gt;
 &lt;/p&gt;

&lt;p&gt;It's repetition made easy! &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HSFviuQi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/d4e1ktyhwi99qiayeooc.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HSFviuQi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/d4e1ktyhwi99qiayeooc.gif" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Templates for List, Set, and Dictionary Comprehensions
&lt;/h1&gt;

&lt;p&gt;This is where the fun begins - let it be list, set or dictionaries, comprehensions are easy with PyCharm. Just start typing &lt;code&gt;comp&lt;/code&gt; which stands for 'comprehension'. For list comprehension, type &lt;code&gt;l&lt;/code&gt;, so it's &lt;code&gt;compl&lt;/code&gt;. For adding an if condition, add an &lt;code&gt;i&lt;/code&gt;, so it becomes &lt;code&gt;compli'. Nothing&lt;/code&gt;compli`cated! &lt;/p&gt;

&lt;p&gt;So goes &lt;code&gt;comps&lt;/code&gt;, &lt;code&gt;compsi&lt;/code&gt;, &lt;code&gt;compd&lt;/code&gt; and &lt;code&gt;compdi&lt;/code&gt; for set and dictionary comprehensions with optional if conditions. &lt;/p&gt;

&lt;h2&gt;
  
  
  List comprehension
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GnL88HKm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/370j35p9p8gy4mgsmm66.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GnL88HKm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/370j35p9p8gy4mgsmm66.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's how you process lists! &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VEjlgQHB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/17ydyca43027bqd7m2p5.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VEjlgQHB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/17ydyca43027bqd7m2p5.gif" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Set comprehension
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3g1QjmuA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/jp14z0kl4i2rynr1abwy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3g1QjmuA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/jp14z0kl4i2rynr1abwy.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's how you deal with sets! &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GHu73Kxz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/3tc6spxigfaxptsrhw16.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GHu73Kxz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/3tc6spxigfaxptsrhw16.gif" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Dictionary comprehension
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--R7hjkhtL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ex97w4la91jht6wsj1av.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--R7hjkhtL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ex97w4la91jht6wsj1av.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's how you deal with dictionaries! &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5UgS5zPy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ty0p5dph4j1f193i5c2k.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5UgS5zPy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ty0p5dph4j1f193i5c2k.gif" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Generator comprehension
&lt;/h2&gt;

&lt;p&gt;Generators create a sequence - we iterate over them one at a time. If you try to print a generator you'll get a generator object (not its content printed!). For example, if small_words is a generator, then print(small_words) will print cryptic reading one like - &lt;code&gt;&amp;lt;generator object &amp;lt;genexpr&amp;gt; at 0x102c1b7c8&amp;gt;&lt;/code&gt;. So convert to list, for example, before printing, like &lt;code&gt;print(list(small_words))&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;Here is an example. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TpGtqR8V--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ie0266sdne8b9kaicfhf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TpGtqR8V--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ie0266sdne8b9kaicfhf.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's how you deal with generators! &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CVRGeif6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/cdrr6ksbp3hjb6x87pm6.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CVRGeif6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/cdrr6ksbp3hjb6x87pm6.gif" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Live Templates to Remember
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;main&lt;/code&gt; - &lt;strong&gt;main&lt;/strong&gt; check&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;iter&lt;/code&gt; / &lt;code&gt;itere&lt;/code&gt; - for loop &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;compl&lt;/code&gt; / &lt;code&gt;compli&lt;/code&gt; - list comprehension&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;comps&lt;/code&gt; / &lt;code&gt;compsi&lt;/code&gt; - set comprehension&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;compd&lt;/code&gt; / &lt;code&gt;compdi&lt;/code&gt; - dictionary  comprehension&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;compg&lt;/code&gt; / &lt;code&gt;compgi&lt;/code&gt; - generators &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Have fun playing around with comprehensions and generators in PyCharm. Check out for ~1 min &lt;a href="//www.youtube.com/c/CodeOpsTech"&gt;PyCharm Tips &amp;amp; Tricks here&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;Have fun coding! &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Tmb51AqO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/l23eisjrgrkp40ptqtgu.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Tmb51AqO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/l23eisjrgrkp40ptqtgu.gif" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>productivity</category>
      <category>codequality</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
