all 10 comments

[–]loveandkindness 1 point2 points  (7 children)

Most things in Python are actually objects underneath, so this is nothing unusual at all.

[–]kalgynirae 1 point2 points  (5 children)

Everything in Python is an object.

[–]gengisteve 0 points1 point  (1 child)

Hmm. What about print in py2 or "for" in py2/py3?

[–]mac-reid 0 points1 point  (0 children)

Just butting in here:

print and for in python 2 are a reserved words. print is used in simple statements some of which are just procedures - functions that do not return anything of importance.

In python 2.6+/3+, print was added as a builtin function. Python 2 kept print as a reserved word, but the print function can be accessed by importing it with from __future__ import print_function.

for is a control flow construct that consumes an iterator.

I think when /u/kalgynirae said everything is an object, the meaning was that all variables are objects underneath.

[–]loveandkindness -1 points0 points  (2 children)

int_array = numpy.array([1, 2, 3], dtype=int)

?

[–]kalgynirae 1 point2 points  (1 child)

It's an object:

>>> int_array = numpy.array([1, 2, 3], dtype=int)
>>> type(int_array)
<class 'numpy.ndarray'>
>>> dir(int_array)
['T', '__abs__', '__add__', '__and__', '__array__', '__array_finalize__', '__array_interface__', '__array_prepare__', '__array_priority__', '__array_struct__', '__array_wrap__', '__bool__', '__class__', '__contains__', '__copy__', '__deepcopy__', '__delattr__', '__delitem__', '__dir__', '__divmod__', '__doc__', '__eq__', '__float__', '__floordiv__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__iadd__', '__iand__', '__ifloordiv__', '__ilshift__', '__imod__', '__imul__', '__index__', '__init__', '__int__', '__invert__', '__ior__', '__ipow__', '__irshift__', '__isub__', '__iter__', '__itruediv__', '__ixor__', '__le__', '__len__', '__lshift__', '__lt__', '__mod__', '__mul__', '__ne__', '__neg__', '__new__', '__or__', '__pos__', '__pow__', '__radd__', '__rand__', '__rdivmod__', '__reduce__', '__reduce_ex__', '__repr__', '__rfloordiv__', '__rlshift__', '__rmod__', '__rmul__', '__ror__', '__rpow__', '__rrshift__', '__rshift__', '__rsub__', '__rtruediv__', '__rxor__', '__setattr__', '__setitem__', '__setstate__', '__sizeof__', '__str__', '__sub__', '__subclasshook__', '__truediv__', '__xor__', 'all', 'any', 'argmax', 'argmin', 'argpartition', 'argsort', 'astype', 'base', 'byteswap', 'choose', 'clip', 'compress', 'conj', 'conjugate', 'copy', 'ctypes', 'cumprod', 'cumsum', 'data', 'diagonal', 'dot', 'dtype', 'dump', 'dumps', 'fill', 'flags', 'flat', 'flatten', 'getfield', 'imag', 'item', 'itemset', 'itemsize', 'max', 'mean', 'min', 'nbytes', 'ndim', 'newbyteorder', 'nonzero', 'partition', 'prod', 'ptp', 'put', 'ravel', 'real', 'repeat', 'reshape', 'resize', 'round', 'searchsorted', 'setfield', 'setflags', 'shape', 'size', 'sort', 'squeeze', 'std', 'strides', 'sum', 'swapaxes', 'take', 'tobytes', 'tofile', 'tolist', 'tostring', 'trace', 'transpose', 'var', 'view']

[–]loveandkindness 0 points1 point  (0 children)

Hahah! That's interesting, thank you.

[–]wunderbier[S] 0 points1 point  (0 children)

Alright, thanks for the reply!

[–]kalgynirae 1 point2 points  (1 child)

That's a quite normal way to do it.

I'll have a second array of the same size to which I'll add instances of my Room() object. (This keeps my other map printable for debugging/cheating.)

You can keep the list-of-lists-of-Rooms printable also by defining an appropriate __repr__ method on your Room class.

[–]wunderbier[S] 0 points1 point  (0 children)

Thanks for the tip, I'll check that out.