> I am making a Hand History converter for online poker players. > This takes the textual record of how a hand played and turns > into a more readable format suitable for posting at various websites > where people discuss how the hand was played. Id like to start > with the converter working for one particular online poker site > (every site formats their hand histories somewhat differently) > and expand it so that it can recognize the site a hand history > came from and format accordingly.
I don't know anything about poker but in general terms this is a text format conversion tool. since you know the source can be in different formats I'd adopt an OOP approach with a generic hand object which can be subclassed for each new format. The methods of the hand object might be something like load() and print(). The load method will be specific to each site and will convert the site format to some standard format defined in the generic hand. The print method then prints to a standard output format and only needs overriding for sites where you need a different output format - which sounds to be rare from your desciption. The generic hand class then allows you to write the resty of the application in a generic way without worrying about site details apart from the point where you instantiate the hands - and even that can be data driven via an external file or environment variable etc.. > So, I am pretty sure that regular expressions will play > a big part in the functions in this program. Possibly but I would defer that decision for as long as possible! > Also, the converter needs to be able to pull dollar amounts > out and add them up to keep a running pot size for each > round of betting. You may need a pot class in the same way as the hand above - but I'm not sure how that would workj since I don't know anything about poker! > really be helpful is if someone was willing to correspond > privately since Im sure I will have a flood of questions It would be more helpful - to you and the rest of the readership - if you keep it public. The kind of questions you will be asking are likely to be the kind any newbie will come across in a real project. By sharing the pain you also share the experience. You also get access to many more heads. > PS I should add that some of these "converters" already exist, > I have the perl script for one but the site I currently play on > isnt supported and plus I just want to do this. :) Converting the Perl into Python shouldn't be too hard when we get to the stage of needing to do that. For now let's start with one site and get it working, while building in enough flexibility for the future sites we know we need to deal with later. In fact maybe we should start at the end and work on the internal data structure needed to print out the final format. Can we define a program that can read the target format in and print oit out in the desired format? It may sound trivial but it gets a lot of the scaffolding in place early. Alan Gauld Author of the Learn to Program web site http://www.freenetpages.co.uk/hp/alan.gauld _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor