The Python Alliance (Lightweight TBA Client in Python)

(this is a CD post of my reddit post here: http://redd.it/4nniua)

Hi everyone,
I spent a day out to learn Python a bit (and am utterly disappointed by the lack of overloading methods, but eh.)
So I wrote a basic interface for TBA using their API and JSON parsing.

Right now, it can do the following things:

  • View all events this season (and their respective alliances for 1-8)
  • View a single team’s basic info.
  • View all teams on a TBA page (1-499, 500-999, etc.)
  • View all district codes and their respective names.
  • View district rankings & points.

With more features as I learn more / get requested!

Happy FIRSTing!

Screenshots
https://i.imgur.com/zhWc8wb.png
https://i.imgur.com/DZ7K7n2.png
https://i.imgur.com/rgnUraW.png
https://i.imgur.com/maI5WZG.png

Looks like great starter code for a TBA API introduction!

Thanks for sharing.

Nice work!

Update!

New features include:

  • Individual Event Information
  • More modularized code!
  • Unfinished feature to automatically highlight a team in your district rank view.

To be worked on:
An entire python library for TBA calls… (v2 only likely)
OPR & rank manipulation (depending on what I get around to doing…)
Data output (hopefully)

Again, the whole project is opensource, so feel free to contribute!

(Side note, this only properly works in Python 2.7 because of input() vs raw_input(). If anyone has a solution that works in both, I’d happily accept…)

Good job, Tim.

A quick-and-dirty solution that comes to mind is writing your own input function with a try-except block:

def my_input(prompt):
     try:
          return raw_input(prompt) 
     except:
          return input(prompt) 

An alternative, more sophisticated approach would be to check the Python version in your function. This Stack Overflow thread talks about how to use the Python version number in a program.

A similar method can be used for print() vs the print keyword, which should make it compatible with both Python 2.7 and 3.X.