Shared2015-06-02-stackoverflow-30579552.sagewsOpen in CoCalc
Author: Samuel Lelièvre
Views : 3
# http://stackoverflow.com/questions/30579552/error-unexpected-eof-while-parsing
# Lack of indented block after "def xxx(yyy):" line # causes the following error here in SageMathCloud def elgamal_encrypt ( pub_key ,g ,p , message ): k = floor ( 1+( p -2)* random ()) return ( Mod (g , p )^ k , message * Mod ( pub_key ^k , p ) )
Error in lines 1-1 Traceback (most recent call last): File "/projects/fc94de41-6af4-4ee1-a684-c33a9e56b2b0/.sagemathcloud/sage_server.py", line 879, in execute exec compile(block+'\n', '', 'single') in namespace, locals File "<string>", line 1 def elgamal_encrypt ( pub_key ,g ,p , message ): ^ SyntaxError: unexpected EOF while parsing
# Proper indentation makes the same code work def elgamal_encrypt ( pub_key ,g ,p , message ): k = floor ( 1+( p -2)* random ()) return ( Mod (g , p )^ k , message * Mod ( pub_key ^k , p ) )
# PEP8-compliant spacing makes code more readable # See "PEP 0008 -- Style Guide for Python Code" # at https://www.python.org/dev/peps/pep-0008/ def elgamal_encrypt(pub_key, g, p, message): k = floor (1 + (p - 2) * random ()) return (Mod(g, p)^k, message * Mod(pub_key^k, p))