{"id":11567,"date":"2021-04-22T19:27:16","date_gmt":"2021-04-22T17:27:16","guid":{"rendered":"https:\/\/www.sqlnethub.com\/?p=11567"},"modified":"2024-03-01T18:48:48","modified_gmt":"2024-03-01T16:48:48","slug":"useful-python-programming-tips","status":"publish","type":"post","link":"https:\/\/www.sqlnethub.com\/blog\/useful-python-programming-tips\/","title":{"rendered":"Useful Python Programming Tips"},"content":{"rendered":"<p>In this post, I will be regularly posting useful Python programming tips.<\/p>\n<p>These tips will be organized in different categories, in order to make it easier to read it.<\/p>\n<p>&nbsp;<\/p>\n<h2>Hello World in Python<\/h2>\n<p>The below command, prints a &#8220;Hello World&#8221; message from within a Python script:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">print(\"Hello World from Python\")<\/pre>\n<p>&nbsp;<\/p>\n<h2>Code Indentation in Python<\/h2>\n<p>In many programming languages, code indentation plays only a formatting role, however, in Python, code indentation is used for setting code blocks. Check for example the below if&#8230;else statement:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">#if...elif...else example\r\na=200\r\nb=200\r\nif a&gt;b:\r\n    print(\"a is greater than b\")\r\nelif a==b:\r\n    print(\"a and b are equal\")\r\nelse:\r\n    print(\"b is greater than a\")<\/pre>\n<p>As you can see, within each if, elif and else code blocks, I include one command in right indent.<\/p>\n<p>This is an example of how code indentation is used in Python.<\/p>\n<p>&nbsp;<\/p>\n<h2>How to use Visual Studio Code for Python Development<\/h2>\n<p>Among the many IDE options you have for programming in Python, you can also use <a href=\"https:\/\/code.visualstudio.com\/\" target=\"_blank\" rel=\"noopener\">Visual Studio Code<\/a>, which is a free IDE by Microsoft that supports developing in many programming languages.<\/p>\n<p>So, after you have installed Visual Studio Code, you can find a free Python extension from its marketplace, install the extension and that&#8217;s it, you are ready to start developing in Python. In my setup, when developing in Python within Visual Studio Code, I use Microsoft&#8217;s <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=ms-python.python\" target=\"_blank\" rel=\"nofollow noopener\">Python extension<\/a>.<\/p>\n<p>In order of course to be able to run a Python script, you also need to install Python in your environment. You can find the available Python installers <a href=\"https:\/\/www.python.org\/downloads\/\" target=\"_blank\" rel=\"nofollow noopener\">here<\/a>.<\/p>\n<p>&nbsp;<\/p>\n<h2>Comments in Python<\/h2>\n<p>To comment a line of code in Python, you just need to use the # sign. Here&#8217;s an example:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">#This is comment in Python<\/pre>\n<p>&nbsp;<\/p>\n<h2>How to Easily Split a String in Python<\/h2>\n<p>In Python, you can split a string very easily. Check the below example:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">string=\"Programming in Python\"\r\nsplitString=string.split()\r\n\r\nprint(splitString)\r\nprint(splitString[0])\r\nprint(splitString[1])\r\nprint(splitString[2])<\/pre>\n<p>&nbsp;<\/p>\n<blockquote><p>Read also: <a href=\"https:\/\/www.essentialdevtips.com\/blog\/main-data-structures-in-python\/\" target=\"_blank\" rel=\"noopener\">Main Data Structures in Python<\/a><\/p><\/blockquote>\n<hr \/>\n<h2>Learn More about Python Programming and SQL Server Data Access<\/h2>\n<p style=\"text-align: left;\">Enroll to our online course\u00a0 &#8220;<a href=\"https:\/\/www.sqlnethub.com\/go\/course-python-sql-server\/\" target=\"_blank\" rel=\"noopener\"><strong>Working with Python on Windows and SQL Server Databases<\/strong><\/a>&#8221; with an exclusive discount, and get started with Python data access programming for SQL Server databases, fast and easy!<\/p>\n<figure id=\"attachment_11451\" aria-describedby=\"caption-attachment-11451\" style=\"width: 205px\" class=\"wp-caption aligncenter\"><a href=\"\/go\/course-python-sql-server\/\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"wp-image-11451\" title=\"Working with Python on Windows and SQL Server Databases - Online Course\" src=\"https:\/\/www.sqlnethub.com\/wp-content\/uploads\/2021\/04\/Working-with-Python-Windows-SQL-Server-Databases.jpg\" alt=\"Working with Python on Windows and SQL Server Databases - Online Course\" width=\"215\" height=\"143\" srcset=\"https:\/\/www.sqlnethub.com\/wp-content\/uploads\/2021\/04\/Working-with-Python-Windows-SQL-Server-Databases.jpg 1280w, https:\/\/www.sqlnethub.com\/wp-content\/uploads\/2021\/04\/Working-with-Python-Windows-SQL-Server-Databases-300x200.jpg 300w, https:\/\/www.sqlnethub.com\/wp-content\/uploads\/2021\/04\/Working-with-Python-Windows-SQL-Server-Databases-1024x683.jpg 1024w, https:\/\/www.sqlnethub.com\/wp-content\/uploads\/2021\/04\/Working-with-Python-Windows-SQL-Server-Databases-768x512.jpg 768w\" sizes=\"(max-width: 215px) 100vw, 215px\" \/><\/a><figcaption id=\"caption-attachment-11451\" class=\"wp-caption-text\">(<strong><span style=\"color: #ff0000;\">Lifetime Access<\/span><\/strong>, Q&amp;A, Certificate of Completion, downloadable resources and more!)<\/figcaption><\/figure>\n<p style=\"text-align: center;\"><a class=\"maxbutton-25 maxbutton maxbutton-enroll-from-12-99\" target=\"_blank\" title=\"Time-Limited Offer\" rel=\"noopener\" href=\"\/go\/course-python-sql-server\/\"><span class='mb-text'>Learn More<\/span><\/a><\/p>\n<hr \/>\n<h2 style=\"text-align: left;\">Get Started with Programming Fast and Easy &#8211; Enroll to the Online Course!<\/h2>\n<p style=\"text-align: left;\">Check our online course &#8220;<span style=\"text-decoration: underline;\"><strong><a href=\"\/go\/course-philosophy-fundamentals-computer-programming\/\" target=\"_blank\" rel=\"noopener\">Introduction to Computer Programming for Beginners<\/a><\/strong><\/span>&#8221; <span style=\"color: #008000;\">(special limited-time discount included in link).<\/span><\/p>\n<p>Learn the philosophy and main principles of Computer Programming and get introduced to C, C++, C#, Python, Java and SQL.<\/p>\n<figure id=\"attachment_6400\" aria-describedby=\"caption-attachment-6400\" style=\"width: 230px\" class=\"wp-caption aligncenter\"><a href=\"\/go\/course-philosophy-fundamentals-computer-programming\/\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"wp-image-6400\" title=\"The Philosophy and Fundamentals of Computer Programming - Online Course - Get Started with C, C++, C#, Java, SQL and Python\" src=\"https:\/\/www.sqlnethub.com\/wp-content\/uploads\/2019\/10\/philosophy-fundamentals-computer-programming-300x169.jpg\" alt=\"The Philosophy and Fundamentals of Computer Programming - Online Course - Get Started with C, C++, C#, Java, SQL and Python\" width=\"240\" height=\"135\" srcset=\"https:\/\/www.sqlnethub.com\/wp-content\/uploads\/2019\/10\/philosophy-fundamentals-computer-programming-300x169.jpg 300w, https:\/\/www.sqlnethub.com\/wp-content\/uploads\/2019\/10\/philosophy-fundamentals-computer-programming-768x432.jpg 768w, https:\/\/www.sqlnethub.com\/wp-content\/uploads\/2019\/10\/philosophy-fundamentals-computer-programming-1024x576.jpg 1024w, https:\/\/www.sqlnethub.com\/wp-content\/uploads\/2019\/10\/philosophy-fundamentals-computer-programming.jpg 2048w\" sizes=\"(max-width: 240px) 100vw, 240px\" \/><\/a><figcaption id=\"caption-attachment-6400\" class=\"wp-caption-text\">(<span style=\"color: #ff0000;\"><strong>Lifetime Access<\/strong><\/span>, Q&amp;A, Certificate of Completion, downloadable resources and more!)<\/figcaption><\/figure>\n<p style=\"text-align: center;\"><a class=\"maxbutton-25 maxbutton maxbutton-enroll-from-12-99\" target=\"_blank\" title=\"Learn more about the online course!\" rel=\"noopener\" href=\"\/go\/course-philosophy-fundamentals-computer-programming\/\"><span class='mb-text'>Learn More<\/span><\/a><\/p>\n<hr \/>\n<p>&nbsp;<\/p>\n<h2>Featured Online Courses:<\/h2>\n<ul>\n<li><strong><span style=\"text-decoration: underline;\"><a href=\"\/go\/course-python-sql-server\/\" target=\"_blank\" rel=\"noopener\">Working with Python on Windows and SQL Server<\/a><\/span><a style=\"text-decoration: underline;\" href=\"\/go\/course-python-sql-server\/\" target=\"_blank\" rel=\"noopener\"> Databases<\/a><\/strong><\/li>\n<li><strong><span style=\"text-decoration: underline;\"><a style=\"text-decoration: underline;\" href=\"https:\/\/www.sqlnethub.com\/go\/course-philosophy-fundamentals-computer-programming\/\" target=\"_blank\" rel=\"noopener\">Introduction to Computer Programming for Beginners<\/a><\/span><\/strong><\/li>\n<li><a href=\"\/go\/course-introduction-ai-essentials\/\" target=\"_blank\" rel=\"noopener\"><span style=\"text-decoration: underline;\"><strong>AI Essentials: A Beginner&#8217;s Guide to Artificial Intelligence<\/strong><\/span><\/a><\/li>\n<li><a href=\"\/go\/course-human-ai-synergy\/\" target=\"_blank\" rel=\"noopener\"><span style=\"text-decoration: underline;\"><strong>Human-AI Synergy: Teams and Collaborative Intelligence<\/strong><\/span><\/a><\/li>\n<li><strong><span style=\"text-decoration: underline;\"><a style=\"text-decoration: underline;\" href=\"https:\/\/www.sqlnethub.com\/go\/course-sql-server-2022\/\" target=\"_blank\" rel=\"noopener\">SQL Server 2022: What\u2019s New &#8211; New and Enhanced Features<\/a><\/span><\/strong><\/li>\n<li><strong><span style=\"text-decoration: underline;\"><a href=\"\/go\/introduction-azure-database-mysql\/\" target=\"_blank\" rel=\"noopener\">Introduction to Azure Database for MySQL<\/a><\/span><\/strong><\/li>\n<li><strong><span style=\"text-decoration: underline;\"><a style=\"text-decoration: underline;\" href=\"https:\/\/www.sqlnethub.com\/go\/course-in-memory-oltp-sql-server\/\" target=\"_blank\" rel=\"noopener noreferrer\">Boost SQL Server Database Performance with In-Memory OLTP<\/a><\/span><\/strong><\/li>\n<li><strong><span style=\"text-decoration: underline;\"><a style=\"text-decoration: underline;\" href=\"https:\/\/www.sqlnethub.com\/go\/course-introduction-azure-sql\/\" target=\"_blank\" rel=\"noopener noreferrer\">Introduction to Azure SQL Database for Beginners<\/a><\/span><\/strong><\/li>\n<li><strong><span style=\"text-decoration: underline;\"><a style=\"text-decoration: underline;\" href=\"https:\/\/www.sqlnethub.com\/go\/course-essential-sql-admin-tips\/\" target=\"_blank\" rel=\"noopener noreferrer\">Essential SQL Server Administration Tips<\/a><\/span><\/strong><\/li>\n<li><strong><span style=\"text-decoration: underline;\"><a style=\"text-decoration: underline;\" href=\"https:\/\/www.sqlnethub.com\/go\/course-sql-server-fundamentals\/\" target=\"_blank\" rel=\"noopener noreferrer\">SQL Server Fundamentals &#8211; SQL Database for Beginners<\/a><\/span><\/strong><\/li>\n<li><strong><span style=\"text-decoration: underline;\"><a href=\"\/go\/course-essential-sql-dev-tips\/\" target=\"_blank\" rel=\"noopener noreferrer\">Essential SQL Server Development Tips for SQL Developers<\/a><\/span><\/strong><\/li>\n<li><span style=\"text-decoration: underline;\"><strong><a href=\"\/go\/course-dot-net-win-forms\" target=\"_blank\" rel=\"noopener\">.NET Programming for Beginners &#8211; Windows Forms with C#<\/a><\/strong><\/span><strong><span style=\"text-decoration: underline;\"><br \/>\n<\/span><\/strong><\/li>\n<li><strong><span style=\"text-decoration: underline;\"><a style=\"text-decoration: underline;\" href=\"https:\/\/www.sqlnethub.com\/go\/course-sql-server-2019\/\" target=\"_blank\" rel=\"noopener\">SQL Server 2019: What\u2019s New &#8211; New and Enhanced Features<\/a><\/span><\/strong><\/li>\n<li><strong><span style=\"text-decoration: underline;\"><a style=\"text-decoration: underline;\" href=\"https:\/\/www.sqlnethub.com\/go\/course-entity-framework-beginner\/\" target=\"_blank\" rel=\"noopener\">Entity Framework: Getting Started &#8211; Complete Beginners Guide<\/a><\/span><\/strong><strong><span style=\"text-decoration: underline;\"><br \/>\n<\/span><\/strong><\/li>\n<li><strong><span style=\"text-decoration: underline;\"><a style=\"text-decoration: underline;\" href=\"https:\/\/www.sqlnethub.com\/go\/data-management-beginners\/\" target=\"_blank\" rel=\"noopener\">Data Management for Beginners &#8211; Main Principles<\/a><\/span><\/strong><strong><span style=\"text-decoration: underline;\"><br \/>\n<\/span><\/strong><\/li>\n<li><strong><span style=\"text-decoration: underline;\"><a style=\"text-decoration: underline;\" href=\"https:\/\/www.sqlnethub.com\/go\/course-start-monetize-successful-blog\/\" target=\"_blank\" rel=\"noopener noreferrer\">A Guide on How to Start and Monetize a Successful Blog<\/a><\/span><\/strong><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h2>Read Also:<\/h2>\n<ul>\n<li><span style=\"text-decoration: underline;\"><a href=\"\/blog\/python-data-access-fundamentals\/\" rel=\"\">Python Data Access Fundamentals<\/a><\/span><\/li>\n<li><a href=\"\/blog\/indexerror-list-index-out-of-range-how-to-resolve-it-in-python\/\"><span style=\"text-decoration: underline;\">IndexError: list index out of range \u2013 How to Resolve it in Python<\/span><\/a><\/li>\n<li><span style=\"text-decoration: underline;\"><a href=\"\/blog\/how-to-connect-to-sql-server-databases-from-a-python-program\/\" rel=\"\">How to Connect to SQL Server Databases from a Python Program<\/a><\/span><\/li>\n<li><a href=\"\/blog\/how-to-run-the-sql-server-bulk-insert-command-from-within-a-python-program\/\" rel=\"\"><span style=\"text-decoration: underline;\">How to Run the SQL Server BULK INSERT Command from Within a Python Program<\/span><\/a><\/li>\n<li><span style=\"text-decoration: underline;\"><a href=\"\/blog\/working-with-python-on-windows-and-sql-server-databases-course-preview\/\" rel=\"\">Working with Python on Windows and SQL Server Databases (Course Preview)<\/a><\/span><\/li>\n<li><span style=\"text-decoration: underline;\"><a href=\"\/blog\/indentationerror-expected-an-indented-block-in-python-how-to-resolve-it\/\">IndentationError: expected an indented block in Python \u2013 How to Resolve it<\/a><\/span><\/li>\n<li><a href=\"\/blog\/how-to-resolve-im002-microsoftodbc-driver-manager-data-source-name-not-found-and-no-default-driver-specified-0-sqldriverconnect\/\"><span style=\"text-decoration: underline;\">How to Resolve: [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnect)<\/span><\/a><\/li>\n<li><a href=\"https:\/\/www.essentialdevtips.com\/blog\/main-data-structures-in-python\/\" target=\"_blank\" rel=\"noopener\">Main Data Structures in Python<\/a><\/li>\n<li><a href=\"https:\/\/www.essentialdevtips.com\/blog\/how-to-read-a-text-file-in-python-live-demo\/\" target=\"_blank\" rel=\"noopener\"><span style=\"text-decoration: underline;\">How to Read a Text File in Python \u2013 Live Demo<\/span><\/a><\/li>\n<li><a href=\"\/blog\/missing-parentheses-in-call-to-print-did-you-mean-print-how-to-resolve-in-python\/\">Missing parentheses in call to &#8216;print&#8217;. did you mean print(&#8230;) &#8211; How to Resolve in Python<\/a><\/li>\n<li><a href=\"https:\/\/www.sqlnethub.com\/blog\/how-to-write-to-text-file-from-c-plus-plus-program\/\" rel=\"\"><span style=\"text-decoration: underline;\">How to Write to a Text File from a C++ Program<\/span><\/a><\/li>\n<li><span style=\"text-decoration: underline;\"><a href=\"https:\/\/www.sqlnethub.com\/blog\/how-to-establish-a-simple-connection-from-a-c-program-to-sql-server\/\">How to Establish a Simple Connection from a C# Program to SQL Server<\/a><\/span><\/li>\n<li><span style=\"text-decoration: underline;\"><a href=\"https:\/\/www.sqlnethub.com\/blog\/the-timeout-period-elapsed-prior-to-obtaining-a-connection-from-the-pool\/\" aria-label=\"\u201cThe timeout period elapsed prior to obtaining a connection from the pool\u201d (Edit)\">The timeout period elapsed prior to obtaining a connection from the pool<\/a><\/span><\/li>\n<li><span style=\"text-decoration: underline;\"><a href=\"https:\/\/www.sqlnethub.com\/blog\/closing-a-c-application-including-hidden-forms\/\">Closing a C# Application (including hidden forms)<\/a><\/span><\/li>\n<li><span style=\"text-decoration: underline;\"><a href=\"https:\/\/www.sqlnethub.com\/blog\/changing-the-startup-form-in-a-c-project\/\">Changing the startup form in a C# project<\/a><\/span><\/li>\n<li><span style=\"text-decoration: underline;\"><a href=\"https:\/\/www.sqlnethub.com\/blog\/using-the-csharp-sqlparameter-object-writing-more-secure-code\/\">Using the C# SqlParameter Object for Writing More Secure Code<\/a><\/span><\/li>\n<li><span style=\"text-decoration: underline;\"><a href=\"https:\/\/www.sqlnethub.com\/blog\/cannot-implicitly-convert-type-string-to-system-windows-forms-datagridviewtextboxcolumn\/\">Cannot implicitly convert type \u2018string\u2019 to \u2018System.Windows.Forms.DataGridViewTextBoxColumn<\/a><\/span><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<blockquote><p>Check our <span style=\"text-decoration: underline;\"><a href=\"\/online-courses\/\">online courses<\/a><\/span>!<\/p>\n<p>Check our <span style=\"text-decoration: underline;\"><a href=\"https:\/\/www.sqlnethub.com\/sql-server-ebooks\/\">eBooks<\/a><\/span>!<\/p>\n<p>Subscribe to our <span style=\"text-decoration: underline;\"><a href=\"https:\/\/www.youtube.com\/sqlnethubtv?sub_confirmation=1\" target=\"_blank\" rel=\"nofollow noopener\">YouTube channel<\/a><\/span>!<\/p>\n<p>Subscribe to our <span style=\"text-decoration: underline;\"><a href=\"\/newsletter\/\">newsletter<\/a>\u00a0<\/span>and stay up to date!<\/p><\/blockquote>\n<p>&nbsp;<\/p>\n<p><strong>Rate this article:<\/strong> <span id=\"post-ratings-11567\" class=\"post-ratings\" data-nonce=\"5e61890179\"><img decoding=\"async\" id=\"rating_11567_1\" src=\"https:\/\/www.sqlnethub.com\/wp-content\/plugins\/wp-postratings\/images\/stars\/rating_on.gif\" alt=\"1 Star\" title=\"1 Star\" onmouseover=\"current_rating(11567, 1, '1 Star');\" onmouseout=\"ratings_off(5, 0, 0);\" onclick=\"rate_post();\" onkeypress=\"rate_post();\" style=\"cursor: pointer; border: 0px;\" \/><img decoding=\"async\" id=\"rating_11567_2\" src=\"https:\/\/www.sqlnethub.com\/wp-content\/plugins\/wp-postratings\/images\/stars\/rating_on.gif\" alt=\"2 Stars\" title=\"2 Stars\" onmouseover=\"current_rating(11567, 2, '2 Stars');\" onmouseout=\"ratings_off(5, 0, 0);\" onclick=\"rate_post();\" onkeypress=\"rate_post();\" style=\"cursor: pointer; border: 0px;\" \/><img decoding=\"async\" id=\"rating_11567_3\" src=\"https:\/\/www.sqlnethub.com\/wp-content\/plugins\/wp-postratings\/images\/stars\/rating_on.gif\" alt=\"3 Stars\" title=\"3 Stars\" onmouseover=\"current_rating(11567, 3, '3 Stars');\" onmouseout=\"ratings_off(5, 0, 0);\" onclick=\"rate_post();\" onkeypress=\"rate_post();\" style=\"cursor: pointer; border: 0px;\" \/><img decoding=\"async\" id=\"rating_11567_4\" src=\"https:\/\/www.sqlnethub.com\/wp-content\/plugins\/wp-postratings\/images\/stars\/rating_on.gif\" alt=\"4 Stars\" title=\"4 Stars\" onmouseover=\"current_rating(11567, 4, '4 Stars');\" onmouseout=\"ratings_off(5, 0, 0);\" onclick=\"rate_post();\" onkeypress=\"rate_post();\" style=\"cursor: pointer; border: 0px;\" \/><img decoding=\"async\" id=\"rating_11567_5\" src=\"https:\/\/www.sqlnethub.com\/wp-content\/plugins\/wp-postratings\/images\/stars\/rating_on.gif\" alt=\"5 Stars\" title=\"5 Stars\" onmouseover=\"current_rating(11567, 5, '5 Stars');\" onmouseout=\"ratings_off(5, 0, 0);\" onclick=\"rate_post();\" onkeypress=\"rate_post();\" style=\"cursor: pointer; border: 0px;\" \/> (<strong>2<\/strong> votes, average: <strong>5.00<\/strong> out of 5)<br \/><span class=\"post-ratings-text\" id=\"ratings_11567_text\"><\/span><\/span><span id=\"post-ratings-11567-loading\" class=\"post-ratings-loading\"><img decoding=\"async\" src=\"https:\/\/www.sqlnethub.com\/wp-content\/plugins\/wp-postratings\/images\/loading.gif\" width=\"16\" height=\"16\" class=\"post-ratings-image\" \/>Loading...<\/span><\/p>\n<p>Reference: SQLNetHub.com (<a href=\"https:\/\/www.sqlnethub.com\">https:\/\/www.sqlnethub.com<\/a>)<\/p>\n<p>\u00a9 SQLNetHub<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this post, I will be regularly posting useful Python programming tips. These tips will be organized in different categories, in order to make it easier to read it. &nbsp; Hello World in Python The below command, prints a &#8220;Hello World&#8221; message from within a Python script: print(&#8220;Hello World from Python&#8221;) &nbsp; Code Indentation in &#8230; <a title=\"Useful Python Programming Tips\" class=\"read-more\" href=\"https:\/\/www.sqlnethub.com\/blog\/useful-python-programming-tips\/\" aria-label=\"Read more about Useful Python Programming Tips\">Read more&#8230;<\/a><\/p>\n","protected":false},"author":1,"featured_media":11579,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[139,152],"tags":[],"class_list":["post-11567","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-programming","category-python"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Useful Python Programming Tips - SQLNetHub<\/title>\n<meta name=\"description\" content=\"In this article which is regularly updated, we share useful Python programming tips that help you be more productive when working with Python\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.sqlnethub.com\/blog\/useful-python-programming-tips\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Useful Python Programming Tips - SQLNetHub\" \/>\n<meta property=\"og:description\" content=\"In this article which is regularly updated, we share useful Python programming tips that help you be more productive when working with Python\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqlnethub.com\/blog\/useful-python-programming-tips\/\" \/>\n<meta property=\"og:site_name\" content=\"SQLNetHub\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/groups\/sqlnethub\" \/>\n<meta property=\"article:published_time\" content=\"2021-04-22T17:27:16+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-03-01T16:48:48+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.sqlnethub.com\/wp-content\/uploads\/2021\/04\/Useful-Python-Programming-Tips.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1280\" \/>\n\t<meta property=\"og:image:height\" content=\"853\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Artemakis Artemiou\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@artemakis\" \/>\n<meta name=\"twitter:site\" content=\"@sqlnethub\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Artemakis Artemiou\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.sqlnethub.com\\\/blog\\\/useful-python-programming-tips\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.sqlnethub.com\\\/blog\\\/useful-python-programming-tips\\\/\"},\"author\":{\"name\":\"Artemakis Artemiou\",\"@id\":\"https:\\\/\\\/www.sqlnethub.com\\\/#\\\/schema\\\/person\\\/51134ce3cf8216f020b20bf9e90da0f3\"},\"headline\":\"Useful Python Programming Tips\",\"datePublished\":\"2021-04-22T17:27:16+00:00\",\"dateModified\":\"2024-03-01T16:48:48+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.sqlnethub.com\\\/blog\\\/useful-python-programming-tips\\\/\"},\"wordCount\":787,\"publisher\":{\"@id\":\"https:\\\/\\\/www.sqlnethub.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.sqlnethub.com\\\/blog\\\/useful-python-programming-tips\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.sqlnethub.com\\\/wp-content\\\/uploads\\\/2021\\\/04\\\/Useful-Python-Programming-Tips.jpg\",\"articleSection\":[\"Programming\",\"Python\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.sqlnethub.com\\\/blog\\\/useful-python-programming-tips\\\/\",\"url\":\"https:\\\/\\\/www.sqlnethub.com\\\/blog\\\/useful-python-programming-tips\\\/\",\"name\":\"Useful Python Programming Tips - SQLNetHub\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.sqlnethub.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.sqlnethub.com\\\/blog\\\/useful-python-programming-tips\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.sqlnethub.com\\\/blog\\\/useful-python-programming-tips\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.sqlnethub.com\\\/wp-content\\\/uploads\\\/2021\\\/04\\\/Useful-Python-Programming-Tips.jpg\",\"datePublished\":\"2021-04-22T17:27:16+00:00\",\"dateModified\":\"2024-03-01T16:48:48+00:00\",\"description\":\"In this article which is regularly updated, we share useful Python programming tips that help you be more productive when working with Python\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.sqlnethub.com\\\/blog\\\/useful-python-programming-tips\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.sqlnethub.com\\\/blog\\\/useful-python-programming-tips\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.sqlnethub.com\\\/blog\\\/useful-python-programming-tips\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.sqlnethub.com\\\/wp-content\\\/uploads\\\/2021\\\/04\\\/Useful-Python-Programming-Tips.jpg\",\"contentUrl\":\"https:\\\/\\\/www.sqlnethub.com\\\/wp-content\\\/uploads\\\/2021\\\/04\\\/Useful-Python-Programming-Tips.jpg\",\"width\":1280,\"height\":853,\"caption\":\"Useful Python Programming Tips - Article on SQLNetHub\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.sqlnethub.com\\\/blog\\\/useful-python-programming-tips\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.sqlnethub.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Useful Python Programming Tips\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.sqlnethub.com\\\/#website\",\"url\":\"https:\\\/\\\/www.sqlnethub.com\\\/\",\"name\":\"SQLNetHub\",\"description\":\"High-Quality Technical Training\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.sqlnethub.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.sqlnethub.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.sqlnethub.com\\\/#organization\",\"name\":\"SQLNetHub\",\"url\":\"https:\\\/\\\/www.sqlnethub.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.sqlnethub.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.sqlnethub.com\\\/wp-content\\\/uploads\\\/2018\\\/01\\\/SQLNetHubLogo-Website-Version.png\",\"contentUrl\":\"https:\\\/\\\/www.sqlnethub.com\\\/wp-content\\\/uploads\\\/2018\\\/01\\\/SQLNetHubLogo-Website-Version.png\",\"width\":180,\"height\":90,\"caption\":\"SQLNetHub\"},\"image\":{\"@id\":\"https:\\\/\\\/www.sqlnethub.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/groups\\\/sqlnethub\",\"https:\\\/\\\/x.com\\\/sqlnethub\",\"https:\\\/\\\/www.youtube.com\\\/user\\\/sqlserverdotnetblog\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.sqlnethub.com\\\/#\\\/schema\\\/person\\\/51134ce3cf8216f020b20bf9e90da0f3\",\"name\":\"Artemakis Artemiou\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/70f03b30e240c249b681733e1901b3092b6147961ae97f6a6647cd6b7d087468?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/70f03b30e240c249b681733e1901b3092b6147961ae97f6a6647cd6b7d087468?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/70f03b30e240c249b681733e1901b3092b6147961ae97f6a6647cd6b7d087468?s=96&d=mm&r=g\",\"caption\":\"Artemakis Artemiou\"},\"description\":\"Artemakis Artemiou is a seasoned Senior Database and AI\\\/Automation Architect with over 20 years of expertise in the IT industry. As a Certified Database, Cloud, and AI professional, he has been recognized as a thought leader, earning the prestigious Microsoft Data Platform MVP title for nine consecutive years (2009-2018). Driven by a passion for simplifying complex topics, Artemakis shares his expertise through articles, online courses, and speaking engagements. He empowers professionals around the globe to excel in Databases, Cloud, AI, Automation, and Software Development. Committed to innovation and education, Artemakis strives to make technology accessible and impactful for everyone.\",\"sameAs\":[\"https:\\\/\\\/www.sqlnethub.com\",\"https:\\\/\\\/x.com\\\/artemakis\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Useful Python Programming Tips - SQLNetHub","description":"In this article which is regularly updated, we share useful Python programming tips that help you be more productive when working with Python","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.sqlnethub.com\/blog\/useful-python-programming-tips\/","og_locale":"en_US","og_type":"article","og_title":"Useful Python Programming Tips - SQLNetHub","og_description":"In this article which is regularly updated, we share useful Python programming tips that help you be more productive when working with Python","og_url":"https:\/\/www.sqlnethub.com\/blog\/useful-python-programming-tips\/","og_site_name":"SQLNetHub","article_publisher":"https:\/\/www.facebook.com\/groups\/sqlnethub","article_published_time":"2021-04-22T17:27:16+00:00","article_modified_time":"2024-03-01T16:48:48+00:00","og_image":[{"width":1280,"height":853,"url":"https:\/\/www.sqlnethub.com\/wp-content\/uploads\/2021\/04\/Useful-Python-Programming-Tips.jpg","type":"image\/jpeg"}],"author":"Artemakis Artemiou","twitter_card":"summary_large_image","twitter_creator":"@artemakis","twitter_site":"@sqlnethub","twitter_misc":{"Written by":"Artemakis Artemiou","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.sqlnethub.com\/blog\/useful-python-programming-tips\/#article","isPartOf":{"@id":"https:\/\/www.sqlnethub.com\/blog\/useful-python-programming-tips\/"},"author":{"name":"Artemakis Artemiou","@id":"https:\/\/www.sqlnethub.com\/#\/schema\/person\/51134ce3cf8216f020b20bf9e90da0f3"},"headline":"Useful Python Programming Tips","datePublished":"2021-04-22T17:27:16+00:00","dateModified":"2024-03-01T16:48:48+00:00","mainEntityOfPage":{"@id":"https:\/\/www.sqlnethub.com\/blog\/useful-python-programming-tips\/"},"wordCount":787,"publisher":{"@id":"https:\/\/www.sqlnethub.com\/#organization"},"image":{"@id":"https:\/\/www.sqlnethub.com\/blog\/useful-python-programming-tips\/#primaryimage"},"thumbnailUrl":"https:\/\/www.sqlnethub.com\/wp-content\/uploads\/2021\/04\/Useful-Python-Programming-Tips.jpg","articleSection":["Programming","Python"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.sqlnethub.com\/blog\/useful-python-programming-tips\/","url":"https:\/\/www.sqlnethub.com\/blog\/useful-python-programming-tips\/","name":"Useful Python Programming Tips - SQLNetHub","isPartOf":{"@id":"https:\/\/www.sqlnethub.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.sqlnethub.com\/blog\/useful-python-programming-tips\/#primaryimage"},"image":{"@id":"https:\/\/www.sqlnethub.com\/blog\/useful-python-programming-tips\/#primaryimage"},"thumbnailUrl":"https:\/\/www.sqlnethub.com\/wp-content\/uploads\/2021\/04\/Useful-Python-Programming-Tips.jpg","datePublished":"2021-04-22T17:27:16+00:00","dateModified":"2024-03-01T16:48:48+00:00","description":"In this article which is regularly updated, we share useful Python programming tips that help you be more productive when working with Python","breadcrumb":{"@id":"https:\/\/www.sqlnethub.com\/blog\/useful-python-programming-tips\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqlnethub.com\/blog\/useful-python-programming-tips\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sqlnethub.com\/blog\/useful-python-programming-tips\/#primaryimage","url":"https:\/\/www.sqlnethub.com\/wp-content\/uploads\/2021\/04\/Useful-Python-Programming-Tips.jpg","contentUrl":"https:\/\/www.sqlnethub.com\/wp-content\/uploads\/2021\/04\/Useful-Python-Programming-Tips.jpg","width":1280,"height":853,"caption":"Useful Python Programming Tips - Article on SQLNetHub"},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqlnethub.com\/blog\/useful-python-programming-tips\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqlnethub.com\/"},{"@type":"ListItem","position":2,"name":"Useful Python Programming Tips"}]},{"@type":"WebSite","@id":"https:\/\/www.sqlnethub.com\/#website","url":"https:\/\/www.sqlnethub.com\/","name":"SQLNetHub","description":"High-Quality Technical Training","publisher":{"@id":"https:\/\/www.sqlnethub.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.sqlnethub.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.sqlnethub.com\/#organization","name":"SQLNetHub","url":"https:\/\/www.sqlnethub.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sqlnethub.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.sqlnethub.com\/wp-content\/uploads\/2018\/01\/SQLNetHubLogo-Website-Version.png","contentUrl":"https:\/\/www.sqlnethub.com\/wp-content\/uploads\/2018\/01\/SQLNetHubLogo-Website-Version.png","width":180,"height":90,"caption":"SQLNetHub"},"image":{"@id":"https:\/\/www.sqlnethub.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/groups\/sqlnethub","https:\/\/x.com\/sqlnethub","https:\/\/www.youtube.com\/user\/sqlserverdotnetblog"]},{"@type":"Person","@id":"https:\/\/www.sqlnethub.com\/#\/schema\/person\/51134ce3cf8216f020b20bf9e90da0f3","name":"Artemakis Artemiou","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/70f03b30e240c249b681733e1901b3092b6147961ae97f6a6647cd6b7d087468?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/70f03b30e240c249b681733e1901b3092b6147961ae97f6a6647cd6b7d087468?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/70f03b30e240c249b681733e1901b3092b6147961ae97f6a6647cd6b7d087468?s=96&d=mm&r=g","caption":"Artemakis Artemiou"},"description":"Artemakis Artemiou is a seasoned Senior Database and AI\/Automation Architect with over 20 years of expertise in the IT industry. As a Certified Database, Cloud, and AI professional, he has been recognized as a thought leader, earning the prestigious Microsoft Data Platform MVP title for nine consecutive years (2009-2018). Driven by a passion for simplifying complex topics, Artemakis shares his expertise through articles, online courses, and speaking engagements. He empowers professionals around the globe to excel in Databases, Cloud, AI, Automation, and Software Development. Committed to innovation and education, Artemakis strives to make technology accessible and impactful for everyone.","sameAs":["https:\/\/www.sqlnethub.com","https:\/\/x.com\/artemakis"]}]}},"_links":{"self":[{"href":"https:\/\/www.sqlnethub.com\/wp-json\/wp\/v2\/posts\/11567","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sqlnethub.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sqlnethub.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sqlnethub.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sqlnethub.com\/wp-json\/wp\/v2\/comments?post=11567"}],"version-history":[{"count":0,"href":"https:\/\/www.sqlnethub.com\/wp-json\/wp\/v2\/posts\/11567\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.sqlnethub.com\/wp-json\/wp\/v2\/media\/11579"}],"wp:attachment":[{"href":"https:\/\/www.sqlnethub.com\/wp-json\/wp\/v2\/media?parent=11567"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sqlnethub.com\/wp-json\/wp\/v2\/categories?post=11567"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sqlnethub.com\/wp-json\/wp\/v2\/tags?post=11567"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}