Python on Mac

Discussion in 'Mac Programming' started by dsbass98, Aug 5, 2014.

  1. dsbass98 macrumors newbie

    Joined:
    Aug 5, 2014
    #1
    Hi,
    i'm just starting out on python. I'm learning boolean data types however every time time i enter a string into terminal, i receive this error message:

    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    NameError: name 'true' is not defined
     
  2. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #2
    Post the exact line you entered.

    Post your OS version and your Python version.
     
  3. drsoong macrumors member

    Joined:
    Mar 24, 2008
    Location:
    Munich
    #3
    Upper case True and False

    True and False are case sensitive upper case in Python:

    >>> a=true
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    NameError: name 'true' is not defined
    >>> a=True
    >>> print a
    True
    >>>

    Quite confusing for C++ developers, where they are lower case.
     
  4. boast macrumors 65816

    boast

    Joined:
    Nov 12, 2007
    Location:
    Phoenix
    #4
    Helps using your favorite text editor with syntax highlighting to remember syntax when jumping between different languages.
     
  5. drsoong macrumors member

    Joined:
    Mar 24, 2008
    Location:
    Munich
  6. ArtOfWarfare macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #6
    Add true = True to your Python startup file and the capitalization stops mattering.
     
  7. dollystereo macrumors 6502a

    dollystereo

    Joined:
    Oct 6, 2004
    Location:
    France
    #7
    String:
    >>>a='true'

    Bool:
    >>>a=True

    Not the same...
     

Share This Page