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


Groups > comp.lang.python > #33860

Re: Is it bad style to override the built-in function `type`?

Newsgroups comp.lang.python
Date 2012-11-23 10:41 -0800
References <d2e59ddf-d44c-44d9-91c5-539b03cfcfcb@googlegroups.com> <CAPM-O+znTEt0eTz=xvaGi6MOLhJaGM_uV-c904c+fFTL6ejD3A@mail.gmail.com> <mailman.237.1353695779.29569.python-list@python.org>
Subject Re: Is it bad style to override the built-in function `type`?
From Michael Herrmann <michael.herrmann@getautoma.com>
Message-ID <mailman.238.1353696074.29569.python-list@python.org> (permalink)

Show all headers | View raw


Thank you for your feedback. I sent the following reply to Joel but it didn't make it through to the mailing list: 

Hi Joel,

thanks for your reply. I can see why you think it's a bad idea. The reason why we want to call it `type` is that this is precisely the word that is most commonly used in our context, GUI automation. There are alternative names (see http://bit.ly/10aOy4H for a huge list) , but leaving aside the fact that Python has an overwriteable meaning for `type`, none fits quite as well. One of the main goals of our tool/API is to be as close to everyday English as possible, and thus hopefully to be intuitive also for novice users. For this reason it is very tempting for us to use `type`. Several people in the original thread http://bit.ly/10aOy4H have suggested `type` because it best fits our problem domain, and have said that they don't mind it overriding a built-in function.

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?

Thanks!
Michael

On Friday, November 23, 2012 7:36:20 PM UTC+1, Terry Reedy wrote:
> On 11/23/2012 11:22 AM, Joel Goldstick wrote:
> 
> >
> 
> >
> 
> >
> 
> > On Fri, Nov 23, 2012 at 11:12 AM, Michael Herrmann
> 
> > <Michael Herrmann>
> 
> > wrote:
> 
> >
> 
> >     Hi,
> 
> >
> 
> >     do you think it's bad style to override the built-in function
> 
> >     `type`? I'm co-developing a GUI automation library called Automa
> 
> >     (http://www.getautoma.com) and 'type' would be a very fitting name
> 
> >     for a function that generates artificial key strokes.
> 
> >
> 
> > Personally, I think this is a horrible idea.  On this list and the tutor
> 
> > list, people often use variable names that are already defined in the
> 
> > language.  It leads to non obvious errors -- especially when revisting
> 
> > old code.  Why not call the thing 'key_stroke'?
> 
> 
> 
> I agree.
> 
> 
> 
> -- 
> 
> Terry Jan Reedy

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


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