{"id":3664,"date":"2015-04-09T11:00:46","date_gmt":"2015-04-09T11:00:46","guid":{"rendered":"http:\/\/blog.bachi.net\/?p=3664"},"modified":"2015-05-10T09:09:41","modified_gmt":"2015-05-10T09:09:41","slug":"python-2-7","status":"publish","type":"post","link":"https:\/\/blog.bachi.net\/?p=3664","title":{"rendered":"Python 2.7"},"content":{"rendered":"<blockquote><p>EAFP is a Python acronym that stands for easier to ask for forgiveness than permission. This coding style is highly pushed in the Python community because it completely relies on the duck typing concept, thus fitting well with the language philosophy.<\/p>\n<p>The concept behind EAFP is fairly easy: instead of checking if an object has a given attribute or method before actually accessing or using it, just trust the object to provide what you need and manage the error case.<\/p><\/blockquote>\n<h3>Datatypes<\/h3>\n<h4>Lists<\/h4>\n<p><a href=\"http:\/\/effbot.org\/zone\/python-list.htm\">An Introduction to Python Lists<\/a><br \/>\n<a href=\"http:\/\/www.tutorialspoint.com\/python\/python_lists.htm\">Python Lists<\/a><\/p>\n<h4>Dict<\/h4>\n<p><a href=\"http:\/\/www.python-kurs.eu\/dictionaries.php\">Dictionaries<\/a><br \/>\n<a href=\"http:\/\/www.tutorialspoint.com\/python\/python_dictionary.htm\">Python Dictionary<\/a><br \/>\n<a href=\"http:\/\/stackoverflow.com\/questions\/1024847\/add-to-a-dictionary-in-python\">Add to a dictionary in Python?<\/a><br \/>\n<a href=\"http:\/\/stackoverflow.com\/questions\/6416131\/python-add-new-item-to-dictionary\">Python add new item to dictionary [duplicate]<\/a><\/p>\n<h3>Iterators &amp; Generators<\/h3>\n<p><a href=\"http:\/\/anandology.com\/python-practice-book\/iterators.html\">Iterators &amp; Generators<\/a><\/p>\n<h3>Classes and Objects<\/h3>\n<p><a href=\"http:\/\/anandology.com\/python-practice-book\/object_oriented_programming.html\">Object Oriented Programming<\/a><br \/>\n<a href=\"https:\/\/fuhm.net\/super-harmful\/\">Python&#8217;s Super is nifty, but you can&#8217;t use it<\/a><br \/>\n<a href=\"http:\/\/stackoverflow.com\/questions\/8972866\/correct-way-to-use-super-argument-passing\">correct way to use super (argument passing)<\/a><br \/>\n<a href=\"http:\/\/lgiordani.com\/blog\/2014\/08\/20\/python-3-oop-part-1-objects-and-types\/#.VSaKieQvA3E\">Python 3 OOP Part 1 &#8211; Objects and types<\/a><br \/>\n<a href=\"http:\/\/lgiordani.com\/blog\/2014\/08\/20\/python-3-oop-part-2-classes-and-members\/#.VSaKeeQvA3E\">Python 3 OOP Part 2 &#8211; Classes and members<\/a><br \/>\n<a href=\"http:\/\/lgiordani.com\/blog\/2014\/08\/20\/python-3-oop-part-3-delegation-composition-and-inheritance\/#.VSaKduQvA3E\">Python 3 OOP Part 3 &#8211; Delegation: composition and inheritance<\/a><br \/>\n<a href=\"http:\/\/lgiordani.com\/blog\/2014\/08\/21\/python-3-oop-part-4-polymorphism\/#.VSaKHOQvA3E\">Python 3 OOP Part 4 &#8211; Polymorphism<\/a><br \/>\n<a href=\"http:\/\/lgiordani.com\/blog\/2014\/09\/01\/python-3-oop-part-5-metaclasses\/#.VSaKqOQvA3E\">Python 3 OOP Part 5 &#8211; Metaclasses<\/a><br \/>\n<a href=\"http:\/\/lgiordani.com\/blog\/2014\/09\/04\/python-3-oop-part-6-abstract-base-classes\/#.VSaKquQvA3E\">Python 3 OOP Part 6 &#8211; Abstract Base Classes<\/a><\/p>\n<h3>Logging<\/h3>\n<p><a href=\"https:\/\/docs.python.org\/2\/library\/logging.html\">15.7. logging \u2014 Logging facility for Python<\/a><br \/>\n<a href=\"https:\/\/docs.python.org\/2\/howto\/logging.html\">Logging HOWTO on docs.python.org<\/a><br \/>\n<a href=\"https:\/\/docs.python.org\/2\/howto\/logging-cookbook.html\">Logging Cookbook on docs.python.org<\/a><br \/>\n<a href=\"http:\/\/victorlin.me\/posts\/2012\/08\/26\/good-logging-practice-in-python\">Good logging practice in Python<\/a><br \/>\n<a href=\"http:\/\/pymotw.com\/2\/logging\/\">PyMOTW &#8211; logging \u2013 Report status, error, and informational messages<\/a><br \/>\n<a href=\"http:\/\/docs.python-guide.org\/en\/latest\/writing\/logging\/\">Python Guide &#8211; Logging<\/a><\/p>\n<h4>Datamodel<\/h4>\n<p><a href=\"https:\/\/docs.python.org\/2\/reference\/datamodel.html#basic-customization\">3.4.1. Basic customization<\/a> (__init__, __str__, &#8230;)<\/p>\n<h4>Uniform Access Principle \/ Property \/ Class Attribute<\/h4>\n<p><a href=\"http:\/\/stackoverflow.com\/questions\/4555932\/public-or-private-attribute-in-python-what-is-the-best-way\">\u201cpublic\u201d or \u201cprivate\u201d attribute in Python ? What is the best way?<\/a><br \/>\n<a href=\"http:\/\/www.toptal.com\/python\/python-class-attributes-an-overly-thorough-guide\">Python Class Attributes: An Overly Thorough Guide<\/a><br \/>\n<a href=\"http:\/\/stackoverflow.com\/questions\/7374748\/whats-the-difference-between-a-python-property-and-attribute\">What&#8217;s the difference between a Python \u201cproperty\u201d and \u201cattribute\u201d?<\/a><br \/>\n<a href=\"https:\/\/docs.python.org\/2\/tutorial\/classes.html#private-variables-and-class-local-references\">Private Variables and Class-local References<\/a><br \/>\n<a href=\"https:\/\/docs.python.org\/2\/reference\/datamodel.html#implementing-descriptors\">Implementing Descriptors<\/a><\/p>\n<h4>old-style vs. new-style<\/h4>\n<p><a href=\"https:\/\/www.python.org\/doc\/newstyle\/\">New-style Classes<\/a><br \/>\n<a href=\"http:\/\/stackoverflow.com\/questions\/54867\/what-is-the-difference-between-old-style-and-new-style-classes-in-python\">What is the difference between old style and new style classes in Python?<\/a><br \/>\n<a href=\"http:\/\/stackoverflow.com\/questions\/13816849\/old-style-and-new-style-classes-in-python-2-7\">old-style and new-style classes in Python 2.7? [duplicate]<\/a><\/p>\n<h4>args and kwargs<\/h4>\n<p><a href=\"http:\/\/stackoverflow.com\/questions\/1769403\/understanding-kwargs-in-python\">Understanding kwargs in Python<\/a><br \/>\n<a href=\"http:\/\/stackoverflow.com\/questions\/3394835\/args-and-kwargs\">*args and **kwargs? [duplicate]<\/a><br \/>\n<a href=\"http:\/\/stackoverflow.com\/questions\/36901\/what-does-double-star-and-star-do-for-python-parameters\">What does ** (double star) and * (star) do for Python parameters?<\/a><\/p>\n<h3>Webserver \/ WSGI<\/h3>\n<p><a href=\"http:\/\/www.fullstackpython.com\/wsgi-servers.html\">Web Server Gateway Interface (WSGI) Servers<\/a><\/p>\n<h3>Documentation \/ docstring<\/h3>\n<p><a href=\"http:\/\/sphinx-doc.org\/latest\/ext\/napoleon.html\">sphinx.ext.napoleon \u2013 Support for NumPy and Google style docstrings<\/a><br \/>\n<a href=\"http:\/\/sphinx-doc.org\/latest\/ext\/example_google.html\">Example Google Style Python Docstrings<\/a><br \/>\n<a href=\"http:\/\/sphinx-doc.org\/latest\/ext\/example_numpy.html\">Example NumPy Style Python Docstrings<\/a><\/p>\n<p><a href=\"https:\/\/www.python.org\/dev\/peps\/pep-0257\/\">PEP 257 &#8211; Docstring Conventions<\/a><br \/>\n<a href=\"https:\/\/www.python.org\/dev\/peps\/pep-0258\/\">PEP 258 &#8211; Docutils Design Specification<\/a><br \/>\n<a href=\"https:\/\/github.com\/numpy\/numpy\/blob\/master\/doc\/HOWTO_DOCUMENT.rst.txt\">numpy &#8211; How-to document<\/a><br \/>\n<a href=\"http:\/\/stackoverflow.com\/questions\/9195455\/how-to-document-a-method-with-parameters\">How to document a method with parameter(s)?<\/a><br \/>\n<a href=\"https:\/\/pythonhosted.org\/an_example_pypi_project\/sphinx.html#full-code-example\">Sphinx Code Example<\/a><\/p>\n<p><a href=\"http:\/\/stackoverflow.com\/questions\/6060813\/how-to-document-fields-and-properties-in-python\">How to document fields and properties in Python?<\/a><br \/>\n<a href=\"http:\/\/stackoverflow.com\/questions\/3051241\/how-to-document-class-attributes-in-python\">How to document class attributes in Python?<\/a><\/p>\n<p><a href=\"http:\/\/www.jesshamrick.com\/2013\/04\/17\/rewriting-python-docstrings-with-a-metaclass\/\">Rewriting Python Docstrings With a Metaclass<\/a><\/p>\n<h3>PyCharm<\/h4>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nFile -&gt; Settings -&gt; Build, Execution, Deployment -&gt; Python Debugger -&gt; Collect run-time types information for code insight\r\n<\/pre>\n<p><a href=\"https:\/\/www.jetbrains.com\/pycharm\/help\/using-docstrings-to-specify-types.html\">Using Docstrings to Specify Types<\/a><br \/>\n<a href=\"https:\/\/www.jetbrains.com\/pycharm\/help\/creating-documentation-comments.html\">Creating Documentation Comments<\/a><br \/>\n<a href=\"https:\/\/www.jetbrains.com\/pycharm\/help\/generating-reference-documentation.html\">Generating Reference Documentation<\/a> (DocUtils, Sphinx)<br \/>\n<a href=\"https:\/\/www.jetbrains.com\/pycharm\/help\/python-integrated-tools.html\">Python Integrated Tools<\/a> (Docstring format: Plain, reStructuredText, Epytext)<br \/>\n<a href=\"https:\/\/www.jetbrains.com\/pycharm\/help\/documenting-source-code-in-pycharm.html\">Documenting Source Code in PyCharm<\/a> (reStructuredText, Epytext)<br \/>\n<a href=\"https:\/\/youtrack.jetbrains.com\/issue\/PY-9795\">PY-9795: wish list item: support for google python style type comments<\/a> (sphinx.ext.napoleon)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>EAFP is a Python acronym that stands for easier to ask for forgiveness than permission. This coding style is highly pushed in the Python community because it completely relies on the duck typing concept, thus fitting well with the language philosophy. The concept behind EAFP is fairly easy: instead of checking if an object has [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3664","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/posts\/3664","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3664"}],"version-history":[{"count":23,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/posts\/3664\/revisions"}],"predecessor-version":[{"id":3755,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/posts\/3664\/revisions\/3755"}],"wp:attachment":[{"href":"https:\/\/blog.bachi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3664"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3664"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3664"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}