Re: [Tutor] OOD - Another class question

2010-03-01 Thread C.T. Matsumoto

James Reynolds wrote:
I have another question related to OOD. What I have is a module with 
one parent class and two child classes. Some stuff is done to the 
object that is passed to the function in one of the child classes and 
this then calls a function from the global class passing local 
variables (from the child class).


When I do this, I am told: AttributeError: 'HillBuilder' object has no 
attribute 'MountainBuilder'


The question is, what am I doing wrong?

Here is an example:

class MountainBuilder(object):
def __init__(self, mountain):
self.mountain = mountain
self.mountain_func
   self.pinetree_func


  def pinetree_func(self, knoll)
do stuff to knoll
return knoll


  def mountain_func(self, hill)
knoll = hill * 2
pinetree = pintree_func(knoll)
return hill


class HillBuilder(MountainBuilder):
def __init__(self, mountain):
  OptionLoad.__init__(self, mountain)
  self.MountainBuilder.mountain_func
  self.hill_func


  def hill_func(self)
hill= do stuff to self.mountain
grassyknoll = MountainBuilder.mountain_func(hill)

return grassy knoll



do stuff with grassy knoll



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

The line grassyknoll = MountainBuilder.mountain ...

Since you inherit MountainBuilder you call the mountain_func (which is a 
method :-) ) with self:

grassyknoll = self.mountain_func(hill)

All methods inside the MountainBuilder can be called as if they are a 
part of the HillBuilder (thus inheritance).


Cheers,

T
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Over-riding radians as default for trig calculations

2010-03-01 Thread Lie Ryan
On 03/01/10 06:39, AG wrote:
> After importing the math module and running
> 
> math.cos( x )
> 
> the result is in radians.
> 
> Is there a way of setting this so that it results in degrees?  I don't
> want to over-ride this permanently for my Python settings, so am happy
> to specifically do it per equation or per program.

I'd recommend you to get used to using radian measurement; though it may
initially looks unfamiliar, working in radian (with computer or by-hand)
is much more natural once you get used to it. Many formulaes become
simpler when using radian while some are only valid in radian.

The only reasonable point where you should convert from and between
radians is when requesting input from non-mathematician users.

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


[Tutor] Why is the max size so low in this mail list?

2010-03-01 Thread Wayne Watson
See Subject. 40K here, but other Python lists allow for larger (total) 
sizes.


--
   Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

 (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
  Obz Site:  39° 15' 7" N, 121° 2' 32" W, 2700 feet

   Stop the illegal killing of dolphins and porpoises.
 
  Wrest the control of the world's fisheries from Japan.

Web Page:

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


Re: [Tutor] Why is the max size so low in this mail list?

2010-03-01 Thread Alan Gauld


"Wayne Watson"  wrote 

See Subject. 40K here, but other Python lists allow for larger (total) 
sizes.


Presumably to discourage long posts or posts with large attachments?
But I'm only guessing...

Alan G




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


Re: [Tutor] Why is the max size so low in this mail list?

2010-03-01 Thread Sander Sweers
On 1 March 2010 18:13, Wayne Watson  wrote:
> See Subject. 40K here, but other Python lists allow for larger (total)
> sizes.

Don't know but if it is that long use pastebin [1].

Greets
Sander

[1] http://python.pastebin.com/
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Why is the max size so low in this mail list?

2010-03-01 Thread Steve Willoughby
On Mon, Mar 01, 2010 at 05:30:00PM -, Alan Gauld wrote:
> 
> "Wayne Watson"  wrote 
> 
> >See Subject. 40K here, but other Python lists allow for larger (total) 
> >sizes.
> 
> Presumably to discourage long posts or posts with large attachments?
> But I'm only guessing...

It's also mailman's* default size, so it could also be that nobody
thought it was important to change it from that default.  On the other
hand, there's a good argument in favor of having people post links
to large code snippets and not send them through the list, or
(and you know it'll happen) 1600x1200 screenshots of error messages.

-- 
Steve Willoughby|  Using billion-dollar satellites
st...@alchemy.com   |  to hunt for Tupperware.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Why is the max size so low in this mail list?

2010-03-01 Thread Bill Campbell
On Mon, Mar 01, 2010, Sander Sweers wrote:
>On 1 March 2010 18:13, Wayne Watson  wrote:
>> See Subject. 40K here, but other Python lists allow for larger (total)
>> sizes.
>
>Don't know but if it is that long use pastebin [1].

40K is the default on Mailman mailing lists, and for good reason.
I don't know how many subscribers there are, but multiplying
message size by number of recipients can generate huge volumes
(don't forget that encoding binary attachments increases their
size by about 1/3).

Not everybody has broadband connections, and getting large
attachments can cost them Real Money(tm) (as if there is any of
that in the world's monetary systems these days :-), and take a
long time to download.

One of the best features of the horde/imp webmail program is that
it makes it easy for one to upload attachments to the web server
with a link to the attachment in the body of the message.  That's
a feature I would like to see an all webmail servers.

Bill
-- 
INTERNET:   b...@celestial.com  Bill Campbell; Celestial Software LLC
URL: http://www.celestial.com/  PO Box 820; 6641 E. Mercer Way
Voice:  (206) 236-1676  Mercer Island, WA 98040-0820
Fax:(206) 232-9186  Skype: jwccsllc (206) 855-5792

I have no reason to suppose that he, who would take away my Liberty, would
not when he had me in his Power, take away everything else.  John Locke
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any Tutor there ? Removing redundant parameters in a models file having include files.

2010-03-01 Thread Karim Liateni


Thanks for this precision!
I'm using standard python so this is ok!
Why people use proprietary python ?
To have more trouble ? To be different from the rest of community ?
Anyway in opensource people do whatever they want but you know
multiple version that was the same before Common C or Lisp it was war 
fields.
It's better to spent energy to participate with the core developers to 
make the

common langage evoluate.

Regards

Karim

Alan Gauld wrote:


"Karim Liateni"  wrote


def getLines(file):
try: lines = open(filename).readlines() ; return lines
except IOError: #handle error


but in the second 'lines = open(filename).readlines()'
I don't hold indirectly a reference to the file? Please, could you 
explain more this point?


Sure, the lines variable holds a reference to the list returned by 
readlines.

There is no variable referring to the file object so immediately after
readlines completes the file will be ready to be closed (at least in
CPython as already pointed out by Lie)

HTH,



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


Re: [Tutor] Why is the max size so low in this mail list?

2010-03-01 Thread Robert Berman

> -Original Message-
> From: tutor-bounces+bermanrl=cfl.rr@python.org [mailto:tutor-
> bounces+bermanrl=cfl.rr@python.org] On Behalf Of Alan Gauld
> Sent: Monday, March 01, 2010 12:30 PM
> To: tutor@python.org
> Subject: Re: [Tutor] Why is the max size so low in this mail list?
> 
> 
> "Wayne Watson"  wrote
> 
> > See Subject. 40K here, but other Python lists allow for larger
> (total)
> > sizes.
> 
> Presumably to discourage long posts or posts with large attachments?
> But I'm only guessing...
> 
> Alan G
> 
> 
It encouraged me to use pastebin when it was necessary to post code a tad
longer than the casual fifteen line snippet.
 
Robert Berman
The opposite of love is not hate, it's indifference.
The opposite of art is not ugliness, it's indifference.
The opposite of faith is not heresy, it's indifference.
And the opposite of life is not death, it's indifference.
 




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


Re: [Tutor] Any Tutor there ? Removing redundant parameters in a models file having include files.

2010-03-01 Thread Steven D'Aprano
On Tue, 2 Mar 2010 07:07:57 am Karim Liateni wrote:
> Thanks for this precision!
> I'm using standard python so this is ok!
> Why people use proprietary python ?
> To have more trouble ? To be different from the rest of community ?

Python is a language, but there can be many different implementations of 
that language, just like there are different C compilers or different 
Javascript engines.

CPython is the version which was made first, it is the most common 
version, but it is not the only one. It is called CPython because it is 
written in C.

Jython is a version of Python written in Java, and it was created by 
people wanting to use Python as a front-end to Java libraries, and to 
take advantage of Java's garbage collector.

IronPython is Microsoft's version of Python written for .Net and Mono.

PyPy is an experimental version of Python written in Python, used by 
people wanting to experiment with Python compilers.

"Python for S60" is a version of Python written for Nokia's S60 devices.

CapPython is an experimental version of Python designed for security.

There are many others, they are all Python, but they have differences.




-- 
Steven D'Aprano
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Any Tutor there ? Removing redundant parameters in a models file having include files.

2010-03-01 Thread ALAN GAULD


> Why people use proprietary python ?

Because it does something normal Python doesn't. For example I often use 
Jython (Python implemented in Java instead of C) because it allows me to 
import Java classes and test them. It also allows me to rapidly build Java 
classes that I can integrate as temporary solutions in Java programs 
until the Java developers get round to writing pure Java versions. (For example 
I can use Python's powerful dynamic collections to create data processing 
classes)

I can also use Jython to interactively experiment with or test Java classes 
using the >>> prompt, to find out how they behave under different conditions.

Others use stackless Python for things like massively parallel processing.

Still others favour Iron Python which is written in .NET so that we can 
use .NET classes and libraries from Python and use Python classes 
within .NET.

> To have more trouble ? To be different from the rest of community ?

No, usually to fit in with another community. Or it may be to experiment 
with different implementation ideas - like many Lisp researchers use Lisp to 
meddle with the interpreter to try out new computing concepts. Its relatively 
easy to do that in Python too. And so the science of computing is advanced.
But at the cost of using non standard implementations. Not everyone 
programs to solve practical problems. :-)

> It's better to spent energy to participate with the core developers to make 
> the
> common langage evoluate.

But sometimes you want to go beyond the language, to explore ideas and 
concepts that underlie everything we do in every language. Languages like Lisp 
and Python make that possible, if not exactly easy!

HTH,

 Alan Gauld
Author of the Learn To Program website
http://www.alan-g.me.uk/



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


Re: [Tutor] Any Tutor there ? Removing redundant parameters in a models file having include files.

2010-03-01 Thread Andreas Kostyrka
> > Why people use proprietary python ?

Well, AFAIK I know, all more or less popular non-Ansi-C implementations of 
Python are free. (Jython is, IronPython too, although I've never checked in 
detail, stackless is, PyPy is too, ...)
> > It's better to spent energy to participate with the core developers to
> > make the common langage evoluate.
> 
> But sometimes you want to go beyond the language, to explore ideas and
> concepts that underlie everything we do in every language. Languages like
>  Lisp and Python make that possible, if not exactly easy!

Actually, having multiple implementations of the language is a huge benefit, 
because that means that we have a language definition apart from the 
implementation. C, C++, Java, C#, Ruby do have alternate implementations. 
Perl, VB, ... do not.

Beside the slightly abstract benefit of splitting definition and 
implementation (which e.g. allows for new and better implementations), most of 
the alternate implementations have, as Alan already pointed out, it's own 
nice.

Jython means that my Python skills carry over into a Java environment.
IronPython means the same for .NET, stackless allows for extreme designs 
without becoming Twisted, Pyrex/Cython (although not Python, but a Python 
look-alike) allows me to interface with C and more important to write code 
that manipulates C data types at the same speed that C does, without the pain 
of all the Python runtime mixing.

Furthermore I do not think that most of the "core" community has a problem 
with the alternate implementations, as they provide very useful functions (it 
helps on the architecture side, because it limits somewhat what can be done, 
it helps on the personal side, because it increases the value of Python 
skills, ...), ...

Andreas
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Verifying My Troublesome ...+My Final Word

2010-03-01 Thread Wayne Watson
For me, I'm done.  I plumbed  this issue elsewhere and the final message 
there stated this.


"I've no time to verify your specific claim and have no readily 
available proof for mine [his claim], but I've seen similar issues on Win7."


Let MS deal with it.  Anyway, thanks for your effort.

 


--
   Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

 (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
  Obz Site:  39° 15' 7" N, 121° 2' 32" W, 2700 feet

   Stop the illegal killing of dolphins and porpoises.
 
  Wrest the control of the world's fisheries from Japan.

Web Page:

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


Re: [Tutor] Why is the max size so low in this mail list?

2010-03-01 Thread Christian Witts

Steve Willoughby wrote:

On Mon, Mar 01, 2010 at 05:30:00PM -, Alan Gauld wrote:
  
"Wayne Watson"  wrote 


See Subject. 40K here, but other Python lists allow for larger (total) 
sizes.
  

Presumably to discourage long posts or posts with large attachments?
But I'm only guessing...



It's also mailman's* default size, so it could also be that nobody
thought it was important to change it from that default.  On the other
hand, there's a good argument in favor of having people post links
to large code snippets and not send them through the list, or
(and you know it'll happen) 1600x1200 screenshots of error messages.

  

And of course they'll be in Bitmap format and not JPG.

--
Kind Regards,
Christian Witts


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