Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6796389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:27:42+00:00 2026-05-26T18:27:42+00:00

Suppose I have following code: def foo(s): A dummy function foo. For example: >>>

  • 0

Suppose I have following code:

def foo(s):
    """A dummy function foo. For example:

>>> a = '''This is a test string line 1
This is a test string line 2
This is a test string line 3'''
>>> foo(a)
This is a test string line 1
This is a test string line 2
This is a test string line 3
>>>
    """
    print s

if __name__ == '__main__':
    import doctest
    doctest.testmod()

And let’s save it as foo.py. When I run:

C:\Python27>python.exe foo.py
**********************************************************************
File "foo.py", line 5, in __main__.foo
Failed example:
    a = '''This is a test string line 1
Exception raised:
    Traceback (most recent call last):
      File "C:\Python27\lib\doctest.py", line 1254, in __run
        compileflags, 1) in test.globs
      File "<doctest __main__.foo[0]>", line 1
        a = '''This is a test string line 1
                                          ^
    SyntaxError: EOF while scanning triple-quoted string literal
**********************************************************************
File "foo.py", line 8, in __main__.foo
Failed example:
    foo(a)
Exception raised:
    Traceback (most recent call last):
      File "C:\Python27\lib\doctest.py", line 1254, in __run
        compileflags, 1) in test.globs
      File "<doctest __main__.foo[1]>", line 1, in <module>
        foo(a)
    NameError: name 'a' is not defined
**********************************************************************
1 items had failures:
   2 of   2 in __main__.foo
***Test Failed*** 2 failures.

Have tried indent the docstring ( >>> a = ”’…”’. Have checked all indents – 4 spaces for each indent) and changed single quote to double quote (>>> a = “””….”””), the errors are different and the doctest just won’t go successfully. Currently the only thing work is to join all lines to a extreme long string and separate with ‘\r\n’.

Do I miss something?

  • 1 1 Answer
  • 3 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T18:27:42+00:00Added an answer on May 26, 2026 at 6:27 pm

    I think you need to put some dots there

    >>> a = """This is a test string line 1
    ... This is a test string line 2
    ... This is a test string line 3"""
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have following string: String asd = this is test ass this is
Suppose I have following code def foo(x:Int):Unit = { if (x == 1) println
Suppose I have the following python code: def outer(): string = def inner(): string
Suppose I have the following code: class siteMS { ... function __CONSTRUCT() { require
Suppose I have the following code: foreach(string str in someObj.GetMyStrings()) { // do some
Say suppose I have the following Java code. public class Example { public static
Suppose I have a line of code that starts like the following: Func1(Func2(Func3 Is
Suppose we have following code defined in tester.py class Tester( object ): def method(
Suppose we have the following code: class Test { private Test() { System.out.println(test); }
Suppose I have the following code: type Vehicle = | Car of string *

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.