Re: When I need classes?

2016-01-14 Thread Rick Johnson
On Tuesday, January 12, 2016 at 11:27:23 PM UTC-6, Steven D'Aprano wrote: > On Wednesday 13 January 2016 14:36, Rustom Mody wrote: > > > 1. Python the LANGUAGE, is rather even-handed in paradigm choice: > > Choose OO, imperative, functional or whatever style pleases/suits > > you 2. Python

Re: When I need classes?

2016-01-13 Thread Mike S via Python-list
On 1/11/2016 3:45 PM, Travis Griggs wrote: On Jan 10, 2016, at 9:48 AM, Bernardo Sulzbach wrote: Essentially, classes (as modules) are used mainly for organizational purposes. Although you can solve any problem you would solve using classes without classes,

Re: When I need classes?

2016-01-13 Thread Rustom Mody
Guess you (Rodrigo) wanted to send this to the list? On Wed, Jan 13, 2016 at 8:22 PM, Rodrigo Bistolfi wrote: > Start by using just functions. As you move forward, you will find that > often you are passing the same data structure as first argument to some > functions. At that point, you

Re: When I need classes?

2016-01-12 Thread Rustom Mody
On Sunday, January 10, 2016 at 1:00:13 PM UTC+5:30, Arshpreet Singh wrote: > Hello Friends, I am quite new to OOP(object oriented Programming), I did some > projects with python which includes Data-Analysis, Flask Web Development and > some simple scripts. > > I have only one question which is

Re: When I need classes?

2016-01-12 Thread Rustom Mody
On Wednesday, January 13, 2016 at 10:57:23 AM UTC+5:30, Steven D'Aprano wrote: > On Wednesday 13 January 2016 14:36, Rustom Mody wrote: > > > 1. Python the LANGUAGE, is rather even-handed in paradigm choice: Choose > > OO, imperative, functional or whatever style pleases/suits you > > 2. Python

Re: When I need classes?

2016-01-12 Thread Steven D'Aprano
On Wednesday 13 January 2016 14:36, Rustom Mody wrote: > 1. Python the LANGUAGE, is rather even-handed in paradigm choice: Choose > OO, imperative, functional or whatever style pleases/suits you > 2. Python LIBRARIES however need to make committing choices. Users of > those then need to align

Re: When I need classes?

2016-01-12 Thread Gregory Ewing
Chris Angelico wrote: So start simplistic, and then look into it like this: "Hey, see how you're doing this five times? There HAS to be a better way!" (With acknowledgement to Raymond Hettinger.) That gave me visions of a little animated cartoon of Raymond popping up in the corner of the

Re: When I need classes?

2016-01-12 Thread Bernardo Sulzbach
On Tue, Jan 12, 2016 at 7:01 PM, Gregory Ewing wrote: > Chris Angelico wrote: >> >> So start simplistic, and then look >> into it like this: "Hey, see how you're doing this five times? There >> HAS to be a better way!" (With acknowledgement to Raymond Hettinger.) > >

Re: When I need classes?

2016-01-12 Thread Ian Kelly
On Mon, Jan 11, 2016 at 5:53 PM, Bernardo Sulzbach wrote: > I have never gone "seriously OO" with Python though. I never wrote > from scratch an application with more than 10 classes as far as I can > remember. However, I would suppose that the interpreter can handle >

Re: When I need classes?

2016-01-12 Thread Steven D'Aprano
On Wed, 13 Jan 2016 11:18 am, Ian Kelly wrote: > On Mon, Jan 11, 2016 at 5:53 PM, Bernardo Sulzbach > wrote: >> I have never gone "seriously OO" with Python though. I never wrote >> from scratch an application with more than 10 classes as far as I can >> remember.

Re: When I need classes?

2016-01-11 Thread Bernardo Sulzbach
On Mon, Jan 11, 2016 at 9:45 PM, Travis Griggs wrote: > >> On Jan 10, 2016, at 9:48 AM, Bernardo Sulzbach >> wrote: >> >> Essentially, classes (as modules) are used mainly for organizational >> purposes. >> >> Although you can solve any

Re: When I need classes?

2016-01-11 Thread Travis Griggs
> On Jan 10, 2016, at 9:48 AM, Bernardo Sulzbach > wrote: > > Essentially, classes (as modules) are used mainly for organizational purposes. > > Although you can solve any problem you would solve using classes > without classes, solutions to some big problems may be

Re: When I need classes?

2016-01-11 Thread Chris Angelico
On Tue, Jan 12, 2016 at 11:53 AM, Bernardo Sulzbach wrote: > On Mon, Jan 11, 2016 at 9:45 PM, Travis Griggs wrote: >> >>> On Jan 10, 2016, at 9:48 AM, Bernardo Sulzbach >>> wrote: >>> >>> Essentially, classes (as

Re: When I need classes?

2016-01-11 Thread Michael Torrie
On 01/11/2016 04:45 PM, Travis Griggs wrote: > As a long term OO purist practitioner, I would add to this. > Obviously, you can organize your code any way you want, with or > without classes. You could put all your functions with an odd number > of letters in one class, and all of the even

Re: When I need classes?

2016-01-10 Thread Chris Angelico
On Mon, Jan 11, 2016 at 1:57 PM, Cameron Simpson wrote: > I always structure this aspect as: > > ... at or near top of script ... > > def main(argv): >... do main logic here ... > > ... at bottom ... > if __name__ == '__main__': >sys.exit(main(sys.argv)) > > This has

Re: When I need classes?

2016-01-10 Thread Cameron Simpson
On 10Jan2016 08:02, Michael Torrie wrote: I can't speak to Flask or any other web development. But for simple scripts, I'll start out with no classes. Just functions as needed, and some main logic. I always use the idiom: if __name__ == '__main__': # do main logic here

Re: When I need classes?

2016-01-10 Thread Arshpreet Singh
On Sunday, 10 January 2016 23:20:02 UTC+5:30, Bernardo Sulzbach wrote: > Essentially, classes (as modules) are used mainly for organizational purposes. > > Although you can solve any problem you would solve using classes > without classes, solutions to some big problems may be cheaper and > more

Re: When I need classes?

2016-01-10 Thread Arshpreet Singh
On Sunday, 10 January 2016 21:09:52 UTC+5:30, Steven D'Aprano wrote: > There are *no* problems that are impossible to solve without classes, but > sometimes classes will make problems easier to solve. And sometimes classes > make problems harder to solve. It depends on the problem. Is there any

Re: When I need classes?

2016-01-10 Thread Arshpreet Singh
On Sunday, 10 January 2016 20:33:20 UTC+5:30, Michael Torrie wrote: > This way I can import functions defined in this script into another > script later if I want. > > If I find I need to share state between functions, and if I find that I > might need to have multiple situations of shared

Re: When I need classes?

2016-01-10 Thread Cameron Simpson
On 10Jan2016 22:45, Arshpreet Singh wrote: On Sunday, 10 January 2016 20:33:20 UTC+5:30, Michael Torrie wrote: This way I can import functions defined in this script into another script later if I want. If I find I need to share state between functions, and if I find that

Re: When I need classes?

2016-01-10 Thread Ulli Horlacher
Cameron Simpson wrote: > I always structure this aspect as: > > ... at or near top of script ... > > def main(argv): >... do main logic here ... > > ... at bottom ... > if __name__ == '__main__': >sys.exit(main(sys.argv)) I, as a Python beginner, came to the same

Re: When I need classes?

2016-01-10 Thread Michael Torrie
On 01/10/2016 12:29 AM, Arshpreet Singh wrote: > Hello Friends, I am quite new to OOP(object oriented Programming), I > did some projects with python which includes Data-Analysis, Flask Web > Development and some simple scripts. > > I have only one question which is bothering me most of the time,

Re: When I need classes?

2016-01-10 Thread Bernardo Sulzbach
Essentially, classes (as modules) are used mainly for organizational purposes. Although you can solve any problem you would solve using classes without classes, solutions to some big problems may be cheaper and more feasible using classes. If Python is your everyday scripting tool, you will

Re: When I need classes?

2016-01-10 Thread Steven D'Aprano
On Sun, 10 Jan 2016 06:29 pm, Arshpreet Singh wrote: > Hello Friends, I am quite new to OOP(object oriented Programming), I did > some projects with python which includes Data-Analysis, Flask Web > Development and some simple scripts. > > I have only one question which is bothering me most of

When I need classes?

2016-01-09 Thread Arshpreet Singh
Hello Friends, I am quite new to OOP(object oriented Programming), I did some projects with python which includes Data-Analysis, Flask Web Development and some simple scripts. I have only one question which is bothering me most of the time, When I will get the need to use Classes in Python?