0

In some tutorial, for syntax from DateTime import DateTime, it is mentioned that importing DateTime object from DateTime module. Somewhere it is said importing DateTime module from DateTime package.

Can anyone explain the correct information?

Mohammed Zayan
  • 859
  • 11
  • 20
Adil
  • 2,418
  • 7
  • 34
  • 38
  • 1
    I guess you mean `datetime.datetime`, read the docs it explains https://docs.python.org/3/library/datetime.html Also, next time don't say "some tutorial" and "Somewhere", be specific and provide your sources – Chris_Rands Jul 23 '18 at 14:36
  • These are four terms easy enough to look up, so we assume you have done so. Without knowing the context of the phrases you cite, we have little way of knowing where you are confused. Please read and follow the posting guidelines in the help documentation, as suggested when you created this account. [On topic](http://stackoverflow.com/help/on-topic), [how to ask](http://stackoverflow.com/help/how-to-ask), and [perfect question](https://codeblog.jonskeet.uk/2010/08/29/writing-the-perfect-question/) apply here. – Prune Jul 23 '18 at 14:48
  • 1
    Possible duplicate: https://stackoverflow.com/questions/7948494/whats-the-difference-between-a-python-module-and-a-python-package – jkdev Jul 23 '18 at 18:07

2 Answers2

21

1-object is instance of class

2-every file of Python source code whose name ends in a .py extension is a module

3-package is collection of modules. It is a directory which contains a special file __init__.py

4-Python packages without an __init__.py file are known as “namespace packages”

5-Library is collection of various packages

6-A framework is a large codebase, or collection of code, meant to provide universal, reusable behavior for a targeted project ,frameworks are different from other external codebases, such as libraries, because they feature inversion of control

for more information visit this site: https://www.quora.com/What-is-the-difference-between-Python-modules-packages-libraries-and-frameworks

kamyarmg
  • 760
  • 2
  • 6
  • 23
0

Module can be a script/library usually in the same working directory. Depending on your IDE this may take some more setup but in your working directory you can see this functionality.

create a new python script called print_stuff.py

In this script write the following:

def print_a_string():
    print('Hello from print_stuff)

Then in a new script in that directory put the import

from print_stuff import print_a_string as pas

pas()

A package is, as implied, a packaged module that is available to the python interpreter. This involves seting up an init.py, setup.py etc so that any script can use that package.

krflol
  • 1,105
  • 7
  • 12