problem port .... :(

RP2040 based microcontroller boards running MicroPython.
Target audience: MicroPython users with an RP2040 boards.
This does not include conventional Linux-based Raspberry Pi boards.
Post Reply
iceelon
Posts: 30
Joined: Tue Jul 12, 2022 11:42 am

problem port .... :(

Post by iceelon » Tue Jul 12, 2022 11:52 am

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)
Last edited by jimmo on Tue Jul 12, 2022 12:16 pm, edited 1 time in total.
Reason: Add [code] formatting

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: problem port .... :(

Post by jimmo » Tue Jul 12, 2022 12:19 pm

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)

iceelon
Posts: 30
Joined: Tue Jul 12, 2022 11:42 am

Re: problem port .... :(

Post by iceelon » Tue Jul 12, 2022 1:06 pm

thanks, it works !!!!

Code: Select all

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

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: problem port .... :(

Post by jimmo » Tue Jul 12, 2022 1:28 pm

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''

iceelon
Posts: 30
Joined: Tue Jul 12, 2022 11:42 am

Re: problem port .... :(

Post by iceelon » Tue Jul 12, 2022 6:06 pm

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

Post Reply