Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    Sharing Variables Between Files

    Scheduled Pinned Locked Moved GPy
    3 Posts 2 Posters 228 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S Offline
      Sn3akyP3t3
      last edited by

      I'm not accustomed to having a boot.py and a main.py having one process run after another and trying to share variables between processes. The official Python documentation shows this is the appropriate way to do shared variables, but it doesn't seem to be the way it will work here. Can someone show an example or point out documentation that shows how this is done?

      O 1 Reply Last reply Reply Quote 0
      • O Offline
        oligauc @Sn3akyP3t3
        last edited by

        @Sn3akyP3t3 Please can you give more details on your project ? The Pycom modules are programmed with micropython which is a subset of Python. You can create classes in different files in flash and create an instance of them in the main.py. In the python classes you can create getters and setters for variables.

        1 Reply Last reply Reply Quote 0
        • S Offline
          Sn3akyP3t3
          last edited by

          Well I haven't written much yet to share, but it doesn't make sense to me that the gpy device can assume that the mobile network is always available and with good signal strength. Also, boot.py appears to be where the network connection is established, but what if in the main.py I want to put the device to sleep for some duration and wake the mobile network connection under some conditions. I would need to refer to the mobile object declared in the boot.py hence the sharing variable need.

          This gpy unit will be traveling and the network signal strength drops off frequently because I live in a horrible rural area.. where networking life is miserable. I would assume the same idea of putting the device into sleep to save on juice would be applicable here, but if its declared in boot.py how would it be interacted with in main.py?

          1 Reply Last reply Reply Quote 0

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          • 1 / 1
          • First post
            Last post

          Pycom on Twitter

          Pycom