be carefulif we want to manipulate single element in the bytearrayit will expect us to pass an integer between and inclusive as the value this integer represents specific bytes pattern if we try to pass character or bytes objectit will raise an exception single byte character can be converted to an integer using the ord (short for ordinalfunction this function returns the integer representation of single characterb bytearray( 'abcdef' [ ord( ' ' [ print(bthe output looks like thisbytearray( 'abcgdf'after constructing the arraywe replace the character at index (the fourth characteras indexing starts at as with listswith byte this integer was returned by the ord function and is the ascii character for the lowercase for illustrationwe also replaced the next character up with the byte number which maps to the ascii character for the uppercase the bytearray type has methods that allow it to behave like list (we can append integer bytes to itfor example)but also like bytes objectwe can use methods like count and find the same way they would behave on bytes or str object the difference is that bytearray is mutable typewhich can be useful for building up complex sequences of bytes from specific input source regular expressions you know what' really hard to do using object-oriented principlesparsing strings to match arbitrary patternsthat' what there have been fair number of academic papers written in which object-oriented design is used to set up string parsingbut the result is always very verbose and hard to readand they are not widely used in practice in the real worldstring parsing in most programming languages is handled by regular expressions these are not verbosebutboyare they ever hard to readat least until you learn the syntax even though regular expressions are not object orientedthe python regular expression library provides few classes and objects that you can use to construct and run regular expressions