- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 33.3k
gh-107017: Change Chapter Strings to Texts in the Introduction chapter. #107104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
      
            hugovk
  merged 8 commits into
  python:main
from
TommyUnreal:107017_tutorial_introduction_assumtions_removal_strings
  
      
      
   
  Jul 24, 2023 
      
    
  
     Merged
                    Changes from 3 commits
      Commits
    
    
            Show all changes
          
          
            8 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      27bd6d5
              
                Change Strings to Texts in introduction chapter.
              
              
                TommyUnreal 3edff8b
              
                New structure of first paragraph in Text chapter.
              
              
                TommyUnreal de2e3c5
              
                Refactor string quotes handling and examples.
              
              
                TommyUnreal 0306f45
              
                Replaced interactive interpreter with Python shell
              
              
                TommyUnreal 7bd1f2a
              
                Adjust length to match header
              
              
                TommyUnreal bd02929
              
                Fix grammar.
              
              
                TommyUnreal ef4f321
              
                Add a space before the hash to follow PEP 8
              
              
                TommyUnreal b737cac
              
                Add a space before the hash to follow PEP 8
              
              
                TommyUnreal File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -138,16 +138,25 @@ and uses the ``j`` or ``J`` suffix to indicate the imaginary part | |
|  | ||
| .. _tut-strings: | ||
|  | ||
| Strings | ||
| Text | ||
| ------- | ||
|  | ||
| Besides numbers, Python can also manipulate strings, which can be expressed | ||
| in several ways. They can be enclosed in single quotes (``'...'``) or | ||
| double quotes (``"..."``) with the same result [#]_. ``\`` can be used | ||
| to escape quotes:: | ||
| Python can manipulate text (represented by type :class:`str`, so called | ||
|         
                  TommyUnreal marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
| "strings") as well as numbers. This includes characters "``!``", words | ||
| "``rabbit``", names "``Paris``", sentences "``Got your back.``", etc. | ||
| "``Yay! :)``". They can be enclosed in single quotes (``'...'``) or double | ||
| quotes (``"..."``) with the same result [#]_. | ||
|  | ||
| >>> 'spam eggs' # single quotes | ||
| 'spam eggs' | ||
| >>> "Paris rabbit got your back :)! Yay!" # double quotes | ||
|         
                  TommyUnreal marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
| 'Paris rabbit got your back :)! Yay!' | ||
| >>> '1975' # digits and numerals enclosed in quotes are also strings | ||
|         
                  TommyUnreal marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
| '1975' | ||
|  | ||
| To quote a quote, we need to "escape" it, by preceding it with ``\``. | ||
| Alternatively, we can use the other type of quotation marks:: | ||
|  | ||
| >>> 'doesn\'t' # use \' to escape the single quote... | ||
| "doesn't" | ||
| >>> "doesn't" # ...or use double quotes instead | ||
|  | @@ -159,23 +168,15 @@ to escape quotes:: | |
| >>> '"Isn\'t," they said.' | ||
| '"Isn\'t," they said.' | ||
|  | ||
| In the interactive interpreter, the output string is enclosed in quotes and | ||
| special characters are escaped with backslashes. While this might sometimes | ||
| look different from the input (the enclosing quotes could change), the two | ||
| strings are equivalent. The string is enclosed in double quotes if | ||
| the string contains a single quote and no double quotes, otherwise it is | ||
| enclosed in single quotes. The :func:`print` function produces a more | ||
| In the interactive interpreter, the string definition and output string | ||
|          | ||
| can look different. The :func:`print` function produces a more | ||
| readable output, by omitting the enclosing quotes and by printing escaped | ||
| and special characters:: | ||
|  | ||
| >>> '"Isn\'t," they said.' | ||
| '"Isn\'t," they said.' | ||
| >>> print('"Isn\'t," they said.') | ||
| "Isn't," they said. | ||
| >>> s = 'First line.\nSecond line.' # \n means newline | ||
| >>> s # without print(), \n is included in the output | ||
| >>> s # without print(), special characters are included in the string | ||
| 'First line.\nSecond line.' | ||
| >>> print(s) # with print(), \n produces a new line | ||
| >>> print(s) # with print(), special characters are interpreted, so \n produces new line | ||
| First line. | ||
| Second line. | ||
|  | ||
|  | ||
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.