You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think the problem is that you're not calling .send_report() in your animals. Note that in the original turtle, every time it does something it calls .send_report(). This makes the screen draw the current position. It even calls .send_report() multiple times in every action so the movement will be smooth.
Why do you think that the right place to call it is in __setattr__? I don't understand. The .send_report() method should be called in the go and turn functions. I think you have removed these calls when you duplicated my_turtle.py to animals.py, so try to bring them back.
And please explain your reasoning regarding __setattr__.
in go and turn self.position and self.orientation changes, so setattr will trigg at proper place (i checked)
real problem is that .sendreport() in turtleprocess.py, and old go() turn() etc was in turtleprocess. but now, go, turn etc in animal.py and i have no idea how to call method of animal.py from animals.py
(Note: Please wrap code segments with backticks (Character to left of "1") for readability.)
I understand the problem now. (Nice idea with __setattr__ by the way.)
I think I have a solution. First, rename .send_report() to ._send_report(). (Should be done anyway.) Now, in TurtleProcess.run() you do Animal._send_report = self.send_report. (The name will have a leading underscore only on Animal.)
Now you could call self._send_report() from any animal, I think.
Getting rid of my_turtle and migrating to animals is fine. There's no concept of backward-compatibility on this software either, so a deprecation period is not needed, we can just move.
I think that letting users switch modes would be slightly confusing. (Remember, little children.) What I think would be good is a combination of both modes: The OOP mode will be on but a turtle will be created at startup, and the go and turn functions will be bound to its respective methods. What do you think?
The snippet of code you gave is indeed a bit confusing; The go function will be tied to the initial turtle. But I think that it's not so hard to get used to.
Giving modes is problematic. Remember this should be usable by a young child who doesn't know what programming is, let alone what OOP is. Even the concept of changing modes might be hard for him. He might not even think to check the menu for it. Also, if you have two separate modes, what will you do with the drawing and existing turtles when the user switches mode? Destroy them? Not nice.
understanding OOP, when we have global function with same name that object method is hard.
i think, we can make 2 "levels"
or 2 modes: "One Turtle (light mode)"
"Many Animals (hard mode)"
by default, we run in "One Turtle (light mode)". If kid is smart, it checks menu.
We can even show warning window:
You select Many Animals (hard mode). If you do not know, what is Object-Oriented Programming,
visit http://our_wikiexplainingsomethings (or may be local help file)
Are you sure that you want to leave "One Turtle (light mode)" and switch to "Many Animals (hard mode)"
yes no
Can you please explain thoroughly what are the advantages of having a separation between the two modes, in contrast to having both of them at the same time?
You gave one argument up to now, that it will be confusing that there is both go and Turtle.go. That's true. But it will be much more confusing, for example, to have two different sets of documentation.
Can you please explain the advantages of your approach?
Here are the advantages of the combined approach:
The child doesn't need to understand the concept of different modes.
We don't have to program the user interface needed for two modes, and solve all the bugs that that will involve.
We don't have to maintain two sets of documentation.
There will not be a case where the child writes down a piece of code only to be disappointed by it not working because he was in the wrong mode.
There will not be a case where the child writes down a piece of code only to be disappointed by it not working because he was mixing code from the two different modes.
Ah, so by default it will be procedural+OOP, and only with the special setting it will be pure OOP? Sounds okay. Having a menu check-box to do it sounds good. (It can be called "Pure OOP Mode (Delete initial turtle)").
A command-line argument for pure OOP can also be added (in addition to the menu setting), I'm okay with that.
I have no time to implement anything regarding PythonTurtle. I can only guide you in implementing it.
I don't see any problem with resetting the process. You terminate the existing process with .terminate(), create a new one, create a queue-pack for it and plug it into the shell. (I'm not sure this is 100% correct, but probably.) If you have any problems with it I'll help.
Activity
darvin commentedon Sep 29, 2010
almost done, one fix needed.
after every change, i need type send() in python console.
please, help me
http://github.com/darvin/PythonTurtle/blob/master/src/animals.py
###FIXME!!!
# locals()"send"
this line must call send_report from turtleprocess.py.
then objective-oriented turtles will work! )
cool-RR commentedon Sep 29, 2010
Very cool idea!
Let me look at that problem.
cool-RR commentedon Sep 29, 2010
I think the problem is that you're not calling
.send_report()in your animals. Note that in the original turtle, every time it does something it calls.send_report(). This makes the screen draw the current position. It even calls.send_report()multiple times in every action so the movement will be smooth.(Note: Classes should have a Capitalized name.)
darvin commentedon Sep 29, 2010
i know about send report, i trying to call it, but i cant. please help me! )
this is correct place to call send report:
http://github.com/darvin/PythonTurtle/blob/master/src/animals.py
###FIXME!!!
locals()"send"
i have no idea
cool-RR commentedon Sep 29, 2010
Why do you think that the right place to call it is in
__setattr__? I don't understand. The.send_report()method should be called in thegoandturnfunctions. I think you have removed these calls when you duplicatedmy_turtle.pytoanimals.py, so try to bring them back.And please explain your reasoning regarding
__setattr__.darvin commentedon Sep 29, 2010
in go and turn self.position and self.orientation changes, so setattr will trigg at proper place (i checked)
real problem is that .sendreport() in turtleprocess.py, and old go() turn() etc was in turtleprocess. but now, go, turn etc in animal.py and i have no idea how to call method of animal.py from animals.py
cool-RR commentedon Sep 29, 2010
(Note: Please wrap code segments with backticks (Character to left of "1") for readability.)
I understand the problem now. (Nice idea with
__setattr__by the way.)I think I have a solution. First, rename
.send_report()to._send_report(). (Should be done anyway.) Now, inTurtleProcess.run()you doAnimal._send_report = self.send_report. (The name will have a leading underscore only onAnimal.)Now you could call
self._send_report()from any animal, I think.darvin commentedon Sep 29, 2010
i ll try
darvin commentedon Sep 29, 2010
cool! it works well!
fixed in my dev branch
cool-RR commentedon Sep 29, 2010
Getting rid of
my_turtleand migrating toanimalsis fine. There's no concept of backward-compatibility on this software either, so a deprecation period is not needed, we can just move.I think that letting users switch modes would be slightly confusing. (Remember, little children.) What I think would be good is a combination of both modes: The OOP mode will be on but a turtle will be created at startup, and the
goandturnfunctions will be bound to its respective methods. What do you think?darvin commentedon Sep 29, 2010
i do not think so.
it be confusing:
d = Turtle()
d.go(10)
go(10)
`
i sure that modes is better.
darvin commentedon Sep 29, 2010
in oop mode, if there is not objects - no turtles. it is clear
cool-RR commentedon Sep 29, 2010
The snippet of code you gave is indeed a bit confusing; The
gofunction will be tied to the initial turtle. But I think that it's not so hard to get used to.Giving modes is problematic. Remember this should be usable by a young child who doesn't know what programming is, let alone what OOP is. Even the concept of changing modes might be hard for him. He might not even think to check the menu for it. Also, if you have two separate modes, what will you do with the drawing and existing turtles when the user switches mode? Destroy them? Not nice.
darvin commentedon Sep 29, 2010
understanding OOP, when we have global function with same name that object method is hard.
i think, we can make 2 "levels"
or 2 modes: "One Turtle (light mode)"
"Many Animals (hard mode)"
darvin commentedon Sep 29, 2010
by default, we run in "One Turtle (light mode)". If kid is smart, it checks menu.
We can even show warning window:
You select Many Animals (hard mode). If you do not know, what is Object-Oriented Programming,
visit http://our_wikiexplainingsomethings (or may be local help file)
Are you sure that you want to leave "One Turtle (light mode)" and switch to "Many Animals (hard mode)"
yes no
cool-RR commentedon Sep 29, 2010
Can you please explain thoroughly what are the advantages of having a separation between the two modes, in contrast to having both of them at the same time?
You gave one argument up to now, that it will be confusing that there is both
goandTurtle.go. That's true. But it will be much more confusing, for example, to have two different sets of documentation.Can you please explain the advantages of your approach?
Here are the advantages of the combined approach:
darvin commentedon Sep 30, 2010
i understand. may be we make "settings" or command-line argument for pure OOP mode?
cool-RR commentedon Sep 30, 2010
Ah, so by default it will be procedural+OOP, and only with the special setting it will be pure OOP? Sounds okay. Having a menu check-box to do it sounds good. (It can be called "Pure OOP Mode (Delete initial turtle)").
A command-line argument for pure OOP can also be added (in addition to the menu setting), I'm okay with that.
darvin commentedon Sep 30, 2010
we can make two options in menu:
Reset
Reset (Delete initial turtle)
cool-RR commentedon Sep 30, 2010
I'd want to change "Reset (Delete initial turtle)" to "Reset and delete initial turtle". That will be alright with me.
darvin commentedon Sep 30, 2010
ok.
i will add GUI options.
can you implement reset python enviroment function? i have no idea how to start
cool-RR commentedon Sep 30, 2010
I have no time to implement anything regarding PythonTurtle. I can only guide you in implementing it.
I don't see any problem with resetting the process. You terminate the existing process with
.terminate(), create a new one, create a queue-pack for it and plug it into the shell. (I'm not sure this is 100% correct, but probably.) If you have any problems with it I'll help.