14 Replies - 322 Views - Last Post: 28 July 2013 - 12:05 PM Rate Topic: -----

#1 Notion  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 23
  • Joined: 14-April 13

Question about which modules should be used?

Posted 23 July 2013 - 01:53 PM

Hello,

I'm new to programming and python, but I figured the best way to learn is by starting a project.
So I'm trying to create a program for personal use, I want it to manage input and output for a database.
Right now, I'm not worried about a GUI, I just want to create something that works, so as to set a foundation for improvement once I have the basics down. I know it might be a little ambitious but, in the words of Eric Raymond "Every good work of software starts by scratching a developer's personal itch."

So here is what it looks like so far
class Welcome:
    def Wmsg():
        print('Welcome to the Inventory')
        print('Please enter the part name and description')
class InventoryInfo:
    def partEntry():
        invalid = 0
        part = input('Enter Part Name')
        desc = input('Enter description')
    if len(part) == invalid: #check if value was entered
        print('please enter a valid description')

    elif len(desc) == invalid:
        print('please enter a valid description')

    else:
        print('Succesfully entered a new part to the inventory database')

Welcome.Wmsg()
InventoryInfo.partEntry()


Basically, its not doing much. But question is, what should I look into for this type of program. In other words, what modules should I look into. I know pickle is good way to store data persistently. For now im thinking it should basically store the input from the user onto a file. From there eventually I want to have it store input into a database, but I'm trying to crawl before I run. also, I would appreciate any suggestions or advice!

This post has been edited by Notion: 23 July 2013 - 01:55 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Question about which modules should be used?

#2 ConciselyVerbose  Icon User is offline

  • D.I.C Regular

Reputation: 90
  • View blog
  • Posts: 315
  • Joined: 05-July 13

Re: Question about which modules should be used?

Posted 24 July 2013 - 11:44 AM

I'm not sure what you are asking in terms of what to use, but if you want to extend it without working on graphics just yet, you could use a simple menu driven program to work with for the time being. E.g.

choice = input("enter choice")
if choice =="1":
    addItem()
elif choice =="2":
    findItem()
elif choice =="3"
    deleteItem()
...


You would probably want text to define the choices and a little better setup of the choices, but that would give you the ability to ensure the choices you make work effectively until you decide to rework it for graphics later.

This post has been edited by ConciselyVerbose: 24 July 2013 - 11:45 AM

Was This Post Helpful? 0
  • +
  • -

#3 Notion  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 23
  • Joined: 14-April 13

Re: Question about which modules should be used?

Posted 24 July 2013 - 07:14 PM

Thanks @ ConciselyVerbose. And as far as writing the input from the user, would you recommend pickle? and I would also like to ask what should I look into as far as storing input into a database. Should I use something like MySQL?
Was This Post Helpful? 0
  • +
  • -

#4 ConciselyVerbose  Icon User is offline

  • D.I.C Regular

Reputation: 90
  • View blog
  • Posts: 315
  • Joined: 05-July 13

Re: Question about which modules should be used?

Posted 24 July 2013 - 07:21 PM

I wouldn't be the best to advise you on that. I have used pickle a bit, and it seems to be effective. I don't have much experience with databases. It's an area I still need to gain experience with before I would feel comfortable making recommendations to others,
Was This Post Helpful? 0
  • +
  • -

#5 nandureddy  Icon User is offline

  • D.I.C Head

Reputation: 28
  • View blog
  • Posts: 129
  • Joined: 31-January 11

Re: Question about which modules should be used?

Posted 24 July 2013 - 07:25 PM

Yes, you could use MySQL with Python.

This post has been edited by nandureddy: 24 July 2013 - 07:25 PM

Was This Post Helpful? 0
  • +
  • -

#6 DblAAssassin  Icon User is offline

  • D.I.C Head

Reputation: 32
  • View blog
  • Posts: 246
  • Joined: 11-May 13

Re: Question about which modules should be used?

Posted 26 July 2013 - 09:38 PM

I say that Pickle would be easier, because you don't have to learn a whole new language. Although use what you think will be best, after all this is your program. If you need help if you use Pickle make a new post in the Python Forum. If you use a Database post on the Databases Forum.

Also I would say pickle would be what you're saying is crawling not running.

This post has been edited by DblAAssassin: 26 July 2013 - 09:39 PM

Was This Post Helpful? 0
  • +
  • -

#7 Notion  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 23
  • Joined: 14-April 13

Re: Question about which modules should be used?

Posted 26 July 2013 - 09:57 PM

So, I'm still thinking about using pickle, just not sure how to incorporate it properly in my code, so far I decided to use the file module to read and write data thats being inputed, though I'm missing a for loop, so the data can be iterated, so far the program only stores data temporarily and only allows for 1 entry, I want to use a loop, so the program doesn't close after just 1 entry, every time I open it, the old data is replaced with new data, so pickle would solve that, as it can store objects persistently, I just need time to get my head around how to use it in my code.
class InventoryXe:
    def Wmsg():
        print('Welcome to "X"')
        print('"X"is a CLI program that will store and organize inventory data')
        print('Version 0.0.1')
        print('Please enter the part info')

    def Pdata():
            part = input('Enter part name:')
            desc = input('Enter description:')
            invalid = '0'

 
            if len(part) == invalid:
                print('Please enter a valid part')

            elif len(desc) == invalid:
                print('Please enter a valid description')


            f = open('Inventory.txt', 'w')
            f.write(part)
            f.write(' : ')
            f.write(desc)
            f.close()

            f = open('Inventory.txt')

            while True:
                line = f.readline()
                if len(line) == 0:
                    break
                print(line, end='')
         
                

InveOrganize.Wmsg()
InveOrganize.Pdata()


And I would greatly appreciate any criticisms (constructive) on my code, this is my first program, and I still have an Immense amount to learn. I just want this to be a 'Useful' program, I and others can use, no matter how simple it is.

This post has been edited by Notion: 26 July 2013 - 09:58 PM

Was This Post Helpful? 0
  • +
  • -

#8 ConciselyVerbose  Icon User is offline

  • D.I.C Regular

Reputation: 90
  • View blog
  • Posts: 315
  • Joined: 05-July 13

Re: Question about which modules should be used?

Posted 26 July 2013 - 10:08 PM

The documentation isn't bad. I haven't used it for anything too complex, but I picked it up fairly easily from the documentation for what I did use.

This post has been edited by ConciselyVerbose: 27 July 2013 - 08:50 AM

Was This Post Helpful? 0
  • +
  • -

#9 DblAAssassin  Icon User is offline

  • D.I.C Head

Reputation: 32
  • View blog
  • Posts: 246
  • Joined: 11-May 13

Re: Question about which modules should be used?

Posted 27 July 2013 - 08:16 AM

ConciselyVerbose your link is throwing up a 404 Error, this this link.
Was This Post Helpful? 0
  • +
  • -

#10 andrewsw  Icon User is offline

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3190
  • View blog
  • Posts: 10,683
  • Joined: 12-December 12

Re: Question about which modules should be used?

Posted 27 July 2013 - 08:46 AM

Quote

I'm new to programming and python, but I figured the best way to learn is by starting a project.

I very much disagree with this statement. You need to study all the fundamentals - the basics - first.

There are a number of tutorials linked here at net-tuts. We have tutorials here @DIC as well, click the Tutorials link at the top of this page.
Was This Post Helpful? 0
  • +
  • -

#11 ConciselyVerbose  Icon User is offline

  • D.I.C Regular

Reputation: 90
  • View blog
  • Posts: 315
  • Joined: 05-July 13

Re: Question about which modules should be used?

Posted 27 July 2013 - 08:51 AM

Somehow it ended up missing the l in HTML. Thanks for pointing that out.
Was This Post Helpful? 0
  • +
  • -

#12 DblAAssassin  Icon User is offline

  • D.I.C Head

Reputation: 32
  • View blog
  • Posts: 246
  • Joined: 11-May 13

Re: Question about which modules should be used?

Posted 27 July 2013 - 05:53 PM

View Postandrewsw, on 27 July 2013 - 08:46 AM, said:

Quote

I'm new to programming and python, but I figured the best way to learn is by starting a project.

I very much disagree with this statement. You need to study all the fundamentals - the basics - first.

There are a number of tutorials linked here at net-tuts. We have tutorials here @DIC as well, click the Tutorials link at the top of this page.

To my understanding he does know the basics, and he is doing he first major project. Which if you haven't made a project I would say your new to programming. But if Andrew is right I recommend Codecademy, here is the Python Track.
Was This Post Helpful? 0
  • +
  • -

#13 Notion  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 23
  • Joined: 14-April 13

Re: Question about which modules should be used?

Posted 28 July 2013 - 10:50 AM

Thanks for the replies. I have been learning at codeacademy, and I've read ( A byte of Python by Swaroop as well as other free learning resources, I even bought Head First Python by O Reilly, which I think is expensive and not a book for beginners), which I think is an excellent book on learning python for beginners, by far the best resource I have. And to be honest, I find learning programming solely by reading books is not the best way for my self to learn (I'm more of a practical than theoretical person), I find that applying what I've learned in a project motivates me a great deal, and I feel like it makes certain things "stick" in my memory better. I see how certain things work in a real project not just an example, but obviously I still need a lot to learn, and most of what I've written is by trial and error ( A great deal of errors) and I doubt is any good in terms of a useful program. In other words, I really want to write code, and I'm not the most patient person but I truly want to make this program because its something I wish to use and for others to use, I know there are lots of better programs I can download but I writing one from the ground is what I want and choose to do.
Was This Post Helpful? 1
  • +
  • -

#14 andrewsw  Icon User is offline

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3190
  • View blog
  • Posts: 10,683
  • Joined: 12-December 12

Re: Question about which modules should be used?

Posted 28 July 2013 - 11:01 AM

Quote

I'm more of a practical than theoretical person

I've heard this, and similar, so many times - still not quite sure what it means :dontgetit:

As you are not the most patient person, I really like The Quick Python Book by Naomi R. Ceder. It is not a full tutorial, and it doesn't cover everything, but it is a nice, compact, read.

Good luck!
Was This Post Helpful? 0
  • +
  • -

#15 DblAAssassin  Icon User is offline

  • D.I.C Head

Reputation: 32
  • View blog
  • Posts: 246
  • Joined: 11-May 13

Re: Question about which modules should be used?

Posted 28 July 2013 - 12:05 PM

I just recently purchased the Python Pocket Reference 4th Edition by Mark Lutz Published by O'Reilly. Great Read if you just forgot the syntax, or if you forgot the elements of a module, etc.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1