Python doesn't recognize the existance of a class parameter

I'm working on a text based RPG game in python, and I have a class that tracks time of day, passage of seasons over time, ect... among other things, it cycles through different moon cycles (28 moon, full, new, etc... like in the real world). The class Date_Time()'s init function includes the statement self.moon_state = 0, but the function I wrote to test some of the methods related to the moon returns the error: "AttributeError: 'Date_Time' object has no attribute 'moon_state'" here's the init function:

def __inti__(self, environment, season=Spring()):

    #### Objects ####
    self.season = season
    self.environment = environment =
    self.player = environment.player

    #### time ####
    self.time_of_day = 0
    self.day_of_season = 0
    self.year = 0

    self.moon_state = 0

and the test code:

for k in range(50):
    print("\n ---- test moon", k + 1, "------------")
    print("Moon state", date_time.moon_state)
    print("Moonlight:", date_time.get_moonlight)
    print(" ---- end test ------------\n")

and the function being tested:

def cycle_moon(self, days_passed): """advances the moon the given amount of states, wrapping it to 0 when it reaches 28 (moon_states go from 0-27)"""

    self.moon_state = self.moon_state + days_passed

    while self.moon_state >= 28:
        self.moon_state = self.moon_state - 28

I'd appreciate any suggestions. The bug makes about as little sense to me as a bug can, the variable exists, but but the interpreter just seems to ignore it.


Very simply, you have a syntax/spelling error. It should be __init__ not __inti__

The interpreter has no problem with have a __inti__ method however, nothing is initialized when you create an instance of the class since the interpreter cannot find the __init__ method

Need Your Help

Replace 0s with next non-zero value in column R

r replace fill

Someone else gave me a data set that looks kind of like this.

Uploadify browser compatibility issue

jquery file-upload upload uploadify

I am using uploadify plugin for allowing users to upload files to my website. The script works fine in chrome but does not work in ie and firefox