Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (47.6k points)

Learning Python, and has some basic doubts.

1. I have seen variable declaration (path here) as

class writer:

    path = ""

sometimes, no explicit declaration but initialize through __init__.

def __init__(self, name):

      self.name = name

I understand the purpose of __init__, but is it advisable to declare a variable in any other functions.

2. How can I create a variable to hold a custom type?

class writer:

    path = "" # string value

    customObj = ??

1 Answer

0 votes
by (106k points)

When you are using Python then you do not need to declare variable because Python does not need any variable to declare and the reason is Python is a dynamically typed language.

To know more about this you can have a look at the following video tutorial:-

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Sep 20, 2019 in Python by Sammy (47.6k points)
+1 vote
1 answer

Browse Categories

...