-
class Test:
-
def __init__(self):
-
self._power = False
-
self._v = 5
-
self._station = 80.0
-
self._presets= [ 72.0, 74.4, 76.6]
-
-
def togglePower(self): # when I tried it this did not work
-
self._powerOn = not self._PowerOn
-
-
def setPreset(self, ind):
-
self._presets[ind]=self_station #when I enter .setPreset(1), it did not work either, global name '_station' is not defined
-
-
5 1155 -
class Test:
-
def __init__(self):
-
self._power = False
-
self._v = 5
-
self._station = 80.0
-
self._presets= [ 72.0, 74.4, 76.6]
-
-
def togglePower(self): # when I tried it this did not work
-
self._powerOn = not self._PowerOn
-
-
def setPreset(self, ind):
-
self._presets[ind]=self_station #when I enter .setPreset(1), it did not work either, global name '_station' is not defined
-
-
-
class Test:
-
def __init__(self):
-
self._power = False
-
self._v = 5
-
self._station = 80.0
-
self._presets= [ 72.0, 74.4, 76.6]
-
-
def togglePower(self): # when I tried it this did not work
-
self._powerOn = not self._PowerOn
-
-
def setPreset(self, ind):
-
self._presets[ind]=self._station
-
-
you left out the "." after self and before _station.
-
class Test:
-
def __init__(self):
-
self._power = False
-
self._v = 5
-
self._station = 80.0
-
self._presets= [ 72.0, 74.4, 76.6]
-
-
def togglePower(self):
-
self._powerOn = not self._powerOn
-
-
Thank you very much.
Another question, how can it make the following code return "True" -
def togglePower(self):
-
self._powerOn = not self._powerOn
-
It only return "none" when I try -
class Test:
-
def __init__(self):
-
self._power = False
-
self._v = 5
-
self._station = 80.0
-
self._presets= [ 72.0, 74.4, 76.6]
-
-
def togglePower(self):
-
self._powerOn = not self._powerOn
-
-
Thank you very much.
Another question, how can it make the following code return "True" -
def togglePower(self):
-
self._powerOn = not self._powerOn
-
It only return "none" when I try -
def togglePower(self):
-
self._power = not self._power
-
return self._power
-
print a.togglePower()
-
Thank you.
Another question related to the one below, can anyone locate the error in the source code below? -
class Test:
-
def __init__(self):
-
self._powerOn = False
-
self._v = 10
-
self._station = 10
-
self._presets= [ 5, 6, 7, 8]
-
-
def togglePower(self):
-
self._powerOn = not self._powerOn
-
-
def setP(self, i):
-
self._presets[i]=self._station
-
-
def gotoP(self, i):
-
self._station = self._presets[i]
-
-
def increaseV(self):
-
self._v = self._v +2
-
-
def decreaseV(self):
-
self._v = self._v -2
-
-
def increaseStation(self):
-
self._station = self._station + 1
-
-
def decreaseStation(self):
-
self._station = self._station - 1
-
Thank you.
Another question related to the one below, can anyone locate the error in the source code below? -
class Test:
-
def __init__(self):
-
self._powerOn = False
-
self._v = 10
-
self._station = 10
-
self._presets= [ 5, 6, 7, 8]
-
-
def togglePower(self):
-
self._powerOn = not self._powerOn
-
-
def setP(self, i):
-
self._presets[i]=self._station
-
-
def gotoP(self, i):
-
self._station = self._presets[i]
-
-
def increaseV(self):
-
self._v = self._v +2
-
-
def decreaseV(self):
-
self._v = self._v -2
-
-
def increaseStation(self):
-
self._station = self._station + 1
-
-
def decreaseStation(self):
-
self._station = self._station - 1
-
It will be hard for us to tell without an example of which error you are getting. I do see that - # these two
-
-
def setP(self, i):
-
self._presets[i]=self._station
-
-
def gotoP(self, i):
-
self._station = self._presets[i]
will raise an error if you call the funtion with a number greater that 3.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Brandon J. Van Every |
last post by:
What's better about Ruby than Python? I'm sure there's something. What is
it?
This is not a troll. I'm language shopping and I want people's answers. I
don't know beans about Ruby or have...
|
by: E. Robert Tisdale |
last post by:
What makes a good C/C++ programmer?
Would you be surprised if I told you that
it has almost nothing to do with your knowledge of C or C++?
There isn't much difference in productivity, for...
|
by: Micha |
last post by:
Hello there,
I think I've run into some classic c++ pitfall and maybe some of
you guys can help me out.
For my project I will need to use matrices and vectors and so I
decided to implement them...
|
by: Jason Huang |
last post by:
Hi,
Would someone explain the following coding more detail for me? What's the
( ) for?
CurrentText = (TextBox)e.Item.Cells.Controls;
Thanks.
Jason
|
by: Midnight Java Junkie |
last post by:
Dear Colleagues:
I feel that the dumbest questions are those that are never asked. I have
been given the opportunity to get into .NET. Our organization has a
subscription with Microsoft that...
|
by: Xah Lee |
last post by:
in March, i posted a essay “What is Expressiveness in a Computer
Language”, archived at:
http://xahlee.org/perl-python/what_is_expresiveness.html
I was informed then that there is a academic...
|
by: Ltez |
last post by:
I use Python 2.4.4. Please read the code below:
-----------------------------------------------------------
from new import classobj
def mymeta(name,bases,clsdict):
print 'meta: %s'%name...
|
by: Mohamed Mansour |
last post by:
Hey there, this will be somewhat a long post, but any response is
appreciated!
I have done many PInvoke in the past from C++ to C#, but I did PInvoke
within C# not C++/CLI.
Can someone explain...
|
by: Vols |
last post by:
class A{
public:
int x;
};
class B : public A{
public:
int y;
};
void foo()
|
by: darren |
last post by:
Hi
I have to write a multi-threaded program. I decided to take an OO
approach to it. I had the idea to wrap up all of the thread functions
in a mix-in class called Threadable. Then when an...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
| |