Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #46557

Re: How clean/elegant is Python's syntax?

Date 2013-05-30 17:30 -0600
From Michael Torrie <torriem@gmail.com>
Subject Re: How clean/elegant is Python's syntax?
References <CAGVx7UWXAFHSHq37Ep-Vk=cM2wYrEGHSUhNc8s43bCvj_VcVow@mail.gmail.com> <mailman.2374.1369852683.3114.python-list@python.org> <51a6ef42$0$11118$c3e8da3@news.astraweb.com>
Newsgroups comp.lang.python
Message-ID <mailman.2462.1369956642.3114.python-list@python.org> (permalink)

Show all headers | View raw


On 05/30/2013 12:18 AM, Steven D'Aprano wrote:
> In some ways, Python is a more pure OOP language than Java: everything in 
> Python is an object, including classes themselves.
> 
> In other ways, Python is a less pure and more practical language. You 
> don't have to wrap every piece of functionality in a class. Python 
> encourages you to write mixed procedural, functional and object oriented 
> code, whatever is best for the problem you are trying to solve, which is 
> very much in contrast to Java.

Depending on your understanding of what object-oriented means,
procedural and functional code is still object-oriented.  In fact
modules (the "file") are in essence singleton objects that define
attributes, but in practice there can only be one instance of this
object (module).  Seems like in Java a lot of code is needed to
implement singletons (factory, etc).  module-level code (procedural
code) could simply be thought of as singleton initialization/constructor
code that's automatically run when the singleton is created, using
import or __import__().

At the function level, a simple function is still an object that
implements callable.

Python's implementation of OO isn't quite smalltalk pure, but it is much
more consistent than in Java or C++.

But yes, Python does not force you to shoe-horn your programming into
one particular pattern.

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Re: How clean/elegant is Python's syntax? Ma Xiaojun <damage3025@gmail.com> - 2013-05-30 02:37 +0800
  Re: How clean/elegant is Python's syntax? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-30 06:18 +0000
    Re: How clean/elegant is Python's syntax? Ma Xiaojun <damage3025@gmail.com> - 2013-05-30 16:54 +0800
      Re: How clean/elegant is Python's syntax? rusi <rustompmody@gmail.com> - 2013-05-30 10:12 -0700
        Re: How clean/elegant is Python's syntax? Chris Angelico <rosuav@gmail.com> - 2013-05-31 03:28 +1000
          Re: How clean/elegant is Python's syntax? rusi <rustompmody@gmail.com> - 2013-05-30 10:59 -0700
            Re: How clean/elegant is Python's syntax? Chris Angelico <rosuav@gmail.com> - 2013-05-31 04:22 +1000
        Re: How clean/elegant is Python's syntax? Ma Xiaojun <damage3025@gmail.com> - 2013-05-31 01:46 +0800
        Re: How clean/elegant is Python's syntax? Chris Angelico <rosuav@gmail.com> - 2013-05-31 03:50 +1000
        Re: How clean/elegant is Python's syntax? Ma Xiaojun <damage3025@gmail.com> - 2013-05-31 01:50 +0800
        Re: How clean/elegant is Python's syntax? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-30 19:36 +0000
    Re: How clean/elegant is Python's syntax? Michael Torrie <torriem@gmail.com> - 2013-05-30 17:30 -0600

csiph-web