oh Sean this so beautiful and elegant, exactly what I was looking for. Thank you very much.
The rest of your code is what I was thinking doing with regex instead. This was the part I was not aware of class := self subclasses detect: [ :c | c pythonClassName = pythonClassName On Mon, Mar 9, 2015 at 11:02 PM, Sean P. DeNigris <s...@clipperadams.com> wrote: > kilon.alios wrote > > Is this possible ? Is this a smart way ? How would you do it ? > > IIUC I would parse just enough to separate the class name from the data, > and > then let each subclass parse the data. Something like: > PythonObject fromString: '< Bone [ "side bone" , IK = True , ( 1.0 , > 0.1 > , 0.2) ]>'. > where: > PythonObject>>#fromString: aString > | bracketContents pythonClassName data class | > bracketContents := aString allButFirst allButLast trimBoth. > pythonClassName := bracketContents copyUpTo: Character space. > data := bracketContents copyAfter: Character space. > class := self subclasses detect: [ :c | c pythonClassName = > pythonClassName > ]. > ^ class data: data. > > > > ----- > Cheers, > Sean > -- > View this message in context: > http://forum.world.st/Dealing-with-multiple-cases-of-a-string-while-keeping-code-short-and-OOP-friendly-tp4810731p4810778.html > Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com. > >