Skip to content

Instantly share code, notes, and snippets.

View asoplata's full-sized avatar
🧠
Initializing Cyberbrain

Austin E. Soplata asoplata

🧠
Initializing Cyberbrain
View GitHub Profile
@asoplata
asoplata / gist:bfbc19fa345c1c77566e81275ef9ee65
Last active May 11, 2026 18:48
Python usage: mutable vs immutable types inside functions

Below is a python script you can copy and run that will illustrate how, inside a function that takes an argument, how that argument behaves depends both on type it is and whether it is rebound or not. This is intended to provide explicit examples of how Python is neither "pass-by-value" nor "pass-by-reference", but instead something more complicated, which is commonly called "pass-by-object-reference".

# This is extended from asking claude about if python is pass-by-val or -by-ref, the answer being "neither, it's complicated and something else called pass-by-obj-ref"
#
# # Immutable types: int, float, str, tuple
# - These basically work like "pass-by-value" where an entirely new obj is created inside the func, independent of the outer scope:
def immu_pbv_int(x):
    x = x + 1  # creates a new int object, rebinds local x
    print(f"INSIDE immu_pbv_int: {x} ")
@asoplata
asoplata / test_network_cx_limit.py
Created May 20, 2025 20:25
Test of HNN-Core network complexity limit (2025-05-20)
# ATTENTION: See which simulations fail and succeed at the bottom of the script.
import os.path as op
import matplotlib.pyplot as plt
from hnn_core import jones_2009_model, simulate_dipole
from hnn_core.viz import plot_dipole
import matplotlib.pyplot as plt
from copy import deepcopy
@asoplata
asoplata / gist:8bb94707810218df95dacaaaaf34bccb
Last active November 27, 2024 01:09
Linting vs Formatting vs Programming

Linting vs Formatting vs "Programming Style Guides"

I will attempt to explain how I differentiate these things in the vain hope that this may make it easier for us to discuss these things. I say "vain" because I will probably fail due to my own communication abilities. I think these things are hard to distinguish due to their historical development in programming culture.

First, if you'll indulge me, when it comes to processing code-as-text, I think of the following 3 things with these definitions:

  1. Linting: True "error-checking", as in using an external program to check that your code file will not run if you try to execute it.
  2. Formatting: How the text looks in a text file. This is independent of whether it runs or not.
  3. "Programming style guide": How the code is organized, on a meta-level.