Hey guys, first time poster, relatively long time reader -- I am struggling creating a buffer class in python for my class. (relatively new to the language).
Here is the basic idea I want to do:
Implement a class that buffers text. The write() method adds a string to the buffer. If the added data contains a '*', print the buffer contents to the console up until and including the '*'.
buffer = Buffer()
buffer.write ('abcd') # prints nothing
buffer.write ('ef*gh') # prints abcdef*
buffer.flush () # prints gh
I get the basic idea, of how to call this stuff up, but I am definitely struggling getting in concatenating the strings within the script itself -- and having the program do what it requested.
Here is my script as it stands, with real and psuedo code. I know it's something really simple and I've run around this for probably twice as long as I should and I just need to move on. Any pushes or help in the right direction would be GREATLY appreciated! Thanks so much! (For whatever reason, the forum is not indenting the code properly, but its set up properly in my code, so no worries about that.)
def write(self, input):
s = input
t = s
if '*' in input:
input += t
# input = input.'do not print anything that comes after the *, but retain it)
s += t
#just keep concatenating until we have a * call
print input.#'print anything after the *'