[Tutor] Python script errors

2018-12-12 Thread Ravi Kumar
Hi, I have developed a python script to get api calls for meraki clientlogevents Thanks for all the help previously I am facing few errors such as Json_string=r.json() raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value:

Re: [Tutor] Python script errors

2018-12-12 Thread Alan Gauld via Tutor
On 12/12/2018 12:57, Ravi Kumar wrote: > '{0:20} {1:30} {2:16} {3:18} {4:10} {5:11} '.format( > deviceserial, type, macaddress,occurredAt, details)) > TypeError: unsupported format string passed to NoneType.__format__ You have 6 format holders in your string but you only pass 5

Re: [Tutor] Python script errors

2018-12-12 Thread Peter Otten
Ravi Kumar wrote: > Hi, > > I have developed a python script to get api calls for meraki > clientlogevents Thanks for all the help previously I am facing few errors > such as > > Json_string=r.json() > > raw_decode > raise JSONDecodeError("Expecting value", s, err.value) from None >

Re: [Tutor] Python script errors

2018-12-12 Thread Steven D'Aprano
On Wed, Dec 12, 2018 at 06:57:09AM -0600, Ravi Kumar wrote: > I know this occurs when the api response is nulls but how do I handle this? if response is None: handle None case else: handle non-None case -- Steve ___ Tutor maillist -

Re: [Tutor] Increase performance of the script

2018-12-12 Thread Peter Otten
Steven D'Aprano wrote: > [...] >> In python 2.6 print statement work as print "Solution" >> however after import collection I have to use print with >> print("Solution") is this a known issue ? > > As Peter says, you must have run > > from __future__ import print_function > > to see this

Re: [Tutor] Increase performance of the script

2018-12-12 Thread Steven D'Aprano
On Wed, Dec 12, 2018 at 12:52:09AM -0500, Avi Gross wrote: > Asad, > > I wonder if an import from __future__ happened, perhaps in the version of > collections you used. Later versions of 2.x allow optional use of the 3.x > style of print. The effect of __future__ imports, like any other import,

Re: [Tutor] Python_About "Guess my number" program

2018-12-12 Thread Alan Gauld via Tutor
On 12/12/2018 05:26, Hoang Quoc Dat wrote: > find out 1 similar program but the coding logic is like: The computer keeps > guessing the middle number of the range and narrow down the range by > focusing on only the upper/lower part of the range after receiving our > answer. > > I somehow have

Re: [Tutor] Python_About "Guess my number" program

2018-12-12 Thread Steven D'Aprano
Hi Dat, and welcome! On Wed, Dec 12, 2018 at 11:26:30AM +0600, Hoang Quoc Dat wrote: [...] > After a while, I went on and search on the internet and > find out 1 similar program but the coding logic is like: The computer keeps > guessing the middle number of the range and narrow down the range by

Re: [Tutor] Increase performance of the script

2018-12-12 Thread Avi Gross
Asad, I wonder if an import from __future__ happened, perhaps in the version of collections you used. Later versions of 2.x allow optional use of the 3.x style of print. When you redefine print, the old statement style is hidden or worse. -Original Message- From: Tutor On Behalf Of

[Tutor] Python_About "Guess my number" program

2018-12-12 Thread Hoang Quoc Dat
Dear all, This is Dat, I am a newbie in learning Python. My recent attempt is to read and practice the book of Michael Dawson-Python Programming for the Absolute Beginner 3rd Edition. At the end of Chapter 3 there is a challenge of creating "Guess my number" program where the computer guess your