Skip to main content
Code Review

Return to Answer

replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/
Source Link

Please follow PEP8, the Python style guide.


This function returns either True or None:

def check_Lights():
 if button.title == 'off':
 if button2.title == 'off':
 if button3.title == 'off':
 if button4. title == 'off':
 return True

Make it a proper boolean. And, instead of the arrow shaped writing style, you can rewrite this as a single boolean expression, for example:

return button1.title == 'off' and button2.title == 'off' and ...

As @Caridorc @Caridorc pointed out in a comment, you can do even better:

return all(b.title == 'off' for b in (button, button2, button3, button4))

Don't repeat yourself. The way you create and add new buttons is very repetitive. Create a utility function to reduce the duplication, for example:

def add_new_button(wcoeff, hcoeff):
 button = ui.Button(title = 'off') 
 button.center = (view.width * wcoeff, view.height * hcoeff)
 button.flex = 'LRTB'
 button.action = button_tapped
 view.add_subview(button)
 return button

Please follow PEP8, the Python style guide.


This function returns either True or None:

def check_Lights():
 if button.title == 'off':
 if button2.title == 'off':
 if button3.title == 'off':
 if button4. title == 'off':
 return True

Make it a proper boolean. And, instead of the arrow shaped writing style, you can rewrite this as a single boolean expression, for example:

return button1.title == 'off' and button2.title == 'off' and ...

As @Caridorc pointed out in a comment, you can do even better:

return all(b.title == 'off' for b in (button, button2, button3, button4))

Don't repeat yourself. The way you create and add new buttons is very repetitive. Create a utility function to reduce the duplication, for example:

def add_new_button(wcoeff, hcoeff):
 button = ui.Button(title = 'off') 
 button.center = (view.width * wcoeff, view.height * hcoeff)
 button.flex = 'LRTB'
 button.action = button_tapped
 view.add_subview(button)
 return button

Please follow PEP8, the Python style guide.


This function returns either True or None:

def check_Lights():
 if button.title == 'off':
 if button2.title == 'off':
 if button3.title == 'off':
 if button4. title == 'off':
 return True

Make it a proper boolean. And, instead of the arrow shaped writing style, you can rewrite this as a single boolean expression, for example:

return button1.title == 'off' and button2.title == 'off' and ...

As @Caridorc pointed out in a comment, you can do even better:

return all(b.title == 'off' for b in (button, button2, button3, button4))

Don't repeat yourself. The way you create and add new buttons is very repetitive. Create a utility function to reduce the duplication, for example:

def add_new_button(wcoeff, hcoeff):
 button = ui.Button(title = 'off') 
 button.center = (view.width * wcoeff, view.height * hcoeff)
 button.flex = 'LRTB'
 button.action = button_tapped
 view.add_subview(button)
 return button
added 273 characters in body
Source Link
janos
  • 113k
  • 15
  • 154
  • 396

Please follow PEP8PEP8, the Python style guide.


This function returns either True or None:

def check_Lights():
 if button.title == 'off':
 if button2.title == 'off':
 if button3.title == 'off':
 if button4. title == 'off':
 return True

Make it a proper boolean. And, instead of the arrow shaped writing style, you can rewrite this as a single boolean expression, for example:

return button1.title == 'off' and button2.title == 'off' and ...

As @Caridorc pointed out in a comment, you can do even better:

return all(b.title == 'off' for b in (button, button2, button3, button4))

Don't repeat yourself. The way you create and add new buttons is very repetitive. Create a utility function to reduce the duplication, for example:

def add_new_button(wcoeff, hcoeff):
 button = ui.Button(title = 'off') 
 button.center = (view.width * wcoeff, view.height * hcoeff)
 button.flex = 'LRTB'
 button.action = button_tapped
 view.add_subview(button)
 return button

Please follow PEP8, the Python style guide.


This function returns either True or None:

def check_Lights():
 if button.title == 'off':
 if button2.title == 'off':
 if button3.title == 'off':
 if button4. title == 'off':
 return True

Make it a proper boolean. And, instead of the arrow shaped writing style, you can rewrite this as a single boolean expression, for example:

return button1.title == 'off' and button2.title == 'off' and ...

Don't repeat yourself. The way you create and add new buttons is very repetitive. Create a utility function to reduce the duplication, for example:

def add_new_button(wcoeff, hcoeff):
 button = ui.Button(title = 'off') 
 button.center = (view.width * wcoeff, view.height * hcoeff)
 button.flex = 'LRTB'
 button.action = button_tapped
 view.add_subview(button)
 return button

Please follow PEP8, the Python style guide.


This function returns either True or None:

def check_Lights():
 if button.title == 'off':
 if button2.title == 'off':
 if button3.title == 'off':
 if button4. title == 'off':
 return True

Make it a proper boolean. And, instead of the arrow shaped writing style, you can rewrite this as a single boolean expression, for example:

return button1.title == 'off' and button2.title == 'off' and ...

As @Caridorc pointed out in a comment, you can do even better:

return all(b.title == 'off' for b in (button, button2, button3, button4))

Don't repeat yourself. The way you create and add new buttons is very repetitive. Create a utility function to reduce the duplication, for example:

def add_new_button(wcoeff, hcoeff):
 button = ui.Button(title = 'off') 
 button.center = (view.width * wcoeff, view.height * hcoeff)
 button.flex = 'LRTB'
 button.action = button_tapped
 view.add_subview(button)
 return button
Source Link
janos
  • 113k
  • 15
  • 154
  • 396

Please follow PEP8, the Python style guide.


This function returns either True or None:

def check_Lights():
 if button.title == 'off':
 if button2.title == 'off':
 if button3.title == 'off':
 if button4. title == 'off':
 return True

Make it a proper boolean. And, instead of the arrow shaped writing style, you can rewrite this as a single boolean expression, for example:

return button1.title == 'off' and button2.title == 'off' and ...

Don't repeat yourself. The way you create and add new buttons is very repetitive. Create a utility function to reduce the duplication, for example:

def add_new_button(wcoeff, hcoeff):
 button = ui.Button(title = 'off') 
 button.center = (view.width * wcoeff, view.height * hcoeff)
 button.flex = 'LRTB'
 button.action = button_tapped
 view.add_subview(button)
 return button
lang-py

AltStyle によって変換されたページ (->オリジナル) /