It’s a very beautiful moon. Too bad one needs a telescope to see it.
- 0 Posts
- 12 Comments
As I said, it’s because you can’t change the value of a primitive value. (That is, unless you abuse the C interface.)
Because Python doesn’t protect classes, you just can’t do the same with the types you create. But that’s what is special, not the way if handles variables.
And this is different from languages like Java/C#, PHP/Perl, etc. Most imperative languages have primitive atomic values that go directly into your variables. But Python has only references (except for some complicated optimizations). Anyway, it is weird, and it’s one of the reasons people should learn C or Rust eventually.
It doesn’t seem to copy the value, just make another reference:
>>> a = 65535 >>> b = a >>> b is a TrueOne thing I know that Python does is optimize the value away for the few smallest values of the primitives. But that’s on optimizations.
Now I’m curious what differences you are talking about, because I’m no Python expert, but I can’t think of any. If you mean identity representation, no, it’s not different:
>>> a = 65535 >>> b = 65535 >>> a is b False
Every variable in Python is actually a reference (maybe optimized out, but still logically a reference). There’s no difference.
Numbers, booleans, and None won’t give you that kind of problem only because you can’t change them.
Hum… No it won’t.
It’s something you only really learn from C or Rust, but your operations will set both to the same list. If you go and change the list, you will change both, but if you set one to a different list, you won’t change the other list.
In other words, if you do
list1.push(4), you will changelist2. Butlist1 = [3, 2, 1]won’t.
marcos@lemmy.worldto
Fediverse@lemmy.world•You Can Post Your Way Out of Fascism if You Own the Means of PostingEnglish
5·9 months agoMany people on lemmy has some ideology that either consider others insufferable, or is considered insufferable by most people.
That doesn’t mean that you can’t organize something on social media, you just need one with freedom of expression (so, no overseeing algorithm), and a clique of people capable of organizing themselves. It may even be possible to get that here.
It’s been a couple o days already that Trump announced he will go against Russia if Ukraine pays his price…
(His price seems to be all about posturing, but he made a point of announcing it.)
marcos@lemmy.worldto
Python@programming.dev•Yes, you should use a Python venv in a container like docker
1·10 months agoI’m sorry but… what?!?
marcos@lemmy.worldtoCartography Anarchy@lemm.ee•Nobody had thought to check what was over there until recentlyEnglish
131·10 months agoI think that map centered on the area you selected.
marcos@lemmy.worldto
Python@programming.dev•Yes, you should use a Python venv in a container like docker
81·10 months agoThat’s the thing, if everybody is forced to use a venv, those projects will either fix their shit or lose all of their userbase.

Well, it is. It’s not sabotaging the company, but it’s absolutely sabotaging the initiative. (You can absolutely sabotage saboteurs.)
That said, it’s not sabotage because no action of those is actually sabotage. It’s just people telling their managers AI is bad on the job, or failing to make it good.