@@ -452,6 +452,7 @@ A line must have at least two points.
452
452
Because of the similarities between polygon and line types it is possible to create
453
453
a line shape using either the "line" or "poly" method.
454
454
455
+
455
456
>>> w = shapefile.Writer()
456
457
457
458
>>> w.line(parts=[[[ 1,5] ,[ 5,5] ,[ 5,1] ,[ 3,3] ,[ 1,1]]] )
@@ -546,14 +547,12 @@ To store very large numbers you must increase the field length size to the total
546
547
>>> w.save('shapefiles/test/dtype')
547
548
548
549
>>> r = shapefile.Reader('shapefiles/test/dtype')
549
- >>> r.record(0)
550
- [1, 1.32, 1.3217328, -3.2302e-25, 1.3217328, 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000L]
551
- >>> r.record(1)
552
- [None, None, None, None, None, None]
550
+ >>> assert r.record(0) == [1, 1.32, 1.3217328, -3.2302e-25, 1.3217328, 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000]
551
+ >>> assert r.record(1) == [None, None, None, None, None, None]
553
552
554
553
555
554
Finally, we can create boolean fields by setting the type to 'L'.
556
- This field can take True or False values, or any string whose first character is one of YyTt (True) or NnFf (False).
555
+ This field can take True or False values, or 1 (True) or 0 (False).
557
556
None is interpreted as missing.
558
557
559
558
@@ -565,22 +564,30 @@ None is interpreted as missing.
565
564
>>> w.null()
566
565
>>> w.null()
567
566
>>> w.record(True)
568
- >>> w.record("Yes" )
567
+ >>> w.record(1 )
569
568
>>> w.record(False)
570
- >>> w.record("No" )
569
+ >>> w.record(0 )
571
570
>>> w.record(None)
571
+ >>> w.record("Nonesense")
572
572
>>> w.save('shapefiles/test/dtype')
573
573
574
574
>>> r = shapefile.Reader('shapefiles/test/dtype')
575
- >>> assert r.record(0) == [True]
576
- >>> assert r.record(1) == [True]
577
- >>> assert r.record(2) == [False]
578
- >>> assert r.record(3) == [False]
579
- >>> assert r.record(4) == [None]
580
-
575
+ >>> r.record(0)
576
+ [True]
577
+ >>> r.record(1)
578
+ [True]
579
+ >>> r.record(2)
580
+ [False]
581
+ >>> r.record(3)
582
+ [False]
583
+ >>> r.record(4)
584
+ [None]
585
+ >>> r.record(5)
586
+ [None]
581
587
582
588
You can also add attributes using keyword arguments where the keys are field names.
583
589
590
+
584
591
>>> w = shapefile.Writer()
585
592
>>> w.field('FIRST_FLD','C','40')
586
593
>>> w.field('SECOND_FLD','C','40')
0 commit comments