Created
June 29, 2021 07:47
-
-
Save PythonDotLand/6737ff43199abfecdc1dfe74c74a0115 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| >>> class Card: | |
| ... __slots__ = 'rank', 'suite' | |
| ... def __init__(self, rank, suite): | |
| ... self.rank = rank | |
| ... self.suite = suite | |
| ... | |
| >>> qh = Card('queen', 'hearts') |
Author
Well I see you apparently misinterpreted the title. It's about writing faster and cleaner code. If you want to type faster, I suggest a typing course ;)
I see. You are right. It seems I am too preoccupied with the subject of writing faster, so I isolated that! :) In fact, for a moment I believed that this "solts" thing allows for not having to add the very stupid, annoying and time wasting 'self' prefix everytime to e.g. 'rank' and 'suite' ! :)) (I know well though that it is necessary and why, as in Java, with the corresp. prefix 'this'.)
Thanks and sorry about the trouble!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I saw this code in an article entitled "10 Advanced Python Tricks To Write Faster, Cleaner Code" (https://medium.com/pythonland) and this is were I referred to. (It is also there where I found the link https://python.land/ thet led me to write my comment.)
In fact, the above code was the first example and I was expecting to see something that will help me writing code faster because I am a relatively slow typist. But now you tell me it's not about faster writing ... Instead, you say that "it's about code safety". Well, the word "safety" is not mentioned even once. I really don't understand ... Anyway, forget about the whole issue, It's not wortwhile. But I hope at least that my message makes improve your articles.