second steps programming in python

The key to the success is the idea. And the key to the knowledge is to practice.
Firstly, I started with objects in PHP, then tried to do some work in VB2010 (i hope soon, till the end of the year there will be the result - groundwater and runoff modelling software METQ-UL aka MetCool) and today I tried to refresh my Py-mories... All day long tried to transfer VB code into the Python, but it seems that I`ve some small problems somewhere.
Another thing about Python - I didn`t find a way how to change values inside in method... as example if I have a method in class which does something, like

def f(self,a,b)
     return a

and in the same time i need to return value b, I have to make a list or dictionary, like
def f(self,a,b)
     return D

In such case it is much more unhandy as it was in VB or Fortran, like

Sub f(ByRef dim a as integer, ByRef dim b as integer)
End sub

The difference is when such sub (function/subroutine) has to be called, the syntax is simple in the VB/Fortran

call f(a,b)
print.debug a,b
//returns 4 and 27

without neccesity to "extract" the modified value from function
unlike the other languages, where it has to be some object or variable which will have the modified values..
in the case of python -

//example when function are inside and are called from the class
dictionary = self.f(a,b)
print a,b //return 2,3
print a,b //return 4, 27

Nav komentāru:

Ierakstīt komentāru