Maybe I've been too cryptic. I apologize.
Il 22/10/2015 01:35, JonRob ha scritto:
@Dennis,
Thanks for your example. My structure is very similar.
And that's ok. But you can also 'attach' the constants to a class, if it
makes sense. For example, the same code of Dennis can be written as:
On 20/10/15 22:33, jon...@mail.python.org wrote:
In your comment you mentioned that convention is to declare variables
(and constants?) in the construction (__ini__).
I would suggest that 'constants' are not 'declared' in the __init__
method body, but either as class variables or (see later)
Il 20/10/2015 23:33, JonRob ha scritto:
Hello Luca,
I very much appreciated your comments. And I understand the
importance of "doing something right" (i.e. convention).
This leads me to another question.
Because I am interfacing with an I2C sensor I have many register
definations to includ
@Dennis,
Thanks for your example. My structure is very similar. Perhaps I was
reading too much into Luca's below statement regarding declaring
variables.
Regards,
JonRob
Luca wrote...
>Please, note that declaring a variable in the constructor is only a
>convention: in Python you can a
Dennis Lee Bieber writes:
> (Python does not have anything that one might consider a true constant
> -- other than the language defined singletons: None, and maybe by now
> True and False).
Python now deals with those by making the names keywords::
>>> True = object()
File "", line 1
Hello Luca,
I very much appreciated your comments. And I understand the
importance of "doing something right" (i.e. convention).
This leads me to another question.
Because I am interfacing with an I2C sensor I have many register
definations to include (30 register addresses and 26 Variables
Thanks to all who replied to my question. I received a lot of
information and points of view that are very helpful. I realize some
of you folks spent more that a few minutes. I really appreciate your
time.
Pardon me that i replied to random832's post and not the original but
my original was l
Il 20/10/2015 08:38, Nagy László Zsolt ha scritto:
When you say "they have nothing to do", it is almost true but not 100%.
I know it, but when it comes to eradicate an idea that comes directly
from C++-like languages, you must be drastic.
Nuances come after...
--
Ciao!
Luca
--
https://mail.
> These two statements make me think you come from C++ or something
> similar.
>
> In Python you can declare variables at class level, but this
> declaration must NOT be interpreted in the same manner of a similar
> declaration in C++: they remain at the abstract level of a class, and
> they have
Il 19/10/2015 20:39, JonRob ha scritto:
I (think) I understand that in the below case, the word self could be
replaced with "BME280" to explicitly call out a variable.
But even still I don't know how explicit call out effects the scope of
a variable.
These two statements make me think you com
> My questions are:
> What is the scope of class variables?
In Python, you bind values (objects) to names. It is conceptually
different from "setting the value of a variable". In Python, scope
applies to names, not variables.
When you say "class variable", what do you mean?
This may help:
A nam
>
> #!/usr/bin/python
> # -- developed using Python 2.7.3
>
> class BME280:
Not strictly related to the question, but you probably want to use so
called "new style classes" when developing a new program for Python
version 2. In other words, use:
class BME280(object):
instead of
class BME280:
On 10/19/2015 7:19 PM, sohcahto...@gmail.com wrote:
Class variables are accessible without creating an instance of a class. Also,
changing the value of a class variable affects ALL instances of that class.
This is because the variable belongs to the class itself, not any of the
instances of
On Monday, October 19, 2015 at 11:39:59 AM UTC-7, JonRob wrote:
> Hi,
>
> I've having trouble understanding the self concept as it applies to
> variables. I think I understand how it affects methods.
>
> I haven't been able to fully grasp the scope of class variables and
> the effect of the "sel
jon...@mail.python.org writes:
>
> The below pseudo code is distilled from my 1st attempt at a functional
> Python program on the RasPi.
>
> My questions are:
> What is the scope of class variables?
You must access them as members of the class or an instance of the class.
> does the self. prefix
Hi,
I've having trouble understanding the self concept as it applies to
variables. I think I understand how it affects methods.
I haven't been able to fully grasp the scope of class variables and
the effect of the "self" to the scope of the variable.
I (think) I understand that in the below ca
16 matches
Mail list logo