• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Problem with creating Array of Object

 
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am trying to create array of Object, But I am getting error messages. Following is my code:




==Syntax Error
I am getting following error message:

Traceback (most recent call last):
 File "/home/zulfi/PycharmProjects/AIHW/GameProjTest.py", line 28, in <module>
   objBoard = Board(8)
 File "/home/zulfi/PycharmProjects/AIHW/GameProjTest.py", line 18, in __init__
   CPieces.pieces.append = CPieces(self, i)#no error if commented
TypeError: __init__() takes 2 positional arguments but 3 were given



Somebody please guide me.

Zulfi.
 
Zulfi Khan
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I removed the self from:

but I am still getting error:

File "/home/zulfi/PycharmProjects/AIHW/GameProjTest.py", line 28, in <module>
   objB = B(8)
 File "/home/zulfi/PycharmProjects/AIHW/GameProjTest.py", line 18, in __init__
   CPieces.pieces.append = CPieces(i)#no error if commented
AttributeError: 'list' object attribute 'append' is read-only



Somebody please guide me.

Zulfi.
 
Zulfi Khan
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I think I have solved that problem:


 
Marshal
Posts: 25956
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks like you got your problem solved, then? I will mark the thread as "resolved" but if it turns out you want more discussion, then sure, carry on posting here.
 
Zulfi Khan
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Is there any way I can use a loop for creating array of objects? I have to create more than 10 array of objects.

Please guide me.

Zulfi.
 
This tiny ad is suggesting that maybe she should go play in traffic.
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic