[Tutor] Tutor Digest, Vol 83, Issue 115
echowit at aol.com
echowit at aol.com
Wed Jan 26 18:35:17 CET 2011
I not offering a program design answer. I don't have a clue as to your operation, but I've been there as far as QA software, CNC programs and Quality record keeping.
My thought is that instead of starting with the casting, think of the BOM on the final ass'y/configuration print and work backwards.
Hint, I wish I'd have had Python's Dictionary & Tuple when I was active.
-----Original Message-----
From: tutor-request <tutor-request at python.org>
To: tutor <tutor at python.org>
Sent: Wed, Jan 26, 2011 6:55 am
Subject: Tutor Digest, Vol 83, Issue 115
Send Tutor mailing list submissions to
tutor at python.org
To subscribe or unsubscribe via the World Wide Web, visit
http://mail.python.org/mailman/listinfo/tutor
r, via email, send a message with subject or body 'help' to
tutor-request at python.org
You can reach the person managing the list at
tutor-owner at python.org
When replying, please edit your Subject line so it is more specific
han "Re: Contents of Tutor digest..."
oday's Topics:
1. Re: class question (Alan Gauld)
2. Re: Shuts down when asking user for info (Alan Gauld)
3. Re: Shuts down when asking user for info (Alan Gauld)
4. Re: class question (Karim)
5. Re: class question (Karim)
6. Re: class question (Elwin Estle)
---------------------------------------------------------------------
Message: 1
ate: Wed, 26 Jan 2011 11:08:07 -0000
rom: "Alan Gauld" <alan.gauld at btinternet.com>
o: tutor at python.org
ubject: Re: [Tutor] class question
essage-ID: <ihovb6$h2n$1 at dough.gmane.org>
ontent-Type: text/plain; format=flowed; charset="iso-8859-1";
reply-type=response
Karim" <karim.liateni at free.fr> wrote
> Program towards interface that means you have to use inheritance.
Just to be picky, you can program by interface without using
nheritance. Inheritance is only needed to implement interfaces
n languages like C++. In Python (and other dynamically
ound OOP languages) you can use polymorphism without
nheritance.
--
lan Gauld
uthor of the Learn to Program web site
ttp://www.alan-g.me.uk/
-----------------------------
Message: 2
ate: Wed, 26 Jan 2011 11:13:59 -0000
rom: "Alan Gauld" <alan.gauld at btinternet.com>
o: tutor at python.org
ubject: Re: [Tutor] Shuts down when asking user for info
essage-ID: <ihovm5$irq$1 at dough.gmane.org>
ontent-Type: text/plain; format=flowed; charset="iso-8859-1";
reply-type=original
Casey Key" <i.eat.brainzzz at gmail.com> wrote
> Please help , run the script and see that once you press enter after
entering name it just shuts it down, help.
> --------------
rint("\tWelcome to Casey's magical python code!")
rint("\tWritten by no other than Casey Key!")
rint("\nWe will begin by getting some information,mmmkay?")
ame = input("what is your name")
rint("your name is",name)
-----------------
Python is case sensitive, print starts with a lowercase P.
However that should have generated an error.
ow did you run the program? If you ran it from an IDE or
rom the command prompt you would have seen the error.
suspect you are just double clicking in a file manager?
oing that the window will close before you can read it.
lways test your code by running from a prompt so that
ou see all output, including errors.
lan Gauld
uthor of the Learn To Program website
ttp://www.alan-g.me.uk/
-----------------------------
Message: 3
ate: Wed, 26 Jan 2011 11:09:35 -0000
rom: "Alan Gauld" <alan.gauld at btinternet.com>
o: tutor at python.org
ubject: Re: [Tutor] Shuts down when asking user for info
essage-ID: <ihovdt$hgl$1 at dough.gmane.org>
ontent-Type: text/plain; format=flowed; charset="iso-8859-1";
reply-type=original
tee chwee liong" <tcl76 at hotmail.com> wrote
> maybe you can use raw_input?
It looks like the OP is using Python 3 so input() is the correct
unction.
lan G.
-----------------------------
Message: 4
ate: Wed, 26 Jan 2011 12:19:43 +0100
rom: Karim <karim.liateni at free.fr>
o: tutor at python.org
ubject: Re: [Tutor] class question
essage-ID: <4D40034F.4080902 at free.fr>
ontent-Type: text/plain; charset=ISO-8859-1; format=flowed
ure, but I come from java world and 1 inheritance is allowed but we can
mplement multiple interfaces.
like to use Abstract classes in Python then inherit and implement
bstract method like in java (at least
hat's all I remember from Java experience).
ndeed I was too direct everybody has the same style.
Regards
arim
On 01/26/2011 12:08 PM, Alan Gauld wrote:
"Karim" <karim.liateni at free.fr> wrote
> Program towards interface that means you have to use inheritance.
Just to be picky, you can program by interface without using
inheritance. Inheritance is only needed to implement interfaces in
languages like C++. In Python (and other dynamically bound OOP
languages) you can use polymorphism without inheritance.
------------------------------
Message: 5
ate: Wed, 26 Jan 2011 12:25:19 +0100
rom: Karim <karim.liateni at free.fr>
o: Steven D'Aprano <steve at pearwood.info>
c: tutor at python.org
ubject: Re: [Tutor] class question
essage-ID: <4D40049F.5050600 at free.fr>
ontent-Type: text/plain; charset=ISO-8859-1; format=flowed
know the the law of Murphy.
ut this one is a must-have.:-)
Regards
arim
> * One way to reduce coupling is with the Law of Demeter: if you want
your dog to walk, don't talk to your dog's legs. You will only confuse
the dog and it won't get anywhere.
http://en.wikipedia.org/wiki/Law_of_Demeter
Hope this helps.
------------------------------
Message: 6
ate: Wed, 26 Jan 2011 04:45:18 -0800 (PST)
rom: Elwin Estle <chrysalis_reborn at yahoo.com>
o: tutor at python.org, Steven D'Aprano <steve at pearwood.info>
ubject: Re: [Tutor] class question
essage-ID: <229841.16130.qm at web130204.mail.mud.yahoo.com>
ontent-Type: text/plain; charset="iso-8859-1"
Elwin Estle wrote:
> Is it better to have one large sort of "do it all" class, or break
the larger class up into smaller classes?
Yes.
Or no.
It's impossible to answer that question definitively without knowing more about
hat "it all" is. But I can give some general advice:
* Python isn't Java. Don't feel that you must use classes. If your problem is
etter solved using a procedural or functional approach, go right ahead and use
t. Classes aren't compulsory.
* The standard model which you should use it:
? verbs -> functions or methods
nouns -> classes or attributes
? You should be able to answer the question "What *thing* does
your class represent?". (The answer can be an abstract thing,
but it should be a thing.)
? If you can't answer that question, then you shouldn't use a
class. You should solve the problem using stand-alone functions.
* Think about "is-a" and "has-a" relationships:
=================================================================
The class in question, does, in fact, deal with a thing.? The problem is, the
thing" is highly mutable.?? The "is-a" and the "has-a" changes.
Here is the scenario:
A raw casting comes into a factory.? It is listed as such.? When machined, this
art number changes to a different part number.?? The raw casting has no
quality related" stuff, but the machined casting does, and it can have more
han one "quality related" thing.
...because, the raw casting may go through multiple operations to get to it's
inal state.? It may get machined on a lathe, then be transferred to a CNC
achining station where a bolt circle may be drilled and tapped into it.? Each
f those operations on separate machines will have a different set of quality
hecks associated with it.
...or it might be a part that goes from a raw casting to a sort of
mini-assembly" such as a rocker lever (if you know what that is), so we have
aw casting = one part number, then it gets a bushing pressed into it = another
art number, then it gets a threaded insert = another part number, but it is
till the same thing, and each one of those steps may have some sort of quality
heck involved.
Lets complicate things even further.? One raw casting may be machined into
ultiple part numbers.? Perhaps the only thing that changes is the location of a
ingle hole.? But again, each one of those part numbers may go through multiple
achining operations on different machines, with different quality checks.? This
s done through something called a "tabbed" blueprint, wherein there is a master
umber, but there are "tabs" indicating that if you changes such and such
eature, then the part number isn't the master number, but the tabbed number.
So, in essence, there's a sort of "network" of "is-a" and "has-a" information.
My idea was to, instead of having just a single "part" class, to have a sort of
component aggregate" class, which would cover not only single parts, but
ssemblies of parts.? So, even if a part was as simple as a raw casting that is
ust machined into a finished part and that's it, it would still be treated as a
ort of assembly, with the raw casting being a component of the finished part
umber, if that makes sense.
So there's all this information associated with a given part.? I am thinking it
as a sort of tree structure.? I am just wondering if some of the branches of
he tree should be separate classes that are then tied into the "trunk" of the
aster class, or if the whole thing should be a tree into and of itself.
...and yeah, I know, it's kind of a complex problem for a newbie to be thinking
bout.
------------- next part --------------
n HTML attachment was scrubbed...
RL: <http://mail.python.org/pipermail/tutor/attachments/20110126/c747b525/attachment.html>
------------------------------
_______________________________________________
utor maillist - Tutor at python.org
ttp://mail.python.org/mailman/listinfo/tutor
nd of Tutor Digest, Vol 83, Issue 115
*************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110126/43915a18/attachment-0001.html>
More information about the Tutor
mailing list