"UtcNow" returns a DateTime, so when you import it into your namespace, you're importing a DateTime instead of some kind of property reference. This is by design. The proper usage is from System import DateTime DateTime.UtcNow
This is also consistent with usage under C#. I think the ability to import "get_UtcNow" was a bug that has been fixed for the RC. On Fri, Oct 24, 2008 at 12:13 PM, Phil Vacca <[EMAIL PROTECTED]> wrote: > Hi, > > I've been using each of the Betas of IPy 2, but now that I've switched > to RC1, I've got a probem. The function get_UtcNow() doesn't seem to > exist in the RC. Also the UtcNow method seems to have a major problem > as well. I am hoping this is related to my own usage, and not to the > IPy build! > > At the interpreter "from System.DateTime import get_UtcNow" fails > under the current RC (ipy.exe fileversion 2.0.11020.0), but works fine > from beta 5 (ipy.exe fileversion 2.0.10310.5). > > The error I get reads: > File "<stdin>", line 1, in <module> > ImportError: Cannot import name get_UtcNow > > running "dir( System.DateTime )" shows confirming results. The "get_" > functions just don't appear to be in there... > > So, I tried just using the System.DateTime UtcNow method. > Unfortunately, it seems to only work once. By this I mean that it > returns the correct time for UtcNow at import, but then every > subsequent call returns the SAME initialized time. This behavior is > consistent at least against Beta 4 & 5, as well as the RC. > > I ran the following code at the beta 5 interpreter and got these results: > import System > from System.DateTime import UtcNow, get_UtcNow > > def problem(): > print UtcNow, get_UtcNow() > print long(sum([i for i in range(10000000)])) ## waste some cycles > print UtcNow, get_UtcNow() > > def noProblem(): > print System.DateTime.UtcNow, get_UtcNow() > print long(sum([i for i in range(10000000)])) ## waste some cycles > print System.DateTime.UtcNow, get_UtcNow() > > >>> problem() > 10/24/2008 7:11:21 PM 10/24/2008 7:11:28 PM > 49999995000000 > 10/24/2008 7:11:21 PM 10/24/2008 7:11:32 PM > >>> noProblem() > 10/24/2008 7:11:43 PM 10/24/2008 7:11:43 PM > 49999995000000 > 10/24/2008 7:11:47 PM 10/24/2008 7:11:47 PM > > Does anyone else observe this same behavior? > > -Phil > > [EMAIL PROTECTED] > _______________________________________________ > Users mailing list > [email protected] > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >
_______________________________________________ Users mailing list [email protected] http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
