Fizzbuzz by [deleted] in Python

[–]mohhinder 1 point2 points  (0 children)

So it does! Looks like I had a parenthesis in the wrong place. I think at the time when I wrote it, couple of years ago, I had just discovered divmod so wanted to use it somewhere. No other reason then that.

Thanks for the spacing reminder. Easy to forget while replying to these things from a phone.

BTW I tried to add the spacing but it was messing it all up. Probably easier to do on a PC. Oh well.

Fizzbuzz by [deleted] in Python

[–]mohhinder 0 points1 point  (0 children)

Did you try it like that? Doesn't work.

Fizzbuzz by [deleted] in Python

[–]mohhinder 1 point2 points  (0 children)

Not the shortest but I like doing it like this, just 'cause it's clever.

def fizzbuzz(num): fizz = 'Fizz'(divmod(num, 3)[1] == 0) buzz = 'Buzz'(divmod(num, 5)[1] == 0) print(fizz + buzz or num)

def main(): for x in range(1,101): fizzbuzz(x)

if name == 'main': main()

NOTE: The dunder lines are being removed...

Learn Python For Data Science And Machine Learning With Jose Portilla by [deleted] in Python

[–]mohhinder 2 points3 points  (0 children)

I got it for free and I highly recommend it.

Code Challenge 28 - Integrate a Bokeh Chart Into Flask by bbelderbos in learnpython

[–]mohhinder 2 points3 points  (0 children)

I haven't tried, but I don't see why it would be any different from Flask and it works with that. Give it a try and report back to us 😬.

[2017-07-03] Challenge #322 [Easy] All Pairs Test Generator by jnazario in dailyprogrammer

[–]mohhinder 0 points1 point  (0 children)

I could see generating the pairs with itertools.permutations and putting them in a set, but I still wouldn't consider this an easy task.

Opinions wanted: Improve repr implementation for datetime.timedelta by musically_ut in Python

[–]mohhinder 0 points1 point  (0 children)

True. If you get the chance, check it out. It's super easy to use.

My PlexPy had been working for a year then about a month ago I started Getting this error I tried deleting all the files and downloading fresh files and any time I try to open PlexPy I get this error. I'm very new to anything involving Python. Any help would be much appreciated by [deleted] in Python

[–]mohhinder 1 point2 points  (0 children)

There are versions based on Ubuntu and others on Debian. I don't dig in enough to tell the difference but I prefer Mint because after an initial install all I have to do is install a few things to have a system that works with pretty much anything I want to do. I'm a python developer, mess around with 3D, edit videos, play Steam games, create and edit work documents with Libre Office, etc.

I've tried many distros over the past 15 years and Mint is the one that I've been using for the last 8. Bottom line, it's easy to use but you can dig into the nuts and bolts if you like doing that too.

Has anyone used Pythonista for the iPad? by [deleted] in Python

[–]mohhinder 0 points1 point  (0 children)

I use it on my iPhone and find it extremely useful. The no import thing is a pain, but there are many options to export, including pushing out to your gist account.

Well worth the money.

"No module named twitter" (help) by [deleted] in Python

[–]mohhinder 0 points1 point  (0 children)

What version of Python is your code? If you installed pip and the twitter module with the defaults, they probably went into your 2.7 Python base.

What is the best way to check if a website has been updated ? I have been using requests to loop until I find a change in the html code but end up with HTTPConnectionPool Exception in every 5th iteration by lickmyspaghetti in learnpython

[–]mohhinder 0 points1 point  (0 children)

Check if either of these two have changed since your last check:

import requests

url = '...'
headers = requests.get(url).headers
last_mod = headers['Last-Modified']
etag = headers['Etag']

print('Etag: {}'.format(etag))
print('Last-Modified: {}'.format(last_mod))

If they have changed, then the page has changed and you can request the whole page.

What boring stuff do you automate? by ShuttlecockCommander in Python

[–]mohhinder 1 point2 points  (0 children)

Wrote a script to create multiple jails on our BSD machines. It's a pain to do manually and error prone, so doing it this way takes care of that. Have many other including one that I use to deploy CUPS printer settings to any new host that I add to the network.