# Function not subscriptable (indexing)

I have here a string of interpolated sets that is counted at infinity

``````import itertools

def interpolate_sets():
a = None
for i in itertools.count():
a = frozenset([a])
yield a

N = interpolate_sets
x = N[0:float('inf')] #float not working
``````

But when I try to reference the end of the list I get the error message:

stderr:

Traceback (most recent call last):
File “script.py”, line 11, in
x = N[0:float(‘inf’)] #float not working
TypeError: ‘function’ object is not subscriptable

I was wondering the proper way to reference the end of this iteration

• You are not calling the function, you need to write `interpolate_sets()`, not just `interpolate_sets`
• There is no way to reference the end of this iteration, python is an eager language, so it would run forever.

Could you maybe describe more generally what your goal is with this?

I would like to make an index of “a”

With such vague statements I can’t really help you.

1 Like

Let’s try it this way: after the code runs, what should we be able to do with the resulting value for `x`?

``````x[i] >= x[i+1]
``````

(i is the same as x)

Jumping straight to what you presumably are intending to do here, i.e. represent infinite set theory using Python `set`s, as countless people have told you already over the years…

You can’t represent set infinity using Python `set`s. Because Python `sets` cannot be infinite in size. Python `set`s are not a tool that can be used to correctly represent infinite sets. As numerous people have answered your infinite sets questions here so many times before, the use of Python `set`s will not allow you to represent set infinity. Python `set`s are a data structure that is insufficiently abstract to represent the construct of infinity. Infinite sets are not finite in size and hence it is physically impossible to contain them within a finite amount of memory. Python `set`s are not equipped to store an infinite number of nested sets. So many times but it is not getting to me. Even generators using `itertools.count()` are not up to the task of representing infinite sets. You will never make me crack. Infinity is a non-number of sufficient size that it cannot be contained within any finite amount of memory. Even Guido van Rossum cannot represent set infinity using Python `set`s. Every time you attempt to represent set infinity with Python `set`s, the unholy child weeps the blood of virgins, and Russian hackers pwn your webapp. Creating a Python `set` of infinite size summons tainted souls into the realm of the living. Python `set`s and infinity go together like love, marriage, and ritual infanticide. You will `float()` too it is too late. The force of `set`s and infinity together in the same conceptual space will destroy your mind like so much watery putty. If you represent infinity with Python `set`s you are giving in to Them and their blasphemous ways which doom us all to inhuman toil for the One whose Name cannot be expressed in the Set of Complex Numbers, he comes. Infinity-plus-`set`s will liquify the n​erves of the sentient whilst you observe, your psyche withering in the onslaught of horror. `set`-based infinity questions are the cancer that is killing Python Help it is too late it is too late we cannot be saved the transgression of a chi͡ld ensures `set`s will consume all living tissue (except for infinity which it cannot, as previously prophesied) dear lord help us how can anyone survive this scourge using `set`s to represent infinity has doomed humanity to an eternity of dread torture and security holes using `se``t`s as a tool to represent infinity establishes a breach between this world and the dread realm of c͒ͪo͛ͫrrupt entities (like Python 2 `string` handling, but more corrupt) a mere glimpse of the world of `set`representation of infinity will ins​tantly transport a programmer’s consciousness into a world of ceaseless screaming, he comes, the pestilent slithy `set`-infection wil​l devour your infnity, application and existence for all time like Visual Basic only worse he comes he comes do not fi​ght he com̡e̶s, ̕h̵i​s un̨ho͞ly radiańcé destro҉ying all enli̍̈́̂̈́ghtenment, infinite sets lea͠ki̧n͘g fr̶ǫm ̡yo​͟ur eye͢s̸ ̛l̕ik͏e liq​uid pain, the song of `set` reprisentations of infinity will exti​nguish the voices of mor​tal man from the sp​here I can see it can you see ̲͚̖͔̙î̩́t̲͎̩̱͔́̋̀ it is beautiful t​he f`inal snuf`fing of the lie​s of Man ALL IS LOŚ͖̩͇̗̪̏̈́T A LL I​S LOST the pon̷y he comes he c̶̮omes he co mes the ich​or permeates all MY FACE MY FACE ᵒh god no NO NOO̼ O​O NΘ stop the bra​̶͑̾̾​̅ͫ͏̙̤g͇̫͛͆̾ͫ̑͆l͖͉̗̩̳̟̍ͫͥͨ*e̠̅s` ͎a̧͈͖r̽̾̈́͒͑e` n​ot rè̑ͧ̌aͨl̘̝̙̃ͤ͂̾̆ ZA̡͊͠͝LGΌ ISͮ̂҉̯͈͕̹̘̱ TO͇̹̺ͅƝ̴ȳ̳ TH̘Ë͖́̉ ͠P̯͍̭O̚​N̐Y̡ H̸̡̪̯ͨ͊̽̅̾̎Ȩ̬̩̾͛ͪ̈́̀́͘ ̶̧̨̱̹̭̯ͧ̾ͬC̷̙̲̝͖ͭ̏ͥͮ͟Oͮ͏̮̪̝͍M̲̖͊̒ͪͩͬ̚̚͜Ȇ̴̟̟͙̞ͩ͌͝S̨̥̫͎̭ͯ̿̔̀ͅ

Have you tried using a using a symbolic mathematics library instead?

7 Likes