bbcmicrobit / bbcmicrobit/micropython

AttributeError: 'str' object has no attribute 'partition'

Open
#641 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
646
Forks
290
PR merge metrics
No merged PRs in 30d

Description

microbit-support:20460

User reports code that previously worked using partition, no longer functions.

``` python

from microbit import *
import radio

radio.on()
started = False

def drive(onTime, offTime):
global started
stop(0)
while True:
incoming = radio.receive()
if incoming is not None:
# display.show(incoming)
uart.write('Received: "' + incoming + '"\n')
head, mid, tail = incoming.partition(' ')
if head == 'buggy':
cmd, mid, args = tail.partition(' ')
# uart.write('cmd=' + cmd + ' mid=' + mid + 'args=' + args + '\n')
if cmd == 'start':
started = True
elif cmd == 'stop':
started = False
stop(0)
elif cmd == 'direction' and started:
x, mid, y = args.partition(' ')
# uart.write('x=' + x + ' y=' + y + '\n')
xf = float(x)
yf = float(y)
if yf < 1:
if xf < 1:
leftforward(int(abs(yf-2)*onTime), offTime)
elif xf > 3:
rightforward(int(abs(yf-2)*onTime), offTime)
else:
forward(int(abs(yf-2)*onTime), offTime)
elif yf > 3:
if xf < 1:
leftbackward(int(abs(yf-2)*onTime), offTime)
elif xf > 3:
rightbackward(int(abs(yf-2)*onTime), offTime)
else:
backward(int(abs(yf-2)*onTime), offTime)
else:
stop(onTime)

```

It appears that this was deactivated in the port to v1.0.0

https://github.com/bbcmicrobit/micropython/blob/e10a5ffdbaf1cc40a82a665d79343c7b6b78d13b/inc/py/mpconfig.h#L709

User has found a workaround that uses a split instead.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.