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
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
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
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
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,
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?)
>
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
> 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
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
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
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
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
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://
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
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
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
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
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
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
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
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
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.
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
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
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
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
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: [
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
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
29 matches
Mail list logo