diff --git a/examples/0004_hello_world.py b/examples/0004_hello_world.py new file mode 100644 index 0000000..17adbf7 --- /dev/null +++ b/examples/0004_hello_world.py @@ -0,0 +1,4 @@ +import judge0 + +result = judge0.run(source_code="print('Hello Judge0')") +print(result.stdout) diff --git a/src/judge0/api.py b/src/judge0/api.py index a892b57..61a7948 100644 --- a/src/judge0/api.py +++ b/src/judge0/api.py @@ -50,8 +50,8 @@ def resolve_client( return JUDGE0_IMPLICIT_EXTRA_CE_CLIENT raise RuntimeError( - "Failed to resolve the client from submissions argument." - "None of the implicit clients supports all languages from the submissions." + "Failed to resolve the client from submissions argument. " + "None of the implicit clients supports all languages from the submissions. " "Please explicitly provide the client argument." ) @@ -95,7 +95,17 @@ def async_execute( *, client: Optional[Union[Client, Flavor]] = None, submissions: Optional[Union[Submission, list[Submission]]] = None, + source_code: Optional[str] = None, + **kwargs, ) -> Union[Submission, list[Submission]]: + if submissions is not None and source_code is not None: + raise ValueError( + "source_code argument cannot be provided if submissions argument is provided." + ) + + if source_code is not None: + submissions = Submission(source_code=source_code, **kwargs) + # Check the edge cases if client is not provided. if client is None: if submissions is None: @@ -119,7 +129,17 @@ def sync_execute( *, client: Optional[Union[Client, Flavor]] = None, submissions: Optional[Union[Submission, list[Submission]]] = None, + source_code: Optional[str] = None, + **kwargs, ) -> Union[Submission, list[Submission]]: + if submissions is not None and source_code is not None: + raise ValueError( + "source_code argument cannot be provided if submissions argument is provided." + ) + + if source_code is not None: + submissions = Submission(source_code=source_code, **kwargs) + # Check the edge cases if client is not provided. if client is None: if submissions is None: diff --git a/src/judge0/submission.py b/src/judge0/submission.py index 229d42f..40ffede 100644 --- a/src/judge0/submission.py +++ b/src/judge0/submission.py @@ -54,7 +54,7 @@ class Submission: def __init__( self, source_code: str, - language_id: Union[Language, int], + language_id: Union[Language, int] = Language.PYTHON, *, additional_files=None, compiler_options=None, pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy