hotel management system

Chris Angelico rosuav at gmail.com
Tue Oct 28 08:09:36 CET 2014


On Tue, Oct 28, 2014 at 5:42 PM, ngangsia akumbo <ngangsia at gmail.com> wrote:
> Please can someone look at my code and may be advice and may be help me with some correction. I have been learning python for some time now. This is my first project i wish to write. A hotel management system.
>
>
> http://pastebin.com/LMHmuTiC
>

Sure, we can do code reviews! It's usually helpful to provide your
code in-line, though, rather than linking to pastebin.

You're using Python 2, as evidenced by the print statements. So don't
do this, ever:

> def emp_age():
>     """displaying employees age"""
>
>     age = input("Enter age: ")

The input function is extremely dangerous. Everywhere else, you use
raw_input, which is correct.

> class Bar:

This is an old-style class. It's better to explicitly subclass object:

class Bar(object):

> class Beer(Bar):

Not sure why you're doing this. Firstly, you never use your Beer
class... but secondly, your Beer isn't a special type of Bar, it's a
quite different thing. When you subclass, it's usually helpful to
follow the Liskov Substitution Principle:

https://en.wikipedia.org/wiki/Liskov_substitution_principle

Think carefully about your class hierarchy, because it defines all
sorts of things about your code. Be sure you're happy with it before
you code up too much else.

ChrisA



More information about the Python-list mailing list