Answers for "how to use underscore in python"

1

how to use underscore in python

def public_api():
    print ("public api")
  
def _private_api():
    print ("private api")
Posted by: Guest on May-29-2021
0

how to use underscore in python

# Ignore a value of specific location/index
for _ in range(10)
    print ("Test")
  
# Ignore a value when unpacking
a,b,_,_ = my_method(var1)
Posted by: Guest on May-29-2021
0

how to use underscore in python

>>> class MyClass():
...     def __init__(self):
...             print ("OWK")
  
>>> def my_defination(var1 = 1, class_ = MyClass):
...     print (var1)
...     print (class_)
  
>>> my_defination()
1
__main__.MyClass
>>>
Posted by: Guest on May-29-2021
0

how to use underscore in python

>>> def function(class):
  File "<stdin>", line 1
    def function(class):
                 ^
SyntaxError: invalid syntax
>>> def function(class_):
...     pass
...
>>>
Posted by: Guest on May-29-2021
0

how to use underscore in python

class Prefix:
...     def __init__(self):
...             self.public = 10
...             self._private = 12
>>> test = Prefix()
>>> test.public
10
>>> test._private
12
Posted by: Guest on May-29-2021

Code answers related to "how to use underscore in python"

Python Answers by Framework

Browse Popular Code Answers by Language