Explains briefly how to use a namespace
try from the python prompt
import this
code
#!/usr/bin/env python
func_demo.py
basic function
scope of variable
how import module
namespace
the ...
def addme(val1,val2):
z = val1 + val2
this ok - local scope
z is only available in the function
print("In the function",z)
return z
run only if from the command line
if _name_ == "__main__":
x = int(input("Enter a value for x "))
y = int(input("Enter a value for y "))
total=addme(x,y)
print(total)
else:
... # ... is how a non-op works in python
#Done.
---------------------------------------------------------------
#!/usr/bin/env python
func_demo_in.py
basic function
how import module
namespaces
import this
you have two options here ...
from func_demo import addme
or
#import func_demo
a = int(input("Enter a value for a "))
b = int(input("Enter a value for b "))
total=addme(a,b)
#total=func_demo.addme(a,b)
print(total)#!/usr/bin/env python3
func_demo_in.py
basic function
how import module
namespaces
import this
from func_demo import addme
#import func_demo
a = int(input("Enter a value for a "))
b = int(input("Enter a value for b "))
total=addme(a,b)
print(total)
#Done.
In questa pagina del sito puoi guardare il video online How namespaces work in Python della durata di ore minuti seconda in buona qualità , che l'utente ha caricato d p 02 novembre 2020, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 33 volte e gli è piaciuto 0 spettatori. Buona visione!