Thanks, and I should have picked up on that even with my limited experience in Python, since all I've been working in is 3x Python.
This DID cause the code to print the set after "All scanned codes:' , but then as usual popped another 'No method found for stringValue' error with it. That likely is an issue nested in P2x v P3x code as this was.
For what I want to use this code for, it really doesn't matter at all, because what i want to do is build a function and nest it in the seeding of the found_codes to send off the data to a database, so this was more a frustration/curiosity that I really wanted to see resolved for my own benefit more than the project I'm working on.
Have you attempted to paste the string from the source into a simple text editor and then copy it back out again to be pasted into Pythonista? I've run into several instances across various platforms and apps where data has hidden data that another app will reject out of hand. I've not seen a situation where striping the data with some other tool was not effective in getting it to paste properly.
One caveat to this is if you're attempting to paste several lines into your python code, often must be accomplished a line at a time. So if the 'string' you are referring to has multiple lines, that is another game entirely.
Hope this helps.
I've found a great little piece of code to scan bar codes from an iOS device. If you would like to see the full code sample got to this link on the infragistics web page.
The code works really well, considering what the author basic premise is (scanning and interpreting bar codes). The only issue I am running into getting it to work perfectly on my iOS 13.3.1 iPhone and iPad, is when exiting the code the script directs a printout to the console of content of the variable 'found_codes'.
print ('All scanned codes:\n'), '\n'.join(found_codes)
This bit of code prints only the line 'All Scanned codes:' to the console.
I had modified this from the original code removing a + sign and inserting a comma (,)
print ('All scanned codes:\n') + '\n'.join(found_codes)
Pythonista protested with...
unsupported operand type(s) for +: 'NoneType'...
The code block that adds the bar code reading to 'found_codes is:
objects = ObjCInstance(_metadata_objects) for obj in objects: s = str(obj.stringValue()) if s not in found_codes: found_codes.add(s)
I'm puzzled by the fact that replacing the plus sign with a comma, clears the error message but after doing that, the print to the console doesn't take place.
I will stress I'm relatively new to python and pythonista, so I may be missing something obvious to the rest of you.
I got this response below which was extremely helpful...
bennr01 posted 3 days ago 0
So what is the proper procedure for pip'ing in new modules?
The community has written a custom implementation of pip, which is included in StaSh. It works rather well, but does not support any modules depending on C/Fortran code.
To install, copy the following: import requests as r; exec(r.get('https://bit.ly/get-stash').text), then paste it in the python REPL (the console) and exute it. Restart pythonista (force quit using double tap). Afterwards, there is a file called launch_stash.py in the my iphone (or whatever it is called) directory. Run it. It takes a bit of time, but you should then see a bash-like shell. This shell supports pip install <modulename>.
Going in a different direction now. I think I will resort to a simple smtp sender and receiver, placing my data in the subject header of each message and extracting it on the other side as it arrives on the pc. I need to setup a lab to make sure this will all work but it should.
I still want to know the pip procedure as what I've found documented doesn't seem to work.
That is a bit disheartening.... I have used the following on windows with Python 3.6 and was hoping to convert it to Phthonista so I could run it from an iPhone or iPad. But it sounds like I need to look for a different solution.
import os import sys import subprocess from socket import * subprocess.call("cls", shell=True) theargis = '' if len(sys.argv) > 1: theargis +=str(sys.argv) if theargis > '': host = theargis print ("Using Server Address of " + theargis + ":") else: host = "220.127.116.11" print ("Using Default Address of " + host + ":") port = 13000 addr = (host, port) UDPSock = socket(AF_INET, SOCK_DGRAM) while True: data = input("Enter message to send or type 'EXIT': ") bytes = data.encode() UDPSock.sendto(bytes, addr) if data.upper() == "EXIT": break UDPSock.close() os._exit(0)``` What I am working out in the larger schema, is to collect bar-code scans and with each collection return the data back to a desktop PC to be processed and distributed as a periodic data feed. This would be the last component in that process. Being new to Python code, adapting around the calls to the subprocess module will make this challenging to say the least. I appreciate the feedback. Kip...