Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #33894
| Path | csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!newsfeed.eweka.nl!eweka.nl!feeder3.eweka.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <michael.herrmann@getautoma.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.008 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'example:': 0.03; 'attribute': 0.05; 'override': 0.07; 'parameter': 0.07; 'strings.': 0.07; 'python': 0.09; 'chunks': 0.09; 'friday,': 0.09; 'to:addr:comp.lang.python': 0.09; 'cc:addr:python-list': 0.10; "wouldn't": 0.11; 'accordingly': 0.16; 'naming': 0.16; 'overwriting': 0.16; 'pythonic': 0.16; 'simpson': 0.16; 'subject:type': 0.16; 'users.': 0.16; 'wrote:': 0.17; 'variables': 0.17; 'module': 0.19; 'trying': 0.21; 'bit': 0.21; '(usually': 0.22; 'stopping': 0.22; 'defined': 0.22; 'mention': 0.23; 'cc:no real name:2**0': 0.24; 'cc:2**1': 0.24; 'pass': 0.25; 'least': 0.25; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'common': 0.26; 'thanks!': 0.26; 'convention': 0.27; 'experiences': 0.27; 'functions.': 0.27; 'comparison': 0.29; 'domain.': 0.29; 'end,': 0.29; 'goods': 0.29; 'occurred': 0.29; 'case,': 0.29; 'probably': 0.29; 'usually': 0.30; 'basic': 0.30; 'function': 0.30; 'primary': 0.30; 'code': 0.31; 'says': 0.33; 'avoiding': 0.33; 'problem': 0.33; 'hi,': 0.33; 'that,': 0.34; 'received:google.com': 0.34; 'built-in': 0.35; 'stores': 0.35; 'similar': 0.35; 'received:209.85': 0.35; 'michael': 0.36; 'but': 0.36; 'method': 0.36; 'possible': 0.37; 'bad': 0.37; 'uses': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'object': 0.38; 'some': 0.38; 'instead': 0.39; 'where': 0.40; 'subject:-': 0.40; 'your': 0.60; 'amazing': 0.61; 'evaluate': 0.62; 'situation': 0.62; 'truly': 0.62; 'ever': 0.63; 'more': 0.63; 'great': 0.64; 'here': 0.65; 'flash': 0.72; 'day': 0.73; 'action.': 0.84; 'bite': 0.84; 'fortunately': 0.84; 'idiom': 0.84; 'overloading': 0.84; 'understand,': 0.84; 'mistake': 0.91; 'relate': 0.91; 'urge': 0.91; 'examine': 0.95 |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=path:newsgroups:date:in-reply-to:complaints-to:injection-info :nntp-posting-host:references:user-agent:x-google-web-client :x-google-ip:mime-version:message-id:subject:from:to:cc:content-type :x-gm-message-state; bh=XAVjws8Pj5qZh5Nkf+yxLrvqodJ5rNE2qrgKecn+xYw=; b=fJUd0A/s31rgWAYgaUbCDlM1oBLUO+eQmxM/Iy1BQWjyowkcyctgG2C754XzAlSkz9 Pn2JsltH7xeg26DB72wZ4xUmJryLIU6V1PPasCZgK2G0bQhnz3UFPHJ9K7FERhngCRM/ 70zjFJobsHIhLjM9X6AC4ot1YBo5mD37TQ7AIWO9E+dqUHEi1XjCjwWCPPsyfmMYg47n RkZKz6KPHs33wWGiewHL07x/5oP20l74YSdx+EDkk6DKxD15TUIQes90T5r9hTMKWiuc pDfyXLKkwuZ+Fo1Zq42GOAjYMk7f7yXAgIhgh0Fw6IiRNZQn8zn70+LjWX6S5qkR0q60 nKdQ== |
| Newsgroups | comp.lang.python |
| Date | Sat, 24 Nov 2012 14:32:19 -0800 (PST) |
| In-Reply-To | <mailman.244.1353709817.29569.python-list@python.org> |
| Complaints-To | groups-abuse@google.com |
| Injection-Info | glegroupsg2000goo.googlegroups.com; posting-host=78.104.121.251; posting-account=oknH1QoAAABqzbD_5ziFTvLQsqNk2LbU |
| References | <5b8a0a43-c737-4543-99e3-76e44c544a02@googlegroups.com> <mailman.244.1353709817.29569.python-list@python.org> |
| User-Agent | G2/1.0 |
| X-Google-Web-Client | true |
| X-Google-IP | 78.104.121.251 |
| MIME-Version | 1.0 |
| Subject | Re: Is it bad style to override the built-in function `type`? |
| From | Michael Herrmann <michael.herrmann@getautoma.com> |
| To | comp.lang.python@googlegroups.com |
| Content-Type | text/plain; charset=ISO-8859-1 |
| X-Gm-Message-State | ALoCoQkB6+g45k+zbqe87nabGe71/ASvbKcbgDw4E9l0yRSZyd8Zh3wtIgaOKdEURBBD+YsZJss4 |
| Cc | python-list@python.org, Michael Herrmann <michael.herrmann@getautoma.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://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 | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Message-ID | <mailman.263.1353796348.29569.python-list@python.org> (permalink) |
| Lines | 110 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1353796348 news.xs4all.nl 6899 [2001:888:2000:d::a6]:59200 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:33894 |
Show key headers only | View raw
Hi,
how about "write" instead of "type"? Just came to me in a flash of inspiration. I know it's also pretty general but at least it's not a built-in!
Thanks!
Michael
On Friday, November 23, 2012 11:30:18 PM UTC+1, Cameron Simpson wrote:
> On 23Nov2012 10:41, Michael Herrmann <> wrote:
>
> [...]
>
> | I know it's a common beginner's mistake to incautiously override
>
> | built-in functions. However, we put in a lot of research and have come to
>
> | the conclusion that, if Python had not already defined it, `type` would
>
> | be the best name. We are now trying to evaluate how bad the disadvantages
>
> | you mention are in comparison to the advantage to having a name that is
>
> | more intuitive to use in the problem domain.
>
> |
>
> | Can you somehow relate to my explanations, or are your experiences
>
> | with overwriting built-in variables so bad that you would advise to
>
> | never ever do it?
>
>
>
> My own experience says that it is a thing best avoiding without a truly
>
> amazing reason not to.
>
>
>
> I urge you not to: type(foo) is a very basic Python idiom and you're
>
> breaking it. One day it _will_ bite you or your users. You will
>
> understand, but I would give goods odds that some of your users will not
>
> the day they go to examine the type of an object for perfectly normal
>
> pythonic reasons.
>
>
>
> Example: I have a module that stores "objects" and they have as a
>
> primary key a "name" and a "type" - not Python types, just strings.
>
> Accordingly I have a similar situation to yours: the desire to use the
>
> word "type". Fortunately for me, as an attribute in (usually small) code
>
> chunks I can usually go:
>
>
>
> t = foo.type
>
> ... work with t here ...
>
>
>
> Where I must pass one as a parameter I use the common convention of
>
> naming the parameter "type_" at the receiving end.
>
>
>
> For the calling end, as in your case, you want to use:
>
>
>
> type(blah)
>
>
>
> Is it at all possible to make all uses of your "type" function method
>
> calls? Eg:
>
>
>
> something.type("text to type")
>
>
>
> It avoids the overloading while keeping your desired name.
>
> --
>
> Cameron Simpson
>
>
>
> Wouldn't it be great if all emergency stopping situations occurred on your
>
> favourite bit of road......you'd probably know about it before it happened
>
> and would be able to take other evasive action.
>
> - Neville Brabet
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Is it bad style to override the built-in function `type`? Michael Herrmann <michael.herrmann@getautoma.com> - 2012-11-23 08:12 -0800
Re: Is it bad style to override the built-in function `type`? Emile van Sebille <emile@fenx.com> - 2012-11-23 08:39 -0800
Re: Is it bad style to override the built-in function `type`? Roy Smith <roy@panix.com> - 2012-11-23 11:47 -0500
Re: Is it bad style to override the built-in function `type`? Michael Herrmann <michael.herrmann@getautoma.com> - 2012-11-23 09:08 -0800
Re: Is it bad style to override the built-in function `type`? Terry Reedy <tjreedy@udel.edu> - 2012-11-23 13:35 -0500
Re: Is it bad style to override the built-in function `type`? Michael Herrmann <michael.herrmann@getautoma.com> - 2012-11-23 10:41 -0800
Re: Is it bad style to override the built-in function `type`? Cameron Simpson <cs@zip.com.au> - 2012-11-24 09:30 +1100
Re: Is it bad style to override the built-in function `type`? Michael Herrmann <michael.herrmann@getautoma.com> - 2012-11-24 14:32 -0800
Re: Is it bad style to override the built-in function `type`? Cameron Simpson <cs@zip.com.au> - 2012-11-25 09:47 +1100
Re: Is it bad style to override the built-in function `type`? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-25 04:06 +0000
Re: Is it bad style to override the built-in function `type`? Cameron Simpson <cs@zip.com.au> - 2012-11-25 17:33 +1100
Re: Is it bad style to override the built-in function `type`? Michael Herrmann <michael.herrmann@getautoma.com> - 2012-11-24 14:32 -0800
Re: Is it bad style to override the built-in function `type`? Michael Herrmann <michael.herrmann@getautoma.com> - 2012-11-23 10:41 -0800
Re: Is it bad style to override the built-in function `type`? Ramchandra Apte <maniandram01@gmail.com> - 2012-11-24 23:02 -0800
Re: Is it bad style to override the built-in function `type`? Michael Herrmann <michael.herrmann@getautoma.com> - 2012-11-29 03:46 -0800
Re: Is it bad style to override the built-in function `type`? rusi <rustompmody@gmail.com> - 2012-11-30 09:54 -0800
Re: Is it bad style to override the built-in function `type`? Michael Herrmann <michael.herrmann@getautoma.com> - 2012-12-03 02:57 -0800
csiph-web