33
you are viewing a single comment's thread
view the rest of the comments
[-] vox@sopuli.xyz 4 points 1 year ago* (last edited 1 year ago)

not unique to python.

function pointers and hashmaps exist in basically all languages

like in lua:

local table = {
  add = function(a, b) return a + b end
}
table["add"](4, 5)

JavaScript:

{
  add: (a, b) => a + b
}

Rust (using hashmaps with string keys is extremely inefficient tho, there are much better options here but whatever)

let map = HashMap::from([
   ("add", |a, b| a + b),
]);

//...

map["add"](1, 3);

this post was submitted on 29 Aug 2023
33 points (100.0% liked)

Python

6187 readers
1 users here now

Welcome to the Python community on the programming.dev Lemmy instance!

📅 Events

October 2023

November 2023

PastJuly 2023

August 2023

September 2023

🐍 Python project:
💓 Python Community:
✨ Python Ecosystem:
🌌 Fediverse
Communities
Projects
Feeds

founded 1 year ago
MODERATORS