Skip to content

Instantly share code, notes, and snippets.

@kshirsagarsiddharth
Created July 19, 2020 17:23
Show Gist options
  • Select an option

  • Save kshirsagarsiddharth/b6358f00cff8fe0ec5bc4f2ba27af7db to your computer and use it in GitHub Desktop.

Select an option

Save kshirsagarsiddharth/b6358f00cff8fe0ec5bc4f2ba27af7db to your computer and use it in GitHub Desktop.
using replace method on namedtuple
from collections import namedtuple
animal = namedtuple('animal',['species_name','legs_no','color'])
dog = animal('canine',4,'white')
dog = dog._replace(legs_no = 6)
print(dog.legs_no)
# Output: 6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment