Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Feb 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to make python ignore undefined attributes.

    Im working on a grid based zork game and am very new to coding. if i did something like this

    location_y = 1 * limit_y

    and limit_y is not defined, is there an easy way to make python ignore limit_y if it is not defined making location_y = 1

    Thanks for the help! it is greatly appreciated.

  • #2
    Regular Coder Samhain13's Avatar
    Join Date
    Aug 2008
    Location
    Pilipinas
    Posts
    169
    Thanks
    4
    Thanked 18 Times in 18 Posts
    Code:
    try:
        location_y = 1 * limit_y
    except:
        location_y = 1
    But that's not very nice. How about just starting with:
    Code:
    limit_y = 1
    I am a Man of Truth. I am a Free Human Person. I am a Peacemaker.
    ** Independent Multimedia Artist in Pasig **


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •