How do you make your Python code more crowded?

Source: Internet
Author: User
I feel like my Python code is very lame, and the person who spits it out is a C + +. I see other people's python is cool to explode, forcing lattice full. How do I make my python look more pushy? ╮(╯▽╰)╭

Reply content:

This year (2014) Hangzhou Pycon has a topic called , you see the subtitle on the first page of the presentation and you know what you're looking for:
Thank you lecturer @ Shihuanmin, Presentation Thank you lecturer @ Shihuanmin, Presentation idiomatic.py , looks like to turn
In fact, you in search engine directly search idiomatic python, will get a lot of related topics, more see more use, certainly can take off "look like C + +" This top hat I come to dry it:
Code like a pythonista:idiomatic Python:

/ http Python.net/~goodger/pro jects/pycon/2007/idiomatic/handout.html


Python Idioms:

Http://safehammad.com/downloads/python-idioms-2014-01-16.pdf


Write idiomatic Python Jeff Knupp: Google yourself

First of all, the most basic code specification is to follow, is the so-called inadequate surrounding area, good indentation style and naming methods to make your code more concise;
Second, do a good job of abstraction, whether it is data abstraction or process abstraction to do, recently in the SICP, the book repeatedly emphasizes abstraction, extracting public logic, standing in a higher, more general perspective to examine the code, in line with the requirements of the code is undoubtedly like the depth of refined ore, content is higher;
Again, the more the code away from the C style, the closer to lisp the more explicit forcing lattice, then functional programming is the part you must try;
Finally, few but Good's comments are definitely the finishing touches. -Use map to never use list comprehension
-You can never define a function name with lambda
-Can never append to list and return with yield
-With *args and **kwargs in the function signature, no matter what.
-Define an empty class to be named Xxxmixin, and then add this mixin in the inheritance list first, regardless of the use.
-Multi-use super Call the parent class function, with the previous bar, let the person looking at the code jump back and forth

UPDATE: Click to feel guilty ... You know I'm in joking, right?
I see other people's python is cool to explode, forcing lattice full
You say that someone else's python cool to explode, presumably you have your own set of measures, it is not equal to you already know how to write is a force lattice it? "Escape laxatives," said one more
The amount of comments is sufficient, conforms to the code specification, submits the main code simultaneously submits the complete test code, then the various coverage detection all to 100%. The first bright blind lazy people, reflects the industry conscience and moral integrity.

And then, after running for n years, there is no bug, no one to change, and no need to change.

Do you have a problem with this? The main question seems to be to make Python code more pythonic.
How can I miss "Python Cookbook"?
Attach the Chinese version of the address: Python Cookbook 3rd Edition Write the LISP for a while before you write Python. Ask me to do code view since upstairs mentions PEP8, that mention: Pylint-code analysis for Python
It's OK to give the code a point, scare them, no more than this score more force lattice it?
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.