[IronPython] [python] Import Now

Davy Mitchell daftspaniel at gmail.com
Sun Oct 7 23:08:09 CEST 2007


Yeah sounds reasonable but a little clunky :-)

Davy

On 10/7/07, Michael Foord <fuzzyman at voidspace.org.uk> wrote:
> Davy Mitchell wrote:
> > IronPython console: IronPython 2.0A4 (2.0.10904.02) on .NET 2.0.50727.312
> > Copyright (c) Microsoft Corporation. All rights reserved.
> >
> >>>> from System.DateTime import Now
> >>>> print Now
> >>>>
> > 07/10/2007 21:23:20
> >
> >>>> print "a few seconds later" + Now.ToString()
> >>>>
> > a few seconds later07/10/2007 21:23:20
> >
> >>>> from System.DateTime import Now
> >>>> print Now
> >>>>
> > 07/10/2007 21:24:02
> >
> >
> > Huh?!??! :-)
> >
> >
>
> That's kind of what I would expect. :-)
>
> Now is actually a (static) member of the DateTime class - but in .NET
> you can do this kind of import.
>
> DateTime instances are immutable - so accessing 'Now' returns the
> current one (which doesn't then change). When you import again you
> look-up the new current time.
>
> Just import DateTime and access 'Now' whenever you need it...
>
> Michael
> http://www.manning.com/foord
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>


-- 
Davy Mitchell
Blog - http://www.latedecember.co.uk/sites/personal/davy/
Twitter - http://twitter.com/daftspaniel
Skype - daftspaniel
needgod.com



More information about the Ironpython-users mailing list