I am new to python but experienced in several other languages. I do not understand yet why numpy.full does not fill an array of strings with the string value I supply in the code.
Example code and output follows. OS is Win10-64 Pro, Python version is 3.8.3.
Thank you in advance for any help you can offer.
Peter
Example code and output follows. OS is Win10-64 Pro, Python version is 3.8.3.
#!/usr/bin/env python
import numpy as np
class arstr:
def __init__(self, asize, aval):
self.strs = np.full([asize, asize, asize], aval, dtype=str)
Mystrs = arstr(3, " ? ")
for s in Mystrs.strs:
print (s)
exit()Output in a cmd.exe window follows.Output:C:\Testdir>python atest.py
[[' ' ' ' ' ']
[' ' ' ' ' ']
[' ' ' ' ' ']]
[[' ' ' ' ' ']
[' ' ' ' ' ']
[' ' ' ' ' ']]
[[' ' ' ' ' ']
[' ' ' ' ' ']
[' ' ' ' ' ']]Why are each of the array elements a single blank character and not the three-character string " ? " that I specified in the invocation of the class?Thank you in advance for any help you can offer.
Peter
