Re: Quick poll: gmean or geometric_mean

2016-07-09 Thread Peter Otten
Steven D'Aprano wrote:

> As requested in issue 27181 on the bug tracker, I'm adding functions to
> calculate the harmonic and geometric means to the statistics module.
> 
> I'd like to get a quick show of hands regarding the names. Which do you
> prefer?
> 
> hmean and gmean
> 
> harmonic_mean and geometric_mean

The long names. Life's too short for abbreviations.

> Remember that the arithmetic mean is just called "mean".

I think it's a safe bet that a user asking for the unqualified mean wants 
just that.

> http://bugs.python.org/issue27181


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Quick poll: gmean or geometric_mean

2016-07-09 Thread Stefan Behnel
Ethan Furman schrieb am 09.07.2016 um 08:27:
> On 07/08/2016 10:49 PM, Random832 wrote:
>> On Sat, Jul 9, 2016, at 01:26, Steven D'Aprano wrote:
> 
>>> hmean and gmean
>>>
>>> harmonic_mean and geometric_mean
>>
>> The latter, definitely.
> 
> My preference is also for the latter.  However, if the rest of the module
> is filled with abbreviated names you may as well be consistent with them.

+1 for consistency, but I'm just fine with the short names. It's in the
statistics module after all, so the context is very narrow and clear and
people who don't know which to use or what the one does that they find in a
given piece of code will have to read the docs and maybe fresh up their
rusty math memory anyway. Longer names don't help much with that.

If further clarity is needed in a given code context that uses a direct
name import, renaming the function at the same time is easy enough. I often
do that with "os.path.join", for example, which turns into "join_path" on
import. Same problem, easy solution.

Stefan


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Quick poll: gmean or geometric_mean

2016-07-09 Thread Ethan Furman

On 07/09/2016 03:23 AM, Stefan Behnel wrote:

Ethan Furman schrieb am 09.07.2016 um 08:27:

On 07/08/2016 10:49 PM, Random832 wrote:

On Sat, Jul 9, 2016, at 01:26, Steven D'Aprano wrote:



hmean and gmean

harmonic_mean and geometric_mean


The latter, definitely.


My preference is also for the latter.  However, if the rest of the module
is filled with abbreviated names you may as well be consistent with them.


+1 for consistency, but I'm just fine with the short names. It's in the
statistics module after all, so the context is very narrow and clear and
people who don't know which to use or what the one does that they find in a
given piece of code will have to read the docs and maybe fresh up their
rusty math memory anyway. Longer names don't help much with that.

If further clarity is needed in a given code context that uses a direct
name import, renaming the function at the same time is easy enough. I often
do that with "os.path.join", for example, which turns into "join_path" on
import. Same problem, easy solution.


+1

I would definitely need to read the docs, whatever the name.  ;)

--
~Ethan~

--
https://mail.python.org/mailman/listinfo/python-list


Re: Quick poll: gmean or geometric_mean

2016-07-09 Thread Jason Friedman
>
> +1 for consistency, but I'm just fine with the short names. It's in the
> statistics module after all, so the context is very narrow and clear and
> people who don't know which to use or what the one does that they find in a
> given piece of code will have to read the docs and maybe fresh up their
> rusty math memory anyway. Longer names don't help much with that.
>
> If further clarity is needed in a given code context that uses a direct
> name import, renaming the function at the same time is easy enough. I often
> do that with "os.path.join", for example, which turns into "join_path" on
> import. Same problem, easy solution.


+1
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Quick poll: gmean or geometric_mean

2016-07-09 Thread Michael Selik
On Sat, Jul 9, 2016 at 10:17 AM Jason Friedman  wrote:

> > +1 for consistency
>

What do other languages use?

Even though I generally prefer complete words instead of abbreviations, if
an abbreviation is a strong standard across many statistics modules (like
"stdev" instead of "standard_deviation"), then it's better to stay
consistent with that standard.
-- 
https://mail.python.org/mailman/listinfo/python-list


__qualname__ exposed as a local variable: standard?

2016-07-09 Thread carlosjosepita
Hi all,

I noticed __qualname__ is exposed by locals() while defining a class. This is 
handy but I'm not sure about its status: is it standard or just an artifact of 
the current implementation? (btw, the pycodestyle linter -former pep8- rejects 
its usage). I was unable to find any reference to this behavior in PEP 3155 nor 
in the language reference.

Thank you in advance
--
Carlos
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Namespaces are one honking great idea

2016-07-09 Thread carlosjosepita
Hi all,

although it doesn't fit the bill 100%, I sometimes use this extremely simple 
function as a decorator:

def new(call):
return call()


For example:

@new
class MySingleton:
x = 2
y = 2
def sum(self, x, y):
return x + y


@new
def my_obj():
x = 2
y = 2
def sum(x, y):
return x + y
return Bundle(locals())


where Bundle is a simple subclass of dict implementing __xxxattr__ dunder 
methods.

Cheers
--
Carlos


 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Quick poll: gmean or geometric_mean

2016-07-09 Thread Robert Kern

On 2016-07-09 17:13, Michael Selik wrote:

On Sat, Jul 9, 2016 at 10:17 AM Jason Friedman  wrote:


+1 for consistency


What do other languages use?


R, the most likely candidate, doesn't have them built-in.

scipy.stats uses gmean() and hmean()

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco

--
https://mail.python.org/mailman/listinfo/python-list


Re: Quick poll: gmean or geometric_mean

2016-07-09 Thread Michael Selik
On Sat, Jul 9, 2016, 12:57 PM Robert Kern  wrote:

> On 2016-07-09 17:13, Michael Selik wrote:
> > On Sat, Jul 9, 2016 at 10:17 AM Jason Friedman 
> wrote:
> >
> >>> +1 for consistency
> >
> > What do other languages use?
>
> R, the most likely candidate, doesn't have them built-in.
>
> scipy.stats uses gmean() and hmean()
>

SciPy also uses other obscure abbreviations. My least favorite is "eye".

My first thought at reading "hmean" might be horizontal mean, especially if
there were a vmean.

>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: __qualname__ exposed as a local variable: standard?

2016-07-09 Thread eryk sun
On Sat, Jul 9, 2016 at 4:08 AM,   wrote:
>
> I noticed __qualname__ is exposed by locals() while defining a class.

This is an undocumented implementation detail used to pass this
information to the metaclass. You'll also see __module__ and, if the
class has a docstring, __doc__. For CPython, this is implemented in
the functions compiler_class (for __module__ and __qualname__) and
compiler_body (for __doc__), which you'll find in Python/compile.c.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: the best online course

2016-07-09 Thread Malik Rumi
I want one of those "knuckle down and learn" classes. But even more than that, 
I want a class with a real teacher who is available to answer questions and 
explain things. I've done a lot of books and online video, but there's usually 
no help. If I search around long enough, I can often find an answer, but this 
is just way too fragmented for me. Where can I find classes like that - online 
- paid or free? Thanks.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Quick poll: gmean or geometric_mean

2016-07-09 Thread Chris Angelico
On Sat, Jul 9, 2016 at 3:26 PM, Steven D'Aprano  wrote:
> I'd like to get a quick show of hands regarding the names. Which do you
> prefer?
>
> hmean and gmean
>
> harmonic_mean and geometric_mean

I'd prefer the shorter names.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: the best online course

2016-07-09 Thread Chris Angelico
On Sun, Jul 10, 2016 at 7:37 AM, Malik Rumi  wrote:
> I want one of those "knuckle down and learn" classes. But even more than 
> that, I want a class with a real teacher who is available to answer questions 
> and explain things. I've done a lot of books and online video, but there's 
> usually no help. If I search around long enough, I can often find an answer, 
> but this is just way too fragmented for me. Where can I find classes like 
> that - online - paid or free? Thanks.
>

Yes, they definitely exist. I work with a company called Thinkful
(www.thinkful.com) which does what you're talking about - you get a
personal mentor with whom you meet regularly, plus access to a number
of experts. It's a paid course. There are other such courses around,
too, but I don't personally know their effectiveness.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: the best online course

2016-07-09 Thread Ethan Furman

On 07/09/2016 02:57 PM, Chris Angelico wrote:

On Sun, Jul 10, 2016 at 7:37 AM, Malik Rumi wrote:



I want one of those "knuckle down and learn" classes. But even more

>> than that, I want a class with a real teacher who is available to
>> answer questions and explain things. I've done a lot of books and
>> online video, but there's usually no help. If I search around long
>> enough, I can often find an answer, but this is just way too fragmented
>> for me. Where can I find classes like that - online - paid or free? 
Thanks.


Yes, they definitely exist. I work with a company called Thinkful
(www.thinkful.com) which does what you're talking about - you get a
personal mentor with whom you meet regularly, plus access to a number
of experts. It's a paid course. There are other such courses around,
too, but I don't personally know their effectiveness.


Udacity.com is another.  They have several free classes, or you can pay 
and get access to instructors.


--
~Ethan~

--
https://mail.python.org/mailman/listinfo/python-list


Re: the best online course

2016-07-09 Thread Chris Angelico
On Sun, Jul 10, 2016 at 9:09 AM, Ethan Furman  wrote:
> On 07/09/2016 02:57 PM, Chris Angelico wrote:
>>
>> On Sun, Jul 10, 2016 at 7:37 AM, Malik Rumi wrote:
>
>
>>> I want one of those "knuckle down and learn" classes. But even more
>
>>> than that, I want a class with a real teacher who is available to
>>> answer questions and explain things. I've done a lot of books and
>>> online video, but there's usually no help. If I search around long
>>> enough, I can often find an answer, but this is just way too fragmented
>>> for me. Where can I find classes like that - online - paid or free?
>>> Thanks.
>>
>>
>> Yes, they definitely exist. I work with a company called Thinkful
>> (www.thinkful.com) which does what you're talking about - you get a
>> personal mentor with whom you meet regularly, plus access to a number
>> of experts. It's a paid course. There are other such courses around,
>> too, but I don't personally know their effectiveness.
>
>
> Udacity.com is another.  They have several free classes, or you can pay and
> get access to instructors.

Yes, I hear a lot about Udacity. Has anyone taken any of the pay-for
classes? Are the instructors helpful, skilled, etc? Did it seem like
good value for money?

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Curious Omission In New-Style Formats

2016-07-09 Thread Lawrence D’Oliveiro
In printf-style formats, you can specify the number of digits for an integer 
separately from the field width. E.g.

>>> "%#0.5x" % 0x123
'0x00123'

but not in new-style formats:

>>> "{:#0.5x}".format(0x123)
Traceback (most recent call last):
  File "", line 1, in 
ValueError: Precision not allowed in integer format specifier

The field width itself doesn’t give the right number of digits in this case:

>>> "{:#05x}".format(0x123)
'0x123'

because you lose 2 characters for the “0x” prefix.
-- 
https://mail.python.org/mailman/listinfo/python-list