Self referential value

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

-oliver

1 Like

I don’t think I understand what you want to do. Can you show us some
code?

The value of id(x) is usually an irrelevant thing, and is what is tested
by the “is” operator.

Cheers,
Cameron Simpson cs@cskk.id.au

1 Like
#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)
1 Like

Hi Oliver, and welcome.

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
1 Like

thd self referential equation is god if the output dependent on it is god

And not if not

You can affect whether an equation is god, but you can’t affect gods existenceemphasized text

The equation is only God if it’s existentially true that that equation exists (not being god if it’s dependabts are not)

Basically the output is “read” by all() to see if that output contradicts

Let me make this more simple

in
operator.eq(self, other)

what are some examples of an operator?

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.

I need something that references the values

Oliver:

“I need something that references the values”

The values of what?

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.

what is a Dereference operator in python

Oliver, please read this:

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)

What do you think? What did I do wrong?

Oliver,

Your description of the problem is vague to the point of being

meaningless:

"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"

Oliver, are you a native English speaker? Perhaps this is a translation

problem, but I can’t understand what you are trying to calculate. Is

this something to do with Russell’s Paradox?

You next have a description of “k”:

“k = overcoming against all else”

What does that mean?

You then have this function:

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

As soon as the function reaches a “return” statement, it will return.

Everything following the return is dead code that will not run, so I

have left it out.

So your code does this:

  • Create an empty set, containing nothing (w).

  • Checks whether that empty set w contains another set, which it

    clearly doesn’t since w is empty, so e is always False.

  • The logical expression "False and " is always

    False, so k is also always False.

  • The mathematical expression “k <= k” is True (k is equal to

    itself), so u is always True.

  • j is set to some arbitrary ID number.

  • You then check to see whether that arbitrary ID number happens,

    by some unbelievably unlikely chance, to equal u. The chances

    of this happening is about one in a billion billion billion

    billion, so the answer here is False.

  • And finally you return False.

The ID number part still bothers me. You seem to think this is

important, that u equals id(u). I can’t imagine why you think that is

the case. ID numbers are arbitrary and unpredictable numbers, and they

will almost always be different each time you run the program:

$ python3 -c "print(id(1234))"

139995877459696

$ python3 -c "print(id(1234))"

140384527361776

$ python3 -c "print(id(1234))"

140366992660208

Even if you happened to stumble across a value equal to its own ID

once, you would not get it to repeat.

I don’t understand why you care about the ID. I don’t know what country

you are in, so I am going to choose an Australia example. In Australia,

when you register a company, you get what is called an ACN (Australian

Company Number) which is a nine digit number like 934509173 or

similar. You are basically asking:

"If I create a company named as a number, like 45 Pty Ltd, will I get 45

back as the ACN?"

The answer is, no, you won’t. If you choose a nine digit number for

your company name, then at least there is a microscopically small chance

that you might get the same digits back as your ACN, but realistically,

the answer will always be no.

How do I make e in w

You said I was just checking whether e was is w

How do I assert e to be in w

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

The trick is to turn e into a frozenset first.

e = frozenset()
w.add(e)  # works now

Now if you try e in w you will get True.

1 Like