What is dead code?
What is dead code? Looks like it depends on who you ask. Some people think it’s unreachable code than never executes. Other people think that it’s redundant code that does […]
What is dead code? Looks like it depends on who you ask. Some people think it’s unreachable code than never executes. Other people think that it’s redundant code that does […]
TL;DR use marshmallow-dataclass. Serializing JSON into dataclasses with validation proved to be unexpectedly difficult. By “validation” here I mean type checking (this must be a valid integer), range checking (this […]
This post describes more fundamental underpinnings of how copy and deepcopy interact with callable attributes. See previous post for some practical examples of unexpected behavior. Methods vs Instance Attributes Consider […]
Executive Summary Avoid using callable instance attributes that call back into the object that contains them. If you must, make the object uncopyable by overriding __copy__ and __deepcopy__ and raising […]
Python eval() receives two optional dictionaries: globals and locals. I was finally able to find at least two differences between them. First difference: global variables survive until after the eval() […]
TL;DR Use default parameters to simulate assignment in lambdas. Unlike C and C++, in Python assignment is an expression, not a statement. Python lambda can only return an expression, which […]
Invalid Exec Format They gave me a MacBook Pro at work. I built a docker image locally. I pushed it to Amazon cloud to run. I got “invalid exec format” […]
Code: https://github.com/ikriv-samples/logarthmic-fibonacci. Fibonacci sequence is defined as a sequence starting with 0, 1 where each subsequent member is calculated as fib(n) = fib(n-1)+fib(n-2). This yields an infinite sequence 0, 1, […]
TL;DR make sure to add magic words WSGIApplicationGroup %{GLOBAL} to the Apache config, otherwise import torch will hang. I tried to integrate my PyTorch AI model with my Apache web […]
I have Synology NAS, and I share the “home” directory as a CIFS share. From Windows, I simply do net use N: \\home\nas /user:myuser *, and it works. Corresponding command […]