From: Joerg L. <jo...@us...> - 2004-07-22 12:17:58
|
Hi André, On 22.07.04, Andre Wobst wrote: [...snip...] > But we could establish something much more intuitive to the user in > terms of the return value of the plot command. First, each style could > have a return value in the donedrawpoints method (or it might return > None, which would be counted as no return value). In case several > return values will occure in the different styles, we could create a > list of return values. Otherwise the return value could be taken as it > is. > > (As a side remark: In case, the plot command was used with a list of > data in the first place, we could always return a list of the result > values ... it might happen to have a list as items than.) Sounds good, except for the problem described by you below. So each style can choose the data it wants to pass back to the user, which might not only be the path but also colours, etc. > But there is, of course, a problem: We can't return something from the > donedrawpoint method at the plot command, because donedrawpoint will > be called much later. But we could return a wrapper along the lines > you can find enclosed. fancy_return acts like the returnvalue of data, > but it deferes referencing to the returnvalue until something is > accessed. We can even automate the neccessary finishing of the graph > that way. This would be one solution. Btw, in principle, this could also be done by returning a list. > In summary the plot command could directly return the path, when a > line is drawn (it would return a fancy_return instance instead, but > this might not matter so much). And as soon as properties of the path > are accessed, the graph could be finished automatically. (BTW: We > could do an automatic finish in graph.pos() and the like as well ...) Alternatively, if we want to act according to "The Zen of Python" #2, namely "Explicit is better than implicit", we could also raise an exception when trying to access the return value and the graph has not yet been finished. > OTOH, I'm not sure whether fancy_return would be too fancy ... The name certainly is, but besides that I begin to like the idea. Jörg |