[Swansea Hackspace] Text Editor for code...

Ian Bullfrog sevendev.tk at gmail.com
Wed Nov 5 20:54:17 GMT 2014


yeah, let me know how it goes Emyr and if you find any good BBedit 
tutorials or handy sites, let me know.
Ive just become a bit of a sublime Whore now, but use BB all the time, 
but, oddly enough just for keeping my essential files together for quick 
viewing. logins etc. real overkill, textwrangler alone would have sufficed.

in other news.

IVe FINALLY got around to starting some programming! woo hoo.
Python.

using Programming the Raspberry Pi , getting started with Python
by Simon Monk (thank you Ponty Library)

http://www.monkmakes.com/?page_id=63#comment-969132

its actually not a bad book! some bits of it ...go a little awry in the 
explanations, but
theres a lot of little bits of enough interesting stuff at a not bad 
rate of delivery to get you trying just about anything!
starts simple, explains hello world etc, how to install and set it up, 
hardware, serial ports, gui programming, python syntax , how to create 
classes and modules of your own etc etc at an interesting mix of levels.

and Ive just written my first program to.... read... and write, between 
My newly aquired Raspberry pi running Raspbian and my Hackspace Arduino!
woo hoo!!!

lots of tinkering, like about 3 days after several more of basic python 
learning. Ive done little else. this pi is strangely addictive to play 
with. no fear factor of trashing the OS cos.   ... you just pull the 
SDcard out and reflash it.
haaa!

I also learnt about the diff between Python 2 and 3. nadda nadda!
something to do with string types and bytes... if anyone else tryies 
this, then they will find the Serial port program in the book doesnt 
work. nuts.
however after much googling, I got it figured.

to do with passing 'str' values along the serial to the Arduino...er, 
you have to use the

ser.write (bytes(somevalue, encoding ='ascii'))

format instead of the much simpler

ser.write('somevalue')  version

if someone could explain, nicely, what the difference between python 
vers 2 and 3 is with regard these types, and what the differece really 
is , in whats getting passed with the two lines to get the same nice 
simple *flashing LED * on the arduino, Id love to know.

also, I can run the program in IDLE3, on the pi, no probs (yay, success) 
in its Python Shell, and can run the program via f5 in the open file, 
text editor, but

If I run the same program via the terminal on the piI get an error along 
the line of

File *<String>*, line 1 in <module>
NameError: name 'o' is not defined.

o is the charecter I entered into the program and the idle shell, with 
success in order to open the serial port to my arduino from the Pi.

when I enter the same charecter in the program running in the shell I 
get that above error.

also,

if I ssh into the pi via the network and try to run the same prorgram via

pi at raspberrypi~ python pi-py.py

then it seems to fire up with other errors ...and looks like it returns 
the IDLE, python shell display, ie,

 >>> is visible, it doesnt just *run* my python file, play nice and open 
my serial port to my arduino and flash my pretty lights.

so a few things there.

if im doing something daft in order to remotely run my python program 
via ssh, can you tell me that too?
ok cheers

bye








More information about the Hackspace mailing list