Python’s saga continue

I have to agree that it is one of the powerful feature of this language. In C#, it has similiar feature but less power since you can only assign ‘same value’ to multiple variables within the same line. But with this powerful feature of python, you can assign multiple values to multiple variables within the same line. As of this writing, in C# it also now has this feature but still less powerful than this since we are required to use var keyword and install additional NuGet package called “System.ValueTuple”.

Anyways, I gave this powerful python’s feature a test and voila I like it:

Here is the practical example: we have a file name called fn which is assigned with string “Abi-10-50m-Back.txt” where Abi is the swimmer name, 10 is her age, 50m is her swimming distance and last but not least Back is her swimming style. Below example is to extract these information from the file name vairable fn into its own separate variable. I am happy with python as it can accomplish this task with mimal code than if using C# for the split string in C# items would be returned as an array. And to access each of them requires using arrary with its index and have to declare each of variable per arrary index for code readibility but with python, less code and it is easy to read.

Leave a Reply

Your email address will not be published. Required fields are marked *