[Idle-dev] Problem with the latest version of Python on macOS

Sara Mistral saramsrl at hotmail.com
Fri Aug 2 23:04:46 EDT 2019


Thank you so much for your help, I will tell my dad. Have a good day

Obtenez Outlook pour iOS<https://aka.ms/o0ukef>
________________________________
De : Beni Cherniavsky-Paskin <beni.cherniavsky at gmail.com>
Envoyé : Wednesday, July 31, 2019 2:50:04 PM
À : Sara Mistral <saramsrl at hotmail.com>
Cc : idle-dev at python.org <idle-dev at python.org>
Objet : Re: [Idle-dev] Problem with the latest version of Python on macOS

It's not bad indentation.  If that were the problem, you'd get `IndentationErrror`.
(The indention is good despite looking weird because the `>>> ` is not part of the code - imagine your first `if` starting at colunn 0.)

The problem is that IDLE Shell window expects a single expression/statement per prompt, and you gave it 2 separate `if` statements.
In many such cases python 3 will give clear "multiple statements" error, but not here.
You can confirm this by changing second `if` to e.g. `elif` (which makes them one statement) - that works for me.

Same syntax would be fine in a .py file editor window - most python scripts contain many statements
It's just limitation of the Shell window - you should execute each statement separately by pressing Enter (possibly twice).

Tip: if you do want to paste many statements together, put them all inside an `if True:` block to turn them into 1 statement.
If the copied code was not indented, select all pasted code, press Ctrl+] (aka Format -> Indent region - this menu is only visible in editor window but the shortcut works in Shell window too).



On Wed, 31 Jul 2019, 20:59 Sara Mistral, <saramsrl at hotmail.com<mailto:saramsrl at hotmail.com>> wrote:
Hello,
I downloaded Python recently on my computer and I have some troubles making it work. It doesn’t allow me to make and if function and elif without the good indentation. I have the latest version of Python (3.7.4) and my mac is updated (macOS Mojave 10.14.5).
As you can see in the picture, the “if” doesn’t align properly. I tried with else, elif, if, and every time I hit “send” it sends me to the wrong indentation.
My dad needs this for his work and he’s trying to learn Python but sadly he is stuck.
Thank you for your help.
Best wishes,
Sara
[Image]

_______________________________________________
IDLE-dev mailing list
IDLE-dev at python.org<mailto:IDLE-dev at python.org>
https://mail.python.org/mailman/listinfo/idle-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/idle-dev/attachments/20190803/1dfc24e9/attachment.html>


More information about the IDLE-dev mailing list