md5 strange error

Rhodri James rhodri at wildebst.demon.co.uk
Wed Oct 21 18:39:34 EDT 2009


On Wed, 21 Oct 2009 23:28:24 +0100, Stephen Fairchild  
<somebody at somewhere.com> wrote:

> Tim Golden wrote:
>
>> catalinfest at gmail.com wrote:
>>> I have this error , what happen ?
>>>
>>> Python 2.5.2 (r252:60911, Sep 30 2008, 15:41:38)
>>> [GCC 4.3.2 20080917 (Red Hat 4.3.2-4)] on linux2
>>> Type "help", "copyright", "credits" or "license" for more information.
>>>>>> import md5
>>>>>> pass = md5.new()
>>>   File "<stdin>", line 1
>>>     pass = md5.new()
>>>          ^
>>> SyntaxError: invalid syntax
>>
>> pass is a keyword, as in:
>>
>> def f ():
>>   pass
>>
>
> Correct form when you want to use a keyword for a variable is to precede  
> it
> with and underscore.
>
> _pass = md5.new()

Other way round; you put the underscore at the end according to PEP-8
(http://www.python.org/dev/peps/pep-0008/)

pass_ = md5.new()

-- 
Rhodri James *-* Wildebeest Herder to the Masses



More information about the Python-list mailing list