[Tutor] Looking for some direction

2019-05-11 Thread Cranky Frankie
I'm a long time IT professional trying to teach myself object-oriented
programming. As such I want to build a traditional PC app using MVC (Model
- View - Controller) architecture. Just want to make sure I'm heading about
this in the best way so I'm looking for some direction.

For the Model or persistence layer I want to use SQLite. For the View or
GUI I want to use wxPython. For the Controller I want to of course use
Python. I'm also planning on using Git for source control.

1) For the IDE I'm most comfortable with Netbeans/Java, but I'm forcing
myself to try and get comfortable with PyCharm. Is it worth sticking it out
with PyCharm, or should I go with the Python module in Netbeans? Or is
there another IDE I should look at?

2) For wxPython I'm finding a lot of the documentation is outdated. Is this
book any good:

http://www.blog.pythonlibrary.org/2019/05/08/creating-gui-applications-with-wxpython-now-available/

Or is there a better book/course/website I should be working with? Or is
there a better grahpics framework at this point for a traditional desktop
app?

3) For the O-O part, I'm comfortable with Inheritance and Composition. Do I
need to worry about any of the more advanced design patterns? This app will
be for vehicle ownership - tracking maintenance, etc. Nothing fancy.

4) I plan to write my Use Case in Libre Office Write. For the UML diagrams,
is there a simple app to handle that? I don't need it to generate code but
I'd like to have a nice class diagram if possible.

5) I'm really having trouble envisioning the GUI screens. How does one get
a handle on that? Just draw the screens on paper, or what?

Any ideas very much appreciated.

-- 
Frank L. "Cranky Frankie" Palmeri, Risible Riding Raconteur & Writer
"I never lose. I either win or I learn"
- Nelson Mandela
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Running Python 3 on Linux Mint

2019-01-14 Thread Cranky Frankie
On Sun, Jan 13, 2019 at 2:04 PM Alan Gauld via Tutor 
wrote:

> "You don't say which Mint version but assuming its 17 or
> greater then you can just use the software manager
> (or Synaptic) and install the python3 packages."
>
> Thanks so much, I'm all set now.
-- 
Frank L. "Cranky Frankie" Palmeri, Risible Riding Raconteur & Writer
"If you have a garden and a library, you have everything you need." - Cicero
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Running Python 3 on Linux Mint

2019-01-13 Thread Cranky Frankie
I want to start developing an application in Python 3 on my main computer
which runs Linux Mint with Python 2.7. What is the best way to work with
Python 3 on this system?

-- 
Frank L. "Cranky Frankie" Palmeri, Risible Riding Raconteur & Writer
"If you have a garden and a library, you have everything you need." - Cicero
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] graphics library for teaching Python

2018-12-21 Thread Cranky Frankie
Tutor@python.org:
"I'm a computer science tutor and I'm asking advice about a graphics or game
library that can be used with Python effectively for teaching purposes."

Michael Dawson's "Python Programming for Absolute Beginners" uses PyGame.
Might be worth a look.



On Fri, Dec 21, 2018 at 3:26 AM Michael Mossey 
wrote:

> I'm a computer science tutor and I'm asking advice about a graphics or game
> library that can be used with Python effectively for teaching purposes.
>
> I've found that having my student pick a long-term project is a good way
> for them to learn coding, and graphics or games make great projects that
> both have stimulating results and bring computer-science-y topics into the
> mix (i.e. they are natural vehicles for OO, data structures, and
> algorithms).
>
> There are two sub-topics I'm interested in - (1) graphics, as in drawing
> interesting pictures or art, or using diagrams for data visualization. (2)
> Simple games, with the use of sprites.
>
> I've been using PyGame, but I'm not happy with it. It's not very well
> organized or documented, and not very capable of general graphics.
>
> So I'm looking into a few other possibilities. No library can be everything
> to everyone, but I'd  like something that gives students exposure to a
> variety of programming tasks, like constructing GUIs, events and event
> loops, and 2-D graphics via stroking and filling common polygon shapes and
> Bezier curves. (3D is not necessary for now.)
>
> Here are some alternatives to PyGame:
>
> - Pyglet. Doesn't look promising. I'm mainly interested in 2D, and I don't
> see common data visualization tasks provided like filling and stroking
> Bezier curve shapes (maybe I'm missing something).
>
> - Cairo. Looks great for static 2D graphics, but not games .. again maybe
> I'm missing something.
>
> - Cocos2D. Good for games but not necessary general 2D graphics.
>
> - PyQt. I used this extensively at my last regular desk job many years ago,
> and if I recall it has the QCanvas element with pretty deep graphics
> ability and also event handling. It has collision detection too, I think,
> allowing for easy 2D game writing.
>
> It looks to me like PyQt is the most capable program and most related to
> what I want to do, but one thing I'm wondering about is how widely its used
> and whether it would be good exposure for students to connect them to the
> wider world of computing they will someday enter.
>
> Any thoughts would be appreciated.
>
> Mike
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>


-- 
Frank L. "Cranky Frankie" Palmeri, Risible Riding Raconteur & Writer
"If you have a garden and a library, you have everything you need." - Cicero
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Curious dictionary printing

2012-05-08 Thread Cranky Frankie
On Mon, May 7, 2012 at 10:31 PM, bob gailer bgai...@gmail.com wrote:

 Asking why does it not do what I want is not IMHO the best way to win
 friends here.

Good morning to you to, Bob.

I see now that dictionaries in Python act like relational databases in
that there is no inherent ordering. At first, when I simply wanted to
print one entry and it came out in what looked like a random order,
this didn't occur to me. A normal dictionary is in fact ordered.

Sorry for the disturbance.

-- 
Frank L. Cranky Frankie Palmeri
Risible Riding Raconteur  Writer
“The problem with quotes on the Internet is that
it is often difficult to verify their authenticity.”
- Abraham Lincoln
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Curious dictionary printing

2012-05-07 Thread Cranky Frankie
In 3.2.2 in IDLE I have this dictionary entry:

Namath = {first_name: Joe, last_name: Namath, phone: 212-222-,\
  email: joe.nam...@gmail.com, stadium: Shea Stadium}

when I print it:

print(Namath)

I get:

{'phone': '212-222-', 'first_name': 'Joe', 'last_name': 'Namath',
'email': 'joe.nam...@gmail.com', 'stadium': 'Shea Stadium'}

Why is it out of order?

-- 
Frank L. Cranky Frankie Palmeri
Risible Riding Raconteur  Writer
“The problem with quotes on the Internet is that
it is often difficult to verify their authenticity.”
- Abraham Lincoln
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] running an imported function

2012-04-27 Thread Cranky Frankie
This is in 3.2.2.

I wanted a function to clear the screen in IDLE. I have this in a
clr.py file in a directory in my path:

# Function to clear the IDLE screen by printing blank lines
def clr():
'''Function to clear the IDLE screen
   by printing 50 lines.'''
for i in range(1, 50):
print()


I can import it in IDLE no problem, but when I do this:

 clr()

I get

Traceback (most recent call last):
  File pyshell#6, line 1, in module
clr()
TypeError: 'module' object is not callable



Is there a way I can import clr.py and then run clr()?


-- 
Frank L. Cranky Frankie Palmeri
Risible Riding Raconteur  Writer
“The problem with quotes on the Internet is that
it is often difficult to verify their authenticity.”
- Abraham Lincoln
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] New to Python programing

2012-04-03 Thread Cranky Frankie
Another resourse for learning to program is YouTube. They just had a
segment on 60 Minutes about a guy who does all kinds of well
regarded free courses on-line, unfortunately I can't remberber the
URL. I've viewed several Stanford University programming courses, and
there are many Python specific vidoes there as well. Just something
else to check out.

-- 
Frank L. Cranky Frankie Palmeri
Risible Riding Raconteur  Writer
“The problem with quotes on the Internet is that
it is often difficult to verify their authenticity.”
- Abraham Lincoln
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] New to Python programing

2012-04-03 Thread Cranky Frankie
On Tue, Apr 3, 2012 at 10:09 AM, Christian Witts cwi...@compuscan.co.za wrote:

 Are you possibly thinking of the Khan Academy [1] ?

 [1] http://www.khanacademy.org/

Yes, that was it, thanks.


-- 
Frank L. Cranky Frankie Palmeri
Risible Riding Raconteur  Writer
“The problem with quotes on the Internet is that
it is often difficult to verify their authenticity.”
- Abraham Lincoln
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] New to this list ....

2012-03-30 Thread Cranky Frankie
Message: 1
Date: Fri, 30 Mar 2012 15:04:09 +0100
Barry Drake bdr...@crosswire.org wrote:

 I'm getting a Raspberry-pi for our local Junior school and am
starting to learn Python so I can show the year five and year six kids
how to write simple games.

Here's what you need - he starts simple and winds up with some nice games:

http://www.amazon.com/Python-Programming-Absolute-Beginner-Edition/dp/1435455002/ref=sr_1_6?ie=UTF8qid=1333131438sr=8-6




-- 
Frank L. Cranky Frankie Palmeri
Risible Riding Raconteur  Writer
“The problem with quotes on the Internet is that
it is often difficult to verify their authenticity.”
- Abraham Lincoln
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] roman to arabic

2012-02-27 Thread Cranky Frankie
Walter Prins wpr...@gmail.com wrote:

A quote worth mentioning here is:  If you need more than 3 levels
of indentation, you're screwed
anyway, and should fix your program. --  Linus Torvalds

I've always wondered about this quote. I'm thinking it means you might
want to have functions or subroutines, depending on the language, to
do big chunks of logic, so the main control flow is clean and easy to
read, like structured programming in COBOL. Still, every language
offers almost unlimted indentation, so it's up to the programmer to
not use it?







Frank L. Cranky Frankie Palmeri
Risible Riding Raconteur  Writer
“How you do anything is how you do everything.”
- from Alabama Crimson Tide training room
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] specific recommendation for a Python book, to move

2012-02-15 Thread Cranky Frankie
The book I recommend is Python Programming, Third Edition, for the
Absolute Beginner, by Michael Dawson. It's Python 3 based. You go from
knowing nothing to writing video games. I think it's great.

-- 
Frank L. Cranky Frankie Palmeri
Risible Riding Raconteur  Writer
“How you do anything is how you do everything.”
- from Alabama Crimson Tide training room
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] possibly a version error

2011-12-22 Thread Cranky Frankie
On the bottom of this web page:

http://developer.yahoo.com/python/python-xml.html

is a program that reads an RSS feed for the weather and then parses
the XML to show weather data by a zip code you input. I'm trying to
run this under Python 3.2 and get this error:

Traceback (most recent call last):
  File D:\MyDocs\Python\Element Tree for XML\weather.py, line 27, in module
pprint(weather_for_zip(12303))
  File D:\MyDocs\Python\Element Tree for XML\weather.py, line 10, in
weather_for_zip
dom = minidom.parse(urllib.urlopen(url))
AttributeError: 'module' object has no attribute 'urlopen'

I'm wondering if this is because this is Python 2.x code? Can someone
who has 2.x try to run this and let me know if that's the problem? Is
there a way to get this to work in Python 3.2?



-- 
Frank L. Cranky Frankie Palmeri
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] possibly a version error

2011-12-22 Thread Cranky Frankie
It says to use import urllib2 but I get this error:

Traceback (most recent call last):
  File D:\MyDocs\Python\Element Tree for XML\weather.py, line 2, in module
import urllib2
ImportError: No module named urllib2

On Thu, Dec 22, 2011 at 11:41 AM, Hugo Arts hugo.yo...@gmail.com wrote:
 On Thu, Dec 22, 2011 at 5:33 PM, Cranky Frankie
 cranky.fran...@gmail.com wrote:
 On the bottom of this web page:

 http://developer.yahoo.com/python/python-xml.html

 is a program that reads an RSS feed for the weather and then parses
 the XML to show weather data by a zip code you input. I'm trying to
 run this under Python 3.2 and get this error:

 Traceback (most recent call last):
  File D:\MyDocs\Python\Element Tree for XML\weather.py, line 27, in 
 module
    pprint(weather_for_zip(12303))
  File D:\MyDocs\Python\Element Tree for XML\weather.py, line 10, in
 weather_for_zip
    dom = minidom.parse(urllib.urlopen(url))
 AttributeError: 'module' object has no attribute 'urlopen'

 I'm wondering if this is because this is Python 2.x code? Can someone
 who has 2.x try to run this and let me know if that's the problem? Is
 there a way to get this to work in Python 3.2?


 I usually find it helpful to check the documentation before doing
 anything else when I encounter errors like this in code found online.
 Right here:

 http://docs.python.org/library/urllib.html

 At the top of the page you should find the information you need
 (you're right on the money, basically).

 HTH,
 Hugo



-- 
Frank L. Cranky Frankie Palmeri
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] possibly a version error

2011-12-22 Thread Cranky Frankie
I got it to work:

Use this for the import - import urllib.request

the use this: dom = minidom.parse(urllib.request.urlopen(url))

Here's the code that works in 3.2:

from pprint import pprint
import urllib.request
from xml.dom import minidom

WEATHER_URL = 'http://xml.weather.yahoo.com/forecastrss?p=%s'
WEATHER_NS = 'http://xml.weather.yahoo.com/ns/rss/1.0'

def weather_for_zip(zip_code):
url = WEATHER_URL % zip_code
dom = minidom.parse(urllib.request.urlopen(url))
forecasts = []
for node in dom.getElementsByTagNameNS(WEATHER_NS, 'forecast'):
forecasts.append({
'date': node.getAttribute('date'),
'low': node.getAttribute('low'),
'high': node.getAttribute('high'),
'condition': node.getAttribute('text')
})
ycondition = dom.getElementsByTagNameNS(WEATHER_NS, 'condition')[0]
return {
'current_condition': ycondition.getAttribute('text'),
'current_temp': ycondition.getAttribute('temp'),
'forecasts': forecasts,
'title': dom.getElementsByTagName('title')[0].firstChild.data
}

pprint(weather_for_zip(12303))

-- 
Frank L. Cranky Frankie Palmeri
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] pygame blinking text

2011-12-12 Thread Cranky Frankie
My Python presentation is just about complete. As a nice ending I want
to do a pygame program that displays the group's .jpg, with the words
Thank You! blinking, say on for a second and off for a second.
Unfortunatley, I can't get the works to blink, but I can get them to
appear for a short time:

from livewires import games, color

games.init(screen_width = 640, screen_height = 480, fps = 50)

bg_image = games.load_image(AEMUG640x480.JPG, transparent = False)
games.screen.background = bg_image


ty_message = games.Message(value = Thank You!,
 size = 100,
 color = color.red,
 x = games.screen.width/2,
 y = games.screen.height/2,
 lifetime = 100,
 after_death = 0)

games.screen.add(ty_message)

games.screen.mainloop()



I tried putting the ty_message block in a WHILE TRUE loop, and that
didn't work. Then I tried the same with the
games.screen.add(ty_message) line and that didn't work either. I think
what might work is if I can find a way to delete the ty_message and
readd it, over and over in a loop with a delay, bu:

games.screen.delete(ty_message)

doesn't work - delete is not a valid method.

Is there any way to get blinking text with pygame? This is not a deal
breaker, but I thought the blinking text would be neat.

-- 
Frank L. Cranky Frankie Palmeri
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] best book for OOP

2011-12-11 Thread Cranky Frankie
surya k sur...@live.com wrote:

I'm reading Core Python Programming - Chun..?
Currently, I am studying OOP in it.. and I feel there is something I
am missing in that while studying. Actually I am from C.. so, no idea
of OOP.
Could you tell me the best, simple, easy to understand book!!

This book: 
http://www.amazon.com/Python-Programming-Absolute-Beginner-3rd/dp/1435455002/ref=sr_1_1?ie=UTF8qid=1323630959sr=8-1

has a really gentle, easy to follow OOP section, and he includes lots
of programs where you can see how the classes and methods make sense
(simple video games). I really found this book helpful. I just
finished reading it for the second time!


-- 
Frank L. Cranky Frankie Palmeri
Risible Riding Raconteur  Writer
“How you do anything is how you do everything.”
- from Alabama Crimson Tide training room
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] What style do you call Python programming?

2011-12-09 Thread Cranky Frankie
I'm looking for a term to call the kind of Python programming that
Python is, in other words, programming with no branching, no GOTOs, no
statement labels and no line numbers. I'm tempted to call it
Structured Progamming, but we had that in COBOL, and this is not like
COBOL.

It seems to be with Python the whole thing is creating functions and
then using loops, with an occasional BREAK or CONTINUE, to control
program flow. I know it's Structured, but it's not like COBOL
structured, if you know what I mean.

I hope this is clear enough.

-- 
Frank L. Cranky Frankie Palmeri
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] What style do you call Python programming?

2011-12-09 Thread Cranky Frankie
I appreciate all the comments in this thread so far, but what I'm
really looking for is what to call the style of programming where you
have no direct branching via line numbers, statement names, and gotos.
I'm finding that lacking these things that I've been familiar with in
other languages is good, in that it forces you to really think through
the best way to organize the logic.

It seems to me that this is such a big departure from traditional
procedural styled programming there ought to be a name for it, other
than structured programming, since you can code that way even with
line numbers, etc.

I'd also be interested in reading the Python history file.


-- 
Frank L. Cranky Frankie Palmeri
Risible Riding Raconteur  Writer
“How you do anything is how you do everything.”
- from Alabama Crimson Tide training room
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] What style do you call Python programming?

2011-12-09 Thread Cranky Frankie
From: Dave Angel d...@davea.name

I don't understand your reluctance to use the name that has applied
for at least 35 years. Just because some of those non-structured
languages have survived, doesn't take anything away from the term
procedural.  You can write object oriented code in hex if you really
want, it doesn't make raw machine language object oriented.

Probably because I work in a shop that still heavily uses older
languages like COBOL and CULPRIT where you still deal with labels,
branching, goto, etc. The fact that it is possible to code
structured that way AND the Python way amazes me.




-- 
Frank L. Cranky Frankie Palmeri
Risible Riding Raconteur  Writer
“How you do anything is how you do everything.”
- from Alabama Crimson Tide training room
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] tkinter message button questions

2011-11-30 Thread Cranky Frankie
Peter Otten __pete...@web.de wrote:
To: tutor@python.org
Subject: Re: [Tutor] tkinter message  button questions
Message-ID: jb38s2$9gg$1...@dough.gmane.org
Content-Type: text/plain; charset=ISO-8859-1

I've no experience with the place layout manager, but the following seems to
be what you want:

root = Tk()
win = Frame(root)
win.place(relheight=1, relwidth=1)

label_widget = Label(win, text=Welcome to Quote of the Day)
label_widget.pack(side=TOP, expand=YES, fill=BOTH)

msg_widget = Message(
   win, anchor=NW, justify=LEFT, width=1000, bd=2,
   bg=white, relief=SOLID, text=choose_quote())
msg_widget.pack(fill=BOTH)

next_button = Button(win, text=Next Quote, command=display_quote)
next_button.pack(side=LEFT)

quit_button = Button(win, text=QUIT, fg=red, command=quit)
quit_button.pack(side=RIGHT)

root.geometry(400x100)
root.mainloop()



Peter thanks again. The msg_widget is still resizing vertically
depending on the lenght of the quote, but at least now the horizontal
sizing is staying the same. Ideally the msg_widget would be the *same
size*, no matter what the quote length is, but since this program is
really just a learning exercise and to show database adminstrators a
simple Python GUI application I can live with it.

The syntax you used, like root.geometry(400x100), I have not seen
before, and I've done a lot of searching. Again, much of the tkinter
stuff I see seems to be based on Python 2.6. If there is a definitive
book or reference on using tkinter in Python 3.x I'd really like to
know about it.

Thanks again Peter, Wayne, and everyone else on the tutor list, you
guys are great.

-- 
Frank L. Cranky Frankie Palmeri
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] problem with msg widget button

2011-11-29 Thread Cranky Frankie
OK, I've stripped out all the comments and put it here:

http://www.pastie.org/2938751


This works but the button doesn't put the next comment in the window.
The only way I could figure to get the next comment in the window is
to add the msg_widget line to the disp_quote function, but when I do
that, it puts out *another* msg-widget! That is not what I want at
all. I just want the next quote button to put the next quote in the
box.

-- 
Frank L. Cranky Frankie Palmeri
Risible Riding Raconteur  Writer
“How you do anything is how you do everything.”
- from Alabama Crimson Tide training room
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] problem with msg widget button

2011-11-29 Thread Cranky Frankie
Peter Otten __pete...@web.de wrote:

snip

Hm, your description doesn't match with the code you posted which only
creates one Message.

What I meant to say was, yes, I only want one message object, but I
want that same object to be updated each time the next quote button is
pressed.

Also you still initialize the command parameter with the function result

Button(..., command=f()) # wrong

instead of the function itself

Button(..., command=f) # correct.

snip again

OK, I think I tried it several ways and couldn't get any of them to
work, but I tried your version and the button now works! My only
question is this line, which is what I was missing:

def display_quote():
   msg_widget[text] = choose_quote()

Isn't msg_widget an object, like everything else in Python. If so, why is it not

def display_quote():
   msg_widget.text = choose_quote()

That is one of the things I tried. I don't understand why the [test]
pair works above.

Now my only problem is the msg_widget box resizing. I'm using the
.pack frame manager like the examples I've been reading say. I know
there's a grid manager as well. I'll have to try that. All I want is
the msg_widget to display the same size each time, no matter what size
string is in it.

Thanks Peter!








-- 
Frank L. Cranky Frankie Palmeri
Risible Riding Raconteur  Writer
“How you do anything is how you do everything.”
- from Alabama Crimson Tide training room
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] tkinter message button questions

2011-11-29 Thread Cranky Frankie
I changed the quote program to use the grid manager:

http://www.pastie.org/2939778

Still, the message widget box keeps resizing based on the length of
the quote. I'm thinking it has to be something to do with the message
widget itself, not the pack vs. grid manager.

When I research this I find that a lot of the information on the
message widget does not work in Python 3.1 - for example, the height
parameter does not work in 3.1.

-- 
Frank L. Cranky Frankie Palmeri
Risible Riding Raconteur  Writer
“How you do anything is how you do everything.”
- from Alabama Crimson Tide training room
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] tkinter message button questions

2011-11-28 Thread Cranky Frankie
I have a program I'm testing in Python 3.1 in Windows XP using tkinker
to dispay random quotes. It works except for two things.

1) The program displays a random quote of the day when it's invoked,
but I want to have a Next quote button so that additional random
quotes can be displayed. Here are the parts of the program were I get
the first quote:


def get_random_quote():# create a function
to get a random quote from quote_dict

rq = (random.randrange(len(quote_dict))+1)  # pick a
random entry from the quote dictionary
return rq


def output_quote():
rand_quote = get_random_quote() # get a random quote
quote = quote_dict[rand_quote][1] # put the quote in a
string varible
author = quote_dict[rand_quote][0]# put the author in a
string variable
om = (quote+\n\n+author)  # format the output
string variable
return om


out_message = output_quote()

msg_widget = Message(win, anchor = NW, justify = LEFT, width = 1000,
bd= 2, bg = white,
 relief = SOLID, text=out_message)




Here is my button the get the next quote:



next_button = Button(win, text=Next Quote, command=output_quote()) #
create button  widget
next_button.pack(side=LEFT)



Even though I'm calling the same function, output_quote(), the screen
is not getting refreshed. There is no error, just the new quote is not
showing up in the message box. How do I refresh the message box?

2) The message widget seems to be sizing based on the size of the text
you present to it. For a small quote it's small, for a longer quote it
streches out wide and then adds more lines. I'd like to present a
consistent sized message box when the program is run, no matter if the
text is small or large, but I can't figure out how to do that. In
other words, I'd like the message widget in question 1 above to
display as a box capable of storing, say, 1,000 characters, even if I
only give it 100, so the program looks the same every time it's
invoked. Is there a way to make a default sized message widget?

-- 
Frank L. Cranky Frankie Palmeri
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] sensing EOF in Python 3.1

2011-11-25 Thread Cranky Frankie
From: Steven D'Aprano st...@pearwood.info wrote:

Pickle does standard file I/O in the same way that opening a JPEG in
an image view does standard file I/O: both programs read data from a
file the standard, ordinary way, but expect data of a certain format.
If you provide it too little data, you will get an EOF error. If you
provide too much data, or messed up data, then you will some other
error. But the file I/O is exactly the same. It's just that pickle, or
your image viewer, handle it for you.

Right, thanks.

Pickling won't tell you anything about Python data structures.
Pickling takes Python data structures, bashes them with a hammer until
they stop wiggling, then runs them through a serialiser turning them
into a stream of text or binary codes.

I want to include this info in my presentation because it shows how
data structures can be externalized.

Pickles tell you only about pickles. You won't learn anything about
(say) dicts by looking at a pickled dict except the bare fact that
dicts can be pickled.

Still though, that is important.

import pickle                            # import the pickle module

Really? Wow! I thought import pickle meant sort the database!!! *wink*

 Sarcasm aside, what else could import pickle mean other than import
 the pickle module?

I was trying to put a comment on every line because the audience who
will be looking at this will have never seen any Python before.

The comment adds absolutely nothing to the code. At best it is
superfluous. At worst it is harmful, because code and comments have a
regrettable tendency to get out of sync.

I know what you mean. The commens could be meaningful at first, then
the code gets edited over the years and the comments don't get
updated. I've seen that many times.

Every comment should carry its weight. If the code is particularly
convoluted, you might write comments explaining *how* you do
something, but generally the code speaks for itself regarding the how,
so comments should explain *why* you do something. If a comment
doesn't tell you something that the code doesn't, that you need to
know (or at least should know). Otherwise it should be throw out into
the back alley for the stray cats to eat.

Again, in this specific instance, this simple example code is intended
to be looked at not by Python programmers, or even programmers, but
rather by database professionals who I am attempting to expose Python
to for the first time.

pickle_file = open(d:/Work/pickle_file, rb) # open the pickled file
read_list = pickle.load(pickle_file)            # read the first pickled row

And this is what I'm talking about. It does NOT read the first pickled
row. Pickles don't have rows. In this case, you are reading the first
and only pickled object, which happens to be a dict.

You are of course, correct, thanks. I'll be fixing that.


Steven thanks for your comments about comments, I'll be doing them
over for sure.


-- 
Frank L. Cranky Frankie Palmeri
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Python 3 dictionary questions

2011-11-23 Thread Cranky Frankie
In playing around with Pyton 3 dictionaries I've come up with 2 questions

1) How are duplicate keys handled? For example:

Qb_Dict = {Montana: [Joe, Montana, 415-123-4567,
joe.mont...@gmail.com,Candlestick Park],
Tarkington: [Fran, 651-321-7657, frank.tarking...@gmail.com,
Metropolitan Stadidum],
Namath: [Joe, 212-222-, joe.nam...@gmail.com, Shea Stadium],
Elway: [John, 303-9876-333, john.el...@gmai.com, Mile High Stadium],
Elway: [Ed, 303-9876-333, john.el...@gmai.com, Mile High
Stadium],
Manning: [Archie,504-888-1234, archie.mann...@gmail.com,
Louisiana Superdome],
Staubach: [Roger,214-765-8989, roger.staub...@gmail.com,
Cowboy Stadium]}

print(Qb_Dict[Elway],\n)# print a dictionary entry

In the above the wrong Elway entry, the second one, where the first
name is Ed, is getting printed. I just added that second Elway row to
see how it would handle duplicates and the results are interesting, to
say the least.

2) Is there a way to print out the actual value of the key, like
Montana would be 0, Tarkington would be 1, etc?

-- 
Frank L. Cranky Frankie Palmeri
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] sensing EOF in Python 3.1

2011-11-23 Thread Cranky Frankie
I'm reading in a pickled file. The program works but I'm having
trouble sensing end of file. Here's the program:

#
# pickle_in.py
# program to read in a pickled file
#
# Frank L. Palmeri
#

import pickle   # import the pickle module
pickle_file = open(d:/Work/pickle_file, rb) # open the pickled input file

read_file = pickle.load(pickle_file)# read the first input record

new_list=[] # create a new empty list

while pickle_file:  # loop until end of file
for i in range(0, 4):   # iterate for each field
new_list.append(read_file[i])   # append each field to
the new list
i = i + 1   # increment loop counter
print(new_list) # print the input
record from the new list
new_list=[] # initialize the new
list for the next record
read_file = pickle.load(pickle_file)# read the next record
in the input file


here's the error:

Traceback (most recent call last):
  File D:\MyDocs\Python\pickle_in.py, line 21, in module
read_file = pickle.load(pickle_file)# read the next record
in the input file
  File D:\Python31\lib\pickle.py, line 1365, in load
encoding=encoding, errors=errors).load()
EOFError







-- 
Frank L. Cranky Frankie Palmeri
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] sensing EOF in Python 3.1

2011-11-23 Thread Cranky Frankie
From: Peter Otten __pete...@web.de wrote:
snip
How did you write the data into the pickle file? The normal approach is to
write all your data in one step, e. g. (all code snippets untested)

Thanks Peter, that was it. I was treating pickle like standard file
i/o when it's not that at all.

The reason why I'm pickling is I'm trying to include information on
Python data structures in the presentaton I'm preparing.

Here are the two programs that now work correctly together:

import pickle
pickle_file = open(d:/Work/pickle_file, wb)

Qb_dict = {Montana: [Joe, Montana, 415-123-4567,
joe.mont...@gmail.com,Candlestick Park],
Tarkington: [Fran, 651-321-7657, frank.tarking...@gmail.com,
Metropolitan Stadidum],
Namath: [Joe, 212-222-, joe.nam...@gmail.com, Shea Stadium],
Elway: [John, 303-9876-333, john.el...@gmai.com, Mile High Stadium],
Elway: [Ed, 303-9876-333, john.el...@gmai.com, Mile High
Stadium],
Manning: [Archie,504-888-1234, archie.mann...@gmail.com,
Louisiana Superdome],
Staubach: [Roger,214-765-8989, roger.staub...@gmail.com,
Cowboy Stadium]}

pickle.dump(Qb_dict, pickle_file)

pickle_file.close()



#
# pickle_in.py
# program to read in a pickled file
#
# Frank L. Palmeri
#

import pickle   # import the pickle
module
pickle_file = open(d:/Work/pickle_file, rb) # open the pickled file

read_list = pickle.load(pickle_file)# read the first pickled row

print(read_list)# print the input row from
the pickled file

pickle_file.close() # close the pickled file




-- 
Frank L. Cranky Frankie Palmeri
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] basic class loading question

2011-11-22 Thread Cranky Frankie
I have a basic question about how to load a class. If I have this class:

class QB:
def __init__(self, first_name='', last_name='', phone='',
email='', stadium=''):
self.first_name = first_name
self.last_name = last_name
self.phone = phone
self.email = email
self.stadium = stadium

and this data:

QB_list = [[Joe, Montana, 415-123-4567,
joe.mont...@gmail.com,Candlestick Park],
[Fran, Tarkington,651-321-7657,
frank.tarking...@gmail.com, Metropolitan Stadidum],
[Joe, Namath, 212-222-, joe.nam...@gmail.com, Shea Stadium],
[John, Elway, 303-9876-333, john.el...@gmai.com, Mile
High Stadium],
[Archie, Manning, 504-888-1234, archie.mann...@gmail.com,
Louisiana Superdome],
[Roger, Staubach, 214-765-8989, roger.staub...@gmail.com,
Cowboy Stadium]]

What is the best way to load it? I'm thinking there should be an
append method, but I'm having trouble getting it to work.


-- 
Frank L. Cranky Frankie Palmeri
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] basic class loading question

2011-11-22 Thread Cranky Frankie
OK, but this is still not working:

class Qb:
def __init__(self, first_name='', last_name='', phone='',
email='', stadium=''):
self.first_name = first_name
self.last_name = last_name
self.phone = phone
self.email = email
self.stadium = stadium



Qb_list = [[Joe, Montana, 415-123-4567,
joe.mont...@gmail.com,Candlestick Park],
[Fran, Tarkington,651-321-7657,
frank.tarking...@gmail.com, Metropolitan Stadidum],
[Joe, Namath, 212-222-, joe.nam...@gmail.com, Shea Stadium],
[John, Elway, 303-9876-333, john.el...@gmai.com, Mile
High Stadium],
[Archie, Manning, 504-888-1234, archie.mann...@gmail.com,
Louisiana Superdome],
[Roger, Staubach, 214-765-8989, roger.staub...@gmail.com,
Cowboy Stadium]]



len_Qb_list = len(Qb_list)

for i in range(0, len_Qb_list):
quarterbacks = Qb(*Qb_list[i])
i = i + 1

print(quarterbacks.last_name(2))




-- 
Frank L. Cranky Frankie Palmeri
Risible Riding Raconteur  Writer
“How you do anything is how you do everything.”
- from Alabama Crimson Tide training room
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] basic class loading question

2011-11-22 Thread Cranky Frankie
On Tue, Nov 22, 2011 at 11:26 AM, Dave Angel d...@davea.name wrote:
snip
 quarterbacks = []
 for 
     quarterbacks.append(       )


 Now that you really have a list, then you can print a particular one with:

 print (quarterbacks[2].last_name)

Dave I'm sorry but I just don't get this. I have virtually no
experience  with classes.

What seems like it shoud work is this:

###
len_Qb_list = len(Qb_list)

for i in range(0, len_Qb_list):
quarterbacks = Qb(*Qb_list[i])
i = i + 1

print (quarterbacks[2].last_name)


In other words, define an instance of the Qb class called
quarterbacks, and then load or instantiate instances of the class
using the 6 sets of values from Qb_list.

My error message is:

Traceback (most recent call last):
  File D:/Python31/q, line 27, in module
print (quarterbacks[2].last_name)
TypeError: 'Qb' object does not support indexing






-- 
Frank L. Cranky Frankie Palmeri
Risible Riding Raconteur  Writer
“How you do anything is how you do everything.”
- from Alabama Crimson Tide training room
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] basic class loading question

2011-11-22 Thread Cranky Frankie
Dave thank you for your patience. It really is appreciated.

In the interest of closing this thread I'm posting the final version
that works, and achieves the goal of showing how to represent data
both in a list and in an object:

#
# Example to show the difference between list data and object data
#
class Qb:
def __init__(self, first_name='', last_name='', phone='',
email='', stadium=''):
self.first_name = first_name
self.last_name = last_name
self.phone = phone
self.email = email
self.stadium = stadium

Qb_list = [[Joe, Montana, 415-123-4567,
joe.mont...@gmail.com,Candlestick Park],
[Fran, Tarkington,651-321-7657,
frank.tarking...@gmail.com, Metropolitan Stadidum],
[Joe, Namath, 212-222-, joe.nam...@gmail.com, Shea Stadium],
[John, Elway, 303-9876-333, john.el...@gmai.com, Mile
High Stadium],
[Archie, Manning, 504-888-1234, archie.mann...@gmail.com,
Louisiana Superdome],
[Roger, Staubach, 214-765-8989, roger.staub...@gmail.com,
Cowboy Stadium]]

quarterbacks = []   # Create an empty object list

len_Qb_list = len(Qb_list)  # Get the lenght of the list of
lists which is the
#number of rows in the input data

for i in range(0, len_Qb_list): # Iterate for the number of rows

nq = Qb(*Qb_list[i])# Create an instance of class Qb called nq
#and populate each field
quarterbacks.append(nq) # Append an instance of object
nq into object list quarterbacks
i = i + 1   # Iterate for each row in Qb_list

print (quarterbacks[3].phone)   # Print an item from the object
list quarterbacks
print (Qb_list[3][2])   # Print the same object from the
original list of lists




-- 
Frank L. Cranky Frankie Palmeri
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] command=F.quit not closing the sample TK program in Vista

2011-11-19 Thread Cranky Frankie
I'm playing around with the Tkinter examples on:

http://www.alan-g.me.uk/l2p/index.htm

and, at least on my Vista laptop, the sample window will not close
when you click the Quit button, which is:

bQuit = Button(fButtons, text=Quit, command=F.quit)

Anyone else have this problem with the sample programs? Python just
hangs, and Vista says it's not responding.

-- 
Frank L. Cranky Frankie Palmeri
Risible Riding Raconteur  Writer
“How you do anything is how you do everything.”
- from Alabama Crimson Tide training room
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] command=F.quit not closing the sample TK program in Vista

2011-11-19 Thread Cranky Frankie
More info:

I added C:\Python32 to the path environment variable in Vista,
rebooted, and tried the test programs at the command prompt, and it
says it can't find the program. If I type Python at the command prompt
it opens the Python intrepreter, but it will not run the test.py
program.

Now I'm really confused:)

-- 
Frank L. Cranky Frankie Palmeri
Risible Riding Raconteur  Writer
“How you do anything is how you do everything.”
- from Alabama Crimson Tide training room
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Thank you!

2011-11-16 Thread Cranky Frankie
Thank you to all for your help on my SQL DDL parsing script, and thank
you Alan for having this wonderful list. I got the program to work and
verified the DDL is being parsed correctly.

I've been working as a database administrator for many years, but
before that I programmed on the mainframe. I'm used to COBOL, SQL,
DB2, and latley XML. I've done some Unix scripting and VB script,
taught myself some basic C and C++, with some odd Visual Basic along
the way, but Python is enitirely new to me. That's why I got thrown
off with the output not lining up in Notepad - I've never written
anything before that could be displayed in a mode that used
proportional fonts.

The things I like about Python:
- the forced indentation makes for really readable code
- it's free!
- it can be used on any platform
- it can be used for scripting or for builing a stand alone program
- it can work in any programming style (O-O, sturctured, etc.)

I'm going to be doing a presentation on Python programming for
database administrators. This script will help a lot to explain some
of the basic concepts.

Thanks again very much for your help.

Python rocks!

-- 
Frank L. Cranky Frankie Palmeri
Risible Riding Raconteur  Writer
“How you do anything is how you do everything.”
- from Alabama Crimson Tide training room
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] interesting behaviour with postional output

2011-11-14 Thread Cranky Frankie
I'm working on writing out postional output. When I use this statement:

print('%-40s%s' % (element_list[0], element_list[1]))   

I get nice, lined up columns on the screen. When I write to a file like this:

new_line = ('%-40s%s%s' % (element_list[0], element_list[1],'\n'))
file_out.write(new_line)

a very funny thing happens. When I open the file in Notepad, the
columns are not lined up, however when I switch the font to Courier,
they * are* lined up. So what's happening is the output statement is
working correctly - the second column starts in the 41st postion - but
you have to use a non-proportional font to see it.

I was hoping to not have the font be an issue.

Very interesting.

-- 
Frank L. Cranky Frankie Palmeri, Guilderland, NY, USA
             Risible Riding Raconteur  Writer
Don't sweat the petty things, and don't pet the sweaty things.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] positional output

2011-11-11 Thread Cranky Frankie
Thank you for your help on this. Now for the rest of the story.

I'm trying to build a script to parse IBM AIX DB2 DDL to line up the
data types (it drives me crazy when the column data types are not
lined up). For example, typical create table DDL might be hundreds of
lines long but will look like this:

-- 
-- table create DDL
--
CREATE TABLE FRANK.TEST (
COLUMN1 DECIMAL(8),
COLUMN2   CHAR(20),
COLUMN3TIMESTAMP,
COLUMN4 INTEGER,
COLUMN5  DATE NOT NULL WITH DEFAULT,
-- repeat for hundreds of columns
);
COMMENT ON TABLE FRANK.TEST IS 'TEST TABLE';

This is just a small sample, there are many other possible lines, but
I'm only concerned about the column lines like COLUMN1 through COLUMN5
above.

I have a script on Windows that reads in the DDL file and writes out
each line to a new file. What I'm doing is using the split() function
to test for the presence of any DB2 standard data type, like CHAR,
INTEGER, SMALINT, etc. If I find one I want to use positional output
to make each like look like:

COLUMN1DECIMAL(8),
COLUMN2CHAR(20),
COLUMN3TIMESTAMP,
COLUMN4 INTEGER,
COLUMN5 DATE NOT NULL WITH DEFAULT,

where all the COLUMNs would be in column 1 of the output file, the
data types would be in column 40, and the comma would be next.

The problem is handling lines that have NOT NULL WITH DEFAULT at the
end. The thing is there could be other valid DDL in that position, and
there may or may not be a comma after the data type. What I want to do
is just take anything after the datatype, which would be element(1) in
the split() output, and just write it out. I thought I could use
rsplit() to do this, but you can't put the output of split() in
rsplit() - I tried.

I need to do something like, after verifying that element(1) is a
valid DB2 datatype, just take everything else on the line after it,
which may be a single comma, or NOT NULL WITH DEFAULT, or something
else, and place it on the output line to be written out.

So, to reiterate: I'm trying to build a script to line up the data
types in a create table DDL file. Splitting each line into individual
space separated elements, then checking for a valid data type, the
rebuilding the line positionally seems to be the way to go. If there's
an easyier way to do it I'm all ears.

I don't have my script available at the moment but I could send it if
it would be helpful.



-- 
Frank L. Cranky Frankie Palmeri, Guilderland, NY, USA
             Risible Riding Raconteur  Writer
Don't sweat the petty things, and don't pet the sweaty things.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] positional output

2011-11-10 Thread Cranky Frankie
What is the easiest way in Python 3.x to write output positionally?
For example I have one literal I want in column 1, the next one in
column 40, the third one in column 50. I've tried usings tabs and I'm
not getting what I want. Is it something to do with C style printf
formatting? An example would be greatly appreciated.

-- 
Frank L. Cranky Frankie Palmeri, Guilderland, NY, USA
             Risible Riding Raconteur  Writer
Don't sweat the petty things, and don't pet the sweaty things.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] string split function - how to tell how many splits

2011-11-08 Thread Cranky Frankie
How do you tell how many splits the string split funtion returns? For example:

field = 'The Good Wife ;'   # a string separated by spaces
new_list = field.split(' ') # create a list of space delimited elements
print (new_list[0]) # print the first one
print (new_list[1]) # print the second one
print (new_list[2]) # print the third one
print (new_list[3]) # print the fourth one
print (new_list[4]) # print the fifth one


The last line above causes an error. I plan on reading in a file where
I don't know what the number of splits will be. How can I find out
before trying to access an out of range index?



-- 
Frank L. Cranky Frankie Palmeri, Guilderland, NY, USA
             Risible Riding Raconteur  Writer
Don't sweat the petty things, and don't pet the sweaty things.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Quote of the Day version 1.0

2011-08-31 Thread Cranky Frankie
I made some headway on the quote of the day program. I just tried to
do it simple using two assumptions:

- long quotes are going to print funny until I figure out the string
splitting stuff
- hard coding the quotes and authors in the program is simple, and I
can use a spreadsheet to generate the strings when I put in the rest
of the quotes (I have a lot of them).

This code works. Now I just have to figure out:

- how to get Ubuntu to run it at startup
- how to associate .py files in Ubuntu to IDLE

Thanks for all who commented, I really appreciate it. Pyhton is fun!





# Quote_a_day_V1.py
#
# This program displays a random quotation
#
# Frank L. Palmeri August 31, 2011

import random

print(\n\tHere is today's quote of the day:\n)

author = (
Kahlil Gibran,
Henrik Ibsen,
Dwight Eisenhower,
Will Rogers,
Will Rogers,
Jean de LaFontaine,
Eleanor Hibbert,
Baruch Spinoza,
Albert Camus,
Thomas a Kempi
)

quotation = (
A candle loses nothing of its light when lighting another.,
The strongest man in the world is he who stands most alone.,
Leadership consists of nothing but taking responsibility for
everything that goes wrong and giving your subordinates credit for
everything that goes well.,
Even if you're on the right track, you'll get run over if you
just sit there.,
I belong to no organized party. I am a Democrat.,
Patience and time do more than strength or passion.,
Never regret. If it's good, it's wonderful. If it's bad, it's experience.,
I have made a ceaseless effort not to ridicule, not to bewail,
not to scorn human actions, but to understand them.,
In the depth of winter I finally learned there was in me an
invincible summer.,
Who has a harder fight than he who is striving to overcome himself.
)

numAuthors = len(author)

printAuthor = random.randrange(numAuthors)

print(quotation[printAuthor])

print(by , author[printAuthor])

input(\nPress the enter key to exit.)




-- 
Frank L. Cranky Frankie Palmeri
Risible Riding Raconteur  Writer

 . . . and the extended forecast,
until you come back to me, baby,
is high tonight, low tomorrow,
and precipitation is expected.
- Tom Waits, Emotional Weather Report
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] fortune-like utility

2011-08-30 Thread Cranky Frankie
On Tue, Aug 30, 2011 at 5:23 AM, Martin A. Brown mar...@linux-ip.net wrote:

 Good morning and welcome to the list,

  : Just planning it out in my head so far, like pseudocode. I hope
  : to get started soon. I'm just looking to have a little dialog box
  : come up, display a random quote of the day, and then hit enter
  : and it's gone. Should be a nice, simple way to get started with
  : Python.

 N.B. Most of the questions and answers here are about the python 2.x
 series, so just note that there are some minor differences with
 python 3.x.

 I would suggest starting with the data/format.

snip

Thanks Martin for the excellent suggestions.

I read in the book that you have to use escape like /n when you want
to span lines. I don't want to have to do that to each of my quotes,
many of which span several lines, so I will look into your
suggestions.

Thanks again.

-- 
Frank L. Cranky Frankie Palmeri
Risible Riding Raconteur  Writer

 . . . and the extended forecast,
until you come back to me, baby,
is high tonight, low tomorrow,
and precipitation is expected.
- Tom Waits, Emotional Weather Report
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Intro

2011-08-29 Thread Cranky Frankie
Hi Python tutor listers, as an intro I'll repost what I sent to my
Linux groups, since one of their members turned me on to you:



Before Borders imploded I'd joined their club so they'd send me 50%
coupons now and then. One afternoon last year I was in the store
browsing the computer books and this Python book caught my eye. I knew
very little about Python but I knew it had a good rep and I love Monty
Python so I bought the book then put in on the shelf. Only recently
did I get around to reading it and I only wish I'd done so sooner,
it's that good.

The book is Python Programming for the Absolute Beginner, Third
Edition by Michael Dawson, Course Technology, ISBN-13
978-1-4354-5500-9, published in 2010. He presumes you know nothing
about programming and then uses simple computer games to demonstrate
the power of Python. He starts with those text based games many of us
used to play, finishing off with GUI based games with music and
animation, and all the code is downloadable from the publisher's web
site. That's pretty good for a beginner book, I'd say.

Python itself is a beautiful language. Because it uses indenting for
constructing programming blocks, not semi-colons or braces, the code
is inherently clean and crisp. More about Python:

- it's easy to learn yet very powerful
- very concise and tight syntax
- comes with it's own IDE
- no compiling yet can create stand alone apps
- can be used for scripting or full blown applications
- runs on all the major OSs
- no variably type declarations, it can infer them
- lots of modules (pre-coded specific code routines) available
- can get productive quickly
- can code in a procedural or object-oriented style

Here's the typical introductory Hello World program:

print(Hello World)

Doesn't get much simpler than that!

He even gets into GUI programming, event driven design, sprites, etc.
For a book for a supposed absolute beginner I think that's amazing,
because I can see someone getting this even if they really have no
coding background. That's how clearly it's written and how clean and
clear the example code is.

One more side benefit of this book: it contains the gentlest, easiest
to digest introduction to object-oriented programming I've ever seen,
and I read a lot of computer stuff. If you're an old-timer like me who
only studied procedural languages, this is about as easy an
introduction to the power and flexibility of O-O programming that you
will ever find.

What I've been wanting to do for a long time is write an app that,
when my computer starts, displays a window with a quote of the day.
With this book I now have several ways to take my huge collected
quotes file, import it into arrays in a Python program, apply a random
function, and display a random quote each time I log on. That kind of
app is a natural for Python, but don't kid yourself - he actually
writes a space invaders type game using some game modules - and this
in a beginner book! Amazing.


This is a great book about a great language.


-- 
Frank L. Cranky Frankie Palmeri
Risible Riding Raconteur  Writer

 . . . and the extended forecast,
until you come back to me, baby,
is high tonight, low tomorrow,
and precipitation is expected.
- Tom Waits, Emotional Weather Report
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Tutor Digest, Vol 90, Issue 97

2011-08-29 Thread Cranky Frankie
Lisi lisi.re...@gmail.com wrote:

Is it just me, or is this a blatant plug for a specific book, and is it
therefore Spam?

I hope it's just you, because it is not spam. As I said, I read a
*lot* of computer books (I'm a database administrator) and this book
really stands out. It's so good I'm thinking of seeing if my wife, who
knows nothing about programming, would like to read it. I've never
felt that way about a computer book before, and since this is so
unusual in the computer book field, I thought I'd share it here.

For what it is worth, I hate all those games.

I'm not a gamer either, but this paradigm allowed the author to show
the great flexibility of Python. I think he made a wise choice. Using
games as a starting point should also make this book useful to
teachers of programming 101, because kids love games. Anything that
gets kids coding instead of just wasting time is good IMHO.


  Alan seems to use address books
(anyhow initially).  Now I can see the point in that.


I'm sorry you were offended by my posts. If others were as well let me
know and I'll unsubscribe immediately.


-- 
Frank L. Cranky Frankie Palmeri
Risible Riding Raconteur  Writer

 . . . and the extended forecast,
until you come back to me, baby,
is high tonight, low tomorrow,
and precipitation is expected.
- Tom Waits, Emotional Weather Report
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Intro

2011-08-29 Thread Cranky Frankie
I'm trying to decide what would be better:

- reading the huge quote file (hundreds of entries, two strings,
author and quotation) in each time the program starts

- loading the quotes into an array in the program

I'd like to be able to add new quotes easily, so that is a factor as well.

I'm satisfied to use a dialog box, I don't need a GUI at this point so
no tkinter (yet).

On Mon, Aug 29, 2011 at 1:29 PM, Brett Ritter swift...@swiftone.org wrote:
ou:

 Glad you're so happy with this book...did you have a question for this list?

 --
 Brett Ritter / SwiftOne
 swift...@swiftone.org




-- 
Frank L. Cranky Frankie Palmeri
Risible Riding Raconteur  Writer

 . . . and the extended forecast,
until you come back to me, baby,
is high tonight, low tomorrow,
and precipitation is expected.
- Tom Waits, Emotional Weather Report
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Tutor Digest, Vol 90, Issue 98

2011-08-29 Thread Cranky Frankie
Joel Goldstick joel.goldst...@gmail.com wrote:

What have you got so far?

Just planning it out in my head so far, like pseudocode. I hope to get
started soon. I'm just looking to have a little dialog box come up,
display a random quote of the day, and then hit enter and it's gone.
Should be a nice, simple way to get started with Python.


-- 
Frank L. Cranky Frankie Palmeri
Risible Riding Raconteur  Writer

 . . . and the extended forecast,
until you come back to me, baby,
is high tonight, low tomorrow,
and precipitation is expected.
- Tom Waits, Emotional Weather Report
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor