Python Forum
Feedback on my first Python module
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Feedback on my first Python module
#4
(Jun-16-2018, 12:55 PM)Larz60+ Wrote: There is a trick you can use to change any value to True or false:
 λ python Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 17:00:18) [MSC v.1900 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> x = 'Hello' >>> not not x True >>> x = 0 >>> not not x False >>> 
so when you write a statement like:
 if result == 0: return True else: return False 
it can be shortened to:
 return not not result 
which will return True or False

Pretty cool. I had to write
return not result
in order for it to write True on 0 and False on any other number. Thanks for the contribution! Updated the module :)
Reply


Messages In This Thread
Feedback on my first Python module - by CodeRaker - Jun-16-2018, 12:07 PM
RE: Feedback on my first Python module - by Larz60+ - Jun-16-2018, 12:55 PM
RE: Feedback on my first Python module - by CodeRaker - Jun-16-2018, 03:21 PM
RE: Feedback on my first Python module - by buran - Jun-16-2018, 03:29 PM
RE: Feedback on my first Python module - by buran - Jun-16-2018, 03:52 PM
RE: Feedback on my first Python module - by buran - Jun-16-2018, 05:17 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  My First Python Script. Feedback Sought. malonn 5 3,875 Jun-29-2018, 03:49 PM
Last Post: Zombie_Programming
  Feedback on module GamePatrol 1 2,501 Mar-06-2018, 07:40 AM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020