Adding Examples

Let’s take a look at some code examples, and how you’d create them with voice.

Requests

Here’s a function that makes a GET request using the requests module:

import requests


def get(url):
    r = requests.get(url)
    return r.text

To code this with voice, you can say:

add import requests
add function get
add parameter url
add r equals requests dot get in parens url
add return r dot text

Flask

Here’s Flask’s hello world example:

from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello():
    return 'hello world'

To code this with voice, you can say:

add from flask import capital flask
add app equals capital flask in parens double underscores name
newline
add function hello
add return in quotes hello world
add decorator app dot route in parens in quotes slash

Django Model

Here’s an example Django model:

from django.db import models

class MyModelName(models.Model):
    my_field_name = models.CharField(max_length=20)

To code this with voice, you can say:

add from django dot db import models
newline
add class my model name
add parent models dot capital model
add my field name equals models dot pascal case char field in parens max length equals twenty

Fizzbuzz

Here’s a simple fizzbuzz implementation:

for number in range(5):
    if number % 3 == 0 and number % 5 == 0:
        print('fizzbuzz')
    elif number % 3 == 0:
        print('fizz')
    elif number % 5 == 0:
        print('buzz')
    else:
        print(number)

To code this with voice, you can say:

add for number in range in parens five
add if number mod three double equals zero and number mod five double equals zero
add print in quotes fizzbuzz
add else if number mod three double equals zero
add print in quotes fizz
add else if number mod five double equals zero
add print in quotes buzz
add else print number