[IronPython] Overloads

Martin Maly martmaly at exchange.microsoft.com
Wed Aug 3 17:52:00 CEST 2005


Hi Jonathan,

the Random.Next is not a static method. You can either pass the instance as the first argument:

>>> System.Random.Next[int](System.Random(), 10)
7
>>> System.Random.Next[int](System.Random(), 10, 20)
IronPython.Objects.PythonValueError: Bad args for the method <method# Next on System.Random>
   at input_8.Run(Frame frame)
>>> System.Random.Next(System.Random(), 10, 20)
18

or call:

>>> r = System.Random()
>>> r.Next.__doc__
'int Next()\r\nint Next(int, int)\r\nint Next(int)'
>>> r.Next[int](10, 20)
IronPython.Objects.PythonValueError: Bad args for the method <method# Next on System.Random>
   at input_12.Run(Frame frame)
>>> r.Next[int](10)
5

However, I think your question brings up a valid point ... how do we distinguish between static and instance methods in the __doc__ strings? Surely there is not difference now and that is confusing.

Martin

________________________________________
From: Jonathan Jacobs
Sent: 8/3/2005 12:31 AM
To: users-ironpython.com at lists.ironpython.com
Cc:
Subject: [IronPython] Overloads

Hi,

I'm pleased to see 0.9 is out and the thank you message. :-)

Hopefully I'm just being stupid about this, but I can't seem to get this
overload story to behave:

>>> System.Random.Next
<method# Next on System.Random>
>>> print System.Random.Next.__doc__
int Next()
int Next(int, int)
int Next(int)
>>> print System.Random.Next[int].__doc__
int Next(int)
>>> System.Random.Next[int](5)
IronPython.Objects.PythonValueError: Bad args for the method <method#
Next on System.Random>
   at input_8.Run(Frame frame)

Any suggestions are most welcome.

--
Jonathan
_______________________________________________
users-ironpython.com mailing list
users-ironpython.com at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20050803/c8891c3b/attachment.html>


More information about the Ironpython-users mailing list