Take the 2-minute tour ×
Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It's 100% free, no registration required.

I am trying to create a class about birds with a few different methods. This is just theoretical code. Is there anything that is inherently wrong with the code from a syntactical or semantics point of view? If so, please fix.

class Bird(object):
    def __init__(self, Height, Weight, HasFeathers, CapableofFlying, BirdMigrates, BirdSings, BirdEatsworms):
            self.Height=Height
    self.Weight=Weight
    self.HasFeathers=HasFeathers
self.HasFeathers= HasFeathers 
self.CapableofFlying= getCapableofFlying
    self.BirdMigrates=BirdMigrates
self.BirdSings=BirdSings
self.BirdEatsworms=BirdEatsworms

def Height():
return Height 

def Weight():
return Weight 

def HasFeathers(): 
if  getHasFeathers=false:
    return “The bird does not have feathers”    
else:   
return “The bird has feathers”  

def CapableofFlying(): 
if CapableofFlying=false:
    return “The bird is incapable of flying”    
else:   
return “The bird  is capable of flying”

def BirdMigrates(): 
if BirdMigrates=false:
    return “The bird does not migrate”  
else:   
return “The bird migrates”

def BirdSings(): 
if BirdSings=false:
    return “The bird cannot sing”   
else:   
return “The bird  can sing”

def BirdEatsworms(): 
if BirdEatsworms=false:
    return “The bird does not eat worms”    
else:   
return “The bird  eats worms”
share|improve this question

closed as off-topic by Gareth Rees, Simon André Forsberg, Mat's Mug, Jeff Vanzella, Jamal Dec 10 '13 at 21:04

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Your question must contain working code for us to review it here. For questions regarding specific problems encountered while coding, try Stack Overflow. After getting your code to work, you may edit this question seeking a review of your working code." – Gareth Rees, Jeff Vanzella, Jamal
If this question can be reworded to fit the rules in the help center, please edit the question.

2  
Hi, welcome to CR! If this code has syntax issues that make it unable to run, CR isn't the right place for "please fix" - please take a look at our Help Center. –  Mat's Mug Dec 10 '13 at 20:38
4  
This question appears to be off-topic because it is about theoretical code, which should go into a theoretical compiler. –  Simon André Forsberg Dec 10 '13 at 20:44
3  
Can we close this question as it is completely ridden with syntax errors. Either that, or the individual doesn't know how to paste code properly. Which does seem likely, as this is Python which requires indentation to be right. Either way, looks like a duplicate from SO. link –  Zoran Pavlovic Dec 10 '13 at 20:54

1 Answer 1

I never wrote a line of Python, so this may be completely wrong.

A couple things are jumping at me:

class Bird(object):
    def __init__(self, Height, Weight, HasFeathers, CapableofFlying, BirdMigrates, BirdSings, BirdEatsworms):
            self.Height=Height
    self.Weight=Weight
    self.HasFeathers=HasFeathers
self.HasFeathers= HasFeathers 

Indendation looks off here, and I don't see why self.HasFeathers=HasFeathers would need to be assigned twice.

Also between .HasFeathers=HasFeathers and .HasFeathers= HasFeathers I prefer the first form, although I'd think .HasFeathers = HasFeathers is easier to read.

I don't know if this is language syntax asking for it, but to me it looks like this:

if  getHasFeathers=false:
    return “The bird does not have feathers”    
else:   
return “The bird has feathers”  

Should be looking like this:

if getHasFeathers=false:
    return “The bird does not have feathers”    
else:   
    return “The bird has feathers”  

Lastly, - I know this is a "theoretical" class, but I don't think it would be the job of this class to determine how each property renders as a string. What if you wanted Deutsch, French and Italian descriptions for "The bird has feathers"? Would you amend your Bird class? I think your class should expose the Booleans.


And all birds have feathers. It's what makes a bird, a bird. ;)

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.