General direction

M

MLT

Hello all: I'm a beginner to Python (and programming altogether), and
am now looking to create a program of my own. What I've got in mind
is a very basic pest control program that would keep track of 1) trap
findings and 2) pesticides. My thought is to make each of these
classes. Looking at the general outline written below, can anyone
give general impression about whether I'm somewhat going in the right
direction or if I need to approach it entirely differently? Thanks
for any suggestions or help!

Class Insect_Trapping attributes:
- Unique Name
- Location
- Type
- Frequency of Checks?
- Next Check Date

Within Insect_Trapping there are Trap_Count objects

Trap_Count objects have the following attributes:
- Date
- Time
- Insect A Finds
- Insect B Finds
- Insect C Finds
- Insect A Number
- Insect B Number
- Insect C Number

Class Pesticides attributes:
- Unique Name
- Usage Instructions

Within Pesticide there are Pesticide_Usage objects

Pesticide_Usage objects have the following attributes:
- Date
- Time
- Location
- Reason for Use
- Amt Used
 
D

Diez B. Roggisch

MLT said:
Hello all: I'm a beginner to Python (and programming altogether), and
am now looking to create a program of my own. What I've got in mind
is a very basic pest control program that would keep track of 1) trap
findings and 2) pesticides. My thought is to make each of these
classes. Looking at the general outline written below, can anyone
give general impression about whether I'm somewhat going in the right
direction or if I need to approach it entirely differently? Thanks
for any suggestions or help!

Familiarize yourself with PEP8 for naming and coding-conventions first.

Class Insect_Trapping attributes:
- Unique Name
- Location
- Type

Depending on what the Type is, you might consider using subclassing here
instead.
- Frequency of Checks?
- Next Check Date

Within Insect_Trapping there are Trap_Count objects

Trap_Count objects have the following attributes:
- Date
- Time
- Insect A Finds
- Insect B Finds
- Insect C Finds
- Insect A Number
- Insect B Number
- Insect C Number

Instead of manually coding attributes for all kinds of insects, better
use a mapping of insect-name to attributes. There are plenty of options
for that - you could a mapping of name to tuple:

{ "cockroach" : (100, 200),
"wasp" : (2000, 3000)
}

Or introduce a InsectInfo-class that has finds and numbers as fields:

{ "bee" : InsectInfo(finds=100, number=200) }

Class Pesticides attributes:
- Unique Name
- Usage Instructions

Within Pesticide there are Pesticide_Usage objects

Pesticide_Usage objects have the following attributes:
- Date
- Time
- Location
- Reason for Use
- Amt Used


HTH,

Diez
 
J

James Stroud

MLT said:
Hello all: I'm a beginner to Python (and programming altogether), and
am now looking to create a program of my own. What I've got in mind
is a very basic pest control program that would keep track of 1) trap
findings and 2) pesticides. My thought is to make each of these
classes. Looking at the general outline written below, can anyone
give general impression about whether I'm somewhat going in the right
direction or if I need to approach it entirely differently? Thanks
for any suggestions or help!
[data structures snipped]

Programs generally *do* something. Here you have described data
structures, which just sit there being full of data. They aren't very
active and hence are not terribly interesting.

Here are some bullet points for your consideration:

1. What will your program do?
2. Understand databases (http://tinyurl.com/6flhbz) before you start.
3. Consider PySQlite (http://trac.edgewall.org/wiki/PySqlite)
before you think about a heavyweight database backend (once
you realize that you will want a database for this project).

James

--
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com
 
S

Steven D'Aprano

Familiarize yourself with PEP8 for naming and coding-conventions first.

Or not.

Enough of the PEP8-fascism please. It is not compulsory to follow PEP8 in
order to be allowed to learn Python. If Guido wanted it compulsory, he'd
have made the compiler enforce it.

Besides, you're talking to a newbie. Chances are he doesn't even know
what PEP8 is: the recommended style-guide for Python code.

http://www.python.org/dev/peps/pep-0008/

Having said that, I will *suggest* to the Original Poster that you should
follow PEP8 as much as possible. It will save you a lot of grief in the
long run. But right now, it is more important to learn the language than
to learn conventions for how to name classes. If you can do both, great,
but don't let the naming conventions get in the way.
 
S

Steven D'Aprano

You are responding to something in Diez's message that I can't see.
Nowhere does he say anything about PEP 8 being compulsory. Quite the
contrary, he suggests gaining *familiarity* with PEP 8, and calls it a
set of *conventions*.

He doesn't *suggest* anything. He uses the imperative case -- it's a
command. It may not have been Diez's deliberate, conscious intention to
order the OP to learn PEP8, but without a modifier like "I think you
should", that's what he did. That's why I emphasised "suggest" in my
response: it's not an order, but it is recommended.

On its own, that wouldn't have been enough to warrant a response. I'm
sure I've thoughtlessly and inappropriately used unmodified imperative
commands in the past, and I'll probably do it again. But add to it the
perfunctory way he used this mysterious (to a newbie) jargon "PEP8",
without even the courtesy of a link, and the overall tone was newbie
hostile.

I'm sure that wasn't Diez's intention, because the rest of his post was
not like that.

This, on the other hand, seems pretty much a re-phrasing of what Diez
already said.

That's because I agree with Diez that following PEP8 is generally a good
thing, but don't agree with him that it is necessary to learn the naming
conventions before learning the language. An overly strict approach will
just frighten the newbies off. Part of the reason that Python is
successful is that it is accessible to newbies, and giving them strict
Thou Shalt Do This commands is quite off-putting.
 
S

Steven D'Aprano

Regardless, even if it was an imperial order with government backing,
the instruction was not to *follow* PEP 8, but to *become familiar with*
it. That isn't fascism, and to read that into it and assume a
commandment that Diez didn't make is overreaction on your part.

Okay, fair enough, I made a mistake in saying "It is not compulsory to
follow PEP8". What I should have said was "It is not compulsory to become
familiar with PEP8".

Now that you've put me in my place, can we please get back to becoming a
hostile and unforgiving place for newbies who dare to try learning Python
without first becoming familiar with PEP8?

*wink*

Seriously, I'll accept a small rebuke. My choice of the word "fascism"
was poor, and I regret it. In my defense, I thought it was better than my
initial thought, which was "style-Nazi", but in hindsight given the
proliferation of somewhat tongue-in-cheek foo-Nazi terms (soup-Nazi,
grammar-Nazi, fashion-Nazi, etc.) maybe I should have stuck with it.

But by focusing on such a small aspect of my post (a quarter of my text),
while ignoring the more substantial aspects, it seems that you are giving
tacit approval of precisely the attitude I am objecting to: that there is
a One True And Correct Right Way to learn and/or use Python.

For a community that celebrates the dynamism of the language, and
supports giving the programmer the ability to shoot themselves in the
foot ("we're all adults here"), we can sometimes be remarkably intolerant
of things which are a matter of taste. Sometimes it seems that there's a
Party line, and individuals can be criticized for failing to be
enthusiastic enough about supporting it. This is a good example: it isn't
enough that I agreed with Diez's substantial point that PEP8 is a good
thing; it isn't enough that I made it more likely that the OP would find
and read PEP8 by posting a link to it; but by making a mild criticism of
*the way* Diez introduced PEP8 to the newbie, *I'm* the bad guy.
 
A

Aaron Brady

Okay, fair enough, I made a mistake in saying "It is not compulsory to
follow PEP8". What I should have said was "It is not compulsory to become
familiar with PEP8".

People are sensitive in differing amounts to the imperative case. I'm
really sensitive to it, and I appreciate it when people say *plonk*
instead of *lonk*.

Diez took an authoritarian posture with the imperative. Instead of
saying what benefit the OP would get from complying, the subtext in
such cases is, "I'm in charge. If you haven't heard of me, get out.
Do what I say, or get out."

That might be extreme, but you'd be hard pressed to defend an
interpretation of what he said to be, "One good option is to skim PEP
8 early. It has a low-maintenance, long-term benefit." It's much
more common to use an imperative in a chain of command, as in "Swab
the deck", or "Convert the heathens", where a task is critical to a
collective mission, or, regrettably, in reminding people who has the
gun, such as in an enforced hierarchy.

There is no chain of command or gun in the Python community (that I've
found), at least outside of the core devs, which I can't attest to.

IMO, it's most likely Diez was performing a hazing ritual on a
newcomer, that he'd forgotten he didn't like when he did it.
Now that you've put me in my place, can we please get back to becoming a
hostile and unforgiving place for newbies who dare to try learning Python
without first becoming familiar with PEP8?

Let us compose odes and sonnets to its glory. (Imperative.)
*wink*

Seriously, I'll accept a small rebuke. My choice of the word "fascism"
was poor, and I regret it. In my defense, I thought it was better than my
initial thought, which was "style-Nazi", but in hindsight given the
proliferation of somewhat tongue-in-cheek foo-Nazi terms (soup-Nazi,
grammar-Nazi, fashion-Nazi, etc.) maybe I should have stuck with it.

You could probably stick with 'style police', as in 'fashion police',
as in, "Don't worry about Diez, he's the self-appointed style
police". Sorry, heard it on t.v. once.
But by focusing on such a small aspect of my post (a quarter of my text),
while ignoring the more substantial aspects, it seems that you are giving
tacit approval of precisely the attitude I am objecting to: that there is
a One True And Correct Right Way to learn and/or use Python.

Not only is there One True And Correct Right Way(tm), but I'm the only
one who knows what it is.
For a community that celebrates the dynamism of the language, and
supports giving the programmer the ability to shoot themselves in the
foot ("we're all adults here")

For what definition of 'here'?
we can sometimes be remarkably intolerant
of things which are a matter of taste.

-- Your code tastes funny.
-- Stop chewing it and swallow. (Imperative.)
Sometimes it seems that there's a
Party line, and individuals can be criticized for failing to be
enthusiastic enough about supporting it. This is a good example: it isn't
enough that I agreed with Diez's substantial point that PEP8 is a good
thing; it isn't enough that I made it more likely that the OP would find
and read PEP8 by posting a link to it; but by making a mild criticism of
*the way* Diez introduced PEP8 to the newbie, *I'm* the bad guy.

I think you're ignoring the diversity of backgrounds that people from
around the world can have. Maybe in Diez's past lives, friends just
roughhouse and show acceptance and affection by using imperatives.
Maybe it is a bellowed 'WELCOME!', instead of an unchecked power bid.

Ever find it hard to get personal with a newsgroup?

A. Brady

P.S. Not that questions are any better.
 
H

Hendrik van Rooyen

8< -------------- stuff giving Diez a hard time for the
above ------------------------

Oh come on you lot - you are carrying on as if Diez were wearing his
skull socks again - do me a favour and give him a break!

- Hendrik
 
S

Steven D'Aprano

Oh come on you lot - you are carrying on as if Diez were wearing his
skull socks again - do me a favour and give him a break!

Well, for what it's worth, I should say one final thing:

I didn't disagree with what Diez said, only the way he said it. I thought
my original post made that clear, but perhaps I should have said so
explicitly. And I certainly don't think less of him because of it.

And... skull socks? Cool. Where can I get some?
 
H

Hendrik van Rooyen

Steven D'Aprano said:
And... skull socks? Cool. Where can I get some?

Don't you remember? - Google the group - there was some
dust raised about them some time ago. I think he got them
from KDW - "Kaufhaus Der Welt" aka "Klau Dir Was"

:)

- Hendrik
 
S

Steven D'Aprano


Not Found
The requested URL /search was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use
an ErrorDocument to handle the request.



You know, it was just a throw-away comment to lighten the mood. I don't
really need to see 18,000+ links to places that sell socks with skulls
printed on them.

On the other hand, if they were socks made from actual skulls, that would
be something...
 
S

Steve Holden

Steven said:
Not Found
The requested URL /search was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use
an ErrorDocument to handle the request.



You know, it was just a throw-away comment to lighten the mood. I don't
really need to see 18,000+ links to places that sell socks with skulls
printed on them.

On the other hand, if they were socks made from actual skulls, that would
be something...
Of course Cliff actually meant

http://letmegooglethatforyou.com/?q=skull+socks

Jokes are never as funny when they go wrong :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top