Python Forum
how set/change env var PYTHONOPTIMIZE in Python 3 / 3.7 / 3.8 ????
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how set/change env var PYTHONOPTIMIZE in Python 3 / 3.7 / 3.8 ????
#1
how set/change env var PYTHONOPTIMIZE in Python 3 / 3.7 / 3.8 ????

I want to skip assertion... how?

a = input("enter a number: ")

assert int(a) > 0 or int(a) < 0, "a is zero" # also a != 0

# https://docs.python.org/3/using/cmdline....ONOPTIMIZE

"""
PYTHONOPTIMIZE
If this is set to a non-empty string it is equivalent to specifying the -O option. If set to an integer, it is equivalent to specifying -O multiple times.
"""
Reply
#2
You can change it like any environment variable in your OS (which is?) That said, why not simply run python with the -O option?
Reply
#3
(Aug-02-2020, 04:12 PM)Gribouillis Wrote: You can change it like any environment variable in your OS (which is?) That said, why not simply run python with the -O option?

when you say:
That said, why not simply run python with the -O option

What do you mean in Python IDLE or Thonny Python Editor? When running/executing the file.py... how?

Please give an example
Reply
#4
With IDLE in python 3.8 it works for me if I open IDLE with the -O switch on the command line
Output:
python3.8 -O -m idlelib
It seems that idle propagates the -O flag to the scripts that it runs.

With Thonny, it didn't work with the -O flag, but it worked with this command line (in linux)
Output:
PYTHONOPTIMIZE=1 python3.8 -m thonny
Reply
#5
idlelib
WIN 10 --- HOW find where IDLE installed ???

This
PYTHONOPTIMIZE=1 can be set as Windows env var???
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020