coding-with-charles (6)

Charles Wong

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...
Charles Wong

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...
Charles Wong

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...
Charles Wong

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...
Charles Wong

Scr... bytecoding 10101

You wake up on a deserted island with... WhAt dO yoU Do? (Please roll an intelligence check) Cursed thoughts may appear on these pages, but they will probably be lined through. Please try not to read them.

Continue reading...