[Tutor] Question on a example in the book "Learn to program
usingpython" by Alan Gauld
Klas Marteleur
klas.martelleur at telia.com
Mon Aug 2 23:51:00 CEST 2004
Sorry to bother you guys again with a few more "stupid" questions more, just
so i understand everything correct.
Is it correct...
1. that there is nothing in this program that "senses" which type of file i
pass as a parameter?
2. that if you want to analyse a .txt file instead of a .html file, you change
the last bit from "D = HTMLDocument(sys.argv[1])" to "D =
TextDocument(sys.argv[1])"?
Kind regards
Klas
måndagen den 2 augusti 2004 22.05 skrev Alan Gauld:
> > Shouldnt there be a "...D = TextDocument(sys.argv[1])... " somewere?
>
> Only if you pass it .txt files.
> An interesting excercise would be to strip off the last bit of
> the filename and see if it matches '.txt' or '.htm' or '.html'
> and create the appropriate type of document object.
>
> Hint: There is a module for manipulating filenames :-)
>
> > OT...and Alan you should not be sorry for the small errors in your
>
> book,
>
> > its the best "computer book" i have ever read
>
> Aw shucks! :-)
>
> As to your problem, I can't see anything significantly different to
> my original code (as per the CD ROM with the book and written prior
> to the reviewers and copy-editors and typesetters "improvements"!)
> which definitely works...
>
> I'll try to get back to it later tonight.
> Meantime, what kind of file are you passing as a parameter?
> And are you actually using TextDocument or HTMLDocument?
>
> Regards,
>
> Alan G.
More information about the Tutor
mailing list