{"id":172747,"date":"2015-07-14T20:55:22","date_gmt":"2015-07-14T18:55:22","guid":{"rendered":"http:\/\/www.bim-me-up.com\/?p=172747"},"modified":"2019-02-04T13:59:33","modified_gmt":"2019-02-04T12:59:33","slug":"python-indentation-or-indentation","status":"publish","type":"post","link":"https:\/\/bim-me-up.com\/en\/python-indentation-or-indentation\/","title":{"rendered":"Python - Indentation or indentation"},"content":{"rendered":"<p>It's been a long time - as some of you may know, I've had an exciting new job since May and therefore haven't been blogging as much recently - but I've been blogging about Dynamo, Python &amp; Co. all the more!<\/p>\n<p>To warm you up, here's a little post for all those who are working with Python and, like me, are struggling with one or two error messages at the beginning:<br \/>\nIndentation plays an important role in Python and structures the script into function blocks. If the indentation is incorrect, you will receive the following error message in Dynamo:<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"186612\" data-permalink=\"https:\/\/bim-me-up.com\/en\/python-indentation-or-indentation\/08-07-2015-13-53-10\/\" data-orig-file=\"https:\/\/i0.wp.com\/bim-me-up.com\/wp-content\/uploads\/2015\/07\/08-07-2015-13-53-10-1.jpg?fit=235%2C133&amp;ssl=1\" data-orig-size=\"235,133\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"08-07-2015 13-53-10\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/bim-me-up.com\/wp-content\/uploads\/2015\/07\/08-07-2015-13-53-10-1.jpg?fit=235%2C133&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/bim-me-up.com\/wp-content\/uploads\/2015\/07\/08-07-2015-13-53-10-1.jpg?fit=235%2C133&amp;ssl=1\" class=\"aligncenter size-full wp-image-186612\" src=\"https:\/\/i0.wp.com\/bim-me-up.com\/wp-content\/uploads\/2015\/07\/08-07-2015-13-53-10-1.jpg?resize=235%2C133\" alt=\"08-07-2015 13-53-10\" width=\"235\" height=\"133\" \/><\/p>\n<p>A correctly written Python script looks like this (note the red-framed blocks that structure the for query):\u00a0<!--more--><\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"186613\" data-permalink=\"https:\/\/bim-me-up.com\/en\/python-indentation-or-indentation\/03-07-2015-14-58-52\/\" data-orig-file=\"https:\/\/i0.wp.com\/bim-me-up.com\/wp-content\/uploads\/2015\/07\/03-07-2015-14-58-52-1.jpg?fit=600%2C490&amp;ssl=1\" data-orig-size=\"600,490\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"03-07-2015 14-58-52\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/bim-me-up.com\/wp-content\/uploads\/2015\/07\/03-07-2015-14-58-52-1.jpg?fit=300%2C245&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/bim-me-up.com\/wp-content\/uploads\/2015\/07\/03-07-2015-14-58-52-1.jpg?fit=600%2C490&amp;ssl=1\" class=\"aligncenter wp-image-186613\" src=\"https:\/\/i0.wp.com\/bim-me-up.com\/wp-content\/uploads\/2015\/07\/03-07-2015-14-58-52-1.jpg?resize=400%2C327\" alt=\"03-07-2015 14-58-52\" width=\"400\" height=\"327\" srcset=\"https:\/\/i0.wp.com\/bim-me-up.com\/wp-content\/uploads\/2015\/07\/03-07-2015-14-58-52-1.jpg?w=600&amp;ssl=1 600w, https:\/\/i0.wp.com\/bim-me-up.com\/wp-content\/uploads\/2015\/07\/03-07-2015-14-58-52-1.jpg?resize=300%2C245&amp;ssl=1 300w\" sizes=\"auto, (max-width: 400px) 100vw, 400px\" \/><\/p>\n<p>Without the indentation of the individual blocks, the above error message appears <strong>Syntax Errror: expected an indented block<\/strong><\/p>\n<p>-&gt;\u00a0<a href=\"http:\/\/www.python-kurs.eu\/python3_bloecke.php\">\u00a0More about blocks in Python (external link).\u00a0<\/a><\/p>\n<p>In the future, there will be much more frequent smaller blog posts here, and I will also regularly publish articles on the official <a href=\"http:\/\/bimblog.typepad.com\/\">Autodesk BIM Blog<\/a> publish.<br \/>\nStay tuned! \ud83d\ude09<\/p>\n<p>&nbsp;<\/p>","protected":false},"excerpt":{"rendered":"It's been a long time - as some of you may know, I've had an exciting new...","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[4],"tags":[88,105,25,50],"class_list":{"0":"post-172747","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-dynamo","7":"tag-blog","8":"tag-deu","9":"tag-dynamo-2","10":"tag-python","11":"cs-entry","12":"cs-video-wrap"},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p2lEa7-IWf","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/bim-me-up.com\/en\/wp-json\/wp\/v2\/posts\/172747","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bim-me-up.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bim-me-up.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bim-me-up.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bim-me-up.com\/en\/wp-json\/wp\/v2\/comments?post=172747"}],"version-history":[{"count":1,"href":"https:\/\/bim-me-up.com\/en\/wp-json\/wp\/v2\/posts\/172747\/revisions"}],"predecessor-version":[{"id":456081,"href":"https:\/\/bim-me-up.com\/en\/wp-json\/wp\/v2\/posts\/172747\/revisions\/456081"}],"wp:attachment":[{"href":"https:\/\/bim-me-up.com\/en\/wp-json\/wp\/v2\/media?parent=172747"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bim-me-up.com\/en\/wp-json\/wp\/v2\/categories?post=172747"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bim-me-up.com\/en\/wp-json\/wp\/v2\/tags?post=172747"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}