• macmacmac

    Thanks for both methods. Very useful to know.

    posted in Pythonista read more
  • macmacmac

    @ywangd: Thanks a lot for the simple solution. Restarting did the trick. Thanks also for writing stash.

    @Webmaster4o : Thanks for the useful advise. For future problems: How do I download, unzip and install a module manually using Pythonista?

    posted in Pythonista read more
  • macmacmac

    I installed the hyphenation module pyphen from pyphen.org using pip install Pyphen in stash. When I run the simple test below I get a TypeError:coercing to Unicode:need... The module should be 100% pure Python.

    import pyphen
    dic = pyphen.Pyphen(lang='en_EN')
    print( dic.wrap('community', 4)  )

    posted in Pythonista read more
  • macmacmac

    The Pythonista code below connects to an HM-10 BLE module connected to an Arduino (TX>RX, RX>TX). It sends the character 'H' to turn on the internal LED of the Arduino.
    It works, but is it possible to simplify the code? I know the name of the module (HM-10-BLE) the UUID of its only service (FFE0) and the UUID of its only characteristic (FFE1). Do I really have to scan and compare, discover and compare and discover and compare each and every time I want to connect? Is there a way to connect directly using name and UUIDs?

    # Sending the character 'H' to an HM-10 BLE module
    # Module Name 'HM-10-BLE’
    # Module Service UUID 'FFE1' 
    # Module Characteristics UUID 'FFE0'
    import cb
    class MyCentralManagerDelegate (object):
        def __init__(self):
            self.peripheral = None
        def did_discover_peripheral(self, p):
            if p.name == 'HM-10-BLE' and not self.peripheral:
                print 'Discovered ' + p.name
                self.peripheral = p
        def did_connect_peripheral(self, p):
            print 'Connected Peripheral ' + p.name
            print 'Looking for Service FFE0'
        def did_discover_services(self, p, error):
            for s in p.services:
                if s.uuid == 'FFE0':
                    print 'Found Service ' + s.uuid
                    print 'Looking for Characteristic FFE1'
        def did_discover_characteristics(self, s, error):       
            for c in s.characteristics:
                if c.uuid == 'FFE1':
                    print 'Found Characteristic ' + c.uuid
                    print 'Writing H'
                    self.peripheral.write_characteristic_value(c, 'H', False)
    cb.set_central_delegate( MyCentralManagerDelegate() )
    print 'Looking for HM-10-BLE module'
    # Keep the connection alive until the 'Stop' button is pressed:
        while True: pass
    except KeyboardInterrupt:
        # Disconnect everything:

    Arduino code:

    Turns thes LED on pin 13 on or off
    Serial.read(); reads one byte in ASCII Format.
    The result is either 65 or ‘A’ in single quotess
    #include <SoftwareSerial.h>
    SoftwareSerial softSerial(10, 11); // RX, TX
    byte command;
    void setup() {
      pinMode(13, OUTPUT);
    void loop() {
      command = softSerial.read(); //Read one byte
      if (command  == 'L') {
        digitalWrite(13, LOW);
      if (command == 'H')  {
        digitalWrite(13, HIGH);

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!