I tried giving it one of the prompts from copilot.github.com:
def strip_suffix(filename):
"""
Removes the suffix from a filename
"""
return filename[:filename.rfind('.')]
def test_strip_suffix():
It completed the test function like this: # test stripping of a suffix
a = strip_suffix("I_am_file.txt")
assert a == "I_am_file"
Compare this with GitHub Copilot, which gives: """
Tests for the strip_suffix function
"""
assert strip_suffix('notes.txt') == 'notes'
assert strip_suffix('notes.txt.gz') == 'notes.txt'
GPT-J also gave a bunch of explanation on how to use the generated code: So this goes in a file called my_file.py and when you run python3.4 -m my_file.strip_suffix you should get the following output
C:\Users\user\Desktop>python3.4 -m my_file.strip_suffix
'strip_suffix'
C:\Users\user\Desktop>
So the strip_suffix function which strips the suffix from a filename is called as part of a larger code that uses some functions from the file. To tell Python what functions are available in a file you just need to put #-comment characters on the first line and then the functions that you want to use, and the first line will be taken as the function documentation:
#-*- coding: utf-8 -*-
#comment
def func_one():
'''
Documentation for function one.
'''
print("This is the doc for func_one