In addition to the rich set of string object methods, Python provides an assortment of functions for working with strings.
- [Instructor] The Python standard library…provides a number of useful string-oriented functions…beyond the methods of the string class itself.…Here in Komodo, I open a working copy of hello.py…from chapter 13 of the exercise files,…and let's just go ahead and make this into a string.…And I'm going to print…the repr function of s,…and when I run this, you notice that…repr will print the string itself.…
So, repr stands for representation.…It'll print the best possible…string representation of an object.…What's interesting about this is…if I create a class here, and…let's say I initialize my variable with this.…Now, when I print the representation of it,…you'll notice it says, it's a bunny object at,…and it gives me the memory address.…This is not terribly helpful.…
What representation does, what repr does is…it will print the value returned…by the special repr method.…And so, if I say def_repr,…and I'll return a string.…And now, when I run this,…the repr is going to have that string,…the number of bunnies is 47.…
Now is this distinct from…
- Python anatomy
- Types and values
- Conditionals and operators
- Building loops
- Defining functions
- Python data structures: lists, tuples, sets, and more
- Creating classes
- Handling exceptions
- Working with strings
- File input/output (I/O)
- Creating modules
- Integrating a database with Python db-api
Skill Level Intermediate
Python: Programming Efficientlywith Michele Vallisneri2h 15m Intermediate
2. Language Overview
3. Types and Values
8. Structured Data
11. String Objects
12. File I/O
13. Built-in Functions
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.