# Need for dereferencing or a virus?

I think my python app has a virus on it… correct me if im wrong but python does do value logic, not just variable logic

What makes you think your Python app has a virus? Can you give an
example?

What do you mean by “variable logic”?

Python could be considered to have two value logic in one sense (all
value in Python are either true or false).

What I mean is when I equalize two different values it checks whether the variables are equal (the variables reference the same thing)…

I expect it to check whether the values are equal (the values referencing the same thing)

Get the diff?

Basically my app is focusing on the address of what I put in, thereby equalizing too early in the script

I.e. I don’t need my variables equal, but I need my values equal

I.e. I don’t need my values equal, but I need what they reference to be equal

Variables in Python are simply names by which you refer to some object. They don’t “contain” anything, exactly. (Ok, they contain the address, but it may be best not to think so concretely. Everything you do to the name, apart from delete or re-assign it, happens to the object.)

I think you are talking about testing the equality of two things with `a == b`.

If they are the same (that is, `a` and `b` reference the same object), they will test equal (`True`).

``````>>> a = object()
>>> b = object()
>>> a == b
False
>>> b = a
>>> a == b
True
``````

If they are not the same object, and one of the objects knows how to compare itself with the other, then the result will be based on the values.

``````>>> a = 42
>>> b = 2**6 - 2*11
>>> a == b
True
>>> b = 42.0
>>> a == b
True
``````

If neither knows how to do the comparison, the answer is `False`.

``````>>> b = "42"
>>> a == b
False
``````

The common built-in types (`int`, `float`, `str`) know how to compare themselves with one another by value, in combinations thought sensible by the language designers. So do lists, tuples and many other types. (The “sensible combinations” may differ from what is supported in other languages you know.)

If that didn’t answer it, post some code. In what way does it not do what you expect?

1 Like

Well I would post code but hackforums firewalls it and apple said to go to a security specialist instead of talking on forums

That would be the `is` operator.

``````>>> int("5000") == 5000
True
>>> int("5000") is 5000
False
``````

The left and right expressions create different objects, that are equal in value. Do this with small numbers and you discover an interesting optimisation, but that would have confused things.

It’s going to be difficult to ask Python questions if your firewall won’t let you post any Python.

1 Like

I see the value and the variable don’t reference the same thing, but it was good to distinguish them!

I see that the is operator uses different variables to reference the same object, I’m assuming it can use different objects for the same reference…

Just copy and paste the text of the code, and surround it with three
back ticks on a line of its own, like this:

`````````
x = 1
y = 2
print(x + y)
`````````

Oliver, you have that test backwards, `is` does not test for two
objects being equal. Please forget about `is`. It doesn’t do what you
want and it is just confusing you.

I can tell you that as a beginner, there is only one time you should
ever use `is`, and that is to test for None. 99% of the time you
should use `==` and test for equality, not for identity.

``````if obj is None  # this is okay

if x is y  # don't do this

if x == y  # do this
``````

If you keep using `is` you will just run into mysterious behaviour which
you probably won’t understand, like this:

``````>>> "hello world" is "hello world"
True
>>> a = "hello world"
>>> a is "hello world"
False
``````

Just don’t use `is` except to test for None, use `==` instead, and you
will find things much, much easier to understand.

All my values are using the address-of themselves.

I can’t use that.

Please use dereferenced variables for values.