omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    [BUG REPORT] file changes in Pythonista 2 folder not refreshed from Pythonista 3 w/out hard reset or force refresh

    Pythonista
    2
    2
    1797
    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.
    • Tizzy
      Tizzy last edited by

      So, perhaps @omz will determine this a non-issue, but it's a peculiarity I've run into, so I figured best to report it.

      I use Pythonista3 mostly with files stored in the Pythonista 2 folder because I haven't gotten around to reimplementing my DropBox sync workflow yet. Because of this unique use case I discovered an interesting bug.

      If you have two separate files in the Pythonista 2 folder, where FileA imports FileB, and you make changes to FileB, and you run FileA from Pythonista3, changes to FileB are not reflected until you hard quit Pythonista, or use the importlib.reload() method.

      Here are the files to reproduce this..
      FileA.py

      # coding: utf-8
      import FileB
      from FileB import *
      
      class FileAClass(object):
      	def __init__(self):
      		self.remote = FileB.FileBClass()
      		
      if __name__ == "__main__":
      	local = FileAClass()
      
      	local.remote.functionB()
      	standaloneFunction()
      

      FileB.py

      # coding: utf-8
      import time
      
      
      class FileBClass():
      
      	def __init__(self):
      		
      		pass
      		
      	def functionB(self):
      		changeThisText = "aaaaaaaaaaaaa"
      		print("watch for changes - "+str(changeThisText))
      		
      def standaloneFunction():
      	phrase = "bananas"
      	print("changes? - "+str(phrase))
      

      Changes to text in both the class method and standalone function in FileB.py aren't reflected in FileA until a hard reset or forced reload.

      1 Reply Last reply Reply Quote 0
      • JonB
        JonB last edited by

        Seems to be because _pythonista_preflight is checking for scripts in the docs folder, but pythonista 2 scripts are not in that folder!

        		if (mod_path.startswith('./') or mod_path.startswith(doc_path)):
        			del sys.modules[name]
        

        Incidentally... I missed this change, perhaps others did as well, as. way to force reload of site packages when developing.
        keep_site_packages = '--reload-site-packages' not in sys.argv[1:]

        1 Reply Last reply Reply Quote 0
        • First post
          Last post
        Powered by NodeBB Forums | Contributors