Re: Problems with IDLE in Windows 8.1 and installer x86 Version 3.10.8

2022-10-31 Thread Eryk Sun
On 10/31/22, darkst...@o2online.de  wrote:
>
> I installed the Standard Distribution from python.org again, and i ensured,
> that the checkmark test Suite is enabled. Idle does’nt start. The installer
> says “Installation successfully” at the end.
>
> What went wrong and how can I further delimit the fault/find the error?

Open a command prompt and run the following command:

py -3.10-32 -m idlelib

If it fails, an exception and traceback should be printed to the console.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Operator: inappropriate wording?

2022-10-31 Thread Chris Angelico
On Tue, 1 Nov 2022 at 08:15, elas tica  wrote:
>
> Le mercredi 26 octobre 2022 à 22:12:59 UTC+2, Weatherby,Gerard a ecrit :
> > No. If the docs say in one place a comma is not an operator, they shouldn’t 
> > call it an operator in another place.
> >
> > I’ve submitted a pull request https://github.com/python/cpython/pull/98736 
> > -- we’ll have to see what The Powers That Be think.
>
>
> Thanks for the (merged) pull request about the "comma operator"!
>
> I return to the last two quotes in the Reference Document regarding these 
> so-called "assignment operators".
>
> The entry in the glossary explains that the comma symbol is not an operator. 
> Well, I just realized that this same entry also explains that the = symbol is 
> not an operator, as you can see by reading the end of their response:
>
> The same is true of the various assignment operators (=, += etc). They are 
> not truly operators but syntactic delimiters in assignment statements.
>
> (glossary entry link: 
> https://docs.python.org/3/faq/programming.html#what-s-up-with-the-comma-operator-s-precedence)
>
> Talking about an assignment operator in Python is even more confusing 
> because, since Python 3.8, there is a real assignment operator, namely the 
> walrus operator. As explained above, the correct expression would be 
> "assignement delimiter" or "assignement statement" or "assignement symbol".
>

Wording is hard. Just ask the SQL standard whether NULL is a value.

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


Re: Fwd: A typing question

2022-10-31 Thread Peter J. Holzer
On 2022-10-30 20:43:23 +0100, Peter Otten wrote:
> On 30/10/2022 14:37, Peter J. Holzer wrote:
> > On 2022-10-30 09:23:27 -0400, Thomas Passin wrote:
> > > On 10/30/2022 6:26 AM, Peter J. Holzer wrote:
> > > > On 2022-10-29 23:59:44 +0100, Paulo da Silva wrote:
> > > > > The funny thing is that if I replace foos by Foos it works because it 
> > > > > gets
> > > > > known by the initial initialization :-) !
[...]
> > 
> > Yes. I was referring to the code as written. Why does that work? I don't
> > think it should.
> 
> For me it makes sense. I think mypy should refrain from trying to figure
> out order of execution.

I was unclear, sorry. What I meant was "why does replacing foos by Foos
make the error disappear?" not "why do forward references work?". But
may have misunderstood what Paulo meant as I cannot reproduce his
results. So maybe the behaviour I don't understand (and would consider
buggy) doesn't actually exist.

hp

-- 
   _  | Peter J. Holzer| Story must make more sense than reality.
|_|_) ||
| |   | h...@hjp.at |-- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |   challenge!"


signature.asc
Description: PGP signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Operator: inappropriate wording?

2022-10-31 Thread elas tica
Le mercredi 26 octobre 2022 à 22:12:59 UTC+2, Weatherby,Gerard a ecrit :
> No. If the docs say in one place a comma is not an operator, they shouldn’t 
> call it an operator in another place. 
> 
> I’ve submitted a pull request https://github.com/python/cpython/pull/98736 -- 
> we’ll have to see what The Powers That Be think.


Thanks for the (merged) pull request about the "comma operator"!

I return to the last two quotes in the Reference Document regarding these 
so-called "assignment operators".

The entry in the glossary explains that the comma symbol is not an operator. 
Well, I just realized that this same entry also explains that the = symbol is 
not an operator, as you can see by reading the end of their response:

The same is true of the various assignment operators (=, += etc). They are not 
truly operators but syntactic delimiters in assignment statements.

(glossary entry link: 
https://docs.python.org/3/faq/programming.html#what-s-up-with-the-comma-operator-s-precedence)

Talking about an assignment operator in Python is even more confusing because, 
since Python 3.8, there is a real assignment operator, namely the walrus 
operator. As explained above, the correct expression would be "assignement 
delimiter" or "assignement statement" or "assignement symbol".


By the way, Alex Martelli shares this view, explaining:

The "=" operator in Python ... doesn't exist, since '=' is not an operator in 
Python (just like it isn't, say, in VB). But, OK, you mean "assignment".

(source: 
https://groups.google.com/g/comp.lang.python/c/K6HfK6HANR4/m/OG9QBzFmTR8J)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Fwd: A typing question

2022-10-31 Thread Peter J. Holzer
On 2022-10-30 11:26:56 +0100, Peter J. Holzer wrote:
> On 2022-10-29 23:59:44 +0100, Paulo da Silva wrote:
> > The funny thing is that if I replace foos by Foos it works because it gets
> > known by the initial initialization :-) !
> > 
> > 
> > from typing import List, Optional
> > 
> > class GLOBALS:
> > Foos: Optional[Foos]=None
> [...]
> > class Foos:
> 
> That seems like a bug to me.

But is it even true?

I just tried to reproduce it (should have done that before answering)
with mypy 0.942 (included in Ubuntu 22.04 LTS):

[p1]---
from typing import List, Optional

class GLOBALS:
foos: Optional[Foos]=None

class Foo:

def __init__(self):
pass

class Foos:
Foos: List[Foo]=[]
# SOME GLOBALS ARE USED HERE

def __init__(self):
pass

GLOBALS.foos=Foos()
---

[p2]---
from typing import List, Optional

class GLOBALS:
Foos: Optional[Foos]=None

class Foo:

def __init__(self):
pass

class Foos:
Foos: List[Foo]=[]
# SOME GLOBALS ARE USED HERE

def __init__(self):
pass

GLOBALS.Foos=Foos()
---

--- p1  2022-10-31 21:59:49.639869922 +0100
+++ p2  2022-10-31 21:58:19.815830677 +0100
@@ -1,7 +1,7 @@
 from typing import List, Optional

 class GLOBALS:
-foos: Optional[Foos]=None
+Foos: Optional[Foos]=None

 class Foo:

@@ -15,4 +15,4 @@
 def __init__(self):
 pass

-GLOBALS.foos=Foos()
+GLOBALS.Foos=Foos()

So the only difference is the capitalization of foos. And mypy accepts
both (as it probably should):

% mypy p1
Success: no issues found in 1 source file
% mypy p2
Success: no issues found in 1 source file


If you did something different, please explain what you did.

hp

-- 
   _  | Peter J. Holzer| Story must make more sense than reality.
|_|_) ||
| |   | h...@hjp.at |-- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |   challenge!"


signature.asc
Description: PGP signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Fwd: A typing question

2022-10-31 Thread dn

On 01/11/2022 01.56, Stefan Ram wrote:

dn  writes:

On 31/10/2022 11.44, Chris Angelico wrote:

...

I'm curious to what extent sloppy English correlates with sloppy code.

...

When it comes to CVs/resumés (see what I did there?), I must admit that
the most egregious of errors in spelling or grammar do ensure that an
applicant's 'work' is quickly routed to "file 13" (an American-English
term, many other English-speakers will not have heard previously).


   This discussion reminds me of something Eric Raymond said:

|While sloppy writing does not invariably mean sloppy thinking,
|we've generally found the correlation to be strong -- and we
|have no use for sloppy thinkers. If you can't yet write
|competently, learn to.
Eric Raymond

   . Other relevant quotations are:

|Besides a mathematical inclination, an exceptionally good
|mastery of one's native tongue is the most vital asset of a
|competent programmer.
Edsgar Dijkstra

|I've found that some of the best [Software ]developers
|of all are English majors. They'll often graduate with
|no programming experience at all, and certainly without
|a clue about the difference between DRAM and EPROM.
|
|But they can write. That's the art of conveying
|information concisely and clearly. Software development
|and writing are both the art of knowing what you're going
|to do, and then lucidly expressing your ideas.
|
Jack Ganssle

|The narrative measures of conjunction use, event
|content, perspective shift, and mental state reference
|were significantly predictive of later Math scores.
"Evidence of a Relation between Early Narrative and ..." (2004)
- DK O’Neill

|I have never, ever, ever seen a great software developer
|who does not have amazing attention to detail.
(2006-08-20) - Rob Walling


+1 Thanks for these!
--
Regards,
=dn
--
https://mail.python.org/mailman/listinfo/python-list


Re: Problems with IDLE in Windows 8.1 and installer x86 Version 3.10.8

2022-10-31 Thread Eryk Sun
On 10/31/22, darkst...@o2online.de  wrote:
>
> i uninstalled this, because my Idle doesn’t start by clicking on the Icon.
> Are there any Solutions for the problem?

If it's the standard distribution from python.org, run the installer
again, and ensure that the test suite is installed.

In 3.10.8, IDLE mistakenly depends on the test suite. This mistake is
fixed in 3.10.9, which is planned to be released in early December.
-- 
https://mail.python.org/mailman/listinfo/python-list


Problems with IDLE in Windows 8.1 and installer x86 Version 3.10.8

2022-10-31 Thread darkstone
Dear Sir or Madam,







i uninstalled this, because my Idle doesn’t start by clicking on the Icon. Are 
there any Solutions for the problem?




Thanks,




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


Re: an oop question

2022-10-31 Thread Alan Gauld
On 30/10/2022 14:01, Julieta Shem wrote:

> I wrote the classes
> 
>   class Empty:
> ...
>   class Pair:
> ...
> 
> (*) How to build a stack?
> 
> These Lisp-like sequences are clearly a stack.  

That is a very important observation. A Pair IS-A Stack(sort of).
If you had a stack you could create a Pair from it certainly.

> So far so good, but when it comes to building a better user interface
> for it I have no idea how to do it.  I think one of the purposes of OOP
> is to organize code hierarchically so that we can reuse what we wrote.

One of the purposes of classes certainly. I'm not so sure it's a purpose
of OOP. They are not the same thing. A class is a programming construct
OOP is a programming style. Classes facilitate OOP but can be used
outside of OOP too.

> So I tried to make a Stack by inheriting Pair.

But you said above that a Pair was a Stack. Inheritance implies an
IS-A relationship, so Stack inheriting Pair would mean that a Stack
was a Pair. That is not really true.

A Stack could use a Pair (or many of them) but it is not a Pair.

Trying to use inheritance inappropriately is one of the
biggest (and commonest) mistakes in OOP. It invariably leads
to complications. If in doubt use delegation instead.


> class Stack(Pair):
> pass
> 
 Stack(1, Empty())
> Stack(1, Empty())
> 
> Then I wrote pop and push.
> 
 Stack(1, Empty()).pop()
> 1
> 
 Stack(1, Empty()).push(2)
> Stack(2, Stack(1, Empty()))
> 
> So far so good.  Now let me show you what I can't do.
> 
> (*) The difficulty of encapsulating a union
> 
> The Lisp-like sequences we're building here are union-like data
> structures.  A /sequence/ is either Empty() or Pair(..., /sequence/).  I
> have not found a way to represent this either-or datastructure with a
> class.  For example, there is no way right now to build an empty Stack
> by invoking the Stack constructor.
> 
 Stack()
> Traceback (most recent call last):
>   File "", line 1, in 
> TypeError: Pair.__init__() missing 2 required positional arguments: 'first' 
> and 'rest'
> 

The usual Python approach to such things is to put some default
values(often None but could be an Empty instance in your case)
in the init() method parameter list. Then test if the inputs
are None and if so take the appropriate action.

> class Pair:
>   def __init__(self, first=Empty(), rest=Empty()):

Like this.

> if not isinstance(rest, Pair) and not isinstance(rest, Empty):
>   raise ValueError("rest must be Empty or Pair")
> self.first = first
> self.rest = rest
>   def fromIterable(it):
> if len(it) == 0:
>   return Empty()
> else:
>   return Pair(it[0], Pair.fromIterable(it[1:]))
>   def __str__(self):
> return "{}({!r}, {})".format(self.__class__.__name__, self.first, 
> str(self.rest))
>   def __repr__(self):
> return str(self)
>   def __len__(self):
> return 1 + self.rest.__len__()
> 
> class Empty:
>   def __len__(self):
> return 0
>   def __str__(self):
> return  "Empty()"
>   def __repr__(self):
> return self.__str__()
>   def __new__(clss):
> if not hasattr(clss, "saved"):
>   clss.saved = super().__new__(clss)
> return clss.saved
> 
> class Stack(Pair):
>   def pop(self):
> return self.first
>   def push(self, x):
> return Stack(x, self)

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


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