View Single Post
  #5   Spotlight this post!  
Unread 15-06-2016, 12:39
Brian Maher's Avatar
Brian Maher Brian Maher is offline
Questionable Decisionmakers
FRC #2791 (Shaker Robotics), FRC #1257 (Parallel Universe)
Team Role: College Student
 
Join Date: Apr 2014
Rookie Year: 2012
Location: Troy, NY; NJ
Posts: 470
Brian Maher has a reputation beyond reputeBrian Maher has a reputation beyond reputeBrian Maher has a reputation beyond reputeBrian Maher has a reputation beyond reputeBrian Maher has a reputation beyond reputeBrian Maher has a reputation beyond reputeBrian Maher has a reputation beyond reputeBrian Maher has a reputation beyond reputeBrian Maher has a reputation beyond reputeBrian Maher has a reputation beyond reputeBrian Maher has a reputation beyond repute
Re: The Python Alliance (Lightweight TBA Client in Python)

Good job, Tim.
Quote:
Originally Posted by tjf View Post
(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...)
A quick-and-dirty solution that comes to mind is writing your own input function with a try-except block:
Code:
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.
__________________
2016-present, Mentor, FRC 2791 - Shaker Robotics
2016: Tech Valley SF (5236, 2791, 3624) and Quality, Finger Lakes SF (5254, 2791, 2383), Battlecry@WPI Winner (195, 2791, 501), Robot Rumble Winner (2791, 195, 6463)

2016-present, Mentor, FRC 1257 - Parallel Universe
2016: Mount Olive Winner (1257, 5624, 1676), Bridgewater-Raritan Finalist (1257, 25, 3340, 555) and GP, MAR CMP Winner (225, 341, 1257), Archimedes SF (4003, 4564, 5842, 1257), IRI Invite

2012-2015, Student, FRC 1257 - Parallel Universe
2015: Mount Olive QF (1257, 1811, 1923) and Safety Award, North Brunswick Finalist (11, 193, 1257) and Team Spirit and Safety Awards
2014: Clifton Winner (1626, 869, 1257), MAR CMP QF (1257, 293, 303)
2013: TCNJ Safety Award
2012: Mount Olive QF (204, 303, 1257)

Last edited by Brian Maher : 15-06-2016 at 18:41.
Reply With Quote