Q. Do you want to do something like generics that takes value from []?

Q. Do you want to do something like generics that takes value from []?

A. Yes. (Use __class_getitem__)

class Hello:
  def __class_getitem__(self, v):
    return v


print(Hello["sh1ma"])

Recommended Posts

Q. Do you want to do something like generics that takes value from []?
Do you want me to fix that copy?
I want to do something like sort uniq in Python
Do you make something like a rocket?
Do something regularly from heroku to Shotgun
Let's summarize what you want to do.
What to do when you want to receive files from a Windows client remotely
Links to do what you want with Sublime Text
I want to do something in Python when I finish
[AWS] What to do when you want to pip with Lambda
[AWS EC2] Settings you want to do on Amazon Linux 2
Expand a Python nested dictionary to do something like Pandas' MultiIndex
Don't you want to say that you made a face recognition program?
I wanted to do something like an Elixir pipe in Python
[Machine learning] I tried to do something like passing an image
I want to improve efficiency with Python even in an experimental system (3) I want to do something like Excel with Pandas