I been teaching someone python for a few day with 2-3 hour each day. It has been very pleasant to teach him programming since he have a goal in mind. He already know what kind of program we wanted to build.

He is a novice and not familiar with programming. It have been a good chance to see how the novice look at the python. I been given a chance to ask the answer like

"Why do we throw exception?" ,

"Why do we put define function at the top of the file and not at __main__?"

"Why do I need to use constructor?" ,

"Why should I call parent constructor in the child constructor?"

Here is the main question.

I have been wondering "should I teach him multi inheritance and the diamond problem?" I haven't been using multi inheritance for a while other than the exercise I done when I started programming and cannot think of the situation to use multi inheritance. I know in other language we use multi inheritance (kind of) regularly by extending multiple interface. I wanted to ask if multi inheritance is common in python.

Another question I have is how should I introduce him to gui programming in a simple manner? I am thinking of introduction him to the gui framework which haved WYSIWYG editor like "Remi"

  • 0
    Depends on what he wants to build.
    What about a lovely server side rendered web app?
  • 0

    He want to ask the quiz/exam program. There will be a timer and the user have to choose the multiple choose question.Then the mark (calculated by correct answer) will be shown to user.
  • 0
    I hope you also taught him to handle every exception that you program in and try to catch everyone that could be thrown by calling code too?

    For me the answer to "Why do we throw an exception?" Seems too often to be "so it's someone else's problem".
  • 0

    The correct answer for throwing answer is "because you cannot or shouldn't handle the error and the right to handle the error should be given for caller.

    For example what would happen when caller divide by 0.

    Will you print the error message? Will you provide -1 as result?

    The point is that you cannot handle it in reasonable way so the right to handle the error should be given to caller by throwing exception. "
  • 0
    @mr-user that is fine but the cases I am talking about are where people say "it is the responsibility of the caller" all the way up to the operator poking at the CLI or the GUI that hides it all.

    Much of the time not only do you throw but you are also the caller. Not in that line of code but often you are writing something that you call. The end user does not want to see you failing to handle a network blip or a full drive or ...

    Handle all the thrown things or think about how to handle them is what I am saying.
  • 1
    @TafT You are right every exception should be handle in a reasonable way such as showing reconnect button when network in not available.

    Sometime the only reasonable thing you can do it is to show an error message and log the exception message.

    I was actually ask "If catching the exception prevent the program from crashing/exiting, will it be better to wrap all the code in try block?"

    I was able to convince him why that not a good idea along my example of my past failure.

    I try to give my own failure as an example (with some code) since I feel showing your actual failure prevent student-teacher barrier.

    I am actually proud of myself that I can convince him why warping everything in if statement is not a good idea.

    I am actually having trouble distinguishing what are the thing to teach to beginner and what thing are for advance for me? It's been over a decade since I started writing my first program so it's difficult for me. I am referencing some online course to as reference.
  • 0
    @mr-user in answer to the question of catching the answer is depends. It may make.sense for the lower level code to catch a couple of disconnections and try to reconnect before bothering the end user.

    Knowing what to teach is always hard. If you bring up a tool/topic (such as exceptions) then I think need to give an overview of the good and bad bits about them. A few clear cases of what to throw and when to catch with a warning about the large gray area between the clear cases.

    It's all about design, decisions and making the best choices you can for the end user after all.
  • 0

    I need to teach him about file IO in our next lesson after that we will go into gui programming (his main interest)

    Do you think RAII (__enter__ ,__exit__ in python) is too advantage for beginner?

    Of course I will need to explain what are the basic widget (textbox,button,checkbox,panel,--etc) but I am having trouble deciding which gui framework is easier for beginner.
  • 0
    @mr-user I cannot really advise on GUI stuff as I have managed a couple of decades without the need for a GUI in my work 😝

    Sometimes someone else has maintained something or I have needed to integrate with semi-auto web generation thing but mostly it's been config files or CLI only for me.
  • 0

    You are one lucky person.Never having to deal with gui is my dream. Although I prefer CLI I have to do gui.
Add Comment