standupmaths / frog_problem

Here is the frog problem code I wrote in an Edinburgh pub.
17 stars 15 forks source link

Clean up Matt's drunken coding #10

Open Adam-Hoelscher opened 5 years ago

Adam-Hoelscher commented 5 years ago

added shebang replaced C-style looping with pythonic looping put in version checking so it runs in python3 also added doc strings poked fun at Matt, even though I'm actually really jealous: I need more friends who want to sit around a pub and write python with me on random nights

septatrix commented 5 years ago

You could also use randint instead of randrange and save a +1 offset.

Also I haven't tried but I think you need to import the print function from future if you want to use it in Python 2🤔

Adam-Hoelscher commented 5 years ago

Also I haven't tried but I think you need to import the print function from future if you want to use it in Python 2

Matt's original code was written for Python2; it's why he manually built a tab-delimited string for printing

AustinTSchaffer commented 5 years ago

@Adam-Hoelscher, @Septatrix is saying that you should add a from __future__ import print_function to the imports in order to unambiguously support Python 3, as well as Matt's development setup, which uses Python 2.

@Septatrix, just tested it, the print statement at the bottom works on Python 2.

Adam-Hoelscher commented 5 years ago

Also I haven't tried but I think you need to import the print function from future if you want to use it in Python 2🤔

This doesn't sound like a request for Python 3 support to me

septatrix commented 5 years ago

Yes you are right but I thought you had to include said statement to use the print('') function instead of the print '' statement in Python 2 but according to the docs and Auston it is optional from version 2.6.0a2 and onwards so my bad :D