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


Groups > comp.lang.python > #101589

Re: When I need classes?

Newsgroups comp.lang.python
Date 2016-01-12 19:36 -0800
References <c0bb7499-c359-4010-aac2-270d1b82a47d@googlegroups.com>
Message-ID <34aa811c-433d-4f8a-90e0-9dd768460415@googlegroups.com> (permalink)
Subject Re: When I need classes?
From Rustom Mody <rustompmody@gmail.com>

Show all headers | View raw


On Sunday, January 10, 2016 at 1:00:13 PM UTC+5:30, Arshpreet Singh wrote:
> Hello Friends, I am quite new to OOP(object oriented Programming), I did some projects with python which includes Data-Analysis, Flask Web Development and some simple scripts. 
> 
> I have only one question which is bothering me most of the time, When I will get the need to use Classes in Python? Or in other way is there any real-life example where you can tell me this problem/solution is kind of impossible in Python without Classes?

I think the answers so far dont cover two complementary sides to this question:

1. Python the LANGUAGE, is rather even-handed in paradigm choice: Choose OO, imperative, functional or whatever style pleases/suits you
2. Python LIBRARIES however need to make committing choices.  Users of those 
then need to align with these.

egs 
1. Majority of basic python is functional; eg stuff in os module

2. Some things need object creation and method call
eg for re-s you need to know about and to use re objects, match objects etc

3. Then there are things that are naturally used by inheriting and extending
eg Basehttpserver is typically used via inheritance
To use these you need to know basic OO

4. Then there may be things whose natural usage needs multiple inheritance
[cant think of examples]

So as others have said, in principle you dont need to go beyond 1.
Unfortunately when you are using non-trivial libraries you are a user both of
python and the library and so the library-author's paradigm choices are a given
for you

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


Thread

When I need classes? Arshpreet Singh <arsh840@gmail.com> - 2016-01-09 23:29 -0800
  Re: When I need classes? Michael Torrie <torriem@gmail.com> - 2016-01-10 08:02 -0700
    Re: When I need classes? Arshpreet Singh <arsh840@gmail.com> - 2016-01-10 22:45 -0800
      Re: When I need classes? Cameron Simpson <cs@zip.com.au> - 2016-01-11 18:27 +1100
  Re: When I need classes? Steven D'Aprano <steve@pearwood.info> - 2016-01-11 02:39 +1100
    Re: When I need classes? Bernardo Sulzbach <mafagafogigante@gmail.com> - 2016-01-10 15:48 -0200
      Re: When I need classes? Arshpreet Singh <arsh840@gmail.com> - 2016-01-10 22:24 -0800
    Re: When I need classes? Arshpreet Singh <arsh840@gmail.com> - 2016-01-10 22:28 -0800
    Re: When I need classes? Travis Griggs <travisgriggs@gmail.com> - 2016-01-11 15:45 -0800
      Re: When I need classes? Mike S <mscir@yahoo.com> - 2016-01-13 22:27 -0800
    Re: When I need classes? Michael Torrie <torriem@gmail.com> - 2016-01-11 16:59 -0700
    Re: When I need classes? Bernardo Sulzbach <mafagafogigante@gmail.com> - 2016-01-11 22:53 -0200
    Re: When I need classes? Chris Angelico <rosuav@gmail.com> - 2016-01-12 12:28 +1100
      Re: When I need classes? Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-01-13 10:01 +1300
        Re: When I need classes? Bernardo Sulzbach <mafagafogigante@gmail.com> - 2016-01-12 19:08 -0200
    Re: When I need classes? Ian Kelly <ian.g.kelly@gmail.com> - 2016-01-12 17:18 -0700
      Re: When I need classes? Steven D'Aprano <steve@pearwood.info> - 2016-01-13 12:33 +1100
  Re: When I need classes? Rustom Mody <rustompmody@gmail.com> - 2016-01-12 19:36 -0800
    Re: When I need classes? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-01-13 16:27 +1100
      Re: When I need classes? Rustom Mody <rustompmody@gmail.com> - 2016-01-12 22:31 -0800
        Re: When I need classes? Rustom Mody <rustompmody@gmail.com> - 2016-01-13 08:33 -0800
      Re: When I need classes? Rick Johnson <rantingrickjohnson@gmail.com> - 2016-01-14 10:00 -0800

csiph-web