1

Just wanted to get the package name of a given module, why does not the dunder package attribute work?

import sys, inspect, os, numpy as np
print("The os package name is " + os.__package__)
print("The np package name is " + np.__package__)
print("The inspect package name is " + inspect.__package__)
print("The sys package name is " + sys.__package__) 

What I get from the above is as follows.

The os package name is 
The np package name is numpy
The inspect package name is 
The sys package name is

As you can see, it works only for numpy and does not work for others. Can someone enlighten me why? What am I missing?

VivekDev
  • 20,868
  • 27
  • 132
  • 202

1 Answers1

1

Check out PEP366

Also check out this other StackOverflow post whats-the-purpose-of-the-package-attribute-in-python

Orenshi
  • 1,773
  • 11
  • 12