Skip to content

Commit ba842ef

Browse files
committed
Update
1 parent 61a5d4e commit ba842ef

File tree

2 files changed

+72
-14
lines changed

2 files changed

+72
-14
lines changed

.ipynb_checkpoints/Modules_and_Packages-checkpoint.ipynb

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -251,23 +251,27 @@
251251
},
252252
{
253253
"cell_type": "code",
254-
"execution_count": 7,
254+
"execution_count": 4,
255255
"metadata": {},
256256
"outputs": [
257257
{
258258
"name": "stdout",
259259
"output_type": "stream",
260260
"text": [
261-
"['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'accumulate', 'acos', 'acosh', 'altzone', 'asctime', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'ceil', 'chain', 'comb', 'combinations', 'combinations_with_replacement', 'compress', 'copysign', 'cos', 'cosh', 'count', 'ctime', 'cycle', 'daylight', 'degrees', 'dist', 'dropwhile', 'e', 'erf', 'erfc', 'exp', 'expm1', 'fabs', 'factorial', 'filterfalse', 'floor', 'fmod', 'frexp', 'fsum', 'gamma', 'gcd', 'get_clock_info', 'gmtime', 'groupby', 'hypot', 'inf', 'isclose', 'isfinite', 'isinf', 'islice', 'isnan', 'isqrt', 'ldexp', 'lgamma', 'localtime', 'log', 'log10', 'log1p', 'log2', 'mktime', 'modf', 'monotonic', 'monotonic_ns', 'nan', 'perf_counter', 'perf_counter_ns', 'perm', 'permutations', 'pi', 'pow', 'prime', 'prime_gen', 'prime_square', 'process_time', 'process_time_ns', 'prod', 'product', 'radians', 'remainder', 'repeat', 'sin', 'sinh', 'sleep', 'sqrt', 'starmap', 'strftime', 'strptime', 'struct_time', 'takewhile', 'tan', 'tanh', 'tau', 'tee', 'thread_time', 'thread_time_ns', 'time', 'time_ns', 'timezone', 'trunc', 'tzname', 'zip_longest']\n",
261+
"['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__primeval__', '__spec__', 'accumulate', 'acos', 'acosh', 'altzone', 'asctime', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'ceil', 'chain', 'comb', 'combinations', 'combinations_with_replacement', 'compress', 'copysign', 'cos', 'cosh', 'count', 'ctime', 'cycle', 'daylight', 'degrees', 'dist', 'dropwhile', 'e', 'erf', 'erfc', 'exp', 'expm1', 'fabs', 'factorial', 'filterfalse', 'floor', 'fmod', 'frexp', 'fsum', 'gamma', 'gcd', 'get_clock_info', 'gmtime', 'groupby', 'hypot', 'inf', 'isclose', 'isfinite', 'isinf', 'islice', 'isnan', 'isqrt', 'ldexp', 'lgamma', 'localtime', 'log', 'log10', 'log1p', 'log2', 'mktime', 'modf', 'monotonic', 'monotonic_ns', 'nan', 'perf_counter', 'perf_counter_ns', 'perm', 'permutations', 'pi', 'pow', 'prime', 'prime_gen', 'prime_square', 'process_time', 'process_time_ns', 'prod', 'product', 'radians', 'remainder', 'repeat', 'sin', 'sinh', 'sleep', 'sqrt', 'starmap', 'strftime', 'strptime', 'struct_time', 'takewhile', 'tan', 'tanh', 'tau', 'tee', 'thread_time', 'thread_time_ns', 'time', 'time_ns', 'timezone', 'trunc', 'tzname', 'zip_longest']\n",
262+
"\n",
263+
"['__annotations__', '__call__', '__class__', '__closure__', '__code__', '__defaults__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__get__', '__getattribute__', '__globals__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__kwdefaults__', '__le__', '__lt__', '__module__', '__name__', '__ne__', '__new__', '__qualname__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__']\n",
262264
"\n",
263-
"['In', 'Out', '_', '__', '___', '__builtin__', '__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__', '_dh', '_i', '_i1', '_i2', '_i3', '_i4', '_i5', '_i6', '_i7', '_ih', '_ii', '_iii', '_oh', 'exit', 'get_ipython', 'i', 'pg', 'pgf', 'prime_gen', 'quit']\n"
265+
"['In', 'Out', '_', '__', '___', '__builtin__', '__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__', '_dh', '_i', '_i1', '_i2', '_i3', '_i4', '_ih', '_ii', '_iii', '_oh', 'exit', 'get_ipython', 'prime_generator', 'quit']\n"
264266
]
265267
}
266268
],
267269
"source": [
268-
"import prime_gen\n",
270+
"import prime_generator\n",
269271
"\n",
270-
"print(dir(prime_gen))\n",
272+
"print(dir(prime_generator))\n",
273+
"print()\n",
274+
"print(dir(prime_generator.prime_gen))\n",
271275
"print()\n",
272276
"print(dir())"
273277
]
@@ -276,14 +280,30 @@
276280
"cell_type": "markdown",
277281
"metadata": {},
278282
"source": [
279-
"## namespace:\n"
283+
"## namespace:\n",
284+
"\n",
285+
"A container that has a list of names (objects) defined in a module. It is the place where python searches for objects defined and used in a function."
280286
]
281287
},
282288
{
283289
"cell_type": "markdown",
284290
"metadata": {},
285291
"source": [
286-
"## Global, Local and Built-in Namespaces"
292+
"## Global, Local and Built-in Namespaces\n",
293+
"\n",
294+
"### Global:\n",
295+
"Namespace containing values defined throughout a file or module (globally)\n",
296+
"\n",
297+
"### Local:\n",
298+
"Namespace containing values defined in a part of a file or module (Locally)\n",
299+
"\n",
300+
"### Builtin:\n",
301+
"Namespace containing values common for all python file.\n",
302+
"\n",
303+
"## Order of Search:\n",
304+
"1. Local\n",
305+
"2. Global\n",
306+
"3. Builtin"
287307
]
288308
},
289309
{

Modules_and_Packages.ipynb

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -251,23 +251,27 @@
251251
},
252252
{
253253
"cell_type": "code",
254-
"execution_count": 7,
254+
"execution_count": 4,
255255
"metadata": {},
256256
"outputs": [
257257
{
258258
"name": "stdout",
259259
"output_type": "stream",
260260
"text": [
261-
"['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'accumulate', 'acos', 'acosh', 'altzone', 'asctime', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'ceil', 'chain', 'comb', 'combinations', 'combinations_with_replacement', 'compress', 'copysign', 'cos', 'cosh', 'count', 'ctime', 'cycle', 'daylight', 'degrees', 'dist', 'dropwhile', 'e', 'erf', 'erfc', 'exp', 'expm1', 'fabs', 'factorial', 'filterfalse', 'floor', 'fmod', 'frexp', 'fsum', 'gamma', 'gcd', 'get_clock_info', 'gmtime', 'groupby', 'hypot', 'inf', 'isclose', 'isfinite', 'isinf', 'islice', 'isnan', 'isqrt', 'ldexp', 'lgamma', 'localtime', 'log', 'log10', 'log1p', 'log2', 'mktime', 'modf', 'monotonic', 'monotonic_ns', 'nan', 'perf_counter', 'perf_counter_ns', 'perm', 'permutations', 'pi', 'pow', 'prime', 'prime_gen', 'prime_square', 'process_time', 'process_time_ns', 'prod', 'product', 'radians', 'remainder', 'repeat', 'sin', 'sinh', 'sleep', 'sqrt', 'starmap', 'strftime', 'strptime', 'struct_time', 'takewhile', 'tan', 'tanh', 'tau', 'tee', 'thread_time', 'thread_time_ns', 'time', 'time_ns', 'timezone', 'trunc', 'tzname', 'zip_longest']\n",
261+
"['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__primeval__', '__spec__', 'accumulate', 'acos', 'acosh', 'altzone', 'asctime', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'ceil', 'chain', 'comb', 'combinations', 'combinations_with_replacement', 'compress', 'copysign', 'cos', 'cosh', 'count', 'ctime', 'cycle', 'daylight', 'degrees', 'dist', 'dropwhile', 'e', 'erf', 'erfc', 'exp', 'expm1', 'fabs', 'factorial', 'filterfalse', 'floor', 'fmod', 'frexp', 'fsum', 'gamma', 'gcd', 'get_clock_info', 'gmtime', 'groupby', 'hypot', 'inf', 'isclose', 'isfinite', 'isinf', 'islice', 'isnan', 'isqrt', 'ldexp', 'lgamma', 'localtime', 'log', 'log10', 'log1p', 'log2', 'mktime', 'modf', 'monotonic', 'monotonic_ns', 'nan', 'perf_counter', 'perf_counter_ns', 'perm', 'permutations', 'pi', 'pow', 'prime', 'prime_gen', 'prime_square', 'process_time', 'process_time_ns', 'prod', 'product', 'radians', 'remainder', 'repeat', 'sin', 'sinh', 'sleep', 'sqrt', 'starmap', 'strftime', 'strptime', 'struct_time', 'takewhile', 'tan', 'tanh', 'tau', 'tee', 'thread_time', 'thread_time_ns', 'time', 'time_ns', 'timezone', 'trunc', 'tzname', 'zip_longest']\n",
262+
"\n",
263+
"['__annotations__', '__call__', '__class__', '__closure__', '__code__', '__defaults__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__get__', '__getattribute__', '__globals__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__kwdefaults__', '__le__', '__lt__', '__module__', '__name__', '__ne__', '__new__', '__qualname__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__']\n",
262264
"\n",
263-
"['In', 'Out', '_', '__', '___', '__builtin__', '__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__', '_dh', '_i', '_i1', '_i2', '_i3', '_i4', '_i5', '_i6', '_i7', '_ih', '_ii', '_iii', '_oh', 'exit', 'get_ipython', 'i', 'pg', 'pgf', 'prime_gen', 'quit']\n"
265+
"['In', 'Out', '_', '__', '___', '__builtin__', '__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__', '_dh', '_i', '_i1', '_i2', '_i3', '_i4', '_ih', '_ii', '_iii', '_oh', 'exit', 'get_ipython', 'prime_generator', 'quit']\n"
264266
]
265267
}
266268
],
267269
"source": [
268-
"import prime_gen\n",
270+
"import prime_generator\n",
269271
"\n",
270-
"print(dir(prime_gen))\n",
272+
"print(dir(prime_generator))\n",
273+
"print()\n",
274+
"print(dir(prime_generator.prime_gen))\n",
271275
"print()\n",
272276
"print(dir())"
273277
]
@@ -276,14 +280,48 @@
276280
"cell_type": "markdown",
277281
"metadata": {},
278282
"source": [
279-
"## namespace:\n"
283+
"## namespace:\n",
284+
"\n",
285+
"A container that has a list of names (objects) defined in a module. It is the place where python searches for objects defined and used in a function."
286+
]
287+
},
288+
{
289+
"cell_type": "markdown",
290+
"metadata": {},
291+
"source": [
292+
"## Global, Local and Built-in Namespaces\n",
293+
"\n",
294+
"### Global:\n",
295+
"Namespace containing values defined throughout a file or module (globally)\n",
296+
"\n",
297+
"### Local:\n",
298+
"Namespace containing values defined in a part of a file or module (Locally)\n",
299+
"\n",
300+
"### Builtin:\n",
301+
"Namespace containing values common for all python file.\n",
302+
"\n",
303+
"## Order of Search:\n",
304+
"1. Local\n",
305+
"2. Global\n",
306+
"3. Builtin"
280307
]
281308
},
282309
{
283310
"cell_type": "markdown",
284311
"metadata": {},
285312
"source": [
286-
"## Global, Local and Built-in Namespaces"
313+
"## Packages:\n",
314+
"Directory or folder containing a number of modules and subpackages.\n",
315+
"\n",
316+
"It contains '\\_\\_init\\_\\_.py' file which defines the modules that can be imported from the package.\n",
317+
"\n",
318+
"### Importing a module from package:\n",
319+
"`from package_name import module_name` \n",
320+
"`import package_name.module_name` \n",
321+
"`import package_name.module_name as custom_name`\n",
322+
"\n",
323+
"### Import a specific object from a module:\n",
324+
"`from package_name.module_name import object_name`"
287325
]
288326
},
289327
{

0 commit comments

Comments
 (0)