extra set of eyes

37 views
Skip to first unread message

Paul Boncher

unread,
Dec 15, 2013, 6:08:49 PM12/15/13
to pym...@googlegroups.com
Hi all!

New to the group. My job has taken me into the realm of python. I was wondering if anyone on here could lend a little advice on where I've gone wrong on a class project, and then onto other python related topics as well. Nothing huge as far as time. Just a few minutes here and there.  I don't want to clog the boards up.

Thanks all!
-Paul

Peter J. Farrell

unread,
Dec 15, 2013, 6:50:50 PM12/15/13
to pym...@googlegroups.com
Unless you're asking questions in which somebody would need to review reams and reams of code, I would suggest just asking your questions here in the open.  We don't bite. Also, if there is more complicated code to be shared -- you might upload it to a public GitHub repo and reference links instead.

Welcome to the group!

.pjf
Manager of PyMNtos

Paul Boncher

unread,
Dec 16, 2013, 9:21:21 AM12/16/13
to pym...@googlegroups.com
Thanks! I didn't know how things went around here. I had a bad experience with Stackoverflow, so I was a little gun shy. I spent more time justifying why I asked a question than actually getting help... But that is (hopefully) behind me.

I'm going to test you on that "we don't bite" thing right away. This is my first foray into OOP having been an HTML dork for longer than I care to admit. I might have a few of my terms wrong. If so, I apologize. Attached are the 3 relevant little files for the example I am trying to hammer out. Running exam3.py brings up the GUI from BankGUI.py. It uses some of the classes from py10.py to do some basic banking functions, Open, Deposit, and Withdraw are essentially the same. the Xfer methods are where I run into the problem. Transfer from either object presents me with something like...

Traceback (most recent call last):
  File "C:\Python27\lib\lib-tk\Tkinter.py", line 1470, in __call__
    return self.func(*args)
  File "C:\Users\Dar\Desktop\ex3\BankGUI.py", line 98, in CXfer
    self.checking.Xfer(balance=fltBal)
  File "C:\Users\Dar\Desktop\ex3\py10.py", line 53, in Xfer
    Savings.Deposit(Savings, balance=balance)
TypeError: unbound method Deposit() must be called with Savings instance as first argument (got type instance instead)

So please be gentle. It's my first time. I am sure that there is plenty of questionable coding going on in here... It's only been a month. Basically I just would like to resolve the error, but I am also happy to hear any constructive criticism. 

Thanks again!
BankGUI.py
Exam3.py
py10.py

Paul Boncher

unread,
Dec 16, 2013, 9:23:08 AM12/16/13
to pym...@googlegroups.com
Ah nuts. I forgot that bit about GitHub.  Something else to learn I suppose.  I will post a relevant link when I have it.

Paul Boncher

unread,
Dec 16, 2013, 9:36:20 AM12/16/13
to pym...@googlegroups.com
https://github.com/pbdev/python1/  --- relevant GitHub repository


Curt Thompson

unread,
Dec 16, 2013, 10:01:58 AM12/16/13
to pym...@googlegroups.com
Paul,

It looks like you're getting confused between an instance (object) of a class (for e.g. my_savings = Savings())  and the actual class itself.  One solution would be to pass in an instance of a savings account to the Xfer method.  You're current calling Xfer as a class method but not defining it as such.

Changing your naming convention might help with that.  Commonly, instance methods (methods with 'self' as a parameter) should be all lower case whereas Camel case is for classes.

Cheers,

-Curtis


On Mon, Dec 16, 2013 at 8:36 AM, Paul Boncher <p.bo...@gmail.com> wrote:
https://github.com/pbdev/python1/  --- relevant GitHub repository


--
Meetings Schedule / RVSP on our Meetup at http://python.mn
---
You received this message because you are subscribed to the Google Groups "PyMNtos" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pymntos+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Paul Boncher

unread,
Dec 16, 2013, 11:00:03 AM12/16/13
to pym...@googlegroups.com
Curtis,

Thank you for the tips. I had my first breakthrough in longer than I care to admit. I will keep the naming convention tips in mind too. I appreciate the help.

-Paul
Reply all
Reply to author
Forward
0 new messages