Charles Wong (8)

Organizing

Larger projects, long-running processes, and code that manages many and various routines, benefits from some organization. Organized code prevents many murders. Disorganized code causes m # supervisor.py import foobaz_interface import summary_builder import emailer import traceback import schedule import time class Supervisor(): """Manages timing + exc…

Continue reading...

More about import

Importing loads a module into memory. For that reason, changing a file while it's running will not change the running program. Likewise, if you import a file into the interactive interpreter, it won't know about changes to the file. # timer.py import schedule import time…

Continue reading...

Passing functions

You can think of functions as a collection of instructions stored as a variable. Different languages handle that differently, so let's just look at python for now. >>> m = {'name':'Fredrick Anderson','ssn':'287-32-4492'} >>> m {'name': 'Fredrick Anderson', 'ssn': '287-32-4492'} >>> def m(): ... print('foo') ...

Continue reading...

import, function, concurrency

Your code is made of many files. At least, I hope it is. Your favorite language will have keywords like `import` or `require` or `include`. Python isn't my favorite language, but it's fine... it uses `import`. Your files get stupid really fast if you can't…

Continue reading...

Adventure time! Wait wth...

Different languages are different... surprise surprise. # python jar = [] # list ?> jar[0] ? Error! ?> jar[0] = 'coin' > Error: No! You cannot! jar.append('coin') ?> jar ? ['coin'] ?> jar[0] ? 'coin' # Ok what else can we put in here? file…

Continue reading...