Re: list(), tuple() should not place at "Built-in functions" in documentation

2011-07-20 Thread Terry Reedy
On 7/20/2011 2:21 AM, Stefan Behnel wrote: Terry Reedy, 19.07.2011 18:31: Chapter 5 is mostly about the behavior of built-in class instances. For some classes, like range, instances only come from class calls and the behavior of instances is intimately tied to the constructor arguments. Having t

Re: list(), tuple() should not place at "Built-in functions" in documentation

2011-07-19 Thread Stefan Behnel
Terry Reedy, 19.07.2011 18:31: Chapter 5 is mostly about the behavior of built-in class instances. For some classes, like range, instances only come from class calls and the behavior of instances is intimately tied to the constructor arguments. Having the constructor described in C.5 might be use

Re: list(), tuple() should not place at "Built-in functions" in documentation

2011-07-19 Thread Terry Reedy
On 7/19/2011 2:52 AM, Raymond Hettinger wrote: On Jul 14, 6:21 pm, Inside wrote: As telling in the subject,because "list" and "tuple" aren't functions,they are types.Is that right? They are not instances of a class whose definition name includes the word 'Function'. They *are* things that ca

Re: list(), tuple() should not place at "Built-in functions" in documentation

2011-07-19 Thread Raymond Hettinger
On Jul 14, 6:21 pm, Inside wrote: > As telling in the subject,because "list" and "tuple" aren't functions,they > are types.Is that right? list() and tuple() are in the right place in the documentation because they would be harder to find if listed elsewhere. Tools like str(), int(), list(), tu

Re: list(), tuple() should not place at "Built-in functions" in documentation

2011-07-16 Thread Corey Richardson
Excerpts from Inside's message of Sat Jul 16 01:40:21 -0400 2011: > Supplement: > The assertion will not be handled anyway. > I want AssertionError raise as early as possible.(mentinoed before) An AssertionError is pretty useless, there are much better exceptions that you could (and should!) use,

Re: Type checking versus polymorphism (was: list(), tuple() should not place at "Built-in functions" in documentation)

2011-07-15 Thread Steven D'Aprano
Chris Rebert wrote: > On Fri, Jul 15, 2011 at 7:47 PM, Steven D'Aprano > wrote: > >> Assertions are for testing internal program logic, not for validation. >> >> (I don't even like using assert for testing. How do you test your code >> with assertions turned off if you use assert for testing?) >

Re: list(), tuple() should not place at "Built-in functions" in documentation

2011-07-15 Thread Inside
Supplement: The assertion will not be handled anyway. I want AssertionError raise as early as possible.(mentinoed before) -- http://mail.python.org/mailman/listinfo/python-list

Re: list(), tuple() should not place at "Built-in functions" in documentation

2011-07-15 Thread Inside
> Perhaps you meant this? > > assert isinstance(user, User) Yes I meant this,sorry,my mistake. Thx for your and Ben's feedbacks first,it's appreciated. your points is taken by me,but I want to make my opinion more clearly. The assertion is JUST show to my function call

Re: Type checking versus polymorphism (was: list(), tuple() should not place at "Built-in functions" in documentation)

2011-07-15 Thread Chris Rebert
On Fri, Jul 15, 2011 at 7:47 PM, Steven D'Aprano wrote: > Assertions are for testing internal program logic, not for validation. > > (I don't even like using assert for testing. How do you test your code with > assertions turned off if you use assert for testing?) I would think that would only m

Re: list(), tuple() should not place at "Built-in functions" in documentation

2011-07-15 Thread Steven D'Aprano
Inside wrote: > Why I use assertion,please check this code: > """ > class User(object):pass > > class Student(User):pass > > class Professional(User):pass > > def add(user): > assert(user, User) This does not do what you think it does. All it does is, in some Python versions, print Synta

Re: Type checking versus polymorphism (was: list(), tuple() should not place at "Built-in functions" in documentation)

2011-07-15 Thread Steven D'Aprano
Ben Finney wrote: [...snip explanation of duck-typing...] > If you don't have comprehensive unit tests, that's where you should put > your effort of strict interface testing. Not type assertions in the > application code. I agree with everything Ben said here, but he has missed something even mor

Re: Liskov substitution principle (was: list(), tuple() should not place at "Built-in functions" in documentation)

2011-07-15 Thread Chris Angelico
On Sat, Jul 16, 2011 at 10:04 AM, Ben Finney wrote: >        def study(self, subject): >            raise NotImplementedError > > See? We can have overstretched analogies *and* remain within the Liskov > substitution principle. > Hehe! Of course I was speaking utterly in jest, but this raises (so

Liskov substitution principle (was: list(), tuple() should not place at "Built-in functions" in documentation)

2011-07-15 Thread Ben Finney
Chris Angelico writes: > The analogy with reality breaks down a bit here. I've seen plenty of > students with no idea of what it means to study. But Python can handle > that too - just 'del' the method in the subclass. No, please don't. That would break the Liskov substitution principle https://

Re: list(), tuple() should not place at "Built-in functions" in documentation

2011-07-15 Thread Chris Angelico
On Sat, Jul 16, 2011 at 5:53 AM, Inside wrote: > def add(users): >    assert(users, (tuple, list)) >    #If necessary I'll also check every obj in the sequence to see whether > it's a User. > > I just follow some coding rules of me: > 1. Controlling "input" strictly. > 2. In a function keep doubt

Type checking versus polymorphism (was: list(), tuple() should not place at "Built-in functions" in documentation)

2011-07-15 Thread Ben Finney
Inside writes: > I just follow some coding rules of me: > 1. Controlling "input" strictly. Asserting that the input is of a specific type is too strict. Does your code work if the input is not a list or tuple? I suspect strongly that the answer is yes, it works fine with any sequence, even ones

Re: list(), tuple() should not place at "Built-in functions" in documentation

2011-07-15 Thread Stefan Behnel
Terry Reedy, 15.07.2011 05:00: On 7/14/2011 9:51 PM, Ben Finney wrote: Steven D'Aprano writes: Inside wrote: As telling in the subject,because "list" and "tuple" aren't functions,they are types.Is that right? At one time (before 2.2), they were functions and not classes. They are still f

Re: list(), tuple() should not place at "Built-in functions" in documentation

2011-07-15 Thread Inside
Why I use assertion,please check this code: """ class User(object):pass class Student(User):pass class Professional(User):pass def add(user): assert(user, User) def add(users): assert(users, (tuple, list)) #If necessary I'll also check every obj in the sequence to see whether it's

Re: list(), tuple() should not place at "Built-in functions" in documentation

2011-07-15 Thread Carl Banks
On Thursday, July 14, 2011 8:00:16 PM UTC-7, Terry Reedy wrote: > I once proposed, I believe on the tracker, that 'built-in functions' be > expanded to 'built-in function and classes'. That was rejected on the > basis that people would then expect the full class documentation that is > in the 'b

Re: list(), tuple() should not place at "Built-in functions" in documentation

2011-07-15 Thread bruno.desthuilli...@gmail.com
On Jul 15, 9:27 am, "bruno.desthuilli...@gmail.com" wrote: > On Jul 15, 4:58 am, Inside wrote: > > > Hey guy,thx for you feedback first. > > > But I can't follow your opinion.Why?because of the list & tuple are placed > > at built-in function,so before I type 'list' unintentionally on the pyshel

Re: list(), tuple() should not place at "Built-in functions" in documentation

2011-07-15 Thread bruno.desthuilli...@gmail.com
On Jul 15, 4:58 am, Inside wrote: > Hey guy,thx for you feedback first. > > But I can't follow your opinion.Why?because of the list & tuple are placed at > built-in function,so before I type 'list' unintentionally on the pyshell and > it show me "", I never know that the name 'list' is a type,I

Re: list(), tuple() should not place at "Built-in functions" in documentation

2011-07-14 Thread Chris Angelico
On Fri, Jul 15, 2011 at 11:32 AM, Steven D'Aprano wrote: > Inside wrote: > >> As telling in the subject,because "list" and "tuple" aren't functions,they >> are types.Is that right? > > Yes they are types. But they can still be used as functions. Does it matter? Python is duck-typed, even in its d

Re: list(), tuple() should not place at "Built-in functions" in documentation

2011-07-14 Thread Ben Finney
Inside writes: > But I can't follow your opinion.Why?because of the list & tuple are > placed at built-in function,so before I type 'list' unintentionally on > the pyshell and it show me "", I never know that the name > 'list' is a type,I used to consider it's a function to produce 'list' > type.

Re: list(), tuple() should not place at "Built-in functions" in documentation

2011-07-14 Thread Terry Reedy
On 7/14/2011 9:51 PM, Ben Finney wrote: Steven D'Aprano writes: Inside wrote: As telling in the subject,because "list" and "tuple" aren't functions,they are types.Is that right? At one time (before 2.2), they were functions and not classes. Yes they are types. But they can still be used

Re: list(), tuple() should not place at "Built-in functions" in documentation

2011-07-14 Thread Inside
Hey guy,thx for you feedback first. But I can't follow your opinion.Why?because of the list & tuple are placed at built-in function,so before I type 'list' unintentionally on the pyshell and it show me "", I never know that the name 'list' is a type,I used to consider it's a function to produce

Re: list(), tuple() should not place at "Built-in functions" in documentation

2011-07-14 Thread Corey Richardson
Excerpts from rantingrick's message of Thu Jul 14 21:36:15 -0400 2011: > On Jul 14, 8:21pm, Inside wrote: > > As telling in the subject,because "list" and "tuple" aren't functions,they > > are types.Is that right? > > You wanna see some warts in the docs. Okay, try to use the search box > to fin

Re: list(), tuple() should not place at "Built-in functions" in documentation

2011-07-14 Thread Ben Finney
Steven D'Aprano writes: > Inside wrote: > > > As telling in the subject,because "list" and "tuple" aren't functions,they > > are types.Is that right? > > Yes they are types. But they can still be used as functions. Does it matter? As a newcomer to the documentation I looked fruitlessly in the ta

Re: list(), tuple() should not place at "Built-in functions" in documentation

2011-07-14 Thread rantingrick
On Jul 14, 8:21 pm, Inside wrote: > As telling in the subject,because "list" and "tuple" aren't functions,they > are types.Is that right? You wanna see some warts in the docs. Okay, try to use the search box to find list, dict, or tuple and see what happens... http://docs.python.org/ Search: [

Re: list(), tuple() should not place at "Built-in functions" in documentation

2011-07-14 Thread Steven D'Aprano
Inside wrote: > As telling in the subject,because "list" and "tuple" aren't functions,they > are types.Is that right? Yes they are types. But they can still be used as functions. Does it matter? -- Steven -- http://mail.python.org/mailman/listinfo/python-list

list(), tuple() should not place at "Built-in functions" in documentation

2011-07-14 Thread Inside
As telling in the subject,because "list" and "tuple" aren't functions,they are types.Is that right? -- http://mail.python.org/mailman/listinfo/python-list