mirror of
https://github.com/python/cpython.git
synced 2025-07-31 23:23:11 +00:00
New class syntax.
Use ImportERror
This commit is contained in:
parent
ce08448165
commit
ccfd6e105b
1 changed files with 8 additions and 12 deletions
|
@ -176,7 +176,6 @@ print 'try_stmt' # 'try' ':' suite (except_clause ':' suite)* ['finally' ':' sui
|
||||||
### except_clause: 'except' [expr [',' expr]]
|
### except_clause: 'except' [expr [',' expr]]
|
||||||
try: pass
|
try: pass
|
||||||
try: 1/0
|
try: 1/0
|
||||||
except RuntimeError: pass
|
|
||||||
except ZeroDivisionError: pass
|
except ZeroDivisionError: pass
|
||||||
try: 1/0
|
try: 1/0
|
||||||
except EOFError: pass
|
except EOFError: pass
|
||||||
|
@ -269,11 +268,11 @@ x = 123
|
||||||
print 'classdef' # 'class' NAME parameters ['=' baselist] ':' suite
|
print 'classdef' # 'class' NAME parameters ['=' baselist] ':' suite
|
||||||
### baselist: atom arguments (',' atom arguments)*
|
### baselist: atom arguments (',' atom arguments)*
|
||||||
### arguments: '(' [testlist] ')'
|
### arguments: '(' [testlist] ')'
|
||||||
class B(): pass
|
class B: pass
|
||||||
class C1() = B(): pass
|
class C1(B): pass
|
||||||
class C2() = B(): pass
|
class C2(B): pass
|
||||||
class D() = C1(), C2(), B(): pass
|
class D(C1, C2, B): pass
|
||||||
class C():
|
class C:
|
||||||
def meth1(self): pass
|
def meth1(self): pass
|
||||||
def meth2(self, arg): pass
|
def meth2(self, arg): pass
|
||||||
def meth3(self, (a1, a2)): pass
|
def meth3(self, (a1, a2)): pass
|
||||||
|
@ -486,12 +485,9 @@ print 'Passed all tests.'
|
||||||
try:
|
try:
|
||||||
import mac
|
import mac
|
||||||
unlink = mac.unlink
|
unlink = mac.unlink
|
||||||
except NameError:
|
except ImportError:
|
||||||
try:
|
import posix
|
||||||
import posix
|
unlink = posix.unlink
|
||||||
unlink = posix.unlink
|
|
||||||
except NameError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
unlink('@test')
|
unlink('@test')
|
||||||
print 'Unlinked @test'
|
print 'Unlinked @test'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue