print

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
badryan
Posts: 3
Joined: Fri May 02, 2014 9:30 am

print

Post by badryan » Fri May 02, 2014 1:36 pm

Hi,

Would it be a lot of work to add a simple "print"? I appreciate it's of little use when not connected to a screen, but for development work in the REPL I'd find it quite useful.

Boris

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: print

Post by dhylands » Fri May 02, 2014 3:08 pm

Hi Boris,

print is there, but with the Python 3.3 syntax (so it requires parenthesis).

Code: Select all

Micro Python build 1f85d62-dirty on 2014-05-01; NetduinoPlus2 with STM32F405RG
Type "help()" for more information.
>>> print('Hello there %s' % 'Boris')
Hello there Boris

badryan
Posts: 3
Joined: Fri May 02, 2014 9:30 am

Re: print

Post by badryan » Fri May 02, 2014 3:24 pm

<blushes>Oh.</blushes> Thank you very very much! I've never looked at the actual differences between Python 2 and 3!

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: print

Post by dhylands » Fri May 02, 2014 3:34 pm

And str.format is also somewhat supported.

Code: Select all

print('This is {} test'.format('a'))
One place to look for examples is in the test tree. This tree contains test code which is run against python 3.3 and against MicroPython to confirm that MicroPython produces the same results.

So with str.format, for example, this works:

Code: Select all

>>> print('{:+8,d}'.format(1234))
  +1,234
but this doesn't (yet)

Code: Select all

>>> print('{foo:}'.format(foo=123))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: function does not take keyword arguments
I think that everything that's supposed to come after the colon is supported.

pfalcon
Posts: 1155
Joined: Fri Feb 28, 2014 2:05 pm

Re: print

Post by pfalcon » Fri May 02, 2014 4:07 pm

> but this doesn't (yet)

I'm glad you're aware ;-). I wanted to post a ticket to capture that, but didn't want it to sound as not appreciating your great work on supporting other format specifiers. But yep, there's yet a way to go before we have "complete" support for .format() or str %.
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

pfalcon
Posts: 1155
Joined: Fri Feb 28, 2014 2:05 pm

Re: print

Post by pfalcon » Fri May 02, 2014 4:10 pm

badryan wrote:<blushes>Oh.</blushes> Thank you very very much! I've never looked at the actual differences between Python 2 and 3!
I didn't know too much of differences between python 2 and 3 when I started with MicroPython, and now I'm pretty much Python3-ready. That's alone a great outcome from being acquainted with MicroPython, as Python3 is indeed the future, which despite some its controversies, becoming as present as we speak (for example, many Linux distros switch to python3 as default one).
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: print

Post by dhylands » Fri May 02, 2014 4:16 pm

Hey Paul,

File the ticket :) I've been developing for so long now that I have a pretty thick hide. Not to mention that at work, everything has to be reviewed by somebody else before it lands (gets checked in). It took me 9 review cycles to get my first bug landed :o

I'm also not one to take offense when bugs are found in my code. A bug is a bug and they should all be eradicated - it doesn't matter how they got there :D

asaf
Posts: 19
Joined: Sat Dec 29, 2018 4:32 pm

Re: print on pycharm

Post by asaf » Fri Mar 01, 2019 3:32 pm

How can i see the print on pycharm on the terminal log?
Thabks
Attachments
Screen Shot 2019-03-01 at 17.30.24.png
Screen Shot 2019-03-01 at 17.30.24.png (152.36 KiB) Viewed 19354 times

fstengel
Posts: 55
Joined: Tue Apr 17, 2018 4:37 pm

Re: print

Post by fstengel » Fri Mar 01, 2019 4:34 pm

You seem to have an encoding problem: your program does not even parse. See this thread on stackoverflow.

_meet_seth
Posts: 1
Joined: Sun Jun 14, 2020 1:58 pm

Re: print

Post by _meet_seth » Sun Jun 14, 2020 2:05 pm

Hello
I uploaded my code to esp8266 via pycharm. Just a simple statement print("Hello World"). When I execute this with REPL it works fine but when I flash it with main.py the pycharm window shows something like Soft Reboot and nothing gets printed.
Please Help
Thanks in advance

Post Reply