I have in my program “x” and “id(x)”
I was wondering how to make them equal with each other.
I’ve tried many things: is, and, eq, union(), intersection(), ==
And it checks whether it can do it and says no, they have no shared reference…
Is there a way to force an equality on seemingly unrelated values?
Thanks in advance
#Amend
def p ():
w = set()
e = set() in w
k = e and not w and not all(not k)
u = k <= (k)
j = id(u)
h = j and u
#force equality of j, u ^^^
return h
global X
X = 0
while X <= 2:
X = X + 1
any(h) in X(p(h) is 0) or all(h) in X(p(h) is 1)
q=""
while True:
i=32
while i < 126:
i= i + 1
o = chr(i)
p ()
v = p()
if v == 1:
q = q + o
elif v == 0:
q = q
if q == q + "":
break
print (q)
You’ve shown us a bunch of code, but you haven’t explained what you want
it to do, what it does instead of what you want, and how any of that
code is related to your question.
I don’t really understand your question, or why you want an integer
equal to its own id(). Seems like a pretty pointless exercise.
You might have better luck doing this in Jython or IronPython, where the
IDs are a lot smaller and more predictable.
# using Jython
>>> x = 65
>>> id(x)
2
>>> x = 3
>>> id(x)
3
Sorry Oliver, your question just confuses me even more. I don’t
understand what this has to do with self-referential values or your
early comments.
Operators in Python include the standard arithmetic operators:
plus +
minus -
multiply *
divide /
and comparison operators:
equals ==
less than <
greater than >
etc. There are about 20 or so operators in Python.
The operator module contains a number of functions which act as
aliases for the operators. For example, operator.eq is a function
which does the same thing as the == operator. You can think of it as
being approximately the same as:
def eq(a, b):
return a == b
You shouldn’t use the functions with leading and trailing underscores,
like operator.__eq__. They are just there for compatibility with old
versions of Python. In new code, you should always use the versions with
the regular names.
So your code snippet:
operator.__eq__(self, other)
is better written as:
operator.eq(self, other)
but even better as:
self == other
You asked for “some examples of an operator” specifically in that code
snippet, but there aren’t any. It’s just a function call.
The usual thing we use to reference something is a named variable:
something = calculate_some_values()
something # this references the values
For example:
x = 1+2 # calculate a value, and give it a name
print(x) and then reference that name to get the value
Is this what you want? If not, I still have no idea what you are trying
to do, or why. Please explain what you are trying to do, in detail
rather than vague generalities.
I’m not a mind-reader. Until you take the time to ask a comprehensible
question, with enough detail and background that the question makes
sense, I’m not going to respond to your posts any further.
This is my program so far… it doesn’t do anything but it basically means (w) set (e) within set (k) nothing besides what comes from within a set (u) of that that itself (j) that specific equation (h) that equation is that of that itself
w = undefined set
e = within undefined set
k = overcoming against all else
u = k from within everything
j = the equation for u
h = the equation for u is also u
#Amend
def p ():
w = set()
e = set() in w
k = e and not w and not all(not k)
u = k <= (k)
j = id(u)
h = j is u
return h
global X
X = 0
while X <= 2:
X = X + 1
any(h) in X(p(h) is 0) or all(h) in X(p(h) is 1)
q=""
while True:
i=32
while i < 126:
i= i + 1
o = chr(i)
p ()
v = p()
if v == 1:
q = q + o
elif v == 0:
q = q
if q == q + "":
break
print (q)
You can’t assert e is in w because w is an empty set. There is nothing in w.
The only way you can “assert e is in w” is to lie about it:
w = set()
e = set()
flag = e in w # flag is actually False
flag = True # e is in w (not really, I'm lying)
Instead of just saying that e is in w, maybe what you mean is that you
actually want e to actually be in w. For that to work you need to
add it to the set, like this:
w.add(e)
But if you try that, you will see it doesn’t work. Python sets can
contain things like ints, and floats, and strings, but not other sets:
w.add(42) # Okay
w.add(1.25) # also okay
w.add("Hello World") # still okay
w.add(set()) # not okay, this fails