Feb-01-2019, 04:16 PM
Hi everyone,
I stuck at a point in my code.
I have two files in a folder named gaming.py and char.py
These are some codes in gaming.py
Traceback (most recent call last):
File "c:\Users\...\Desktop\hello\gaming.py", line 2, in <module>
import char
File "c:\Users\...\Desktop\hello\char.py", line 1, in <module>
import gaming
File "c:\Users\...\Desktop\hello\gaming.py", line 129, in <module>
charclass=char.Char()
AttributeError: module 'char' has no attribute 'Char'
I couldn't solve this. Can you help?
I stuck at a point in my code.
I have two files in a folder named gaming.py and char.py
These are some codes in gaming.py
import pygame,sys,random,time import char charclass=char.Char() playerpos = charclass.get_position() monsterpos = charclass.get_position()And these are the codes of char.py
import gaming class Char(object): def __init__(self): pass def get_position(self): while True: column = random.randint(2, mapheight - 3) row = random.randint(2, mapwidth - 3) if floormap[column][row] == "dirt": return [row, column]I want to work with classes and split the project to the seperate python files like char,monsters etc. However when I try to import gaming.py to char.py and call get_position method it says;
Traceback (most recent call last):
File "c:\Users\...\Desktop\hello\gaming.py", line 2, in <module>
import char
File "c:\Users\...\Desktop\hello\char.py", line 1, in <module>
import gaming
File "c:\Users\...\Desktop\hello\gaming.py", line 129, in <module>
charclass=char.Char()
AttributeError: module 'char' has no attribute 'Char'
I couldn't solve this. Can you help?