Last active
October 9, 2016 18:53
-
-
Save dglaude/fc9dfae354e2f82b85e3317219c688d3 to your computer and use it in GitHub Desktop.
microPython tools: cat, copy & decat (a debug cat with line number)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Now working on adding a debug cat that print a line number in front of each line to detect where an error is located.