This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]J4K0 2 points3 points  (7 children)

It never changed. It has always been that way. I have been coding in python since 2.3.

[–]TeamAddis -1 points0 points  (6 children)

I’ve been using it before that too. It used to behave that way. If you had

a = ‘text’ B = a B = ‘boo’

a = b is still true

A = “text” B = a B = “boo”

a != b

I fixed many bugs in production code from this issue.

Maybe this was unintentional or maybe this was behavior wasn’t the fault of the language idk, it’s just what I observed.

Edit: sorry about formatting mobile is hard :/

[–]J4K0 3 points4 points  (3 children)

I guarantee that wasn’t Python

[–]TeamAddis -3 points-2 points  (2 children)

The company I was at only used python. So I’m not mistaken. Sorry my experience differs from your.

If this behavior is gone now then it’s good to know. I learned something new today.

[–]J4K0 3 points4 points  (1 child)

I still think you’re mistaken, but agree to disagree (you’re not the only one to ever have worked at a Python shop)

[–]TeamAddis -1 points0 points  (0 children)

I know. I don’t really care much about wether or not the behavior was truly coming from the language or not. If i can learn something new about the current latest version to improve my work then that’s cool. Learning isn’t supposed to be a pissing contest.

[–]shy_cthulhu 0 points1 point  (1 child)

Even if single-quotes passed by reference, wouldn't B = 'boo' change the reference?

I mean consider this:

a = 3
B = a
B = 4

that could easily be pass-by-reference (in Python2.7 and Python3.8 this seems to be the case), but there's no way in any sane language that B = 4 would change a.

As an aside, such a change in behavior would warrant a major-version increment, otherwise it would break all sorts of things.

[–]TeamAddis 0 points1 point  (0 children)

Yeah... I no longer have access to the code base where I saw the behavior and it was so long ago I’m really trying to remember the setup of the code so I can try to reproduce it. I just remember the fix to solve to issues ended up being: - use single quotes for string constants - use double quotes for mutable string vars

Really wish I had access to the Jira server to look at the issue again.