<commit_before># minimal.py --- Minimal example of using traits.

#--[Imports]--------------------------------------------------------------------
from enthought.traits.api import HasTraits, Float

#--[Code]-----------------------------------------------------------------------

class Person(HasTraits):
    weight = Float(150.0)

#--[Example*]-------------------------------------------------------------------

# instantiate the class
joe = Person()
# Show the default value
joe.weight
150.0
# Assign new values
joe.weight = 161.9     # OK to assign a float 
joe.weight = 162       # OK to assign an int
# The following line causes a traceback:
joe.weight = 'average' # Error to assign a string 

<commit_msg>Modified example so it doesn't display the traceback, but instead displays a message.<commit_after># minimal.py --- Minimal example of using traits.

#--[Imports]--------------------------------------------------------------------
from enthought.traits.api import HasTraits, Float, TraitError

#--[Code]-----------------------------------------------------------------------

class Person(HasTraits):
    weight = Float(150.0)

#--[Example*]-------------------------------------------------------------------

# instantiate the class
joe = Person()

# Show the default value
print joe.weight

# Assign new values
joe.weight = 161.9     # OK to assign a float 
print joe.weight

joe.weight = 162       # OK to assign an int
print joe.weight

# The following line causes a traceback:
try:
    joe.weight = 'average' # Error to assign a string
    print "You should not see this message."
except TraitError:
    print "You can't assign a string to the 'weight' trait."


{'fraction_non_alphanumeric': 0.32281119714115547, 'fraction_numerical': 0.015485407980941036, 'mean_word_length': 1.4034334763948497, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6265983', 'n_tokens_mistral': 442, 'n_tokens_neox': 401, 'n_words': 157}