servo library, set() conflict
Moderators: adafruit_support_bill, adafruit

Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit:

servo library, set() conflict

by watanabe on Fri Mar 01, 2013 1:32 pm

Not sure if this is the right place for this, but last night I was working on a little bit of code to cross reference two strings for any matching words, and made use of the set() type(function?) in python. I spent an hour or two trying to figure out why it was giving me the error "set requires 2 arguments, only providing 1".

Finally figured out the conflict was because of the code I was using from the ada examples on using a servo. I got around it by renaming the function in the servo. Anyways not sure if this solution is the best way to go about it and/or if the servo code should be updated to not include this standard python namespace (also not sure if that is the correct term or not).

string search code:
Code: Select all | TOGGLE FULL SIZE
# Word Find
def find_words(text, search):
        word_set = set(search.split())
        phrase_set = set(text.split())
        matches = word_set.intersection(phrase_set)
        numMatches = len(matches)
        return numMatches

offending adacode (replaced set() with setS(ervo) )
Code: Select all | TOGGLE FULL SIZE
# Servo Control
def setS(property, value):
                f = open("/sys/class/rpi-pwm/pwm0/" + property, 'w')
                print("Error writing to: " + property + " value: " + value)

def setServo(angle):
        setS("servo", str(angle))
setS("delayed", "0")
setS("mode", "servo")
setS("servo_max", "180")
setS("active", "1")
Posts: 1
Joined: Fri Mar 01, 2013 1:23 pm