Re: PyWart: More surpises via "implict conversion to boolean" (and other steaming piles!)

2014-02-13 Thread Ian Kelly
On Feb 12, 2014 9:16 PM, "Steven D'Aprano" wrote: > > On Tue, 11 Feb 2014 07:36:34 -0800, Travis Griggs wrote: > > > On Feb 10, 2014, at 10:30 PM, Steven D'Aprano > > wrote: > > > > > >>>1. Parenthesis should not be required for parameter- less > >>>functions. > >> > >> Of course they sho

Re: PyWart: More surpises via "implict conversion to boolean" (and other steaming piles!)

2014-02-13 Thread Chris Angelico
On Fri, Feb 14, 2014 at 1:58 AM, Roy Smith wrote: > In article , > Chris Angelico wrote: > >> Whether it's a module-level function, a bound method, a closure, or a >> callable object, a zero-arg function in Python always has some kind of >> implicit state. > > Sometimes, it has a *lot* of implic

Re: PyWart: More surpises via "implict conversion to boolean" (and other steaming piles!)

2014-02-13 Thread Roy Smith
In article , Chris Angelico wrote: > Whether it's a module-level function, a bound method, a closure, or a > callable object, a zero-arg function in Python always has some kind of > implicit state. Sometimes, it has a *lot* of implicit state: os.fork() -- https://mail.python.org/mailman/listi

Re: PyWart: More surpises via "implict conversion to boolean" (and other steaming piles!)

2014-02-13 Thread Tim Chase
On 2014-02-13 05:39, Tim Chase wrote: > def age(self, as_of=None): > if as_of is None: > as_of = datetime.date.today() > return as_of = self.dob and of course I mean return as_of - self.dob which is what I get for typing in the dark and the "-" and "=" keys are adjacent. :-/ -

Re: PyWart: More surpises via "implict conversion to boolean" (and other steaming piles!)

2014-02-13 Thread Tim Chase
On 2014-02-13 04:11, Steven D'Aprano wrote: > give_me_an_even_number() > => returns 42 > give_me_an_even_number() > => returns 23 > > Hmmm. There's a bug in give_me_an_even_number(). How do I reproduce > that bug? What arguments do I pass? Oh, the same no-arguments as > for the working call. > >

Re: PyWart: More surpises via "implict conversion to boolean" (and other steaming piles!)

2014-02-12 Thread Chris Angelico
On Thu, Feb 13, 2014 at 3:11 PM, Steven D'Aprano wrote: > Think about the difference in difficulty in confirming that > math.sin() of some value x returns the value 0.5, and confirming that > random.random() of some hidden state returns a specific value: > > py> assert math.sin(0.5235987755982989)

Re: PyWart: More surpises via "implict conversion to boolean" (and other steaming piles!)

2014-02-12 Thread Steven D'Aprano
On Tue, 11 Feb 2014 07:36:34 -0800, Travis Griggs wrote: > On Feb 10, 2014, at 10:30 PM, Steven D'Aprano > wrote: > > >>>1. Parenthesis should not be required for parameter- less >>>functions. >> >> Of course they should. Firstly, parameter-less functions are a code- >> smell, and ough

Re: PyWart: More surpises via "implict conversion to boolean" (and other steaming piles!)

2014-02-11 Thread Terry Reedy
On 2/11/2014 11:19 AM, Travis Griggs wrote: On Feb 11, 2014, at 7:52 AM, Chris Angelico wrote: So in that situation, the no-args call does make sense. Of course, this is a call to a function that does take args, but it's accepting all the defaults and providing no additional content. It's qui

Re: PyWart: More surpises via "implict conversion to boolean" (and other steaming piles!)

2014-02-11 Thread Travis Griggs
On Feb 11, 2014, at 7:52 AM, Chris Angelico wrote: > On Wed, Feb 12, 2014 at 2:36 AM, Travis Griggs wrote: >> OTOH, I’m not sure I’ve heard the parameters-less functions are a code one? >> Is it just loose functions that you’re referring to? As opposed to methods >> (which are just bound func

Re: PyWart: More surpises via "implict conversion to boolean" (and other steaming piles!)

2014-02-11 Thread Chris Angelico
On Wed, Feb 12, 2014 at 3:07 AM, Jussi Piitulainen wrote: > Travis Griggs writes: > >> in fact, methods with long parameter lists are generally seen as > > "If you have a predicate with ten arguments, you probably forgot some" > (heard long time ago over in the Prolog world). Conversely: "Thirte

Re: PyWart: More surpises via "implict conversion to boolean" (and other steaming piles!)

2014-02-11 Thread Jussi Piitulainen
Travis Griggs writes: > in fact, methods with long parameter lists are generally seen as "If you have a predicate with ten arguments, you probably forgot some" (heard long time ago over in the Prolog world). -- https://mail.python.org/mailman/listinfo/python-list

Re: PyWart: More surpises via "implict conversion to boolean" (and other steaming piles!)

2014-02-11 Thread Chris Angelico
On Wed, Feb 12, 2014 at 2:36 AM, Travis Griggs wrote: > OTOH, I’m not sure I’ve heard the parameters-less functions are a code one? > Is it just loose functions that you’re referring to? As opposed to methods > (which are just bound functions)? I could maybe accept that. But methods with > fewe

Re: PyWart: More surpises via "implict conversion to boolean" (and other steaming piles!)

2014-02-11 Thread Travis Griggs
On Feb 10, 2014, at 10:30 PM, Steven D'Aprano wrote: >> >>1. Parenthesis should not be required for parameter- less functions. > > Of course they should. Firstly, parameter-less functions are a code- > smell, and ought to be discouraged. Secondly, even if you have a good > reason for usin

Re: PyWart: More surpises via "implict conversion to boolean" (and other steaming piles!)

2014-02-11 Thread Tim Chase
On 2014-02-11 06:30, Steven D'Aprano wrote: > You need to understand the difference between syntax and semantics. > This is invalid English syntax: > > "Cat mat on sat the." > > This is valid syntax, but semantically wrong: > > "The mat sat on the cat." > > This is both syntactically and semant

Re: PyWart: More surpises via "implict conversion to boolean" (and other steaming piles!)

2014-02-10 Thread Steven D'Aprano
On Mon, 10 Feb 2014 10:45:40 -0800, Rick Johnson wrote: > ## START CODE ### > def foo(): > # foo represents a patternless function Patternless? I have never heard that term before in this context. Do you mean a parameter-less or argument-less functio

Re: PyWart: More surpises via "implict conversion to boolean" (and other steaming piles!)

2014-02-10 Thread Terry Reedy
On 2/10/2014 4:12 PM, Rotwang wrote: On 10/02/2014 18:45, Rick Johnson wrote: [...] 3. Implicit introspection is evil, i prefer all references to a callable's names to result in a CALL to that callable, not an introspection! So, for example, none of isinstance(x, myclass)

Re: PyWart: More surpises via "implict conversion to boolean" (and other steaming piles!)

2014-02-10 Thread Chris Angelico
On Tue, Feb 11, 2014 at 5:45 AM, Rick Johnson wrote: > if foo: # <- forgot parenthesis! > print 'implicit conversion to bool bites!' You also forgot the parentheses on the second line, and that's nothing to do with boolification :) ChrisA -- https://mail.python.org/mailman/listinfo/python-l

Re: PyWart: More surpises via "implict conversion to boolean" (and other steaming piles!)

2014-02-10 Thread Ned Batchelder
On 2/10/14 4:12 PM, Rotwang wrote: On 10/02/2014 18:45, Rick Johnson wrote: [...] 3. Implicit introspection is evil, i prefer all references to a callable's names to result in a CALL to that callable, not an introspection! So, for example, none of isinstance(x, myclass)

Re: PyWart: More surpises via "implict conversion to boolean" (and other steaming piles!)

2014-02-10 Thread Rotwang
On 10/02/2014 18:45, Rick Johnson wrote: [...] 3. Implicit introspection is evil, i prefer all references to a callable's names to result in a CALL to that callable, not an introspection! So, for example, none of isinstance(x, myclass) map(myfunc, range(10)) x = p

Re: PyWart: More surpises via "implict conversion to boolean" (and other steaming piles!)

2014-02-10 Thread Ned Batchelder
On 2/10/14 1:45 PM, Rick Johnson wrote: ## START CODE ### def foo(): # foo represents a patternless function # or method that returns a Boolean value # based on some internal test. # if 1==1: return True return False #

Re: PyWart: More surpises via "implict conversion to boolean" (and other steaming piles!)

2014-02-10 Thread Mark Lawrence
On 10/02/2014 18:45, Rick Johnson wrote: ## START CODE ### def foo(): # foo represents a patternless function # or method that returns a Boolean value # based on some internal test. # if 1==1: return True return False

PyWart: More surpises via "implict conversion to boolean" (and other steaming piles!)

2014-02-10 Thread Rick Johnson
## START CODE ### def foo(): # foo represents a patternless function # or method that returns a Boolean value # based on some internal test. # if 1==1: return True return False # # The fun begins when two tiny chars are forgott