Skip to content

Instantly share code, notes, and snippets.

@dglaude
Last active October 9, 2016 18:53
Show Gist options
  • Save dglaude/fc9dfae354e2f82b85e3317219c688d3 to your computer and use it in GitHub Desktop.
Save dglaude/fc9dfae354e2f82b85e3317219c688d3 to your computer and use it in GitHub Desktop.
microPython tools: cat, copy & decat (a debug cat with line number)
import os
os.mkdir("lib")
os.chdir("lib")
f=open("decat.py","w")
f.write('''
import os
def decat(filename):
i = 1
with open(filename, 'rt') as f:
for line in f.readlines():
print('{num:02d}: '.format(num=i), end='')
print(line, end='')
i = i + 1
''')
f.close()
f=open("cat.py","w")
f.write('''
import os
def cat(filename):
with open(filename, 'rt') as f:
for line in f.readlines():
print(line, end='')
''')
f.close()
f=open("copy.py","w")
f.write('''
import os
def copy(source, destination):
f = open (source, 'r')
g = open (destination, 'w')
g.write(f.read())
f.close()
g.close()
''')
f.close()
@dglaude
Copy link
Author

dglaude commented Sep 24, 2016

Now working on adding a debug cat that print a line number in front of each line to detect where an error is located.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment