0

I am newbie to Python and trying to decode a line to port over to Go. In the current python script, I come across this declaration (dataValue) under most of the class.

class Keys(object):
   AB1 = 0x0FF
   AB2 = 0x0A2
   dataValue = {'0xffff':None}

   @classmethod
   def _init(cls):
     for ke, vl in vars(cls).items():
       
  1. What is dataValue? Is 0xffff a key and hold None as a value?
  2. What does vars(cls).items() return?
  3. @classmethod means this class keys is used only once? (I came across many definitions for @propoerty, @classmthods still these keywords confuses me)

Trying to understand the concepts thru real projects. Thanks in advance!

2
  • 2
    I think you understand dataValue already. It's a dictionary. Commented Apr 1, 2021 at 2:15
  • 1
    For #3: stackoverflow.com/a/38276/12975140 Commented Apr 1, 2021 at 2:22

1 Answer 1

3
  1. dataValue is a dictionary variable name, which has in it key:value pair of '0xffff':None https://docs.python.org/3/tutorial/datastructures.html.
  2. vars(cls).items() Return the __dict__ attribute for a module, class, instance, or any other object with a __dict__ attribute https://docs.python.org/3/library/functions.html#vars.
  3. A function returning another function, usually applied as a function transformation using the @wrapper syntax. Common examples for decorators are classmethod() and staticmethod() https://docs.python.org/3/glossary.html#term-decorator https://docs.python.org/3/library/functions.html#classmethod https://docs.python.org/3/library/functions.html#staticmethod.
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.