ure.sub not available in v1.10?
-
- Posts: 35
- Joined: Fri Apr 12, 2019 8:55 am
ure.sub not available in v1.10?
Hi,
I am developing my MicroPython code on Windows and I see an error when trying to use ure.sub ...
However, the docs say this should be available.
D:\micropython.exe
MicroPython v1.10-278-g673e154df on 2019-04-12; win32 version
Use Ctrl-D to exit, Ctrl-E for paste mode
>>> import ure
>>> xx="a simple test"
>>> ure.sub('^a', '', xx)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'sub'
I am developing my MicroPython code on Windows and I see an error when trying to use ure.sub ...
However, the docs say this should be available.
D:\micropython.exe
MicroPython v1.10-278-g673e154df on 2019-04-12; win32 version
Use Ctrl-D to exit, Ctrl-E for paste mode
>>> import ure
>>> xx="a simple test"
>>> ure.sub('^a', '', xx)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'sub'
Re: ure.sub not available in v1.10?
Hi,
I just typed this does it help as I'm just starting out ?
>>> import ure
>>> help(ure)
object <module 'ure'> is of type module
__name__ -- ure
compile -- <function>
match -- <function>
search -- <function>
sub -- <function>
DEBUG -- 4096
>>>
Andy
I just typed this does it help as I'm just starting out ?
>>> import ure
>>> help(ure)
object <module 'ure'> is of type module
__name__ -- ure
compile -- <function>
match -- <function>
search -- <function>
sub -- <function>
DEBUG -- 4096
>>>
Andy
-
- Posts: 35
- Joined: Fri Apr 12, 2019 8:55 am
Re: ure.sub not available in v1.10?
I get this:
>>> help (ure)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'help' isn't defined
>>>
I seem to be missing something.
>>> help (ure)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'help' isn't defined
>>>
I seem to be missing something.
Re: ure.sub not available in v1.10?
The Windows version of MicroPython is somewhat limited. For whatever reason the help module is not included. Other modules may be missing too. Did you build that version yourself, or where did you get that from
-
- Posts: 35
- Joined: Fri Apr 12, 2019 8:55 am
Re: ure.sub not available in v1.10?
I compiled MicroPython from the Github sources at:
https://github.com/micropython/micropyt ... ts/windows
cross compiled for Windows using Ubuntu sub-system.
Thanks.
https://github.com/micropython/micropyt ... ts/windows
cross compiled for Windows using Ubuntu sub-system.
Thanks.
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
I can't explain this
This is an aspect of MicroPython that I find baffling, despite nearly 5 years involvement.
tl;dr the availability of features is often in inverse proportion to the capabilities of the hardware.
On the Unix build:
On a Pyboard D:
On an ESP8266:
I could understand if ure.sub were omitted on a resource constrained platform like ESP8266. The converse is true. It (and other features) are left out on the platforms with effectively unlimited resources: PC's. Can anyone explain this?
tl;dr the availability of features is often in inverse proportion to the capabilities of the hardware.
On the Unix build:
Code: Select all
>>> dir(ure)
['__class__', '__name__', 'DEBUG', 'compile', 'match', 'search']
>>>
Code: Select all
>>> dir(ure)
['__class__', '__name__', 'DEBUG', 'compile', 'match', 'search', 'sub']
>>>
Code: Select all
>>> dir(ure)
['__class__', '__name__', 'DEBUG', 'compile', 'match', 'search', 'sub']
>>>
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: ure.sub not available in v1.10?
I compiled a version of micropython for Windows which includes ure.sub(9 and help(). You'll find it here: https://github.com/robert-hh/Shared-Stuff
And yes, it's strange that ure.sub is not included into all versions, when ist is present in the version with the strongest memory constrainst
And yes, it's strange that ure.sub is not included into all versions, when ist is present in the version with the strongest memory constrainst
-
- Posts: 35
- Joined: Fri Apr 12, 2019 8:55 am
Re: ure.sub not available in v1.10?
Thanks!
It works. I am curious how you compiled this.
It works. I am curious how you compiled this.
Re: ure.sub not available in v1.10?
I used MINGW for that (https://mingw-w64.org/doku.php). No magic. Just install MINGW on Windows, download the repository and run make. I had to adapt mpconfigport.h in microypthon/ports/windows to enable these features along the line of micropython/ports/esp8266 or the other ports.