• Don't put everything into classes. Python's built-in list and dictionaries will take you far.
  • Don't worry about keeping one class per module. Divide modules by purpose, not by class.
  • Use inheritance for behavior, not interfaces. Don't create an "Animal" class for "Dog" and "Cat" to inherit from, just so you can have a generic "make_sound" method.

Just do this:

class Dog(object):
    def make_sound(self):
        return "woof!"

class Cat(object):
    def make_sound(self):
        return "meow!"

class LolCat(object):
    def make_sound(self):
        return "i can has cheezburger?"
Answer from Ryan Ginstrom on Stack Overflow
🌐
Medium
medium.com › @pabba.varun › learning-python-a-quick-guide-for-experienced-java-developers-e49403e295ef
Learning Python: A Quick Guide for Experienced Java Developers | by Pabba Varun Kumar | Medium
August 23, 2024 - Are you an experienced Java programmer looking to learn Python? If so, this article will help you start your Python journey with ease. All programming languages share similar logic but often differ in syntax. This guide will walk you through setting up your Python environment and getting started with writing Python code.
Top answer
1 of 7
26
  • Don't put everything into classes. Python's built-in list and dictionaries will take you far.
  • Don't worry about keeping one class per module. Divide modules by purpose, not by class.
  • Use inheritance for behavior, not interfaces. Don't create an "Animal" class for "Dog" and "Cat" to inherit from, just so you can have a generic "make_sound" method.

Just do this:

class Dog(object):
    def make_sound(self):
        return "woof!"

class Cat(object):
    def make_sound(self):
        return "meow!"

class LolCat(object):
    def make_sound(self):
        return "i can has cheezburger?"
2 of 7
23

The referenced article has some good advice that can easily be misquoted and misunderstood. And some bad advice.

Leave Java behind. Start fresh. "do not trust your [Java-based] instincts". Saying things are "counter-intuitive" is a bad habit in any programming discipline. When learning a new language, start fresh, and drop your habits. Your intuition must be wrong.

Languages are different. Otherwise, they'd be the same language with different syntax, and there'd be simple translators. Because there are not simple translators, there's no simple mapping. That means that intuition is unhelpful and dangerous.

  • "A static method in Java does not translate to a Python classmethod." This kind of thing is really limited and unhelpful. Python has a staticmethod decorator. It also has a classmethod decorator, for which Java has no equivalent.

    This point, BTW, also included the much more helpful advice on not needlessly wrapping everything in a class. "The idiomatic translation of a Java static method is usually a module-level function".

  • The Java switch statement in Java can be implemented several ways. First, and foremost, it's usually an if elif elif elif construct. The article is unhelpful in this respect. If you're absolutely sure this is too slow (and can prove it) you can use a Python dictionary as a slightly faster mapping from value to block of code. Blindly translating switch to dictionary (without thinking) is really bad advice.

  • Don't use XML. Doesn't make sense when taken out of context. In context it means don't rely on XML to add flexibility. Java relies on describing stuff in XML; WSDL files, for example, repeat information that's obvious from inspecting the code. Python relies on introspection instead of restating everything in XML.

    But Python has excellent XML processing libraries. Several.

  • Getters and setters are not required in Python they way they're required in Java. First, you have better introspection in Python, so you don't need getters and setters to help make dynamic bean objects. (For that, you use collections.namedtuple).

    However, you have the property decorator which will bundle getters (and setters) into an attribute-like construct. The point is that Python prefers naked attributes; when necessary, we can bundle getters and setters to appear as if there's a simple attribute.

    Also, Python has descriptor classes if properties aren't sophisticated enough.

  • Code duplication is often a necessary evil in Java (e.g. method overloading), but not in Python. Correct. Python uses optional arguments instead of method overloading.

    The bullet point went on to talk about closure; that isn't as helpful as the simple advice to use default argument values wisely.

Discussions

Best way to learn Java (no videos or tutorials) for a python mid-level programmer?
I get so many errors. Honestly, even though you said "no videos or tutorials", you need one. Do the MOOC Java Programming from the University of Helsinki. Python and Java are very different beasts. You can be a decent programmer at either and will find the other difficult. Hence, do a course. I just recently started learning Python coming from a long history (>3 decades) of professional programming in multiple languages (Delphi, VB, C, Java, bit of C#) and still found that I absolutely need a structured course to get started. The gap between the languages was just too big. Sure, with the experience, you can breeze through the initial chapters as they deal with very basic things, like variables, conditionals, input/output, but you will still learn a lot. If you absolutely do not want to go that way, you need to learn to read and understand the errors and debug them. Yet, going this approach will make it way more tedious than it need be. More on reddit.com
🌐 r/learnprogramming
4
0
September 22, 2022
Experienced Java Dev Needing to Learn Python

Pick a project you’ve done in Java and replicate it in Python

More on reddit.com
🌐 r/learnpython
2
3
July 8, 2022
Coming to Java from Python, frustrated. Any tips for connecting the dots?
Have you looked at Java for Python Programmers ? More on reddit.com
🌐 r/java
70
39
October 24, 2014
New to programming did I choose the wrong language? Java vs Python
Most programmers have several languages in their repertoire. Java and Python are both solid choices and honestly you should be familiar with both to be competitive in today’s market. Add JavaScript, and you’ll be a Swiss Army knife ready for a wide variety of job opps and projects. Java is huge in the corporate space, even though you often will hear more about Python in social media because it is very widely used. I am a Java first programmer who has branched out into other languages. More on reddit.com
🌐 r/java
106
45
August 24, 2020
People also ask

How much math do I need to know to take this Specialization?
The only math that learners will need for this Specialization is arithmetic and basic concepts in logic.
🌐
coursera.org
coursera.org › browse › computer science › software development
Introduction to Programming with Python and Java | Coursera
Is this course really 100% online? Do I need to attend any classes in person?
This course is completely online, so there’s no need to show up to a classroom in person. You can access your lectures, readings and assignments anytime and anywhere via the web or your mobile device.
🌐
coursera.org
coursera.org › browse › computer science › software development
Introduction to Programming with Python and Java | Coursera
Can I take the course for free?
No, you cannot take this course for free. When you enroll in the course, you get access to all of the courses in the Specialization, and you earn a certificate when you complete the work. If you cannot afford the fee, you can apply for financial aid.
🌐
coursera.org
coursera.org › browse › computer science › software development
Introduction to Programming with Python and Java | Coursera
🌐
Reddit
reddit.com › r/learnpython › any good resources for an experienced java developer new to python?
r/learnpython on Reddit: Any good resources for an experienced Java developer new to Python?
January 13, 2022 -

Does anyone have any recommendations for material pitched a experienced developers wanting to get up-to-speed with Python quickly. Assume I can already read and write complex code in another language but have never used Python before.

🌐
Runestone Academy
runestone.academy › ns › books › published › java4python › index.html
Welcome to Java for Python Programmers — Java for Python Programmers
Java for Python Programmers · Preface · Introduction · Why Learn another programming Language? Lets look at a Java Program · Java Data Types · Conditionals · Loops and Iteration · Defining Classes in Java · Naming Conventions · Common Mistakes · Java Documentation ·
Find elsewhere
🌐
GitHub
github.com › blu3r4y › python-for-java-developers
GitHub - blu3r4y/python-for-java-developers: If you are a Java developer and want to get a quick glance at Python, this course is for you · GitHub
If you are a Java developer and want to get a quick glance at Python, this course is for you - blu3r4y/python-for-java-developers
Starred by 66 users
Forked by 13 users
Languages   Markdown 62.4% | Python 15.9% | Java 7.7% | HTML 4.5% | Jupyter Notebook 4.5% | CSS 2.5%
🌐
Imperial College London
python.pages.doc.ic.ac.uk › java
Python for Java Programmers | Department of Computing
Python Programming course at the Department of Computing, Imperial College London
🌐
Coursera
coursera.org › browse › computer science › software development
Introduction to Programming with Python and Java | Coursera
Course 1, 28 hoursCourse 1•28 hoursCourse details · Identify core aspects of programming and features of the Python language · Understand and apply core programming concepts like data structures, conditionals, loops, variables, and functions ...
Rating: 4.5 ​ - ​ 1.9K votes
🌐
Quora
quora.com › What-are-some-good-ways-for-a-Java-programmers-to-learn-Python
What are some good ways for a Java programmers to learn Python? - Quora
Answer (1 of 3): I am recommended the following method because this is what worked for me. It's, by no means, exhaustive. The Google's Python Class should be a good start. It teaches the core of the languages within 16 hours of lectures interspersed with lots of (good) exercises. Also, Nick Parl...
🌐
Udemy
udemy.com › development
Python for Java Developers
December 15, 2024 - This course will help you to learn to program in Python by leveraging the skills you already have in Java, or another high-level object-oriented programming language. I won't waste your time explaining things you already know, like what functions ...
Rating: 4.7 ​ - ​ 96 votes
🌐
Smc
careertraining.smc.edu › training-programs › java-programmer-python-developer
Java Developer + Python Developer
Thank you. You should be receiving a reset link at the email address you provided shortly
🌐
Carnegie Mellon University
cs.cmu.edu › ~mjs › courses › 121-F14-W › Java4Python.pdf pdf
Java for Python Programmers Bradley N. Miller January 27, 2008 1
January 27, 2008 - This book assumes that you are already familiar with the Python programming language. We will · use Python as a starting point for our journey into Java.
🌐
Real Python
realpython.com › java-vs-python
Java vs Python: Basic Python for Java Developers – Real Python
August 16, 2024 - Free Bonus: Click here to get a Python Cheat Sheet and learn the basics of Python 3, like working with data types, dictionaries, lists, and Python functions. Python is a programming language that was developed by Guido van Rossum.
🌐
O'Reilly Media
oreilly.com › videos › java-to-python › 9781789611960
Java to Python in 100 Easy Steps - The Fastest Way to Learn Python for Experienced Java Programmers [Video]
Their methodology combines a deep understanding of key programming concepts with practical, hands-on examples to ensure learning effectiveness. ... This course is tailored for experienced Java developers seeking to learn Python efficiently.
🌐
Quora
quora.com › Is-learning-Python-useful-to-a-Java-developer
Is learning Python useful to a Java developer? - Quora
Answer (1 of 2): Not at all, Python and Java have different careers. Python is used for Data Science, Machine learning field. However if you have idea of both then it is beneficial for you.
Top answer
1 of 4
3
I get so many errors. Honestly, even though you said "no videos or tutorials", you need one. Do the MOOC Java Programming from the University of Helsinki. Python and Java are very different beasts. You can be a decent programmer at either and will find the other difficult. Hence, do a course. I just recently started learning Python coming from a long history (>3 decades) of professional programming in multiple languages (Delphi, VB, C, Java, bit of C#) and still found that I absolutely need a structured course to get started. The gap between the languages was just too big. Sure, with the experience, you can breeze through the initial chapters as they deal with very basic things, like variables, conditionals, input/output, but you will still learn a lot. If you absolutely do not want to go that way, you need to learn to read and understand the errors and debug them. Yet, going this approach will make it way more tedious than it need be.
2 of 4
3
I highly recommend these two free online Java courses: MOOC.fi . The courses have you learn Java while simultaneously doing mini exercises to apply what you learned. The exercises get more complex as the course goes on. At the end of the second course you create a pretty decent GUI game. I skimmed your profile to gauge your level of Python. You'll probably find the first half of course 1 pretty easy, but everything after that will likely be mostly new to you. Course 2 will likely be all new to you. It's very easy to learn Python without really thinking about object oriented programming (OOP) concepts, but with Java you must learn object oriented programming concepts. After those two courses, I recommend doing a couple of small projects in Java and then reading a book on OOP design patterns. I recommend a called book "Head First Design Patterns". After that you should have a very solid understanding of Java and OOP fundamentals.
🌐
Aryaboudaie
aryaboudaie.com › java › python › technical › educational › 2017 › 11 › 13 › python-for-java-programmers.html
Python for Java Programmers - Part 1 - The Big Picture
November 13, 2017 - In this guide, I’ll go through a list of all the topics you have learned in Java, and explain how you can do similar things in Python, as well as new tips and tricks to keep you learning! As someone who has been a TA for many intro to programming classes, one common misconception I’ve seen of programming is that it’s all about learning languages, and once you learn six or seven different languages, then you’re good to go.
🌐
Amazon
amazon.com › Python-Experienced-Java-Developers-Richter › dp › B0D6MB9XBR
Python for Experienced Java Developers: 9798327682344: Computer Science Books @ Amazon.com
Are you an experienced Java developer ... Experienced Java Developers" is your comprehensive guide to mastering Python with your existing knowledge of object-oriented and functional programming....
🌐
Luc
anh.cs.luc.edu › 170 › html
Welcome to Java for Python Programmers — Java for Python Programmers
Java for Python Programmers · Runestone in social media: Follow @iRunestone · Help support us: Table of Contents · Book Index · Scratch ActiveCode · Join a Study Group · Group Schedule · Schedule New Chapter · Manage Group · Instructor's Page · Progress Page ·