How to make phone calls using Python?

Learn how to make phone calls with few lines of Python code and Twilio
03 August 2017   642

Despite the popularity of such services as messagers, skype, voip, emails, etc. good old-fashioned phone calls remain one of the best and the most popular form of communication for billions of people all over the world. Full Stack Python had prepared a tutorial for you about how to make and receive phone calls from any application with just a few lines of Python code plus a web application programming interface

In the tutorial, example calls will say a snippet of text and put all incoming callers into a recorded conference call.

Requirements:

  • Python 2 or 3
  • pip and virtualenv to handle application dependencies
  • A free Twilio account to use their phone calling web API
  • Twilio's Python helper library, version 5.7.0, which is available on PyPI

Twilio is a web application programming interface (API) that software developers can use to add communications such as phone calling, messaging, video and two-factor authentication into their Python applications.

Created app will use the Twilio Python helper library to create an HTTP POST request to Twilio's API. 

You can view full tutorial at the Full Stack Python.

What is YAPF?

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

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.