@@ -263,11 +263,11 @@ Many of the other unicode operators work as you would expect
263
263
(exponents, fractions, π), but every unicode operator
264
264
or symbol that can be used in Perl 6 has an ASCII equivalent.
265
265
266
- = head2 Control flow
266
+ = head2 X < Control flow|Python >
267
267
268
268
Python has C < for > loops and C < while > loops:
269
269
270
- = for code :lang<python >
270
+ = for code :lang<Python >
271
271
for i in 1, 2:
272
272
print i
273
273
j = 1
@@ -346,7 +346,7 @@ Perl 6
346
346
}
347
347
348
348
349
- = head2 Lambdas, functions and subroutines
349
+ = head2 X < Lambdas, functions and subroutines|Python >
350
350
351
351
Declaring a function (subroutine) with C < def > in Python is accomplished
352
352
with C < sub > in Perl 6.
@@ -452,9 +452,10 @@ i.e. these are the same:
452
452
my $power = { $^x ** $^y };
453
453
my $power = -> $x, $y { $x ** $y };
454
454
455
- = head2 List comprehensions
455
+ = head2 X < List comprehensions|Python >
456
456
457
- Postfix statement modifiers and blocks can be combined to make list comprehensions.
457
+ Postfix statement modifiers and blocks can be combined to make list
458
+ comprehensions.
458
459
459
460
Python
460
461
@@ -491,9 +492,10 @@ becomes either of these:
491
492
Using C < map > (which is just like Python's C < map > ) and
492
493
C < grep > (which is like Python's C < filter > ) is an alternative.
493
494
494
- = head2 Classes and objects
495
+ = head2 X < Classes and objects|Python >
495
496
496
- Here's an example from the Python L < docs|https://docs.python.org/3/tutorial/classes.html#class-and-instance-variables > .
497
+ Here's an example from the Python
498
+ L < docs|https://docs.python.org/3/tutorial/classes.html#class-and-instance-variables > .
497
499
First, "instance variables", aka attributes in Perl 6:
498
500
499
501
Python:
@@ -512,7 +514,7 @@ Perl 6:
512
514
Constructors by default take named arguments in Perl 6,
513
515
and use the method C < new > .
514
516
515
- Python
517
+ Python:
516
518
517
519
= for code :lang<python>
518
520
d = Dog('Fido')
633
635
...
634
636
}
635
637
636
- = head2 Decorators
637
- X < |Decorators (Python) >
638
- X < |@decorator (Python) >
638
+ = head2 X < Decorators|Python >
639
639
640
640
Decorators in Python are a way of wrapping a function
641
641
in another one. In Perl 6, this is done with C < wrap > .
@@ -685,15 +685,13 @@ An alternative would be to use a trait:
685
685
686
686
world;
687
687
688
- = head2 Context managers
689
- X < |Context Managers (Python) >
690
- X < |with (Python) >
688
+ = head2 X < Context managers|Python >
691
689
692
690
Context managers in Python declare actions that happen when entering
693
691
or exiting a scope.
694
692
695
- Here's a python context manager that prints the strings
696
- 'hello', 'world', and 'bye':
693
+ Here's a Python context manager that prints the strings
694
+ 'hello', 'world', and 'bye'.
697
695
698
696
= begin code :lang<python>
699
697
class hello:
@@ -706,7 +704,7 @@ with hello():
706
704
print 'world'
707
705
= end code
708
706
709
- For enter and exit events, passing a block as
707
+ For " enter" and " exit" events, passing a block as
710
708
an argument would be one option:
711
709
712
710
sub hello(Block $b) {
@@ -728,8 +726,7 @@ run on entering or leaving a block.
728
726
say 'world';
729
727
}
730
728
731
- X < |input (Python) >
732
- = head2 Input
729
+ = head2 X < C < input > |Python>
733
730
734
731
In Python 3, the C < input > keyword is used to prompt the user:
735
732
0 commit comments