python icon indicating copy to clipboard operation
python copied to clipboard

[New Concept Exercise] : imports

Open DavidGerva opened this issue 5 years ago • 1 comments

This issue describes how to implement the imports concept exercise for the Python track, which should explain how & why it is useful to import names (libraries, modules, classes, functions, etc.) in Python. We're naming the concept "imports" to avoid a file name clash with the import keyword.

Getting started

Please please please read the docs before starting. Posting PRs without reading these docs will be a lot more frustrating for you during the review cycle, and exhaust Exercism's maintainers' time. So, before diving into the implementation, please read up on the following documents:

Please also watch the following video:

Goal

This concept exercise should convey a basic understanding and usage of import and import from in a Python program. Additionally, the student should learn how to employ the as keyword for aliasing (re-naming) in animport context.

Learning objectives

  • Use the import keyword to import an entire Python library or module for use in a program
  • use the as keyword to refer to an imported module by some other (aliased) name
  • use the from keyword to import only specific classes/functions/names from a library or module
  • use the as keyword with the from keyword to alias or re-name the specific classes/functions/names imported from a library or module.
  • be aware of import conventions as outlined in PEP8

Out of scope

  • The importlib module, and the customization of import behavior.

Concepts

  • import statement
  • import from statement
  • import ... as statement

Prerequisites

  • basics

Resources to refer to

Hints

  • Hints should refer to one or more of the links above, or analogous links from trusted sources or the Python docs.

Concept Description

(a variant of this can be used for the v3/languages/python/concepts/<concept>/about.md doc and this exercises introduction.md doc.)

Concept Description Needs to Be Filled In Here/Written

Some "extras" that we might want to include as notes in the concept description, or as links in links.json:

  • Considerations and conventions when importing a large amount of libraries.
  • Specific conventions used in large frameworks and projects such as django or pandas
  • More details on Pythons import system and importlib
  • Modules and and the module search path

Representer

No changes required.

Analyzer

No changes required.

Implementing

The general Python track concept exercise implantation guide can be found here.

Tests should be written using unittest.TestCase and the test file named imports_test.py.

Code in the .meta/example.py file should only use syntax & concepts introduced in this exercise or one of its prerequisites. Please do not use comprehensions, generator expressions, or other syntax not previously covered. Please also follow PEP8 guidelines.

Help

If you have any questions while implementing the exercise, please post the questions as comments in this issue, or contact one of the maintainers on our Slack channel.

Edits

  • Added additional links for as and from keywords. Re-phrased goals and objectives for clarity. @BethanyG

DavidGerva avatar May 24 '20 19:05 DavidGerva

Not yet sure we need/want an entire exercise devoted to import. Putting this back on hold until we decide.

BethanyG avatar Jun 16 '21 00:06 BethanyG

Flagging as close and re-open with new issue template. Also needs clarification on scope.

BethanyG avatar Sep 13 '22 15:09 BethanyG