Python Forum
raspberry pico second core ?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
raspberry pico second core ?
#2
global is only used inside functions. The purpose of global is to tell python that the variable(s) is in the global scope, and assignment to the variable should not create a local variable inside the function. The code where you use "once" is not inside a function. Any variables assigned in the while loop are global.

Interestingly, this is a syntax error:
once = 0
while True:
    global once
    if once == 0:
But this is not. It raises a NameError when run, but it is not a syntax error.
while True:
    global once
    if once == 0:
Reply


Messages In This Thread
raspberry pico second core ? - by trix - Jun-23-2024, 04:57 PM
RE: raspberry pico second core ? - by deanhystad - Jun-24-2024, 01:42 PM
RE: raspberry pico second core ? - by trix - Jun-24-2024, 04:10 PM
RE: raspberry pico second core ? - by trix - Jun-24-2024, 04:11 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  hardware timer raspberry pico trix 4 318 Jun-27-2024, 09:29 AM
Last Post: Larz60+
Question Sonar Code in Thonny for Pi Pico iansmiler 1 470 Nov-22-2023, 12:27 PM
Last Post: deanhystad
  Illegal instruction (core dumped) when import pandas. amandacstr 1 2,356 Dec-31-2022, 11:31 PM
Last Post: stevendaprano
  ImportError: /home/ali/Documents/test/charm/core/crypto/AES.cpython-39-x86_64-linux-g Anldra12 0 1,344 Apr-28-2022, 07:13 AM
Last Post: Anldra12
  Segmentation fault (core dumped) hobbyist 1 10,913 Jun-07-2021, 12:56 PM
Last Post: supuflounder
  Python script in Ubuntu core Nithin_Kumar 1 3,472 May-11-2021, 01:14 AM
Last Post: Skaperen
  I want to install core mod. Blue Dog 3 3,413 Jul-18-2017, 08:02 PM
Last Post: sparkz_alot

Forum Jump:

User Panel Messages

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