#Python help requested

@thrrgilag @unixb0y @33MHz

From the example:
https://github.com/pnut-api/PNUTpy/blob/master/README.rst

I fail using *variable* `secrettoken` read from a file:

pnutpy.api.add_authorization_token(secrettoken)

How can it be done?
212906
@bazbt3 Pretty sure you need a file reader first and tell it the filename, then read from it and put it in a variable. @thrrgilag @33MHz
212907
@unixb0y Like this? (Print commented out.) ;)

tokenfile = open("secrettoken.txt", "r")
secrettoken = tokenfile.read()
# print secrettoken
pnutpy.api.add_authorization_token(secrettoken)

Pasting the token in 'quotes' just works.

// @33MHz @thrrgilag
212908
@bazbt3

def slurp(path):
text = ''
with open(path, 'r', encoding='utf8') as f:
text = f.read()
return text
212964
@bazbt3 yeah that should work :) @33MHz @thrrgilag
212983
@unixb0y BTW, can you see my app name?
// @33MHz @thrrgilag
212912
@bazbt3 yep pasting certainly works. For code that I share I typically store it in a config file and read it in on startup but if your code is secret you can hard code it. And yeah I can see the app name. :-)

@33MHz @unixb0y
212922
@thrrgilag :) I feel the need to make a gist.
// @unixb0y @33MHz
212931
@bazbt3 Feel free to crib from any of my code on https://code.monkeystew.net/thrrgilag. pnut-matrix and partybot are a couple of projects I write in python. hopefully soon I'll get PNUTpy based example code up along with other bits.
//@unixb0y @33MHz
212934
@thrrgilag Thanks. Hopefully I'll learn patience along the way too. :)
// @33MHz @unixb0y
212936
@thrrgilag Btw, does PNUTpy have other features besides posting, already or not? @bazbt3 @33MHz
212986
@unixb0y it does, though it's not all battle tested or nuanced, I'd say. /@thrrgilag
212997
@33MHz @unixb0y My intention is to switch my python projects like pnutbot and pnut-matrix over to using PNUTpy so that I can start filling in the gaps and make it solid.
213001
@33MHz where can I find docs? @thrrgilag
213209
212984
@unixb0y Choosing the app name took longer than coding and breaking and debugging *and* asking for help and receiving then implementing it. It really did. :}
// @thrrgilag @33MHz
213014
@bazbt3 Haha :D 👍 Good name is important 😉 @thrrgilag @33MHz
213211
@bazbt3 Path to file is likely wrong. Play in the REPL to verify.
212958
@jws I should have been more explicit. Uncommenting the print line prints the whole of the token text to the screen. Is the variable rather than text used by PNUTpy that's stumped me. :/

I've a use for the code you posted, so thankyou!!!
212970
@bazbt3 Unwanted newline at end of token? Try file.readlines()[0] or just token.strip().
212972
@bazbt3 In app this works: os.path.expanduser('~/Documents/mirabai-stats.txt')
212962
@bazbt3 In extension code I needed:

def sibling_path(filename):
return os.path.join(os.path.dirname(__file__), filename)
212963