This forum is now read-only. Please use our new forums at

How to use APIs with Python Forum

View Course » View Exercise

166 points
Submitted by
over 4 years ago

Q. Best practice for determining text start/end for arguments.

As shown in the get placekitten tutorial you send a request with arguments ...500/1000).
I can see this refers to the text location of the ascii kitten.
Is there a way of telling how far a specific component of text is within the document without trial and error. Such that in the kitten example it is assumed it will always be 500 characters in.

2 votes


Basically, you'd loop through the each line of the file your program received, and check if line == "< main >". You could call that startIndex. Then you just have to find a "< /main >" using another conditional and now you have your two bounds that are now a bit more flexible than the given examples.

(I know there aren't spaces in < main >, but otherwise the forum software blanks it out for some reason)

999 points
Submitted by
about 4 years ago

0 votes


i don't understand exactly. could you explain in layman's terms please? :)

734 points
Submitted by
about 4 years ago

1 Comment

9b8dbfda258d124f11a39693dd297fae?s=140&d=retro Mitchell75 about 4 years ago

Ok another way of looking at it. If I was pulling data from an XML i could locate data in between to so basically a placeholders. Not sure of the correct naming refernces for this. So in the above example if the webmaster updated the page shifting the ascii text further down the page you would have to retweak your script each time to find the start of the oh so cute kitty.