in java, the following code defines an array of the predefined class (myCls
):
myCls arr[] = new myCls
how can I do that in python? I want to have an array of type (myCls
)?
thanks in advance
Python is dynamically typed. You do not need to (and in fact CAN'T) create a list that only contains a single type:
arr = list()
arr = []
If you require it to only contain a single type then you'll have to create your own list-alike, reimplementing the list methods and __setitem__()
yourself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With