I made a Python-with-Evennia tutorial (looking for feedback)


  • Coder

    https://github.com/evennia/evennia/wiki/Python-basic-introduction

    Since many people coming to Evennia are not previously familiar with Python (or any programming in some cases) I put together a tutorial for the absolute Python beginner that just got Evennia up and running. It explores some basic Python concepts using Evennia as well as helps the budding developer start finding their way with concepts like imports, object inheritance and overriding. After previous feedback it was split in two parts since it's pretty chunky to do in one sitting.

    Obviously a short tutorial can't do more than graze the surface of Python and general programming concepts. This won't teach you Python. But it covers some of the most common questions and initial hurdles newcomers tend to ask about in a format that is, while technical, hopefully not too hard to follow when getting started.

    If you follow it and have feedback on further improvements, let me know!
    .
    Griatch


  • Tutorialist

    @griatch THANK YOU



  • @griatch This is good stuff. I've been playing with Evennia and reading over all the documentation and you guys have done a great job.


  • Pitcrew

    Reading that makes me foolishly optimistic about learning Python and being able to self-sufficiently run a game. So well done there!


  • Coder

    The purist in me balks at describing print as a function; its a statement in Python 2 without a future import. That you can call a statement with parens around its arguments is just an accident of the fact you can put parens about nearly anything in Python. Its a function of parens are grouping syntax, and they don't make tuples-- commas do.

    Otherwise, looks good :)


  • Coder

    Thanks for the nice comments, glad to hear it could be useful to people!

    @cobaltasaurus said in I made a Python-with-Evennia tutorial (looking for feedback):

    @griatch THANK YOU

    You are welcome!

    @thatonedude said in I made a Python-with-Evennia tutorial (looking for feedback):

    @griatch This is good stuff. I've been playing with Evennia and reading over all the documentation and you guys have done a great job.

    Glad you think so. :)

    @bad-at-lurking said in I made a Python-with-Evennia tutorial (looking for feedback):

    Reading that makes me foolishly optimistic about learning Python and being able to self-sufficiently run a game. So well done there!

    Python is often considered one of the simpler mainstream languages to learn and we have plenty or people learning Python/programming through Evennia actually. So it's certainly doable!

    @ixokai said in I made a Python-with-Evennia tutorial (looking for feedback):

    The purist in me balks at describing print as a function; its a statement in Python 2 without a future import. That you can call a statement with parens around its arguments is just an accident of the fact you can put parens about nearly anything in Python. Its a function of parens are grouping syntax, and they don't make tuples-- commas do.

    Thanks for the feedback! This exception to print is mentioned in the immediately following paragraph but yes, calling it a 'function' is indeed technically incorrect. I didn't think this was something a complete newbie would gain much from learning out the door. I felt it better to learn calling print as a (sort-of) function from the get-go so that the concept of a function was introduced early and can be referenced later in the tutorial when a real function is created.
    .
    Griatch


  • Coder

    @ixokai said in I made a Python-with-Evennia tutorial (looking for feedback):

    The purist in me balks at describing print as a function; its a statement in Python 2 without a future import. That you can call a statement with parens around its arguments is just an accident of the fact you can put parens about nearly anything in Python. Its a function of parens are grouping syntax, and they don't make tuples-- commas do.

    Thanks for the feedback! This exception to print is mentioned in the immediately following paragraph but yes, calling it a 'function' is indeed technically incorrect. I didn't think this was something a complete newbie would gain much from learning out the door. I felt it better to learn calling print as a (sort-of) function from the get-go so that the concept of a function was introduced early and can be referenced later in the tutorial when a real function is created.

    Honestly, I wonder if the first thing you'd teach is me.msg -- and only teach print in an advanced mode about debugging. Because what is the classical 'first thing' anyone learns in a programming language? How to print out a statement and see the result. In Evennia, that's not print, that's me.msg.

    me.msg("Hello world!") is really Evennia's version of the first programming exercise for every language ever.


  • Coder

    @ixokai said in I made a Python-with-Evennia tutorial (looking for feedback):

    @ixokai said in I made a Python-with-Evennia tutorial (looking for feedback):

    The purist in me balks at describing print as a function; its a statement in Python 2 without a future import. That you can call a statement with parens around its arguments is just an accident of the fact you can put parens about nearly anything in Python. Its a function of parens are grouping syntax, and they don't make tuples-- commas do.

    Thanks for the feedback! This exception to print is mentioned in the immediately following paragraph but yes, calling it a 'function' is indeed technically incorrect. I didn't think this was something a complete newbie would gain much from learning out the door. I felt it better to learn calling print as a (sort-of) function from the get-go so that the concept of a function was introduced early and can be referenced later in the tutorial when a real function is created.

    Honestly, I wonder if the first thing you'd teach is me.msg -- and only teach print in an advanced mode about debugging. Because what is the classical 'first thing' anyone learns in a programming language? How to print out a statement and see the result. In Evennia, that's not print, that's me.msg.

    me.msg("Hello world!") is really Evennia's version of the first programming exercise for every language ever.

    The use of print is there because people somewhat familiar with Python will usually try it first and wonder why nothing happens. It also makes sure newcomers early learn to look at the console since that's where many errors will show up (we've found it's common for beginners to hide/close this window and not realize this source of info exists when they get errors). But yeah, the immediately visible output of me.msg() is indeed more matching the traditional Hello World! example.
    .
    Griatch


  • Tutorialist

    Sooo.... lets say you set up Evennia with the purpose of exploring it, but then got busy for a month and forgot the name of the, erh, wizbit equivalent... How would one reset that?


  • Admin


  • Tutorialist

    @arkandel Thanks boo.


  • Coder

    @cobaltasaurus If you forgot the name you used (not just the password) you could also drop into the database to see it. But if you are just starting out, you could just as well reset the database and add your account anew.

    • Start your virtualenv (like you did in the GettingStarted instructions). Go to your game dir (mygame in all documentation).
    • make sure Evennia is not running: evennia stop.
    • Delete the file mygame/server/evennia.db3. This is the default database unless you changed to use something like mysql/psycopg2 (then you need to use their tools to wipe the database) (Backing up your database is otherwise just a matter of making a copy of this file).
    • evennia migrate - this creates a new database file and sets it up.
    • evennia start - you will be asked for your name/password again.

  • Tutorialist

    @griatch Apologies if I should use another thread, but I'm attempting to get Evennia set up on a DO droplet, and keep getting this error right at the beginning. :x

    alt text


  • Pitcrew

    @cobaltasaurus Have you done a sudo apt-get update before running the apt-get install? I often don't do it and then find out half the packages are missing.


  • Tutorialist

    @ifrit Hooray! You are the best! This seems to have worked, thank you!


  • Tutorialist

    @ifrit @Griatch Okay now I'm having this happen:

    ![alt text](0_1527709129097_af6106bb-0272-47b4-8255-1ec1bf279920-image.png image url)

    I've tried, several times, to do the 'touch', and to copy the init.py file. Nothing seems to do anything. when I try to touch the init.py from inside my game dir it tells me no such file or folder exists, when i move to zope/interface and use it it returns nothing.


  • Coder

    Ah! I think I know what the issue is. Give me a second, @Cobaltasaurus. Is DigitalOcean running Ubuntu?


  • Coder

    @Cobaltasaurus are you putting it here: /pyenv/local/lib/python2.7/site-packages/zope/ inside your game directory? For instance, mine is in: ~/dsdev/pyenv/lib/python2.7/site-packages/zope$

    Also, I assume by the bolded init that you are doing dunder init.py (double underscore init double underscore .py)


  • Coder

    @golgoth said in I made a Python-with-Evennia tutorial (looking for feedback):

    Is DigitalOcean running Ubuntu?

    You have a choice of OS but Ubuntu is the default.


  • Coder

    @faraday Twisted/Zope/Evennia seems to get confused with Ubuntu.