Page 1 of 1

problem port .... :(

Posted: Tue Jul 12, 2022 11:52 am
by iceelon
Hi !!

first of all, thank you...
Some time ago I saw a code in gist of a Des3
I have basic level knowledge in python but I encounter the following problem in this line :

Code: Select all

                if _pythonMajorVersion < 3:
			return ''.join(result)
		else:
			return bytes.fromhex('').join(result)

Re: problem port .... :(

Posted: Tue Jul 12, 2022 12:19 pm
by jimmo
iceelon wrote:
Tue Jul 12, 2022 11:52 am
bytes.fromhex('')
MicroPython doesn't support bytes.fromhex

I think it should be added -- see the PR I raised here: https://github.com/micropython/micropython/pull/7539

What is the code actually trying to do though? MicroPython is also only Python 3, so you don't need the if statement. I feel like the whole thing should just be

Code: Select all

return b''.join(result)

Re: problem port .... :(

Posted: Tue Jul 12, 2022 1:06 pm
by iceelon
thanks, it works !!!!

Code: Select all

			return ubinascii.unhexlify('').join(result)

Re: problem port .... :(

Posted: Tue Jul 12, 2022 1:28 pm
by jimmo
iceelon wrote:
Tue Jul 12, 2022 1:06 pm
thanks, it works !!!!

Code: Select all

ubinascii.unhexlify('')
is exactly the same as just writing

Code: Select all

b''

Re: problem port .... :(

Posted: Tue Jul 12, 2022 6:06 pm
by iceelon
ummm not :(

Code: Select all

		 return ''.join(result)
show this error

Code: Select all

TypeError: join expects a list of str/bytes objects consistent with self object

oo sorry ...

Code: Select all

return b''.join(result)
work