I will agree with everything but the first one. I prefer functions that claim to return True or False to return precisely that, rather than Truthy/Falsy values. Otherwise, if I want to do "if func() is other_val" where "other_val" is True or False, it will fail.
PEP 8 only mentions truth checks, it doesn't mention if functions' return values should be True or the truthy value. Personally, I find it very unclean to have your function return half a string, or some unrelated int or something similar when your function is called, e.g. "is_member()".
Ah, sorry think we are talking about different things. I thought you where complaining about:
if [something]:
VS
if [something] is True:
In the case I think you are talking about I would probably agree with you that returning some non-boolean is less clean, though I would probably just use the equality operator to force a boolean result:
'copyright': 'For use only by clients authorized in writing by IMDb. Authors and users of unauthorized clients accept full legal exposure/liability for their actions.'
There has been a ruby library called imdb-party that I used several years ago to do this: https://github.com/maddox/imdb-party. Leverages the IMDB iOS API also.
20 comments
[ 5.0 ms ] story [ 53.4 ms ] threadA few unsolicited code tips that seem to come up often if I may:
- `if <somestuff>: return True; else: return False` is always best spelled `return <somestuff>`
- You only need the global statement when you want to assign to a global, not access one
- `foo = d["bla"] if "bla" in d else None` is just `foo = d.get("bla")`
- You have mutable default args. They probably are not what you want. See http://docs.python-guide.org/en/latest/writing/gotchas/#muta... for e.g. for an explanation.
- Lots of your dicts with enumerates to set indices should just probably be lists
If I get a chance later I'll try to throw together a quick pull request, but otherwise, thanks for sharing.
Also, here the point is that <some stuff> was a boolean expression already.
The second one is rather restrictive (and the first one does not exist...)
[1]: https://developers.google.com/webmasters/control-crawl-index...
For use by clients authorized in writing by IMDb.
-- http://app.imdb.com/
OP: Did you ask for authorization?
Since he is using the API key taken from the official app (see: https://github.com/maddox/imdb-party/issues/8#issuecomment-1... ) i really doubt he got anything from them.
There has been a ruby library called imdb-party that I used several years ago to do this: https://github.com/maddox/imdb-party. Leverages the IMDB iOS API also.
Here is part of the code I used for simulating their id system (ex: tt0903624): # http://www.imdb.com/title/tt0903624/
require "imdb_party"
imdb = ImdbParty::Imdb.new
all_movies = (1..999999).map{ |m| "tt" + ("%07d" % m).to_s }
https://github.com/dpiers/pymdb
Last I checked it still worked, surprising since I was just scraping html. :)