Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #101510
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: When I need classes? |
| Date | Tue, 12 Jan 2016 12:28:24 +1100 |
| Lines | 35 |
| Message-ID | <mailman.37.1452562107.13488.python-list@python.org> (permalink) |
| References | <c0bb7499-c359-4010-aac2-270d1b82a47d@googlegroups.com> <56927b37$0$1586$c3e8da3$5496439d@news.astraweb.com> <CAERt=-xWsUoy6bHdtE0W+VrLgGA3OE2=-GzwFfMWBxqi=s02bA@mail.gmail.com> <DA39F138-7794-4CB4-AC93-63937D15D6D6@gmail.com> <CAERt=-xnhCmrHPzY+8+0u2rCjOX4fqUjaBC0-v0Ef8HDoehKkw@mail.gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| X-Trace | news.uni-berlin.de IPyNYUNmNh5A8qfoM17Kgw+ezK+Uy9mpaA/81ZgrUC9g== |
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'classes,': 0.05; 'think,': 0.05; '*not*': 0.07; 'classes.': 0.07; 'unittest': 0.07; 'cc:addr :python-list': 0.09; 'function),': 0.09; 'methods,': 0.09; 'script,': 0.09; 'themselves,': 0.09; 'jan': 0.11; '(when': 0.16; '2016': 0.16; 'afterwards.': 0.16; 'feasible': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'instantiate': 0.16; 'knock': 0.16; 'naive': 0.16; 'readability.': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'rigid': 0.16; 'simplifies': 0.16; 'travis': 0.16; 'why,': 0.16; 'wrote:': 0.16; 'subject:need': 0.18; '>>>': 0.20; 'math': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'do.': 0.22; 'java': 0.22; 'c++,': 0.22; 'tuples': 0.22; 'pass': 0.22; 'am,': 0.23; 'this:': 0.23; 'written': 0.24; 'header:In-Reply-To:1': 0.24; 'mon,': 0.24; 'script': 0.25; 'message-id:@mail.gmail.com': 0.27; 'purposes.': 0.29; 'classes': 0.30; 'code': 0.30; 'raymond': 0.30; 'especially': 0.32; 'good.': 0.32; 'point': 0.33; 'class': 0.33; 'problem': 0.33; 'tue,': 0.34; 'add': 0.34; 'gets': 0.35; 'received:google.com': 0.35; 'could': 0.35; 'improving': 0.35; 'quite': 0.35; 'but': 0.36; 'project': 0.36; 'there': 0.36; 'received:209.85': 0.36; 'structures': 0.36; 'subject:?': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'two': 0.37; '12,': 0.37; 'received:209.85.213': 0.37; 'doing': 0.38; '(with': 0.38; 'received:209': 0.38; 'data': 0.39; 'enough': 0.39; 'some': 0.40; 'organization': 0.60; 'your': 0.60; 'making': 0.62; 'more': 0.63; 'different': 0.63; 'experience.': 0.66; "they're": 0.66; '"hey,': 0.84; '9:45': 0.84; 'around,': 0.84; 'bernardo': 0.84; 'chrisa': 0.84; 'enhances': 0.84; 'subject:When': 0.84; 'together,': 0.84; 'to:none': 0.91; 'students,': 0.97 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=r/bOzppLiBVSj1mhCkiwNTqblwjq9wGkSrgqW+KUQSo=; b=kZPXQo/PkRGz5Agpbg/5Juxm3rFDKYZul1L5VedZJxKSzZndFWnaMAya47SSA5owhv XufEFiVwb3HQTVJcsr9xh1izv2/7ujLR3BmA0B/BqaxpjUzDGXaEKc2ehCN8IVHBw8SQ 5jTggzfxfiPJrbzBUqRapl1zB0DCFhGCqEJJGBEXhVq9USsr/mAq85+D0h8zE/uH/HgI UgKjMowJeD0shn3eV2SShF2IALMvattRDW3RPmdtP98w7WUJYAqlpT/CGfgkNZTGYKmJ HE8J1mhwZv/fVdaa1b9I5J0Nw5xj9ANGld4vYCAgWQB8vvZQ/lL650PUXLVl6L9RPULd pweQ== |
| X-Received | by 10.50.134.227 with SMTP id pn3mr15077389igb.13.1452562104455; Mon, 11 Jan 2016 17:28:24 -0800 (PST) |
| In-Reply-To | <CAERt=-xnhCmrHPzY+8+0u2rCjOX4fqUjaBC0-v0Ef8HDoehKkw@mail.gmail.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Xref | csiph.com comp.lang.python:101510 |
Show key headers only | View raw
On Tue, Jan 12, 2016 at 11:53 AM, Bernardo Sulzbach <mafagafogigante@gmail.com> wrote: > On Mon, Jan 11, 2016 at 9:45 PM, Travis Griggs <travisgriggs@gmail.com> wrote: >> >>> On Jan 10, 2016, at 9:48 AM, Bernardo Sulzbach <mafagafogigante@gmail.com> wrote: >>> >>> Essentially, classes (as modules) are used mainly for organizational purposes. >>> >>> Although you can solve any problem you would solve using classes >>> without classes, solutions to some big problems may be cheaper and >>> more feasible using classes. >> >> I think, this is often why, for a simple script, OO just kind of gets in the way. You have a straightforward procedure that you just want to do. The state (data) is not rich enough to make making it the focal point of your program. > > Your answer is quite good. I am not a purist myself (when it comes to > Java and C++, I am never going to instantiate a Math class to get a > logarithm function), but I understand the value of OO from experience. > As I mentioned those "tuples and dictionaries" to pass data around, I > would like to add that when a single script has two kinds of tuples or > dictionaries, you may be better of using two different classes, as > having "dedicated" types simplifies project organization and > enhances readability. > Yeah. One thing I often recommend, especially to students, is to start with the very simplest and most naive code they can knock together, and then look at making it tidier afterwards. Classes, decorators, the unittest setUp/tearDown methods, and even functions themselves, are all just ways of improving code that could be written some other way. They're not rigid structures that you HAVE to comply with or your code is *just* *not* *good* *enough*. So start simplistic, and then look into it like this: "Hey, see how you're doing this five times? There HAS to be a better way!" (With acknowledgement to Raymond Hettinger.) ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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