Skip to main content

Does Minecraft Education Edition Python allow creation of Classes?

Comments

8 comments

  • Deepak Pandit

    PS: In the code above the indents are present but not displayed.

    0
  • Debbie Alexander
    Moderator Beacon of Knowledge Super Star

    Welcome fellow coder! =]

    I tried this and it worked:

    class MyStuff:
        #"""A simple example class"""
        i = 12345

    testCase = MyStuff()
    say(testCase.i)
     
    0
  • Deepak Pandit

    Thanks Debbie,

    However I am still having no luck... I am getting the following error messages for the first program:

    Line 6: can't find called function "MyStuff"
    Line 7: unknown object type; cannot lookup attribute 'i'

    0
  • Debbie Alexander
    Moderator Beacon of Knowledge Super Star

    You are running this in Python Azure Notebooks, not the MakeCode Python window, right?

    class MyStuff:
        i = 12345
    testCase = MyStuff()
    say(testCase.i)
     

     

    0
  • Deepak Pandit

    Hi Debbie,

    Sorry for the late response. I am using the MakeCode window in Minecraft. I do not know how to use the Python Azure Notebooks with Minecraft Education Edition. Can you please guide?

    0
  • Debbie Alexander
    Moderator Beacon of Knowledge Super Star

    All I can get to work in MakeCode is this - no function, no instantiation, no new objects in the class - I managed to keep it from throwing syntax errors but not actually working for those. Just creating variables for a class is pretty limited capability, but here you are: (P.S. Python Azure Notebooks is great!)

    class MyStuff:
        #"""A simple example class"""
        i = "Hello Classes"
    testCase1 = MyStuff.i
    player.say(testCase1)
    1
  • Deepak Pandit

    Thanks Debbie... The code works in Notebooks.

    0
  • Moderator Beacon of Knowledge Super Star

    Hooray! I'm so glad!

    0

Please sign in to leave a comment.