Answers.Body: <p>The object models of Java and Python are just about the same. But the reference model is a bit different. But the biggest difference is that in Java, a reference variable is defined to have a certain type (class) and in Python it is just a name. In other words, in Java, references are typed. In Python they are untyped. But in both languages the objects themselves are strongly typed at time of creation.</p>
  <p>This difference implies that reference types (validity) are checked by the compiler - or even earlier when a good IDE is used. Thus Eclipse will highlight type errors in Java but cannot do so in Python. In Python, the validity of an expression is checked only when the program actually runs since any variable can actually refer to any object, regardless of type.</p>
  <p>In Python if you say foo.bar(x); then this is valid or not depending on whether, at that moment the object that foo references has a method bar with appropriate parameters. The actual type of that object doesn't matter, only its available methods do. But the object itself, as distinct from the reference to it, has a specific type that doesn't change.</p>
  <p>But in Java, this gets checked before the program runs, making error detection earlier in the process. If the declared class of foo, which is explicit in the program text has a matching bar method then the expression is guaranteed valid prior to the run.</p>
  <p>For the programmer, this implies that you need to take more care in writing your program in Python since you get fewer hints from the IDE or the compiler if you don't use an IDE. Thus thorough testing becomes even more important in Python since untested code can harbor errors for a long time undetected.</p>
  <p>I would hope that any decent undergraduate level programming text in either language will give you proper guidance and a mental model for that language.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-10-29T13:44:58.050Z
Answers.Text: The most obvious difference between Python and Java is multiple inheritance, but since Python uses MI with *linearization*, there is still a single, well-defined, linear chain of ancestors for each class, just like in Java.
Answers.UserDisplayName: Jörg W Mittag
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-10-29T13:56:21.127Z
Answers.Text: @JörgWMittag, Java has multiple inheritance? Since when? Implementing multiple interfaces isn't the same thing.
Answers.UserDisplayName: Buffy
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-10-29T14:05:17.697Z
Answers.Text: Java doesn't, but Python does, hence it's (at least to me) the most obvious difference between Java and Python.
Answers.UserDisplayName: Jörg W Mittag
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-11-20T14:29:19.823Z
Answers.Text: I say "Java is a Victorian convent and Python is a nudist colony," because Java has a much stronger form of encapsulation in the form of access specifiers.  There is no compiler to enforce privacy in Python.  This amounts to a very significant difference.  Python has no notion of finality either.
Answers.UserDisplayName: ncmathsadist
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-10-26T15:18:01.787Z
Answers.LastActivityDate: 2021-10-26T15:18:01.787Z
Answers.UserDisplayName: Buffy
Body: <p>What would one suggest for a junior lever programming student to learn object oriented Python? For me, it is quite easy to understand objects in Java and non-object oriented Python but objects in Python seems weirder than in Java. Are there good books or lecture notes?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-10-25T11:44:05.523Z
Comments.Text: Weirder in what way? The object models are very similar. Python misses explicit interfaces, of course. The big difference is when a reference is checked for validity.
Comments.UserDisplayName: Buffy
Tags: <self-learning><python>
Title: How to learn object oriented Python?
ThreadText: # How to learn object oriented Python?
  
  (Asked by: username_0 on 2021-10-25)
  
  What would one suggest for a junior lever programming student to learn object oriented Python? For me, it is quite easy to understand objects in Java and non-object oriented Python but objects in Python seems weirder than in Java. Are there good books or lecture notes?
  
  **Tags:** self-learning, python
  
  > **Comments:**
  > **username_1**: Weirder in what way? The object models are very similar. Python misses explicit interfaces, of course. The big difference is when a reference is checked for validity.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-10-26. Score: 1 | Accepted answer
  
  The object models of Java and Python are just about the same. But the reference model is a bit different. But the biggest difference is that in Java, a reference variable is defined to have a certain type (class) and in Python it is just a name. In other words, in Java, references are typed. In Python they are untyped. But in both languages the objects themselves are strongly typed at time of creation.
  
  This difference implies that reference types (validity) are checked by the compiler - or even earlier when a good IDE is used. Thus Eclipse will highlight type errors in Java but cannot do so in Python. In Python, the validity of an expression is checked only when the program actually runs since any variable can actually refer to any object, regardless of type.
  
  In Python if you say foo.bar(x); then this is valid or not depending on whether, at that moment the object that foo references has a method bar with appropriate parameters. The actual type of that object doesn't matter, only its available methods do. But the object itself, as distinct from the reference to it, has a specific type that doesn't change.
  
  But in Java, this gets checked before the program runs, making error detection earlier in the process. If the declared class of foo, which is explicit in the program text has a matching bar method then the expression is guaranteed valid prior to the run.
  
  For the programmer, this implies that you need to take more care in writing your program in Python since you get fewer hints from the IDE or the compiler if you don't use an IDE. Thus thorough testing becomes even more important in Python since untested code can harbor errors for a long time undetected.
  
  I would hope that any decent undergraduate level programming text in either language will give you proper guidance and a mental model for that language.
  
  > **Comments:**
  > **username_2**: The most obvious difference between Python and Java is multiple inheritance, but since Python uses MI with *linearization*, there is still a single, well-defined, linear chain of ancestors for each class, just like in Java.  
  > **username_1**: @username_2, Java has multiple inheritance? Since when? Implementing multiple interfaces isn't the same thing.  
  > **username_2**: Java doesn't, but Python does, hence it's (at least to me) the most obvious difference between Java and Python.  
  > **username_3**: I say "Java is a Victorian convent and Python is a nudist colony," because Java has a much stronger form of encapsulation in the form of access specifiers.  There is no compiler to enforce privacy in Python.  This amounts to a very significant difference.  Python has no notion of finality either.  
  
  ---
  
  