[Edu-sig] OK, time for 2.4

Kirby Urner urnerk at qwest.net
Sun Oct 24 18:53:46 CEST 2004


OK, it's that time of year again, when we dive into a new Python.  

Here's transcript of my first baby steps, edited to remove some butt bumps
and head knocks.

Kirby

================

 Python 2.4b1 (#57, Oct 15 2004, 15:23:38) [MSC v.1310 32 bit (Intel)] 
 on  win32
 Type "copyright", "credits" or "license()" for more information.

     ****************************************************************
     Personal firewall software may warn about the connection IDLE
     makes to its subprocess using this computer's internal loopback
     interface.  This connection is not visible on any external
     interface and no data is sent to or received from the Internet.
     ****************************************************************
    
IDLE 1.1a3      
 >>> g = (i for i in range(10))
 >>> g
 <generator object at 0x00C43710>
 >>> g.next()
 0
 >>> g.next()
 1
 >>> g.next()
 2
 >>> help(decimal)

 Traceback (most recent call last):
   File "<pyshell#5>", line 1, in -toplevel-
     help(decimal)
 NameError: name 'decimal' is not defined

 [read docs for awhile ]

 >>> import decimal
 >>> d1 = decimal.Decimal(2)
 >>> d1
 Decimal("2")
 >>> type(d1)
 <class 'decimal.Decimal'>
 >>> d1 + d1
 Decimal("4")
 >>> float(d1)
 2.0

 >>> d1.prec()

 Traceback (most recent call last):
   File "<pyshell#21>", line 1, in -toplevel-
     d1.prec()
 AttributeError: 'Decimal' object has no attribute 'prec'

[read PEP in more depth]

 >>> decimal.getcontext()
 Context(prec=28, rounding=ROUND_HALF_EVEN, Emin=-999999999, Emax=999999999,

 capitals=1, flags=[], traps=[DivisionByZero, Overflow, InvalidOperation])
 >>> c = decimal.getcontext()
 >>> c.prec
 28

Ah so...

Kirby




More information about the Edu-sig mailing list