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.


    I cannot seem to get os.uname() in a console.alert()

    Pythonista
    2
    3
    1598
    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.
    • JJGadgets
      JJGadgets last edited by

      So, I'm trying to make a Pythonista script that has this code:

      import os
      import sys
      import sysconfig
      
      #def uname():
      	#os.uname()
      	
      def alert(message):
          alert_result=console.alert('Kernel/uname info',message, button1='Dismiss',hide_cancel_button=True)
          return
      alert[os.uname()]
      
      

      However, I get a error of so:

      **TypeError:** 'function' object has no attribute '__getitem__'
      

      Can someone help?
      teacher walks into class okay bye! Will see responses after class in an hour :) thanks community!

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

        import os
        import sys
        import console
        
        #def uname():
            #os.uname()
            
        def alert(message):
            alert_result=console.alert('Kernel/uname info',str(message), button1='Dismiss',hide_cancel_button=True)
            return
        alert(os.uname())
        

        alert needs round brackets, message needs to be converted to a string and you have to import console.

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

          Okay, thanks! I must have been tired so I didn't realise my mistake (having slight fever and sore throat :/) 😅

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