Re: Python Classes

2014-08-05 Thread Chris Angelico
On Wed, Aug 6, 2014 at 1:37 AM, Neil D. Cerutti wrote: > In simple cases like that, functions could do very well by including a > little bundle of data (probably a dict) as one of the parameters for each > related function. And this is exactly how object orientation is done in C. You just have a

Re: Python Classes

2014-08-05 Thread Neil D. Cerutti
On 8/4/2014 6:44 PM, John Gordon wrote: In Shubham Tomar writes: classes. I understand that you define classes to have re-usable methods and procedures, but, don't functions serve the same purpose. Can someone please explain the idea of classes If a function simply accepts some data, does

Re: Python Classes

2014-08-04 Thread dieter
Shubham Tomar writes: > Python is the first programming language that I'm learning. > I'm confused by the idea of classes and intimidated by syntax defining > classes. I understand that you define classes to have re-usable methods and > procedures, but, don't functions serve the same purpose. As

Re: Python Classes

2014-08-04 Thread Terry Reedy
On 8/4/2014 6:44 PM, John Gordon wrote: __init__() is the initializer method, which is called as one step of creating a class object. In fact, it is the last step and usually is the main step for user-defined classes, and the only step one need be concerned with. Object is the lowest-level

Re: Python Classes

2014-08-04 Thread John Gordon
In Shubham Tomar writes: > classes. I understand that you define classes to have re-usable methods and > procedures, but, don't functions serve the same purpose. > Can someone please explain the idea of classes If a function simply accepts some data, does some calculations on that data and th

Re: Python Classes

2014-08-04 Thread Terry Reedy
On 8/4/2014 4:40 AM, Shubham Tomar wrote: Hi, Python is the first programming language that I'm learning. I'm confused by the idea of classes and intimidated by syntax defining classes. I understand that you define classes to have re-usable methods and procedures, but, don't functions serve the

Re: Python classes for reading/writing/parsing MIDI files

2013-11-19 Thread David
On 20 November 2013 12:57, Steven D'Aprano wrote: > On Wed, 20 Nov 2013 10:32:08 +1000, alex23 wrote: >> >> They appear to be resurrecting a 12 year old thread. > > Wow, that's one slow News server. http://en.wikipedia.org/wiki/Slow_Movement :) -- https://mail.python.org/mailman/listinfo/python

Re: Python classes for reading/writing/parsing MIDI files

2013-11-19 Thread Steven D'Aprano
On Wed, 20 Nov 2013 10:32:08 +1000, alex23 wrote: > On 20/11/2013 12:12 AM, Chris Angelico wrote: >> On Wed, Nov 20, 2013 at 12:50 AM, Annmarina Nagy >> wrote: >>> the command label gets "stuck" >> >> A bit of context would help hugely. Are you replying to someone else's >> post? All we have is a

Re: Python classes for reading/writing/parsing MIDI files

2013-11-19 Thread alex23
On 20/11/2013 12:12 AM, Chris Angelico wrote: On Wed, Nov 20, 2013 at 12:50 AM, Annmarina Nagy wrote: the command label gets "stuck" A bit of context would help hugely. Are you replying to someone else's post? All we have is a subject line. They appear to be resurrecting a 12 year old threa

Re: Python classes for reading/writing/parsing MIDI files

2013-11-19 Thread Chris Angelico
On Wed, Nov 20, 2013 at 12:50 AM, Annmarina Nagy wrote: > the command label gets "stuck" A bit of context would help hugely. Are you replying to someone else's post? All we have is a subject line. ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Re: Python classes for reading/writing/parsing MIDI files

2013-11-19 Thread Annmarina Nagy
the command label gets "stuck" -- https://mail.python.org/mailman/listinfo/python-list

Re: Python classes: Simplify?

2012-03-23 Thread Steven Lehar
Many thanks to all who responded to my "Python Classes: Simplify?" thread. There seem to be several good reasons for this particular syntactical choice, I am all the wiser for your kind explanations. My faith in the simplicity and elegance of this beautiful language is reinforced. Thanks all! --

Re: Python classes: Simplify?

2012-03-23 Thread Jean-Michel Pichavant
Steven Lehar wrote: It seems to me that the Python class system is needlessly confusing. Am I missing something? For example in the class Complex given in the documentation *class Complex:* *def __init__(self, realpart, imagpart):* *self.r = realpart* *self.i = imagpart* *

Re: Python classes: Simplify?

2012-03-22 Thread J. Cliff Dyer
The issue of explicitly naming a "self" parameter has been discussed in depth on a number of occasions. I recommend a google search for "python implicit self" for some of the reasons why it exists. Here's what Guido has to say about it: http://neopythonic.blogspot.com/2008/10/why-explicit-self-h

Re: Python classes: Simplify?

2012-03-22 Thread Andrea Crotti
On 03/22/2012 10:51 AM, Steven Lehar wrote: It seems to me that the Python class system is needlessly confusing. Am I missing something? For example in the class Complex given in the documentation *class Complex:* *def __init__(self, realpart, imagpart):* *self.r = realpart* *

Re: Python classes: Simplify?

2012-03-22 Thread Chris Rebert
On Thu, Mar 22, 2012 at 3:51 AM, Steven Lehar wrote: > It seems to me that the Python class system is needlessly confusing. Am I > missing something? Explicit `self` is slightly annoying, but you'll get over it quickly (trust me). > For example in the class Complex given in the documentation > >

Re: Python classes: Simplify?

2012-03-22 Thread Chris Angelico
On Thu, Mar 22, 2012 at 9:51 PM, Steven Lehar wrote: > It seems to me that the Python class system is needlessly confusing. Am I > missing something? > > For example in the class Complex given in the documentation > > class Complex: >     def __init__(self, realpart, imagpart): >         self.r =

Re: Python Classes

2007-08-28 Thread Lamonte Harris
Ok thanks I'll try remembering it. On 8/28/07, Erik Jones <[EMAIL PROTECTED]> wrote: > > On Aug 28, 2007, at 12:04 AM, Lamonte Harris wrote: > > > How come you have to set the initialized created variables to equal > > the parameters, shouldn't that be default? > > > > class testing: > >

Re: Python Classes

2007-08-28 Thread Erik Jones
On Aug 28, 2007, at 12:04 AM, Lamonte Harris wrote: > How come you have to set the initialized created variables to equal > the parameters, shouldn't that be default? > > class testing: > def __init__(self,testing): >self.testing = testing > x = testing("testing") >

Re: Python Classes and dynamic class members

2006-11-03 Thread James Stroud
[EMAIL PROTECTED] wrote: > James Stroud wrote: > >>[EMAIL PROTECTED] wrote: >> >>>I have a text file that I am parsing. Each line is of the form: >>> >>>max_time 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.10 0.11 0.12 >>> >>>The first item is the field name and the next twelve items are valu

Re: Python Classes and dynamic class members

2006-11-03 Thread [EMAIL PROTECTED]
James Stroud wrote: > [EMAIL PROTECTED] wrote: > > I have a text file that I am parsing. Each line is of the form: > > > > max_time 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.10 0.11 0.12 > > > > The first item is the field name and the next twelve items are values > > for each month in the y

Re: Python Classes and dynamic class members

2006-11-03 Thread John Machin
[EMAIL PROTECTED] wrote: > I have a text file that I am parsing. Each line is of the form: > > max_time 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.10 0.11 0.12 > > The first item is the field name and the next twelve items are values > for each month in the year. There are multiple lines eac

Re: Python Classes and dynamic class members

2006-11-03 Thread James Stroud
[EMAIL PROTECTED] wrote: > I have a text file that I am parsing. Each line is of the form: > > max_time 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.10 0.11 0.12 > > The first item is the field name and the next twelve items are values > for each month in the year. There are multiple lines e

Re: python classes taught

2005-08-20 Thread jean-marc
Cegep du Vieux Montreal (technical college level), uses Python for CGI in web developement class. ...At least when I give this course ;-) Jean-Marc -- http://mail.python.org/mailman/listinfo/python-list

Re: python classes taught

2005-08-20 Thread bruno modulix
[EMAIL PROTECTED] wrote: > anyone know of any college/school that is teaching the python language? > Bordeaux University (France) uses Python in a "programming 101" course. -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.sp

Re: python classes taught

2005-08-19 Thread Simon Percivall
Yeha, sure. The Royal Institute of Technology in Stockholm, Sweden teaches Python for some of its introductory programming and algorithm courses. -- http://mail.python.org/mailman/listinfo/python-list

Re: python classes/file structure

2005-04-22 Thread Terry Hancock
On Thursday 21 April 2005 08:48 am, codecraig wrote: > widget = gui.MyCustomWidget.MyCustomWidge() > > ...seems weird, how should I structure this? Is it not common to have > one class in a .py? No, it isn't really. Usually, there will be several related classes in a single module. Only if the

Re: python classes/file structure

2005-04-21 Thread Steve Holden
codecraig wrote: also is it common to have one class per file? seems weird to have, MyCustomWidget.MyCustomWidget thanks Well, this *is* fairly normal, but you can manage the namespace to your advantage if you wish. So, for example, gui/__init__.py could do from CustomWidget import CustomWidg

Re: python classes/file structure

2005-04-21 Thread Steve Holden
codecraig wrote: Thanks, but I am not familiar with the "__all__" variable, could u give me an example? Without using, __all__would i do this in my __init__.py? import MyCustomWidget1 import MyCustomWidget2 import MyCustomWidget3 etc? Yes, correct. __all__ just limits the names that are importe

Re: python classes/file structure

2005-04-21 Thread codecraig
also is it common to have one class per file? seems weird to have, MyCustomWidget.MyCustomWidget thanks -- http://mail.python.org/mailman/listinfo/python-list

Re: python classes/file structure

2005-04-21 Thread codecraig
Thanks, but I am not familiar with the "__all__" variable, could u give me an example? Without using, __all__would i do this in my __init__.py? import MyCustomWidget1 import MyCustomWidget2 import MyCustomWidget3 etc? -- http://mail.python.org/mailman/listinfo/python-list

Re: python classes/file structure

2005-04-21 Thread Steve Holden
codecraig wrote: What is the best/common way to structure ur python code for an application? For example...if I create some custom GUI widgets I have this C:\stuff --> gui --: MyCustomWidget.py --: TestWidgets.py so MyCustomWidget.py has one class, class MyCustomWidget: ... so from