This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-11-18
Channels
- # aws (1)
- # babashka (35)
- # beginners (52)
- # biff (4)
- # calva (55)
- # cider (19)
- # clojure (54)
- # clojure-dev (3)
- # clojure-europe (23)
- # clojure-nl (1)
- # clojure-norway (3)
- # clojure-uk (2)
- # clojurescript (9)
- # code-reviews (3)
- # datahike (1)
- # fulcro (1)
- # funcool (4)
- # graalvm (21)
- # gratitude (2)
- # java (5)
- # jobs (2)
- # joyride (1)
- # kaocha (13)
- # malli (2)
- # off-topic (22)
- # other-languages (11)
- # pathom (4)
- # re-frame (35)
- # reagent (3)
- # reitit (3)
- # releases (2)
- # remote-jobs (1)
- # rum (1)
- # shadow-cljs (42)
- # sql (18)
- # tools-deps (72)
- # web-security (6)
- # xtdb (15)
Do we have anything in Python that is equivalent to Clojure’s dynamic binding?
Wouldn't that just be a global variable?
you could use that with
a context manager to set and unset a global variable for a similar effect
I don’t think global variables do the job. it’s not thread-safe right?
I thought python was still operated under the GIL
I don’t know much about GIL but I tried it and seems like it doesn’t
bigger
oh yea. you're right. I guess you'd have to use a thread local, https://docs.python.org/3/library/threading.html#thread-local-data
An interesting things is that binding
is also not thread-safe on ClojureScript 😢
An example code. If it was thread safe, it would print:
:before :first :first
:before :second :second
:after :first :first
:after :second :second
And keep the value of the var as :none