![]() Keep object names short: this makes them easier to read when scanning through code. Below are some of the PEP 8 guidelines related to expressive object names. PEP 8 style guide has a suite of recommendations that focus on making Python code more readable. Source: Jenny Bryan, Reproducible Science Curriculum.ĭata Tip: The the PEP 8 Style Guide suggests that all objects (variables, functions and methods) in your code are named using meaningful words. It's easier for someone to understand your code without running it when your code variables describe the objects that they contain. You can imagine that this might be confusing to someone who is looking for rice in your kitchen! Consider this when writing code. This container clearly contains cookies and yet it's labeled as rice. After you’ve been programming for a while, you will begin to see that consistently formatted code is much easier for your eye to scan and quickly understand. Source: Jenny Bryan, Reproducible Science Curriculum.Įxpressive code is also important for naming variables and functions in your Python code because it will make your code easier to understand for someone who is skimming it in the same way that it makes it easier for someone to understand a file directory structure.Įxpressive code is another part of clean coding - that is writing code that is easier for you, your future self and for someone else to look at and understand. Compare the list of file names on the LEFT to those on the right - which ones are easier to quickly understand? File and directory names that clearly indicate the type of information stored within that file or directory are the most useful or expressive to your colleagues or your future self as they allow you to quickly understand the structure and contents of a project directory. ![]() So for example you probably expect a directory called data to contain data within it. As a refresher, expressive names are ones that describe the contents of the object itself. In chapter one on open reproducible science, you learned about best practices for organizing open reproducible science projects, including how to create directories and files with names that are both expressive and machine readable. Describe the PEP 8 recommendations for Python object names.Create expressive names for objects in your Python code. ![]() ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |