Python Forum
Creating a script with a class have specific properties - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Homework (https://python-forum.io/forum-9.html)
+--- Thread: Creating a script with a class have specific properties (/thread-13347.html)

Pages: 1 2


RE: Creating a script with a class have specific properties - dvldgs05 - Oct-14-2018

Not sure. I am new to python and at a loss.


RE: Creating a script with a class have specific properties - buran - Oct-14-2018

(Oct-14-2018, 04:26 AM)CxxJxxYxx Wrote: May I ask why the 'tree' in 'print(tree.report(1))' isn't capitalized? I am confused about this point. Because in previous sentences nothing is defined as 'tree', but only the class 'Tree'

I think this is about my example. Tree is the class. tree is just a variable name, i.e. it could be whatever you want. So tree is an instance of class Tree. It's created on line #18. You are not correct there is nothing defined as tree. From my example:

#example how to instanciate object of class Tree
#ignore numbers if they don't make business sense
   
tree = Tree(block=1, plot=5, species=7, dhb=200)
print(tree.report(1))
Once again - tree is just variable, instance of Tree. You may have many instances of a class in your code.


RE: Creating a script with a class have specific properties - buran - Oct-14-2018

@dvldgs05, did you check the tutorials I shared in a previous post? It seems you still lack basic understanding of working with classes. You need to understanding the basics in order to understand what is offered as help and use it the way you want


RE: Creating a script with a class have specific properties - dvldgs05 - Oct-15-2018

I will check them again. It is just not clicking for me at this time.