SirAnthony
28.01.2011 06:04
text = re.sub('---.*$', '', text, 0, re.M)
TypeError: sub() takes at most 4 arguments (5 given)
>re.sub(pattern, repl, string[, count, flags])
Я в замешательстве.
Python 2.7.1 (r271:86832, Jan 6 2011, 11:45:30)
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> text = re.sub('—-.*$', '', text, 0, re.M)
>>> text = re.sub('---.*$', '', text, 0, re.M)
>>> print text
bugaga
Python 3.1.3 (r313:86834, Dec 1 2010, 12:16:07)
[GCC 4.5.1 20101125 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> text = 'bugaga---test'
>>> text = re.sub('---.*$', '', text, 0, re.M)
>>> print(text)
bugaga
Python 2.6.6 (r266:84292, Dec 11 2010, 01:41:36)
[GCC 4.5.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> text = 'bugaga---test'
>>> text = re.sub('---.*$', '', text, 0, re.M)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: sub() takes at most 4 arguments (5 given)
>>>
Лол, надо копать, что-то не то с питоном.
Python 2.4.6 (#1, Apr 1 2010, 09:51:23)
[GCC 4.4.3 20100316 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> text = 'bugaga---test'
>>> text = re.sub('---.*$', '', text, 0, re.M)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: sub() takes at most 4 arguments (5 given)
>>> print help(re.sub)
Help on function sub in module sre:
sub(pattern, repl, string, count=0)
Return the string obtained by replacing the leftmost
non-overlapping occurrences of the pattern in string by the
replacement repl. repl can be either a string or a callable;
if a callable, it's passed the match object and must return
a replacement string to be used.
(END)
p.s. print перед хелпом бессмысленный
Ох, и правда. А в доках 5 аргументов.