Thread has been deleted
Last comment
Python Programmers Come
Dominican Republic EssentialBeing 
i stuck, i need i try to make few different turtles on Y axis, it worked well when I had everything in main.py simple code: # for num in range(9): # new_turtle = Turtle(shape="turtle") # new_turtle.penup() # new_turtle.turtlesize(stretch_wid=2, stretch_len=2) # new_turtle.setposition(x=-330, y=y) # new_turtle.color(colors[num]) # y += 60 # all_turtle.append(new_turtle) but then i made separate file for turtles. randomturtles.py like this: value_posit_x = -330 value_posit_y = -240 class RandomTurtle(Turtle): def __init__(self): super().__init__() self.position_x = value_posit_x self.position_y = value_posit_y self.shape("turtle") self.penup() self.shapesize(stretch_wid=2, stretch_len=2) self.setposition(x=self.position_x, y=self.position_y) self.pick_rand_color() self.adding_name() now and when I try loop in main.py to create few turtle, they all stuck on each other for _ in range(9): from randomturtles import value_posit_y new_turt = RandomTurtle() value_posit_y += 60 print(value_posit_y) this code works strangely print same value for each of for loop iteration, doesn't add 60 every time but only once, plz help, im helpless
2021-09-22 19:42
Topics are hidden when running Sport mode.
Move the import in front of the loop
2021-09-22 19:47
1 reply
that change the print only but turtle are still stuck on each other i assume doesn't return to that file B where is the class of turtles, and it still takes the value from there instead of updated one
2021-09-22 20:01
i need help how to convert this from reddit to hltv website :tf: reddit.com/r/forsen/comments/ps5tlp/how_.. python user help, no experience user here
2021-09-22 19:48
Didnt run your code but from what im seeing every single iteration is calling value_posit_y and then adding 60 which means if you run it 100 times itll always be the same. What you can do is assign it to a local variable and increment that so like newVariable = value_posit_y for _ in range(9): new_turt = RandomTurtle() newVariable += 60 print(newVariable) and then of course at the end you assign newVariable back to RandomTurtle.self.position_y
2021-09-22 19:54
6 replies
how do i return that to RandomTurtle.self.position_y ?
2021-09-22 19:59
5 replies
You want to update value_posit_y in that imported file?
2021-09-22 20:08
2 replies
yes
2021-09-23 01:17
1 reply
Try creating another method in your class like: def yUpdate( self, val ) : self.value_posit_y = val In your main method call this update method to change the value of the variable like, new_turt.yUpdate( anyvalue )
2021-09-23 09:01
Youre not returning anything youre reassigning a class member variable new_turt.position_y = newVariable
2021-09-22 20:22
1 reply
where? in main.py that doesn't work
2021-09-23 01:20
If I remember correctly, cause i haven't been programming in python for a while, you're trying to refer and move a turtle, that now is an object taken from different file. You have to import the class to main and refer to object, so for example new_turt.value_posit_y += 60. Cause now you're trying to call into global value you got from randomturtles file. Also, you're updating value_posit_y to the old one every loop. Set a local variable as value_posit_y and modify it. So for example: y = value_posit_y (keep this out of your loop) y += 60 As I said, I might be wrong, cause i had some break in programming, but it least it maybe will help.
2021-09-22 19:56
3 replies
+1 This is most probable. He is missing an update method in his class to change/update 'value_posit_y'.
2021-09-22 20:01
2 replies
how do i update that ?
2021-09-23 01:21
1 reply
You will have to define Update method inside your RandomTurtle class so it can update position of your object. That method will have to get an input, most likely x and y or just y, depends on how this app have to work. In that method you will have to add that input to your objects position, then you will call it in main as new_trtl.Update(pos_x,pos_y) depends on what you want to put into that method. Also it's not like we will create that program for you, you will have to work on your own, but this might help you.
2021-09-23 11:43
First off, I'm not even going to try to debug your code when it is formatted like that. If your error has something to do with a tab, then I will never know. edit: have a link to something that can have the right formatting and I will look at it for you.
2021-09-22 19:54
are you going to trust hltv programmers to solve your problem?
2021-09-22 20:02
4 replies
#21
 | 
Germany Jonaah
what should possible go wrong? :p
2021-09-22 20:11
what do you mean? you can check if the code works in few second, the problem is when u get solution you still don't understand yourself, in that way you learn nothing and when the similar problem occurs again u will be in next black hole
2021-09-23 00:47
1 reply
it was a joke mens))
2021-09-23 11:53
better than stackoverflow
2021-09-23 01:40
Stack overflow mens?
2021-09-23 00:34
#29
 | 
North America Phyxda
I don’t think changing value_posit_y += 60 after creating new_turt will work. Maybe try new_turt.setposition(y+=60).
2021-09-23 01:38
Login or register to add your comment to the discussion.