Significant growth of Python

According to Stack Overflow, Python is fastest-growing major programming language
12 September 2017   447

Python is one of the most popular programming language in the world. And recently new proof of this statement appeared. Stack Overflow, one of the most popular resource for all kind of coders, published the metrics, demonstrating the giant growth of Python's popularity.

We can see on Stack Overflow Trends that Python has been growing rapidly in the last few years. But let's focus on high-income countries, and consider visits to questions rather than questions asked (this tends to give similar results, but has less month-by-month noise, especially for smaller tags).

Stack Overflow Trends
Stack Overflow Trends

Data on Stack Overflow question views going back to late 2011, and in this time period Stack team considered the growth of Python relative to five other major programming languages. These are currently six of the ten most-visited Stack Overflow tags in high-income countries; CSS, HTML, Android, and JQuery aren't included.

Growth of major programming languages
Growth of major programming languages

In June, Python became the most visited tag on the developer community site for the first time among high income countries, including hitting top spot in the US and UK and being in the top two almost everywhere else, behind either Java or JavaScript.

What is YAPF?

A formatter for Python files, developed by Google team
30 October 2017   451

What is YAPF?

Most of the current formatters for Python --- e.g., autopep8, and pep8ify --- are made to remove lint errors from code. This has some obvious limitations. For instance, code that conforms to the PEP 8 guidelines may not be reformatted. But it doesn't mean that the code looks good.

YAPF takes a different approach. It's based off of 'clang-format', developed by Daniel Jasper. In essence, the algorithm takes the code and reformats it to the best formatting that conforms to the style guide, even if the original code didn't violate the style guide. The idea is also similar to the 'gofmt' tool for the Go programming language: end all holy wars about formatting - if the whole codebase of a project is simply piped through YAPF whenever modifications are made, the style remains consistent throughout the project and there's no point arguing about style in every code review.

The ultimate goal is that the code YAPF produces is as good as the code that a programmer would write if they were following the style guide. It takes away some of the drudgery of maintaining your code.

Code examples

YAPF takes this code:

x = {  'a':37,'b':42,

'c':927}

y = 'hello ''world'
z = 'hello '+'world'
a = 'hello {}'.format('world')
class foo  (     object  ):
  def f    (self   ):
    return       37*-+2
  def g(self, x,y=42):
      return y
def f  (   a ) :
  return      37+-+a[42-x :  y**3]

and reformat it into:

x = {'a': 37, 'b': 42, 'c': 927}

y = 'hello ' 'world'
z = 'hello ' + 'world'
a = 'hello {}'.format('world')


class foo(object):
    def f(self):
        return 37 * -+2

    def g(self, x, y=42):
        return y


def f(a):
    return 37 + -+a[42 - x:y**3]

See GitHub for more information.