DolphDev / pynationstates

Python API wrapper for NationStates
MIT License
15 stars 4 forks source link

'from' in census mode history is a Python reserved keyword and cannot be used #5

Closed L4in closed 8 years ago

L4in commented 8 years ago

I would like to implement a watcher system that reports all changes in a nation's census since last week. For the moment, I built a shard nationstates.Shard("census", scale="all", mode="history"), collect the data and manually browse the points until I find the desired timestamp.

Using nationstates.Shard("census", scale="all", mode="history",from="one_week_ago") would be the best option server-wise, as it would reduce network usage and not contain any unneeded data, thus being in accord with the Nationstates API. Alas, the keyword from is reserved in Python and cannot be used in this way as it yield a SyntaxError The current implementation put an unneeded strain on the server as it forces to fetch much more data than needed. This is specially true for quite old nations, with great amounts of data points.

DolphDev commented 8 years ago

There is currently a work-around for python syntax clashes.

nationstates.Shard("census", scale="all", mode="history", **{"from":"one_week_ago"})

Other python modules will sometimes use something like _from, but that's not currently supported.