[Tutor] OOP

2009-04-15 Thread mbikinyi brat
Dear ALL, I am a python beginner and has never programmed and has been struggling to understand how to create objects or classes in python. Can anyone help with any concrete example. I have read most recommended textbooks but still have difficulties figuring what it is all about.   Thanks, Henry

Re: [Tutor] OOP

2009-04-15 Thread Alan Gauld
"mbikinyi brat" wrote I am a python beginner and has never programmed Welcome to the tutor list. and has been struggling to understand how to create objects or classes in python. Can anyone help with any concrete example. Most tutorials have examples of classes and objects. Certainly

[Tutor] calculate area of a circle

2009-04-15 Thread mbikinyi brat
Hi All, This is a code I have written to calculate the area of a circle. def area(radius):  temp=math.pi*radius**2  return temp   I now call it by entering area(12) at the prompt in IDLE. This is the error message I get. Can someone help please? Traceback (most recent call last):   File "", line

[Tutor] Looking for starter projects

2009-04-15 Thread Evert Edel
Hi all, This is my first post to this tutor list, so I hope you'll all get this message :). I've bought last year a book on python programming (Learning python from O'Reilly) to get started with python. I'm wanting to learn python for two purposes: learning some webdevving (with django?) and being

Re: [Tutor] calculate area of a circle

2009-04-15 Thread vishwajeet singh
you need import math On Wed, Apr 15, 2009 at 2:22 PM, mbikinyi brat wrote: > Hi All, > This is a code I have written to calculate the area of a circle. > *def area(radius): > temp=math.pi*radius**2 > return temp* > ** > *I* now call it by entering *area(12)* at the prompt in IDLE. This is the >

Re: [Tutor] colours in IDLE

2009-04-15 Thread Oxymoron
Hi, On Wed, Apr 15, 2009 at 7:29 PM, mbikinyi brat wrote: > Dear ALL, > When you type a code in IDLE-Python, they appear in different colours. > For instance: >  def factorial(n): >  if n==0: >   return 1 >  else: >   recurse=factorial(n-1) >   result=n*recurse >   return result > factorial in bl

Re: [Tutor] python books

2009-04-15 Thread Wayne Watson
It's unlikely you are going to find a pdf on Python that's suitable for beginners. Do you mean pdf or a digital book? There are Python books in digital form on the web. I'm not quite sure how it works, but I know of at least one public library has them. I think it works that if you have a libra

Re: [Tutor] colours in IDLE(How does the interpreter knows the meaning of factorial)

2009-04-15 Thread Oxymoron
Hi, <> On Wed, Apr 15, 2009 at 7:41 PM, mbikinyi brat wrote: > Dear Oxymoron, > In my previous example I had to import math for it to work . But in this > code with the factorial, I have not imported anything yet when I call it > with factorial(5), I get the result. How is this possible? In thi

Re: [Tutor] calculate area of a circle

2009-04-15 Thread Oxymoron
Hi, On Wed, Apr 15, 2009 at 6:52 PM, mbikinyi brat wrote: > Hi All, > This is a code I have written to calculate the area of a circle. > def area(radius): >  temp=math.pi*radius**2 >  return temp > > I now call it by entering area(12) at the prompt in IDLE. This is the error > message I get. Can

[Tutor] colours in IDLE

2009-04-15 Thread mbikinyi brat
Dear ALL, When you type a code in IDLE-Python, they appear in different colours. For instance:  def factorial(n):  if n==0:   return 1  else:   recurse=factorial(n-1)   result=n*recurse   return result factorial in blue and return and else and result in red. Any significance to these colours?   Reg

Re: [Tutor] OOP

2009-04-15 Thread Kent Johnson
On Wed, Apr 15, 2009 at 3:43 AM, mbikinyi brat wrote: > Dear ALL, > I am a python beginner and has never programmed and has been struggling to > understand how to create objects or classes in python. Can anyone help with > any concrete example. I have read most recommended textbooks but still have

Re: [Tutor] sorting file paths made up of of strings and numbers

2009-04-15 Thread عماد نوفل
On Tue, Apr 14, 2009 at 10:36 PM, Bill Campbell wrote: > On Tue, Apr 14, 2009, Emad Nawfal ( ) wrote: > > > > Hi tutors, > > How can I sort the following list in a way that takes care of the > > right order of numbers? The sorted function compares strings here as > > far as I can

Re: [Tutor] Looking for starter projects

2009-04-15 Thread W W
On Wed, Apr 15, 2009 at 3:50 AM, Evert Edel wrote: > Hi all, > > Now since I've got the learning python book I first did a quick read trough > it and now I'm going more slowly trough it and doing all the explained > things (in the interactive prompt). I do understand the basics behind OOP > and

Re: [Tutor] python books

2009-04-15 Thread W W
On Wed, Apr 15, 2009 at 4:45 AM, Wayne Watson wrote: > It's unlikely you are going to find a pdf on Python that's suitable for > beginners. Do you mean pdf or a digital book? There are Python books in > digital form on the web. I'm not quite sure how it works, but I know of at > least one public l

[Tutor] Import Modules

2009-04-15 Thread Giorgio Bonfiglio
Hi, hope this mailing list is still active. I'm learning phyton. I can write simple programs, and i've studied all examples provided by the Google App Engine Documentation. As i understood, i can import a module using something like: import modulename Or, import a specific function, using: fro

[Tutor] Here's something to talk about

2009-04-15 Thread Weidner, Ronald
# This code is posted for the purpose of conversation. If it is of some # value to someone that would be great. But what I hope is that the code # sparks conversations about what I did in this code and why I did it. Since # the list seems thick with OOP questions at the moment, I thought this m

[Tutor] regular expression problem

2009-04-15 Thread Spencer Parker
I have a python script that takes a text file as an argument. It then loops through the text file pulling out specific lines of text that I want. I have a regular expression that evaluates the text to see if it matches a specific phrase. Right now I have it writing to another text file that outp

Re: [Tutor] regular expression problem

2009-04-15 Thread bob gailer
Spencer Parker wrote: I have a python script that takes a text file as an argument. It then loops through the text file pulling out specific lines of text that I want. I have a regular expression that evaluates the text to see if it matches a specific phrase. Right now I have it writing to an

Re: [Tutor] regular expression problem

2009-04-15 Thread Spencer Parker
After he said that...I realized where I was being dumb... On Wed, Apr 15, 2009 at 10:29 AM, bob gailer wrote: > Spencer Parker wrote: > >> I have a python script that takes a text file as an argument. It then >> loops >> through the text file pulling out specific lines of text that I want. I >

Re: [Tutor] Here's something to talk about (Weidner, Ronald)

2009-04-15 Thread Carnell, James E
Since # the list seems thick with OOP questions at the moment, I thought this might # be relevant. Digest and enjoy. class Item ( object ): def __init__( self ): self._FullName = '' self._Recovery = 0 self._Exporter = SimpleItemExporter (); #

Re: [Tutor] Here's something to talk about (Weidner, Ronald)

2009-04-15 Thread Weidner, Ronald
class Item ( object ): def __init__( self ): self._FullName = '' self._Recovery = 0 self._Exporter = SimpleItemExporter (); #

Re: [Tutor] Here's something to talk about (Weidner, Ronald)

2009-04-15 Thread Carnell, James E
"""But what I hope is that the code # sparks conversations about what I did in this code and why I did it.""" If anyone answers me thank you. really. Nevertheless, I am personally not pursuing to understand this code. Ronald Weidner left on vacation and won't be back until the 19th (I don't kno

Re: [Tutor] Here's something to talk about (Weidner, Ronald)

2009-04-15 Thread W W
On Wed, Apr 15, 2009 at 12:27 PM, Carnell, James E < jecarn...@saintfrancis.com> wrote: > Since # the list seems thick with OOP questions at the moment, I thought > this might # be relevant. Digest and enjoy. > > class Item ( object ): > >def __init__( self ): >self._FullName = '' >

Re: [Tutor] Here's something to talk about (Weidner, Ronald)

2009-04-15 Thread Emile van Sebille
W W wrote: On Wed, Apr 15, 2009 at 12:27 PM, Carnell, James E mailto:jecarn...@saintfrancis.com>> wrote: Since # the list seems thick with OOP questions at the moment, I thought this might # be relevant. Digest and enjoy. class Item ( object ): def __init__( self ):

Re: [Tutor] Here's something to talk about

2009-04-15 Thread spir
Le Wed, 15 Apr 2009 08:29:30 -0700, "Weidner, Ronald" s'exprima ainsi: > # This code is posted for the purpose of conversation. If it is of some > # value to someone that would be great. But what I hope is that the code > # sparks conversations about what I did in this code and why I did it. >

Re: [Tutor] Here's something to talk about

2009-04-15 Thread Paul McGuire
1. Python is not Java (see Philip Eby's blog entry http://dirtsimple.org/2004/12/python-is-not-java.html). Let go of your concepts that only Items can go into an ItemCollection - Python already has some perfectly good collection builtins. Instead of writing a custom ItemCollection, why not write

Re: [Tutor] Here's something to talk about

2009-04-15 Thread wesley chun
> 1. Python is not Java although i agree with all 4 points that paul makes, this 1st one stands out the most. when i saw the code the first time, the immediate thought that came to my mind was, "This looks like Java code written with Python syntax." i thing the same functionality can be accomplish

Re: [Tutor] Here's something to talk about

2009-04-15 Thread Weidner, Ronald
I must confess I do not really understand your intent (a) with the code itself (b) with the fact of publishing it Maybe I have read it too fast. What I saw is an implementation of strict object interface, in the sense strictly separating the inner and outer parts of an object. Sure, this is an

Re: [Tutor] Here's something to talk about

2009-04-15 Thread spir
Le Wed, 15 Apr 2009 12:20:20 -0700, wesley chun s'exprima ainsi: > i think it's a common style guideline in multiple > languages i'm familiar with (other than Python) to Capitalize class > names but keep variables, functions, and methods all lowered. In most cases I know, class names are capital

Re: [Tutor] Here's something to talk about

2009-04-15 Thread wesley chun
>> i think it's a common style guideline in multiple >> languages i'm familiar with (other than Python) to Capitalize class >> names but keep variables, functions, and methods all lowered. > > In most cases I know, class names are capitalized, while func and method > names are camel-cased: >   Thi

Re: [Tutor] colours in IDLE

2009-04-15 Thread Alan Gauld
"mbikinyi brat" wrote When you type a code in IDLE-Python, they appear in different colours. For instance: factorial in blue and return and else and result in red. Any significance to these colours? Yes, they indicate different syntactic features. You can change them and see what they are

Re: [Tutor] Here's something to talk about

2009-04-15 Thread Weidner, Ronald
1. Python is not Java (see Philip Eby's blog entry http://dirtsimple.org/2004/12/python-is-not-java.html). Let go of your concepts that only Items can go into an ItemCollection - Python already has some perfectly good collection builtins. Instead of writing a custom ItemCollection, why not write

Re: [Tutor] Import Modules

2009-04-15 Thread Alan Gauld
"Giorgio Bonfiglio" wrote from google.appengine.ext import webapp from google.appengine.ext.webapp.util import run_wsgi_app The first line imports the webapp subpackage (that is not actually a module, it's a subdirectory with some .py files into). So why do i need to import the specific fun

Re: [Tutor] Here's something to talk about

2009-04-15 Thread Alan Gauld
"Weidner, Ronald" wrote # This code is posted for the purpose of conversation. If it is of some # value to someone that would be great. But what I hope is that the code # sparks conversations about what I did in this code and why I did it. Since # the list seems thick with OOP questions at

Re: [Tutor] Here's something to talk about (Weidner, Ronald)

2009-04-15 Thread Alan Gauld
"Emile van Sebille" wrote Redundant, yes; syntax error, no. IIRC, semi-colons are optional line terminators. statement terminators I think. ie you can have several statements on a line by separating with semicolons: x=5; print x+2 7 Alan G __

Re: [Tutor] Here's something to talk about

2009-04-15 Thread Paul McGuire
Ronald - I really encourage you to try to embrace some of the basic Python idioms as part of your Java->Python journey: 1. Iterators for item in list_of_items: # do something with item Is all that is needed to visit each item in a Python list. Your verbose MoveFirst, MoveNext, if more <> N

Re: [Tutor] Import Modules

2009-04-15 Thread Kent Johnson
On Wed, Apr 15, 2009 at 6:57 PM, Alan Gauld wrote: > When you import you import names, in the first case webapp. > Where the name is a package (ie a folder) that gives you access > to the modules (or sub packages) contained in that folder but > not to the contents of those items directly, hence t