Re: [Tutor] method, type?

2016-01-06 Thread Cameron Simpson
On 07Jan2016 00:06, ALAN GAULD wrote: On 06/01/16 23:00, Cameron Simpson wrote: ... ensures that if you subclass the class, you automatically get a valid constructor as well. Wouldn't it return an instance of the superclass rather than the sub class? You'd need to override it wouldn't you?

Re: [Tutor] method, type?

2016-01-06 Thread Steven D'Aprano
On Thu, Jan 07, 2016 at 12:06:17AM +, Alan Gauld wrote: > On 06/01/16 23:00, Cameron Simpson wrote: > > >>> ... ensures that if you subclass the class, you automatically > >>> get a valid constructor as well. > >> > >> Wouldn't it return an instance of the superclass rather than > >> the sub c

Re: [Tutor] Teaching Python

2016-01-06 Thread Steven D'Aprano
On Wed, Jan 06, 2016 at 07:04:24PM +, Alan Gauld wrote: > On 06/01/16 18:23, yehudak . wrote: > > My grandson Guy (8th grader) is learning Python at school. That's what made > > me teach myself Python programming as well. > > Yesterday he asked my help in his homework: > > > > Write a FOR-loop

Re: [Tutor] method, type?

2016-01-06 Thread Steven D'Aprano
On Wed, Jan 06, 2016 at 06:57:31PM +, Alan Gauld wrote: > On 06/01/16 14:46, Steven D'Aprano wrote: > > I don't understand what you mean by "Python doesn't support named > > constructors". It seems to me that this is the *only* sort of > > constructor that Python supports. > > No, Python co

Re: [Tutor] method, type?

2016-01-06 Thread Alan Gauld
On 06/01/16 18:57, Alan Gauld wrote: >> The solution is to use constructors with different names, which C++ >> calls "named constructors". > > I stopped using C++ around v2 and it didn't have such a feature. > Maybe its been added since. If so that's good to know. (Time > for some googling methi

Re: [Tutor] method, type?

2016-01-06 Thread Alan Gauld
On 06/01/16 23:00, Cameron Simpson wrote: >>> ... ensures that if you subclass the class, you automatically >>> get a valid constructor as well. >> >> Wouldn't it return an instance of the superclass rather than >> the sub class? You'd need to override it wouldn't you? > > No, when you call: > >

Re: [Tutor] How to get Key from multiple value dictionary search

2016-01-06 Thread Martin A. Brown
Hello there, >I refer to this website >https://www.codecademy.com/forum_questions/50721fce7c7091000201e56a > >dic = {'key1': ["value1", "value2"], > 'key2': ["value77", "something"] } > >what I wanted to learn is : > >a) how do i get the key only by providing value i.e value77 ? N.B. Fir

Re: [Tutor] method, type?

2016-01-06 Thread Cameron Simpson
On 06Jan2016 18:57, ALAN GAULD wrote: On 06/01/16 14:46, Steven D'Aprano wrote: It would be reasonable to make this a factory function declared in the global module level. But I think making it a classmethod is better. I won't put up much of an argument here. In C++ or Java I'd definitely say

[Tutor] How to get Key from multiple value dictionary search

2016-01-06 Thread Fosiul Alam
Hi All, I refer to this website https://www.codecademy.com/forum_questions/50721fce7c7091000201e56a dic = {'key1': ["value1", "value2"], 'key2': ["value77", "something"] } what I wanted to learn is : a) how do i get the key only by providing value i.e value77 ? b) Please help to break t

Re: [Tutor] Tutor Digest, Vol 143, Issue 17

2016-01-06 Thread Tahir Hafiz
On Wed, Jan 6, 2016 at 9:07 PM, yehudak . wrote: > Alan, Tahir & friends, > My post was not a question, merely an observation. > I hope there's no objection to my mail. > > Yehuda > > On Wed, Jan 6, 2016 at 10:59 PM, wrote: > > > Send Tutor mailing list submissions to > > tutor@python.or

Re: [Tutor] Tutor Digest, Vol 143, Issue 17

2016-01-06 Thread yehudak .
Alan, Tahir & friends, My post was not a question, merely an observation. I hope there's no objection to my mail. Yehuda On Wed, Jan 6, 2016 at 10:59 PM, wrote: > Send Tutor mailing list submissions to > tutor@python.org > > To subscribe or unsubscribe via the World Wide Web, visit >

Re: [Tutor] Teaching Python

2016-01-06 Thread yehudak .
Ahlan Tahir, That's EXACTLY my point. Thank you, Yehuda On Wed, Jan 6, 2016 at 10:59 PM, Tahir Hafiz wrote: > Yes that is a huge for loop. > I can do it like this but I won't try: > >>> for num in list(range(100)): > >>> print(num) > > Sort of strange that the school wanted so much loopin

Re: [Tutor] Teaching Python

2016-01-06 Thread Tahir Hafiz
Yes that is a huge for loop. I can do it like this but I won't try: >>> for num in list(range(100)): >>> print(num) Sort of strange that the school wanted so much looping for your grandson, they could have picked a lower number to demonstrate a for loop. By the way there is the tqdm module

Re: [Tutor] Teaching Python

2016-01-06 Thread Danny Yoo
On Wed, Jan 6, 2016 at 10:23 AM, yehudak . wrote: > My grandson Guy (8th grader) is learning Python at school. That's what made > me teach myself Python programming as well. > Yesterday he asked my help in his homework: > > Write a FOR-loop that prints all numbers up to 100 Try to say explici

Re: [Tutor] Teaching Python

2016-01-06 Thread Peter Otten
yehudak . wrote: > My grandson Guy (8th grader) is learning Python at school. That's what > made me teach myself Python programming as well. > Yesterday he asked my help in his homework: > > Write a FOR-loop that prints all numbers up to 100 > > Thank you, the gods of Ctrl+C Did you mean to

Re: [Tutor] Teaching Python

2016-01-06 Thread Alan Gauld
On 06/01/16 18:23, yehudak . wrote: > My grandson Guy (8th grader) is learning Python at school. That's what made > me teach myself Python programming as well. > Yesterday he asked my help in his homework: > > Write a FOR-loop that prints all numbers up to 100 And the question is? Python has

Re: [Tutor] method, type?

2016-01-06 Thread Alan Gauld
Second attempt, my PC crashed just as I was sending the first one. You might see two similar posts, if so apologies... On 06/01/16 14:46, Steven D'Aprano wrote: > I don't understand what you mean by "Python doesn't support named > constructors". It seems to me that this is the *only* sort of > c

[Tutor] Teaching Python

2016-01-06 Thread yehudak .
My grandson Guy (8th grader) is learning Python at school. That's what made me teach myself Python programming as well. Yesterday he asked my help in his homework: Write a FOR-loop that prints all numbers up to 100 Thank you, the gods of Ctrl+C Yehuda

Re: [Tutor] Tutor Digest, Vol 143, Issue 15

2016-01-06 Thread Joel Goldstick
On Wed, Jan 6, 2016 at 9:57 AM, yehudak . wrote: > Not a question, just ranting. > > My 2 commonest coding errors are forgetting the : before a block, and > mismatch between the number of ('s and )'s. The error message is a simple > 'Syntax Error', but the line quoted is not the offending line. I

Re: [Tutor] Tutor Digest, Vol 143, Issue 15

2016-01-06 Thread yehudak .
Not a question, just ranting. My 2 commonest coding errors are forgetting the : before a block, and mismatch between the number of ('s and )'s. The error message is a simple 'Syntax Error', but the line quoted is not the offending line. I would love a much more explicit 'syntax error'. Anyone her

Re: [Tutor] method, type?

2016-01-06 Thread Steven D'Aprano
On Wed, Jan 06, 2016 at 09:59:49AM +, Alan Gauld wrote: > On 06/01/16 04:58, Alex Kleider wrote: > > > class JournalLineItem(object): > > def __init__(self, account, debit_or_credit, amount): > > self.account = account > > self.debit_or_credit = debit_or_credit > >

Re: [Tutor] method, type?

2016-01-06 Thread Steven D'Aprano
On Tue, Jan 05, 2016 at 08:58:42PM -0800, Alex Kleider wrote: > class JournalLineItem(object): > def __init__(self, account, debit_or_credit, amount): > self.account = account > self.debit_or_credit = debit_or_credit > self.amount = float(amount) > def show(self): >

Re: [Tutor] method, type?

2016-01-06 Thread Alan Gauld
On 06/01/16 04:58, Alex Kleider wrote: > class JournalLineItem(object): > def __init__(self, account, debit_or_credit, amount): > self.account = account > self.debit_or_credit = debit_or_credit > self.amount = float(amount) > ... > def get_line_item(text): >

Re: [Tutor] Python 3.5.1 64 bit?

2016-01-06 Thread Alan Gauld
On 06/01/16 07:06, yehudak . wrote: > eryk, > Thank you. > What's wrong with upgrading to newer version? There's nothing wrong with it. It's just more work and for minor releases often for very little gain. So unless you know why you are upgrading you can probably spend your time more productively

[Tutor] Thanks Alan.

2016-01-06 Thread yehudak .
I'll look into it. Yehuda ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Python 3.5.1 64 bit?

2016-01-06 Thread yehudak .
Thanks eryk. I've downloaded and installed 3.5.1 64 bit, as Alan suggested. So far no problem. I can anytime return to 3.5 if it will be needed. Yehuda On Wed, Jan 6, 2016 at 10:01 AM, eryk sun wrote: > On Wed, Jan 6, 2016 at 1:06 AM, yehudak . wrote: > > What's wrong with upgrading to newer v

Re: [Tutor] Python 3.5.1 64 bit?

2016-01-06 Thread yehudak .
eryk, Thank you. What's wrong with upgrading to newer version? Yehuda On Wed, Jan 6, 2016 at 8:32 AM, eryk sun wrote: > On Tue, Jan 5, 2016 at 5:50 PM, Alan Gauld > wrote: > > On 05/01/16 19:47, yehudak . wrote: > >> I'm using version 3.5 of Python and want to upgrade. > > > > 3.5 is the lates

Re: [Tutor] method, type?

2016-01-06 Thread Peter Otten
Alex Kleider wrote: > #!/usr/bin/env python3 > # OS: Ubuntu 10.4LTS > > # My code: > > class JournalLineItem(object): > """ > """ > > def __init__(self, account, debit_or_credit, amount): > self.account = account > self.debit_or_credit = debit_or_credit >

Re: [Tutor] Python 3.5.1 64 bit?

2016-01-06 Thread eryk sun
On Wed, Jan 6, 2016 at 1:06 AM, yehudak . wrote: > What's wrong with upgrading to newer version? It depends on how many systems and virtual environments that you're upgrading. It shouldn't be an issue if it's just a new micro release for your own development machine. If you come across a regressi