Re: Python slang

2016-08-06 Thread BartC

On 06/08/2016 04:10, Steven D'Aprano wrote:

On Sat, 6 Aug 2016 10:13 am, Chris Angelico wrote:


On Sat, Aug 6, 2016 at 9:21 AM, Marco Sulla
 wrote:

I want to clarify that when I say "different from the other
languages", I mean "different from the most used languages", that in
my mind are C/C++, C#, Java, PHP and Javascript, mainly.



Ah, well, that's because those are all one family of languages. If
instead you were familiar with four LISPy languages, you'd have a
completely different set of expectations.


Furthermore, that's only six languages out of, what, a couple of thousand
known programming languages?

And even languages clearly in the C family, like Objective-C, D, Swift, Java
and Go, can end up using quite different syntax and execution models.

It amuses me when people know a handful of languages, all clearly derived
from each other, and think that's "most" languages. That's like somebody
who knows Dutch, Afrikaans and German[1] being surprised that Russian,
Cantonese, Hebrew and Vietnamese don't follow the same language rules
as "most languages".


The analogy isn't quite right. Most programming languages use English 
keywords.


It's more like why US English uses words like "windshield", "hood" and 
"trunk" instead of the proper "windscreen", "bonnet" and "boot".


Oddly, for all its dynamism, Python doesn't allow aliases for its 
keywords to allow for personal taste.


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


Re: datetime vs Arrow vs Pendulum vs Delorean vs udatetime

2016-08-06 Thread Mario R. Osorio
... so you decided to start the post already hijacked by yourself ...

very clever!!


On Friday, August 5, 2016 at 8:19:53 PM UTC-4, bream...@gmail.com wrote:
> On Friday, August 5, 2016 at 7:15:37 PM UTC+1, DFS wrote:
> > On 8/4/2016 6:41 PM, breamore...@gmail.com wrote:
> > > Fascinating stuff here
> > > https://aboutsimon.com/blog/2016/08/04/datetime-vs-Arrow-vs-Pendulum-vs-Delorean-vs-udatetime.html
> > >
> > >  I hereby ask that only people who know and use Python reply, not the
> > > theoretical idiots who could not fight their way out of a wet paper
> > > bag.  Thank you.
> > >
> > > Kindest regards.
> > >
> > > Mark Lawrence.
> > 
> > 
> > What would really be nice is if the idiot who asked for a reply actually 
> > posed a question.
> 
> I do not need to ask questions, I simply put the reference forward as being 
> interesting.  Regretably so many threads are now hijacked so rather than 
> discussing Python, which everything in the reference does, the people who are 
> more interested in the theory than the practice take over, such that the next 
> thing you know you're discussing anything except Python.  I'll be blunt, I 
> don't give a crap about Scheme, Lisp, Pike, Go, Rust, or any other language 
> on this, the main *PYTHON* mailing list/newsgroup.  I further don't give a 
> crap about filosofy.  In future can we please keep this place to discussing 
> Python.  If you want to discuss something else, why not go and find a more 
> suitable venue, whereby, for example, you can chat about the problems with 
> Unicode in Python3 with the RUE to your hearts content?
> 
> Kindest regards.
> 
> Mark Lawrence.

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


Out of line posts (was datetime vs Arrow vs Pendulum vs Delorean vs udatetime)

2016-08-06 Thread Rustom Mody
On Saturday, August 6, 2016 at 5:19:08 PM UTC+5:30, Mario R. Osorio wrote:
> ... so you decided to start the post already hijacked by yourself ...
> 
> very clever!!

If you see 
https://mail.python.org/pipermail/python-list/2016-August/thread.html#start
you will see that there was only one post there — by Steven d'Aprano
And now yours.

IOW both Mark Lawrence and “DFS” have been banned (it seems) at least from
the mailing list.

They do appear on google-groups — ironic given Mark’s feelings for the same

To DFS: I believe you were banned for some insults/profanities.  Would it not
be a good idea to desist and stay within the ambit of this list’s subject?
I would expect in due course the ban would be lifted.

Would give the same advice to Mark… not sure if he’s listening

[Personal note]  I don’t like bans and have on occasion disagreed with the mods
on that.  Unfortunately it seems that their judgement is proving more right
than mine  :-(
-- 
https://mail.python.org/mailman/listinfo/python-list


Ned Batchelder: Loop Like A Native

2016-08-06 Thread breamoreboy
A couple or three years old but this is well worth seeing for anybody, 
regardless of your Python expertise. http://nedbatchelder.com/text/iter.html

Kindest regards.

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


Re: Capturing the bad codes that raise UnicodeError exceptions during decoding

2016-08-06 Thread Matt Ruffalo
On 2016-08-04 15:45, Random832 wrote:
> On Thu, Aug 4, 2016, at 15:22, Malcolm Greene wrote:
>> Hi Chris,
>>
>> Thanks for your suggestions. I would like to capture the specific bad
>> codes *before* they get replaced. So if a line of text has 10 bad codes
>> (each one raising UnicodeError), I would like to track each exception's
>> bad code but still return a valid decode line when finished. 
> Look into writing your own error handler - there's enough information
> provided to do this.
>
> https://docs.python.org/3/library/codecs.html
You could also use the 'surrogateescape' error handler, and count the
number of high surrogate characters (each of which represents a byte
that couldn't be decoded under the specified encoding). This will give
you a text string, which you can then process to replace code points in
the range U+DC80 - U+DCFF (inclusive).

"""
In [1]: bad_byte_string = b'Some \xf9 odd \x84 bytes \xc2 here'

In [2]: decoded = bad_byte_string.decode(errors='surrogateescape')

In [3]: decoded
Out[3]: 'Some \udcf9 odd \udc84 bytes \udcc2 here'

In [4]: high_surrogate_range = range(0xdc80, 0xdd00)

In [5]: sum(ord(char) in high_surrogate_range for char in decoded)
Out[5]: 3

In [6]: from collections import Counter

In [7]: from typing import Iterable

In [8]: def get_bad_bytes(string: str) -> Iterable[bytes]:
...: for char in string:
...: if ord(char) in high_surrogate_range:
...: yield char.encode(errors='surrogateescape')
...:

In [9]: bad_byte_counts = Counter(get_bad_bytes(decoded))

In [10]: bad_byte_counts
Out[10]: Counter({b'\x84': 1, b'\xc2': 1, b'\xf9': 1})
"""

MMR...

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


Re: Python slang

2016-08-06 Thread Marco Sulla via Python-list
On 6 August 2016 at 00:31, Chris Angelico  wrote:
> On Sat, Aug 6, 2016 at 8:00 AM, Marco Sulla via Python-list
>  wrote:
> This isn't slang; it's jargon

Right.


>> * `raise` instead of `throw`
>
> Quite a few other languages talk about raising exceptions rather than
> throwing them. Those would be the two most common terms, I think.
>
>> * `self` instead of `this` (I know, it's not enforced, but it's a de
>> facto standard and some IDEs like PyDev gives you an error if you
>> declare a non-static method without `self` as first parameter)
>
> Smalltalk and friends also use "self", so again, this would be the
> other common word for the parameter.
>
>> * `str.strip()` instead of `str.trim()`
>
> Another case where both words are in common use.

I want to clarify that when I say "different from the other
languages", I mean "different from the most used languages", that in
my mind are C/C++, C#, Java, PHP and Javascript, mainly.


>> * `dict` instead of `map`
>
> "map" has many other meanings (most notably the action wherein you
> call a function on every member of a collection to produce another
> collection).

Well, the word `map` of the `map` function is a verb. IMO there would
be no ambiguity.


>> * `list.append()` instead of `list.push()`
>
> Better description of what it does, IMO. It's adding something to the
> end of the list - appending to the list.

I agree.


>> * and furthermore much abbreviation, like `str` instead of `string`
>> and `len()` instead of `length()`, that seems to contrast with the
>> readability goal of Python.
>
> Brevity can improve clarity, if it is obtained without the expense of
> accuracy.

I agree it's not hard to understand that `str` is the string type and
`len()` is the function that gives you the length, even if you don't
know Python (and it's shorter to type...) But it's hard to remember,
in particular if you code also in other languages. When I come back to
Python, I always ends to write  `somelist.length` instead of
`len(somelist)`, some arcane words come out my mouth and a little
fairy dies.


> Hope that helps a bit!

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


How do I make a game in Python ?

2016-08-06 Thread Cai Gengyang
How do I make a game in Python ?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python slang

2016-08-06 Thread Michael Selik via Python-list
On Sat, Aug 6, 2016, 10:10 AM Marco Sulla via Python-list <
python-list@python.org> wrote:

> On 6 August 2016 at 00:31, Chris Angelico  wrote:
> > On Sat, Aug 6, 2016 at 8:00 AM, Marco Sulla via Python-list
> >  wrote:
> >> * `dict` instead of `map`
> >
> > "map" has many other meanings (most notably the action wherein you
> > call a function on every member of a collection to produce another
> > collection).
>
> Well, the word `map` of the `map` function is a verb. IMO there would
> be no ambiguity.
>

Are you thinking of Lisp-2 where functions have a separate namespace from
everything else?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python slang

2016-08-06 Thread Terry Reedy

On 8/6/2016 2:30 AM, Michael Selik wrote:


When people ask me why the core classes are lowercased,


Int, float, list, dict, etc were once functions that return objects of 
type 'int', 'float', 'list', 'dict', etc, before they became 'new-style 
classes', which are not just 'classes'.  The lowercasing was maintained 
as new builting classes were added.



--
Terry Jan Reedy

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


Re: Python slang

2016-08-06 Thread Chris Angelico
On Sun, Aug 7, 2016 at 5:17 AM, Marco Sulla  wrote:
>
> Nope, I was thinking that "map()" should be a method of an iterable.
> But this is another topic :)

The problem with that is that it has to become a method of _every_
iterable type, which means it becomes part of the protocol of
iterables. Much easier to make it a built-in function, which can then
accept any iterable based only on the __iter__ method.

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


Re: Python slang

2016-08-06 Thread Bernd Nawothnig
On 2016-08-06, Chris Angelico wrote:
> On Sat, Aug 6, 2016 at 11:14 AM, Steven D'Aprano
> wrote:
>>> I don't ask about `None` instead of `null` because I suppose here it's
>>> a matter of disambiguation (null, in many languages, is not equal to
>>> null).
>>
>> Really? Which languages? That's not true in Pascal, C, Ruby or
>> Javascript.
>>
>
> SQL (shown here with PostgreSQL's CLI):
>
> rosuav=> \pset null NULL
> Null display is "NULL".
> rosuav=> select NULL = NULL;
>  ?column?
> --
>  NULL
> (1 row)
>
> But SQL's NULL is a cross between C's NULL, IEEE's NaN, Cthulhu, and
> Emrakul.

SQL NULL has the semantic of "unknown". So if one or both operands of
a comparison (or any other operation) are unknown the result is
unknown too. And that means NULL.

That is also the reason why you have the keyword STRICT when declaring
a function in PostgreSQL. If only one parameter of the function is
NULL and the result depends directly on the parameter the planner can
then automatically skip the function call completely und replace the
result by NULL without any need to analyse or enter the function body.




Bernd

-- 
no time toulouse
-- 
https://mail.python.org/mailman/listinfo/python-list


where is it

2016-08-06 Thread Dave via Python-list
I am trying to associate the .py file extension with idle...where IS idle?  
Can you make it a bit more difficult to load/use your software please.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python slang

2016-08-06 Thread Marco Sulla via Python-list
On 6 August 2016 at 20:03, Michael Selik  wrote:
> On Sat, Aug 6, 2016, 10:10 AM Marco Sulla via Python-list
>  wrote:
>>
>> On 6 August 2016 at 00:31, Chris Angelico  wrote:
>> > "map" has many other meanings (most notably the action wherein you
>> > call a function on every member of a collection to produce another
>> > collection).
>>
>> Well, the word `map` of the `map` function is a verb. IMO there would
>> be no ambiguity.
>
>
> Are you thinking of Lisp-2 where functions have a separate namespace from
> everything else?

Nope, I was thinking that "map()" should be a method of an iterable.
But this is another topic :)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python slang

2016-08-06 Thread Marco Sulla via Python-list
On 6 August 2016 at 02:13, Chris Angelico  wrote:
> On Sat, Aug 6, 2016 at 9:21 AM, Marco Sulla
>  wrote:
>> I want to clarify that when I say "different from the other
>> languages", I mean "different from the most used languages", that in
>> my mind are C/C++, C#, Java, PHP and Javascript, mainly.
>>
>
> Ah, well, that's because those are all one family of languages. If
> instead you were familiar with four LISPy languages, you'd have a
> completely different set of expectations.

Well, they are the most used languages. I think about the 80% of
programmers knows at least one of that languages. It's more simple to
learn a new language if it's similar to the others.


>> I agree it's not hard to understand that `str` is the string type and
>> `len()` is the function that gives you the length, even if you don't
>> know Python (and it's shorter to type...) But it's hard to remember,
>> in particular if you code also in other languages. When I come back to
>> Python, I always ends to write  `somelist.length` instead of
>> `len(somelist)`, some arcane words come out my mouth and a little
>> fairy dies.
>>
>
> You open your mouth and a fairy dies hmm. Can I offer you a breath mint? 
> :)

Do you have also a plenary indulgence?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python slang

2016-08-06 Thread Marco Sulla via Python-list
On 6 August 2016 at 03:14, Steven D'Aprano  wrote:
> On Sat, 6 Aug 2016 08:00 am, Marco Sulla wrote:
>> I'm referring to:
>> * `except` instead of `catch`
>
> Because this isn't a game of "catch the ball". They're called "exceptions",
> not "catchions". You *try* something, and if an *exception* happens, the
> except block runs.

So if I try to pick up a girl, I have to knock back the refuse?


>> * `self` instead of `this` (I know, it's not enforced, but it's a de
>> facto standard and some IDEs like PyDev gives you an error if you
>> declare a non-static method without `self` as first parameter)
>
> Because "this" is a stupid name.
>
> In English, we refer to ourselves in the first person as I, me, myself, and
> sometimes "self", never as "this". One can say "this one has a hat", for
> example, but it sounds weird, like something the Borg would say about a
> specific Borg unit.

It's simply a matter of point of view. In the point of view of class,
you are referring to the class itself, so "self" it's a good word.
>From the point of view of the programmer, you're referring to this
class, so "this" is a good word as well. I don't see a semantic
advantage of "self".


>> * `dict` instead of `map`
>
> Because "map" is a piece of paper showing a visual representation of a
> territory, and a dict (dictionary) is a set of words (the keys) followed by
> their definitions (the values).

If map is only a piece of paper, dictionary is only a book, isn't it?
Dictionary is a book, and inside it there's a set of words followed by
their definitions, as you said.
Map is a piece of paper, and every element of the map represent some
other element, in a 1-1 relationship.


>> * `str.strip()` instead of `str.trim()`
>
> Because "trim" is a stupid name for stripping whitespace from the ends of a
> string. When you trim hair or a plant, you unconditionally cut it and make
> it shorter.

Not at all. "trim" word is used when you have to remove something that
is useless, usually. On the contrary, "strip" can be used also in
other means.


>> * `True`, `False` and None instead of `true`, `false` and `none` (they
>> seems classes)
>
> You'd have to ask other languages why they use 'true', 'false' and 'none'
> (they seem like ordinary variables).

I think you find the reason. Not sure it was a good idea (also vim has
syntax highlighting).


>> * and furthermore much abbreviation, like `str` instead of `string`
>> and `len()` instead of `length()`, that seems to contrast with the
>> readability goal of Python.
>
> Just because something is short doesn't make it less readable. According to
> Wolfram Alpha, the average length of words in English is 5.1 characters:
>
> http://www.wolframalpha.com/input/?i=average+english+word+length
>
> but of the ten most common words themselves, nine are of three or fewer
> characters:
>
> "the of to and a in is it you that"

And according to Wolfram Alpha, the readability of Huckleberry Finn is
5.5. I think it doesn't fit in this discussion in the same way :P
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python slang

2016-08-06 Thread Marco Sulla via Python-list
On 6 August 2016 at 03:35, Chris Angelico  wrote:
> On Sat, Aug 6, 2016 at 11:14 AM, Steven D'Aprano
>  wrote:
>>> I don't ask about `None` instead of `null` because I suppose here it's
>>> a matter of disambiguation (null, in many languages, is not equal to
>>> null).
>>
>> Really? Which languages? That's not true in Pascal, C, Ruby or Javascript.
>>
>
> SQL (shown here with PostgreSQL's CLI):
>
> rosuav=> \pset null NULL
> Null display is "NULL".
> rosuav=> select NULL = NULL;
>  ?column?
> --
>  NULL
> (1 row)
>
> But SQL's NULL is a cross between C's NULL, IEEE's NaN, Cthulhu, and Emrakul.

Yes, I was thinking manly to SQL. That furthermore is NOT a
programming language. So I suppose I have also to ask why "None"
instead of "Null"
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python slang

2016-08-06 Thread Chris Angelico
On Sun, Aug 7, 2016 at 5:37 AM, Bernd Nawothnig
 wrote:
>> But SQL's NULL is a cross between C's NULL, IEEE's NaN, Cthulhu, and
>> Emrakul.
>
> SQL NULL has the semantic of "unknown". So if one or both operands of
> a comparison (or any other operation) are unknown the result is
> unknown too. And that means NULL.

That's not entirely accurate, and it doesn't explain why NULL
sometimes behaves as if it's a genuine value, and sometimes as if it's
completely not there. For instance, taking the average of a column of
values ignores NULLs completely, and COUNT(column) is the same as
COUNT(column) WHERE column IS NOT NULL; but in some situations it
behaves more like NaN:

rosuav=> select null or true, null or false, null and true, null and false;
 ?column? | ?column? | ?column? | ?column?
--+--+--+--
 t| NULL | NULL | f
(1 row)

Anything "or true" has to be true, so NULL OR TRUE is true. And then
there are the times when NULL acts like a completely special value,
for instance in a foreign key - it means "there isn't anything on the
other end of this relationship", and is perfectly legal. Or in a
SELECT DISTINCT, where NULL behaves just like any other value - if
there are any NULL values in the column, you get back exactly one NULL
in the result.

So Innistrad's plot becomes far simpler. Jace Beleren went mad because
Emrakul tried to explain SQL's NULL to him.

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


Re: Python slang

2016-08-06 Thread Michael Torrie
On 08/05/2016 07:14 PM, Steven D'Aprano wrote:
> In English, we refer to ourselves in the first person as I, me, myself, and
> sometimes "self", never as "this". One can say "this one has a hat", for
> example, but it sounds weird, like something the Borg would say about a
> specific Borg unit.

Sadly it has become an epidemic of late for folks to misuse the word,
"myself."  I think it comes from people not wanting to sound
presumptuous when referring to themselves.  It drives me crazy to hear
so many people say something like, "this research was done by myself and
my colleague Bob." No, this research was done by my colleague Bob and I.
 Or this research was just only by me.

However I have no problem with Python programmers using self in their code!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python slang

2016-08-06 Thread Ian Kelly
On Aug 6, 2016 2:10 PM, "Marco Sulla via Python-list" <
python-list@python.org> wrote:


Yes, I was thinking manly to SQL. That furthermore is NOT a
programming language.


Why not? It's claimed to be Turing complete.

http://beza1e1.tuxen.de/articles/accidentally_turing_complete.html
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python slang

2016-08-06 Thread Chris Angelico
On Sun, Aug 7, 2016 at 7:33 AM, Michael Torrie  wrote:
> Sadly it has become an epidemic of late for folks to misuse the word,
> "myself."  I think it comes from people not wanting to sound
> presumptuous when referring to themselves.  It drives me crazy to hear
> so many people say something like, "this research was done by myself and
> my colleague Bob." No, this research was done by my colleague Bob and I.
>  Or this research was just only by me.
>

More likely, the correct version is "this research was done by my
colleague Bob, while I looked on". :D

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


Re: How do I make a game in Python ?

2016-08-06 Thread Ian Kelly
On Aug 6, 2016 11:57 AM, "Cai Gengyang"  wrote:

How do I make a game in Python ?


import random

answer = random.randint(0, 100)
while True:
guess = input("What number am I thinking of? ")
if int(guess) == answer:
print("Correct!")
break
print("Wrong!")

And now you've made a game in Python.


On Aug 6, 2016 11:57 AM, "Cai Gengyang"  wrote:

> How do I make a game in Python ?
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python slang

2016-08-06 Thread Ian Kelly
On Aug 6, 2016 3:36 PM, "Michael Torrie"  wrote:

Sadly it has become an epidemic of late for folks to misuse the word,
"myself."  I think it comes from people not wanting to sound
presumptuous when referring to themselves.  It drives me crazy to hear
so many people say something like, "this research was done by myself and
my colleague Bob." No, this research was done by my colleague Bob and I.


"by my colleague Bob and *me*". If you're going to gripe about word usage
(not grammar, since "myself" is grammatically correct), at least correct it
correctly.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How do I make a game in Python ?

2016-08-06 Thread Cai Gengyang
As in, any recommended websites that helps users create complex games in Python 
?


On Sunday, August 7, 2016 at 5:41:25 AM UTC+8, Ian wrote:
> On Aug 6, 2016 11:57 AM, "Cai Gengyang"  wrote:
> 
> How do I make a game in Python ?
> 
> 
> import random
> 
> answer = random.randint(0, 100)
> while True:
> guess = input("What number am I thinking of? ")
> if int(guess) == answer:
> print("Correct!")
> break
> print("Wrong!")
> 
> And now you've made a game in Python.
> 
> 
> On Aug 6, 2016 11:57 AM, "Cai Gengyang"  wrote:
> 
> > How do I make a game in Python ?
> > --
> > https://mail.python.org/mailman/listinfo/python-list
> >

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


Re: How do I make a game in Python ?

2016-08-06 Thread Ned Batchelder
On Saturday, August 6, 2016 at 5:51:40 PM UTC-4, Cai Gengyang wrote:
> As in, any recommended websites that helps users create complex games in 
> Python ?

http://inventwithpython.com/

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


Re: Ned Batchelder: Loop Like A Native

2016-08-06 Thread Lawrence D’Oliveiro
On Saturday, August 6, 2016 at 12:08:30 PM UTC+12, bream...@gmail.com wrote:
> A couple or three years old but this is well worth seeing for anybody,
> regardless of your Python expertise. http://nedbatchelder.com/text/iter.html

A loop like

for i in ... :
   ...
   if ... cond ... :
   break
   ...
#end for

actually has two different ways to terminate. Is there any good reason for them 
to be written two different ways?
-- 
https://mail.python.org/mailman/listinfo/python-list


Announcing HarfPy

2016-08-06 Thread Lawrence D’Oliveiro
HarfPy  is a Python binding for the HarfBuzz 
typographic shaping library. It is designed to work in conjunction with my 
Python wrappers for the other major parts of the Linux typography stack:

* Qahirah  -- my binding for the
  Cairo graphics library
* python_freetype  -- my
  binding for FreeType
* PyBidi  -- my binding for FriBidi

Some simple examples of it in action are here 
, output from which may be viewed here 
.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python slang

2016-08-06 Thread Grant Edwards
On 2016-08-06, Michael Torrie  wrote:

> Sadly it has become an epidemic of late for folks to misuse the
> word, "myself."  I think it comes from people not wanting to sound
> presumptuous when referring to themselves.  It drives me crazy to
> hear so many people say something like, "this research was done by
> myself and my colleague Bob." No, this research was done by my
> colleague Bob and I.

Sadly it has become an epidemic of late for folks to misuse the
subjective pronoun "I" when the objective pronoun "me" is correct. It
drives me crazy to hear people say something like "this research was
done by my colleague Bob and I."  No, this research was done by my
colleague Bob and me.

:)

Unfortunately, the Internet allows no posting containing grammar
criticism to be grammatically correct.

[Including this one, which I'm sure has an error in grammar -- I just
can't find it.]

--
Grant

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


Re: Ned Batchelder: Loop Like A Native

2016-08-06 Thread Ned Batchelder
On Saturday, August 6, 2016 at 6:06:27 PM UTC-4, Lawrence D’Oliveiro wrote:
> On Saturday, August 6, 2016 at 12:08:30 PM UTC+12, bream...@gmail.com wrote:
> > A couple or three years old but this is well worth seeing for anybody,
> > regardless of your Python expertise. http://nedbatchelder.com/text/iter.html
> 
> A loop like
> 
> for i in ... :
>...
>if ... cond ... :
>break
>...
> #end for
> 
> actually has two different ways to terminate. Is there any good reason for 
> them to be written two different ways?

Didn't we already do this debate?

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


Re: Ned Batchelder: Loop Like A Native

2016-08-06 Thread Ned Batchelder
On Saturday, August 6, 2016 at 7:36:06 PM UTC-4, Ned Batchelder wrote:
> On Saturday, August 6, 2016 at 6:06:27 PM UTC-4, Lawrence D’Oliveiro wrote:
> > On Saturday, August 6, 2016 at 12:08:30 PM UTC+12, bream...@gmail.com wrote:
> > > A couple or three years old but this is well worth seeing for anybody,
> > > regardless of your Python expertise. 
> > > http://nedbatchelder.com/text/iter.html
> > 
> > A loop like
> > 
> > for i in ... :
> >...
> >if ... cond ... :
> >break
> >...
> > #end for
> > 
> > actually has two different ways to terminate. Is there any good reason for 
> > them to be written two different ways?
> 
> Didn't we already do this debate?

For example: https://mail.python.org/pipermail/python-list/2016-June/709758.html

Maybe we don't have to revisit it... :)

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


Re: How do I make a game in Python ?

2016-08-06 Thread Terry Reedy

On 8/6/2016 5:51 PM, Cai Gengyang wrote:

As in, any recommended websites that helps users create complex games in Python 
?


For 2D graphics, try pygame among others.  For 3D, I don't know what is 
current.



On Sunday, August 7, 2016 at 5:41:25 AM UTC+8, Ian wrote:

On Aug 6, 2016 11:57 AM, "Cai Gengyang"  wrote:

How do I make a game in Python ?


import random

answer = random.randint(0, 100)
while True:
guess = input("What number am I thinking of? ")
if int(guess) == answer:
print("Correct!")
break
print("Wrong!")

And now you've made a game in Python.


I suspect you missed the wisdom contained in this answer.
1. Define the core mechanic.
2. Start simple.

Guess/Search for something hidden is a common core mechanic.
Do you want this to be part of your game.

With this start ...
3. Elaborate.

I can think of several ways.  Give hints.  Add graphics.  Increase 
player skill with repeated play.  Use objects other than counts.  Keep 
track of number of guesses and grade results.  Keep track of actual 
guesses and inform about repeats.  Record guesses visually so repetition 
is essentially impossible.




On Aug 6, 2016 11:57 AM, "Cai Gengyang"  wrote:


How do I make a game in Python ?


Start with an idea for the game.

--
Terry Jan Reedy

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


Re: Win32 API in pywin32

2016-08-06 Thread Lawrence D’Oliveiro
On Saturday, August 6, 2016 at 8:05:40 AM UTC+12, eryk sun wrote:
> I don't know all of the compatibility problems and
> constraints (and pressure from important customers) that they faced ...

Given some of their more recent (and not-so-recent) decisions, one wonders how 
much of this “pressure from important customers” they really pay attention to...
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Ide or code editor confusion

2016-08-06 Thread Lawrence D’Oliveiro
On Friday, August 5, 2016 at 6:36:45 AM UTC+12, Michael Torrie wrote:
> On 08/04/2016 01:23 AM, Lawrence D’Oliveiro wrote:
>> That’s why I’ve come to the conclusion it’s a waste of time buying books
>> on computing topics. They start to reek of decay while they’re still on
>> the shelf.
> 
> Except for old Unix books!

I don’t think this one 
 has 
aged well.

> I've got an old book on sed and awk that will likely be in date for years
> to come!

I may have used sed, but I could never see the point in awk--everything it 
could do, I could do just as concisely in Perl, and more.

> There's also an old book on vi, another on regular expression.

Does your book on regular expressions mention character classes, for example 
?

> So some things are invaluable references.

I would say that applies to more fundamental principles and theory, rather than 
the detailed functions of particular pieces of software.

> Moving targets like Python, that's another story of course!

When even bash comes out with new versions with major new features, you realize 
that everything is a moving target...
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python slang

2016-08-06 Thread Gregory Ewing

Ian Kelly wrote:

(not grammar, since "myself" is grammatically correct)


Not sure about that. "Myself" is a reflexive pronoun,
used when the subject and object of a verb are the same.
So "I did this research by myself" is correct. But if
Bob is involved, the subject and object are different,
so "myself" is not appropriate.

Whether that's a syntax error or a semantic error,
I'm not enough of a linguist to say.

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


Re: Ned Batchelder: Loop Like A Native

2016-08-06 Thread Lawrence D’Oliveiro
On Sunday, August 7, 2016 at 11:36:06 AM UTC+12, Ned Batchelder wrote:

> Didn't we already do this debate?

I understand. You want to discuss loops, just not *those* sorts of loops...
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Ned Batchelder: Loop Like A Native

2016-08-06 Thread Ned Batchelder
On Saturday, August 6, 2016 at 9:21:24 PM UTC-4, Lawrence D’Oliveiro wrote:
> On Sunday, August 7, 2016 at 11:36:06 AM UTC+12, Ned Batchelder wrote:
> 
> > Didn't we already do this debate?
> 
> I understand. You want to discuss loops, just not *those* sorts of loops...

I didn't post this link here.  I'm merely pointing out that your concern
about multiple ways to exit loops sounds like exactly what was discussed
here two months ago.  Is there any reason to think there is new material
to discuss?

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


RE: Python slang

2016-08-06 Thread Clayton Kirkwood
You can always tell the correctness by removing the other person. If it
doesn't sound right then, then it is wrong. You don't say 'I gave to I', or
'I gave to me', it is 'I gave to myself'. 

crk

> -Original Message-
> From: Python-list [mailto:python-list-
> bounces+crk=godblessthe...@python.org] On Behalf Of Gregory Ewing
> Sent: Saturday, August 06, 2016 6:17 PM
> To: python-list@python.org
> Subject: Re: Python slang
> 
> Ian Kelly wrote:
> > (not grammar, since "myself" is grammatically correct)
> 
> Not sure about that. "Myself" is a reflexive pronoun, used when the
subject and
> object of a verb are the same.
> So "I did this research by myself" is correct. But if Bob is involved, the
subject
> and object are different, so "myself" is not appropriate.
> 
> Whether that's a syntax error or a semantic error, I'm not enough of a
linguist
> to say.
> 
> --
> Greg
> --
> https://mail.python.org/mailman/listinfo/python-list

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


Re: Python slang

2016-08-06 Thread Steven D'Aprano
On Sun, 7 Aug 2016 04:33 am, Terry Reedy wrote:

> On 8/6/2016 2:30 AM, Michael Selik wrote:
> 
>> When people ask me why the core classes are lowercased,
> 
> Int, float, list, dict, etc were once functions that return objects of
> type 'int', 'float', 'list', 'dict', etc, before they became 'new-style
> classes', which are not just 'classes'.  The lowercasing was maintained
> as new builting classes were added.


That's a good point, but it's not the only reason. After all, come Python 3,
they could have changed their name to Int, Float, List, Dict etc, but
didn't.

These built-ins may be classes, but they continue to be used as if they were
functions, in a context where their function-ness is more important than
their class-ness. (Especially int, float and str.) They were left as
lowercase names even when they could have changed for that reason.

The naming conventions are a little bit inconsistent in Python, partly for
historical reasons, partly for aesthetic reasons. For example, in general
classes which produce "atomic types" tend to be written in lowercase.

By "atomic type", I mean a class which "feels" like it is a primitive,
low-level structure rather than an object with attributes, for example:

- builtins int, float, str, bytes, dict, list, tuple, set, frozenset, bool;
- array from the array module;
- defaultdict and deque from collections;

but not

- Decimal from decimal module;
- Fraction from fractions module;
- Counter and ChainMap from collections module.


although I suppose ChainMap does expose at least the "maps" attribute. But
in my opinion Decimal, Fraction and Counter should all be lowercased, like
float, int and dict.



-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

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


Re: Python slang

2016-08-06 Thread Rustom Mody
On Sunday, August 7, 2016 at 1:25:43 AM UTC+5:30, Marco Sulla wrote:
> On 6 August 2016 at 02:13, Chris Angelico wrote:
> > On Sat, Aug 6, 2016 at 9:21 AM, Marco Sulla wrote:
> >> I want to clarify that when I say "different from the other
> >> languages", I mean "different from the most used languages", that in
> >> my mind are C/C++, C#, Java, PHP and Javascript, mainly.
> >>
> >
> > Ah, well, that's because those are all one family of languages. If
> > instead you were familiar with four LISPy languages, you'd have a
> > completely different set of expectations.
> 
> Well, they are the most used languages. I think about the 80% of
> programmers knows at least one of that languages.

True

> It's more simple to learn a new language if it's similar to the others.

Not true

At a specific level (of programming languages) :
http://blog.languager.org/2015/06/functional-programming-moving-target.html
talks of functional programming taking about 50 years to get mainstream

More generally:
http://blog.languager.org/2016/01/how-long.html
is a collection of examples showing how humans en masse can persist in error
for hundreds, sometimes thousands, of years 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python slang

2016-08-06 Thread Chris Angelico
On Sun, Aug 7, 2016 at 12:32 PM, Steven D'Aprano
 wrote:
> By "atomic type", I mean a class which "feels" like it is a primitive,
> low-level structure rather than an object with attributes, for example:
>
> - builtins int, float, str, bytes, dict, list, tuple, set, frozenset, bool;
> - array from the array module;
> - defaultdict and deque from collections;
>
> but not
>
> - Decimal from decimal module;
> - Fraction from fractions module;
> - Counter and ChainMap from collections module.
>
>
> although I suppose ChainMap does expose at least the "maps" attribute. But
> in my opinion Decimal, Fraction and Counter should all be lowercased, like
> float, int and dict.

I somewhat agree with you about Decimal and Fraction, but not Counter.
In that situation, I'd be more inclined to make DefaultDict than
counter, if consistency is needed; there are too many other ways the
word "counter" can be used, so I'd rather not dedicate it to a class.
IMO the only types that really deserve the lower-case name are
built-ins (or ones where they're really functions in disguise, like
functools.partial). Of course, there's no point renaming them now, but
I don't see any particular value in "a modified version of dict"
getting a lower-case name - if I subclass dict myself, PEP 8 says it
should be called MyDict, not mydict, and defaultdict should be no
different.

The only reason Decimal and Fraction could plausibly be lowercased is
that they function very much the same way that int and float do, and
also they could potentially become builtins. But they probably won't,
so I don't have any problem with them remaining as they are, feeling
like classes rather than feeling like atoms.

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


Re: Python slang

2016-08-06 Thread Michael Torrie
On 08/06/2016 08:27 PM, Clayton Kirkwood wrote:
> You can always tell the correctness by removing the other person. If it
> doesn't sound right then, then it is wrong. You don't say 'I gave to I', or
> 'I gave to me', it is 'I gave to myself'. 

Yup good point, and I failed at that obviously.  Good rule of thumb (for
which there are likely exceptions I'm not aware of.

This work was done by me, or I did the work myself.

I gave to myself, but it was given to me.

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


Re: How do I make a game in Python ?

2016-08-06 Thread Michael Torrie
On 08/06/2016 03:51 PM, Cai Gengyang wrote:
> As in, any recommended websites that helps users create complex games in 
> Python ?

I imagine you create a complex game in Python the same way you'd do it
in just about any other language.  Thus any website on game design would
be broadly applicable.  And I'm sure there are a wide variety of topics
that are relevant.  Logic, game play, artificial intelligence, user
interface, physics engines, and so forth.

What you need to learn depends on what you already know and have
experience in. The programming language is really only a part of
developing "complex games." You'd probably want to start with simple,
even child-like games first.  Asking how to program complex games is a
bit like asking how to build a car.
-- 
https://mail.python.org/mailman/listinfo/python-list


Me, myself and I [was Re: Python slang]

2016-08-06 Thread Steven D'Aprano
On Sun, 7 Aug 2016 07:33 am, Michael Torrie wrote:

> On 08/05/2016 07:14 PM, Steven D'Aprano wrote:
>> In English, we refer to ourselves in the first person as I, me, myself,
>> and sometimes "self", never as "this". One can say "this one has a hat",
>> for example, but it sounds weird, like something the Borg would say about
>> a specific Borg unit.
> 
> Sadly it has become an epidemic of late for folks to misuse the word,
> "myself."  I think it comes from people not wanting to sound
> presumptuous when referring to themselves.

I myself must admit that myself hasn't come across that often.

*wink*


> It drives me crazy to hear 
> so many people say something like, "this research was done by myself and
> my colleague Bob." No, this research was done by my colleague Bob and I.

Heh, Muphry's Law strikes again!

http://grammar.about.com/od/il/g/MuphrysLaw.htm


"This research was done by my colleague Bob and I" is a case of
hyper-correction. It's a very common mistake, but a mistake it is. The test
for whether it is correct or not is to get rid of your colleague Bob:

"This research was done by I" 

is clearly wrong, as you recognise in your next statement:

>  Or this research was just only by me.

Which is correct. Or at least it would be, if you inserted the missing
verb :-)

The technical reason is that "I" is the first-person singular subject case,
and "me" the first-person singular object case. When the subject of the
sentence or clause is the first-person singular, you use "I":

"I did the research."
"I cannot tell a lie, I chopped down the cherry tree."


When the object of the sentence is the first-person singular, you say "me":

"George is a big bully, he punched me."

Passive sentences reverse subject and object:

"I did the research" becomes "The research was done by me".

"George punched me" because "I was punched by George".


But you don't exchange subject and object just because there are two people
involved!

Still unsure which to use? Blame somebody else:

"The research was done by George and I/me" => 
"The research was done by George and she/her".

Clearly it must be *her*, the objective case, therefore the right answer
is "me" not "I".


> However I have no problem with Python programmers using self in their
> code!

"Myself" is an alternative objective case for first-person singular,
typically used for emphasis:

"I did it myself."
"I did the research, myself."

It is also used as the object of a reflexive verb (verbs where the object is
the same as the subject):

"I will defend myself."
"I accidentally kicked myself in the head."


But using it in place of "me"? I don't think so.

"The research was done by myself."
"He punched myself in the head."

I wouldn't say it is *wrong*, just inelegant and rather pretentious.




-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

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


Re: where is it

2016-08-06 Thread Steven D'Aprano
On Sun, 7 Aug 2016 03:16 am, Dave wrote:

> I am trying to associate the .py file extension with idle...where IS
> idle?  Can you make it a bit more difficult to load/use your software
> please.

We certainly could, but we're not going to make it more difficult just to
suit you. You can make it as difficult as you want by just continuing your
current behaviour of being unnecessarily obnoxious.

If IDLE is installed, you should be able to use your general computer
knowledge (assuming you have any) to find it. I don't use Windows and can't
remember how you do this, but surely there is a way to find out the
location of any application under the Start Menu?

If there is a shortcut on the desktop, right click on the desktop and use
that to locate IDLE.

Or use Start Menu > Find File (or whatever Windows calls it) to find IDLE.

But I think you may find something of a problem, since IDLE is itself a
Python script. So perhaps you should worry less about where IDLE is located
and more about how do you get Windows to open Python files in IDLE.




-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

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


Re: Ned Batchelder: Loop Like A Native

2016-08-06 Thread Steven D'Aprano
On Sun, 7 Aug 2016 08:05 am, Lawrence D’Oliveiro wrote:

> On Saturday, August 6, 2016 at 12:08:30 PM UTC+12, bream...@gmail.com
> wrote:
>> A couple or three years old but this is well worth seeing for anybody,
>> regardless of your Python expertise.
>> http://nedbatchelder.com/text/iter.html
> 
> A loop like
> 
> for i in ... :
>...
>if ... cond ... :
>break
>...
> #end for
> 
> actually has two different ways to terminate. Is there any good reason for
> them to be written two different ways?

Yes. The two ways of ending the loop are distinct and different:

- reach the end, and stop;
- bail out early.


When you read a book, there are two ways of stopping:

- reach the end, and run out of pages to read, so you stop;
- give up reading early, and just put the book away.

(Or possibly throw the book across the room.)


Why would you treat these two cases in the same way?

interested = True
for page in book:
if interested:
read(page)
if bored_now():
interested = False

finished = False
while not finished:
try:
page = next(book)
except StopIteration:
finished = True
else:
read(page)
if bored_now():
finished = True



-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

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


Re: where is it

2016-08-06 Thread Steven D'Aprano
On Sun, 7 Aug 2016 01:31 pm, Steven D'Aprano wrote:

> If there is a shortcut on the desktop, right click on the desktop and use
> that to locate IDLE.

Sorry, I meant right-click on the SHORTCUT.

> Or use Start Menu > Find File (or whatever Windows calls it) to find IDLE.
> 
> But I think you may find something of a problem, since IDLE is itself a
> Python script. So perhaps you should worry less about where IDLE is
> located and more about how do you get Windows to open Python files in
> IDLE.

https://duckduckgo.com/html/?q=associate+python+with+idle

should help.




-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

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


Re: How do I make a game in Python ?

2016-08-06 Thread Chris Angelico
On Sun, Aug 7, 2016 at 1:14 PM, Michael Torrie  wrote:
> On 08/06/2016 03:51 PM, Cai Gengyang wrote:
>> As in, any recommended websites that helps users create complex games in 
>> Python ?
>
> I imagine you create a complex game in Python the same way you'd do it
> in just about any other language.  Thus any website on game design would
> be broadly applicable.  And I'm sure there are a wide variety of topics
> that are relevant.  Logic, game play, artificial intelligence, user
> interface, physics engines, and so forth.
>
> What you need to learn depends on what you already know and have
> experience in. The programming language is really only a part of
> developing "complex games." You'd probably want to start with simple,
> even child-like games first.  Asking how to program complex games is a
> bit like asking how to build a car.

Three of my students just recently put together a game (as their
first-ever collaborative project, working on different parts of the
project simultaneously), so I can tell you broadly how you would go
about it:

1) SCOPE. This is incredibly important. With the student project, they
had to have something demonstrable by Friday 5PM, so they had just
five days to get something working. But even when you don't have a
hard cut-off like that, you should scope back hard - brutally, even -
so you can get something workable as early as possible.

2) Pin down exactly what the *point* of your game is. What is the
fundamental thing you're trying to do? In their case, it was: Click on
the red squares before they turn back to white, then watch for another
square to turn red. As you develop, you'll mess around with everything
else, but don't mess with that.

3) Build a very basic project, managed in source control (git/hg/bzr
etc), and get it to the point of being testable. I don't mean unit
tests (although if you're a fan of TDD, you might well go that route),
but be able to fire up your game and actually run it. Commit that.

4) Progressively add features, constantly committing to source
control. Whenever your game isn't runnable, STOP and debug it until it
is. It's just way too hard to debug something that you can't even run.

5) Eventually, you'll get bored of the project or be forced to move on
to something else. At that point, the game is done. :)

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


Re: Me, myself and I [was Re: Python slang]

2016-08-06 Thread Chris Angelico
On Sun, Aug 7, 2016 at 1:22 PM, Steven D'Aprano
 wrote:
> But using it in place of "me"? I don't think so.
>
> "The research was done by myself."
> "He punched myself in the head."
>
> I wouldn't say it is *wrong*, just inelegant and rather pretentious.

I'm sure there's good poetic reason for writing sentences like that.
Maybe you want to sound like a nine hundred year old master of
oogie-boogie 'Force' power?

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


Re: Ned Batchelder: Loop Like A Native

2016-08-06 Thread Chris Angelico
On Sun, Aug 7, 2016 at 1:42 PM, Steven D'Aprano
 wrote:
> When you read a book, there are two ways of stopping:
>
> - reach the end, and run out of pages to read, so you stop;
> - give up reading early, and just put the book away.
>
> (Or possibly throw the book across the room.)
>

Or someone might rip the book out of your hands (unexpected
exception). You don't need to handle that case specifically, but it
will terminate the loop.

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


Re: Win32 API in pywin32

2016-08-06 Thread Rustom Mody
On Friday, August 5, 2016 at 5:29:37 PM UTC+5:30, Matt Wheeler wrote:
> On Fri, 5 Aug 2016, 02:23 Lawrence D’Oliveiro, wrote:
> 
> > On Friday, August 5, 2016 at 12:06:23 PM UTC+12, Igor Korot wrote:
> > >
> > > On Thu, Aug 4, 2016 at 4:57 PM, Lawrence D’Oliveiro wrote:
> > >> On Friday, August 5, 2016 at 11:50:28 AM UTC+12, jj0ge...@gmail.com
> > wrote:
> > >>> According to Python.org Mark Hammond has an Add-on (pywin32) that
> > >>> supports Win32 and COM.
> > >>
> > >> Are people still using Win32? I thought Windows went 64-bit years ago.
> >
> 
> The API is still called Win32 (fun fact: on 64 bit windows
> C:\Windows\System32 actually contains the 64 bit system (binaries &
> libraries). The 32 bit equivalents live in a dir called SysWOW64 (stands
> for Windows on Win64 or something) and get mapped to their regular
> locations for any 32 bit processes. That's right, 64 bit libraries live in
> System32 and 32 bits in SysWOW64 :) )*
> 
> > This is the question about Win API calls
> > >
> > > Thank you.
> >
> > This is a Python group.
> >
> 
> And the question was about using the Windows API in Python. Not sure what
> point you're trying to make here.
> 
> 
> > You’re welcome.
> >
> 
> ...
> 
> 
> * anyone from Microsoft listening and want to offer an explanation (don't
> worry, I don't think anyone expects it to be good :D)?

A two-word explanation: “It’s Microsoft” 

To be fair my head spins in Linux-land trying to work out what all these 
32's and 64's mean: mingw-w64-x86-64
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Win32 API in pywin32

2016-08-06 Thread Chris Angelico
On Sun, Aug 7, 2016 at 2:59 PM, Rustom Mody  wrote:
> To be fair my head spins in Linux-land trying to work out what all these
> 32's and 64's mean: mingw-w64-x86-64

There aren't any 32s in that. The beginning of that probably means the
Win64 version of MinGW, which (IIRC) is distinctly different from the
Win32 version (a project fork, or something); the end of it is the
architecture, x86-64, meaning "Intel 64-bit". Sometimes that's
described as AMD64, to distinguish it from IA-64, the Intel Itanium
64-bit architecture. The "86" in the name derives from 8086 and
family.

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


Re: where is it

2016-08-06 Thread eryk sun
On Sat, Aug 6, 2016 at 5:16 PM, Dave via Python-list
 wrote:
> I am trying to associate the .py file extension with idle...where IS 
> idle?  Can you
> make it a bit more difficult to load/use your software please.

You can run IDLE from the command-line as follows:

3.x:python[3][w] -m idlelib [script_path]
2.x:python[w] -m idlelib.idle [script_path]

This should work on all supported platforms. If you omit the script
path, it starts an interactive shell. On Windows, pythonw.exe (or
pyw.exe) runs without an attached console.

For Windows, the installer should have set up a right-click
context-menu command to edit .py and .pyw files with IDLE. You can
also use this command in a script via os.startfile. However, the way
it's set up to create a cascaded menu is inconvenient, i.e. the
command for IDLE 3.5 is "editwithidle\shell\edit35". You can copy this
as a default "edit" command for .py and .pyw files. This isn't too
hard to do in PowerShell. For example, if Python 3.5 is installed for
all users (otherwise replace HKLM with HKCU):

$base = "HKLM:\Software\Classes"
foreach ($p in ((".py",  "Python.File"),
(".pyw", "Python.NoConFile"))) {
$src = "$base\{0}\Shell\editwithidle\shell\edit35" -f $p[1]
$dst = "$base\SystemFileAssociations\{0}\Shell" -f $p[0]
# only set an "edit" command if the source key exists
# and the default isn't already defined.
if ((test-path $src) -and
(-not (test-path $dst\edit))) {
if (-not (test-path $dst)) {
new-item -force $dst
}
copy-item -recurse $src $dst\edit
}
}

The Windows shell looks in HKCR\SystemFileAssociations for default
file associations. The user's selected file type (e.g. Python.File)
can override this key by defining its own "edit" command.
-- 
https://mail.python.org/mailman/listinfo/python-list


Awful code of the week

2016-08-06 Thread Steven D'Aprano
Seen in the office IRC channel:


(13:23:07) fred: near_limit = []
(13:23:07) fred: near_limit.append(1)
(13:23:07) fred: near_limit = len(near_limit)
(13:23:09) fred: WTF



Speaks for itself.



-- 
Steve

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