| 
      
      
      From: Andre W. <wo...@us...> - 2005-09-01 16:54:27
      
     | 
| Hi,
On 01.09.05, se...@so... wrote:
> I would like to ask you whether the following "feature" could be 
> implemented 
> in pyx. Currently, things like colour, style etc. are given to methods in 
> a list
> (such as [color.rgb.blue] in
> c.fill(union, [color.rgb.blue])
> taken from one of your examples)
> 
> What do you think about allowing (e.g.)
> c.fill(union, color.rgb.blue)? (it is just that sometimes there are too 
> many brackets, so it might be good to get rid of the frequent [,]). 
> Naively it should require just replacing
> 
> def fill(..., list_of_args=[]):
>     ...
> 
> with
> 
> def fill(..., *list_of_args):
>     if len(list_of_args) is 1 and isinstance(list_of_args[0],list):
>         list_of_args=list_of_args[0]
>     ...
> 
> 
> but I imagine in real life things are more complicated.
> Anyway, I'd be glad for your opinion.
Thanks for your suggestion. I should tell you, that in earlier
versions we had such an automatism and at some point we dropped it!
Let me briefly explain you why: There are frequently cases, where we
do have not just a single attributes list accepted by the
method/constructor/etc. Still, one could think of such an automatism.
Suppose you have something like:
    def arrow(styles=[], length=1*unit.v_cm):
        ...
Currently you could use it by:
    arrow(styles=[style1, style2])
but also by
    arrow([style1, style2])
(The point is, that Python allows you to omit the keywords, when using
the arguments in the order they are defined.) Suppose we do such an
automatism. Than you could do:
    arrow(styles=[style1, style2])
    arrow(styles=style1)
    arrow(style1)
but the following would fail with a very strange error message:
    arrow(style1, style2)
So the whole point is, that you could easily forget the brackets.
That's why we started at all places, where from the design point of
few, we do want to be able to handle several distinct arguments.
You may have a look to the mailing list archive ... about 1 1/2 years
ago. There was quite some discussion about it which all the pro's and
con's ...
André
-- 
by  _ _      _    Dr. André Wobst
   / \ \    / )   wo...@us..., http://www.wobsta.de/
  / _ \ \/\/ /    PyX - High quality PostScript and PDF figures
 (_/ \_)_/\_/     with Python & TeX: visit http://pyx.sourceforge.net/
 |