March 5, 20251 yr Supporter Hi, can somebody please help me out with this? i want to use var "RwShapeIndex" from "i loop" in "j loop" how i can do that if anyone know. Thanks in advance! bs.seek(RwShapeIndexTableOffset, NOESEEK_ABS) for i in range(0, RwVertexInfoCount): RwUnknown_0 = bs.readUShort() RwUnknown_1 = bs.readUShort() RwShapeIndex = bs.readUShort() bs.seek(RwVertexInfoOffset, NOESEEK_ABS) for j in range(0, RwVertexInfoCount): Underline = "_" RwShapeInc = j RwShapeIdxNum = "{:04d}".format(RwShapeIndex) RwShapeIndexTmp = str(RwShapeIdxNum) print(RwShapeIndexTmp)
March 5, 20251 yr Author Supporter If you mean something like that > RwShapeIdxNum = "{:04d}".format(RwShapeIndex[i]) it doesn't work. I also created initial var RwShapeIndex = [] Saying > RwShapeIdxNum = "{:04d}".format(RwShapeIndex[i]) TypeError: 'int' object is not subscriptable Edited March 5, 20251 yr by h3x3r
March 5, 20251 yr Supporter yeah, that's the reason I usually don't use python. There's solutions which say: Quote To fix this error, you need to convert the integer to an iterable data type, for example, a string. but that sounds funny to me.
March 5, 20251 yr Author Supporter Already tried. No luck... Yeah i like python too... 🙃Anyway thank you for your time.
March 5, 20251 yr Supporter Solution Did you tried Store RwShapeIndex Values in a List? Somenthing like that? bs.seek(RwShapeIndexTableOffset, NOESEEK_ABS) rw_shape_indices = [] # Create a list to store RwShapeIndex values for i in range(0, RwVertexInfoCount): RwUnknown_0 = bs.readUShort() RwUnknown_1 = bs.readUShort() rw_shape_indices.append(bs.readUShort()) # Append to the list bs.seek(RwVertexInfoOffset, NOESEEK_ABS) for j in range(0, RwVertexInfoCount): Underline = "_" RwShapeInc = j RwShapeIndex = rw_shape_indices[j] #get the value from the list using the j index. RwShapeIdxNum = "{:04d}".format(RwShapeIndex) RwShapeIndexTmp = str(RwShapeIdxNum) print(RwShapeIndexTmp)
March 5, 20251 yr Supporter That's funny. Isn't rw_shape_indices a list of ints (shorts) while python claims an array of ints not to be subscriptable? The magic is append - apparently python prefers lists over arrays because these have a fixed size.
March 5, 20251 yr Supporter 59 minutes ago, shak-otay said: That's funny. Isn't rw_shape_indices a list of ints (shorts) while python claims an array of ints not to be subscriptable? The magic is append - apparently python prefers lists over arrays because these have a fixed size. Lists are the default go-to dynamic sequence type in Python because of their flexibility. The append method works naturally on lists, while array.append() requires that the appended value be of the correct type. Many Python libraries and frameworks default to lists for simplicity.
Create an account or sign in to comment