Re: What is the semantics meaning of 'object'?

2013-06-22 Thread Ian Kelly
On Sat, Jun 22, 2013 at 11:23 PM, Steven D'Aprano wrote: > On Sat, 22 Jun 2013 22:27:10 -0600, Ian Kelly wrote: >> I actually consider that an up side. Sure it's inconvenient that you >> can't delegate all such methods at once just by overriding >> __getattribute__, but it would be more troubleso

Re: What is the semantics meaning of 'object'?

2013-06-22 Thread Steven D'Aprano
On Sat, 22 Jun 2013 22:27:10 -0600, Ian Kelly wrote: > On Sat, Jun 22, 2013 at 9:20 PM, Steven D'Aprano > wrote: >> * on the down side, automatic delegation of special double-underscore >> methods like __getitem__ and __str__ doesn't work with new-style >> classes. > > I actually consider that a

Re: What is the semantics meaning of 'object'?

2013-06-22 Thread Ian Kelly
On Sat, Jun 22, 2013 at 9:20 PM, Steven D'Aprano wrote: > * on the down side, automatic delegation of special double-underscore > methods like __getitem__ and __str__ doesn't work with new-style classes. I actually consider that an up side. Sure it's inconvenient that you can't delegate all such

Re: n00b question on spacing

2013-06-22 Thread Chris Angelico
On Sun, Jun 23, 2013 at 12:58 PM, Steven D'Aprano wrote: > On Sun, 23 Jun 2013 02:20:56 +0100, MRAB wrote: > >> One vs not-one isn't good enough. Some languages use the singular with >> any numbers ending in '1'. Some languages have singular, dual, and >> plural. Etc. It's surprising how inventive

Re: n00b question on spacing

2013-06-22 Thread Chris Angelico
On Sun, Jun 23, 2013 at 1:22 PM, Steven D'Aprano wrote: > On Sat, 22 Jun 2013 23:12:49 -0400, Roy Smith wrote: > >> In article <51c66455$0$2$c3e8da3$54964...@news.astraweb.com>, >> Steven D'Aprano wrote: >> >>> http://infiniteundo.com/post/25326999628/falsehoods-programmers- > believe-about-

Re: n00b question on spacing

2013-06-22 Thread Steven D'Aprano
On Sat, 22 Jun 2013 23:12:49 -0400, Roy Smith wrote: > In article <51c66455$0$2$c3e8da3$54964...@news.astraweb.com>, > Steven D'Aprano wrote: > >> http://infiniteundo.com/post/25326999628/falsehoods-programmers- believe-about- >> time > > Number 2 on the list is "Months have either 30 or 3

Re: What is the semantics meaning of 'object'?

2013-06-22 Thread Steven D'Aprano
On Sat, 22 Jun 2013 19:58:38 -0700, Adam wrote: > class FooBar(object): > def __init__(self): > ... > > Inheritance usually takes a class name to indicate which class is the > 'parent' class. However, in the previous example, from a django book, > the class actually takes an 'object'

Re: n00b question on spacing

2013-06-22 Thread Roy Smith
In article <51c66455$0$2$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > http://infiniteundo.com/post/25326999628/falsehoods-programmers-believe-about- > time Number 2 on the list is "Months have either 30 or 31 days", which was obviously believed by whoever made this sign: h

Re: newbie question

2013-06-22 Thread Steven D'Aprano
On Sat, 22 Jun 2013 19:39:30 -0700, christhecomic wrote: > Writing simple program asking a question with the answer being > "yes"...how do I allow the correct answer if user types Yes, yes, or > YES? Take the user's input, strip off any whitespace from the beginning and end, then fold the case t

What is the semantics meaning of 'object'?

2013-06-22 Thread Adam
class FooBar(object): def __init__(self): ... Inheritance usually takes a class name to indicate which class is the 'parent' class. However, in the previous example, from a django book, the class actually takes an 'object' like parameter, doesn't it? What is the semantics meaning of

Re: n00b question on spacing

2013-06-22 Thread Steven D'Aprano
On Sun, 23 Jun 2013 02:20:56 +0100, MRAB wrote: > One vs not-one isn't good enough. Some languages use the singular with > any numbers ending in '1'. Some languages have singular, dual, and > plural. Etc. It's surprising how inventive people can be! :-) This is a good time to link to these intere

Re: newbie question

2013-06-22 Thread Rick Johnson
On Saturday, June 22, 2013 9:39:30 PM UTC-5, christ...@gmail.com wrote: > Writing simple program asking a question with the answer being > "yes"...how do I allow the correct answer if user types Yes, > yes, or YES? Here is a clue. py> 'e' == 'e' True py> 'E' == 'E' True -- http://mail.p

Re: newbie question

2013-06-22 Thread Chris Angelico
On Sun, Jun 23, 2013 at 12:39 PM, wrote: > Writing simple program asking a question with the answer being "yes"...how do > I allow the correct answer if user types Yes, yes, or YES? The thing you're looking for is case-folding, or possibly lower-casing. You should be able to find what you want

newbie question

2013-06-22 Thread christhecomic
Writing simple program asking a question with the answer being "yes"...how do I allow the correct answer if user types Yes, yes, or YES? Thanks -- http://mail.python.org/mailman/listinfo/python-list

Re: n00b question on spacing

2013-06-22 Thread Chris Angelico
On Sun, Jun 23, 2013 at 10:48 AM, Rick Johnson wrote: > On Saturday, June 22, 2013 6:12:50 PM UTC-5, Chris Angelico wrote: >> As a general rule, I don't like separating format strings and their >> arguments. > > Huh? Format strings don't take arguments because Python's built-in string > type is n

Re: How can i fix this?

2013-06-22 Thread Борислав Бориславов
okay i got it thank you all :)) -- http://mail.python.org/mailman/listinfo/python-list

Re: n00b question on spacing

2013-06-22 Thread Dave Angel
On 06/22/2013 09:20 PM, MRAB wrote: On 23/06/2013 00:56, Dave Angel wrote: Certainly the reorderability of the format string is significant. Not only can it be reordered, but more than one instance of some of the values is permissible if needed. (What's missing is a decent handling of

Re: n00b question on spacing

2013-06-22 Thread MRAB
On 23/06/2013 00:56, Dave Angel wrote: On 06/22/2013 07:37 PM, Chris Angelico wrote: On Sun, Jun 23, 2013 at 9:28 AM, Dave Angel wrote: On 06/22/2013 07:12 PM, Chris Angelico wrote: On Sun, Jun 23, 2013 at 1:24 AM, Rick Johnson wrote: _fmtstr = "Item wrote to MongoDB database {0}, {1}

Re: How can i fix this?

2013-06-22 Thread John Gordon
In <54f1fb77-355b-4796-824f-1ee29c402...@googlegroups.com> =?UTF-8?B?0JHQvtGA0LjRgdC70LDQsiDQkdC+0YDQuNGB0LvQsNCy0L7Qsg==?= writes: > > > while 1: > > > name=raw_input("What is your name? ") > > > if name == "bobi": > > print "Hello Master!" > > break > > > else:

Re: Default Value

2013-06-22 Thread Rotwang
On 22/06/2013 19:49, Rick Johnson wrote: On Saturday, June 22, 2013 12:19:31 PM UTC-5, Rotwang wrote: On 22/06/2013 02:15, Rick Johnson wrote: IS ALL THIS REGISTERING YET? DO YOU UNDERSTAND? No, I don't. These two special cases are not sufficient for me to determine what semantics you are prop

Re: n00b question on spacing

2013-06-22 Thread Rick Johnson
On Saturday, June 22, 2013 6:12:50 PM UTC-5, Chris Angelico wrote: > As a general rule, I don't like separating format strings and their > arguments. Huh? Format strings don't take arguments because Python's built-in string type is not callable. py> callable("") False "Format string" is ju

Re: n00b question on spacing

2013-06-22 Thread Dave Angel
On 06/22/2013 08:27 PM, Chris Angelico wrote: On Sun, Jun 23, 2013 at 9:56 AM, Dave Angel wrote: On 06/22/2013 07:37 PM, Chris Angelico wrote: On the contrary, i18n should be done with config files. The format string **as specified in the physical program** is the key to the actual stri

Re: n00b question on spacing

2013-06-22 Thread Chris Angelico
On Sun, Jun 23, 2013 at 9:56 AM, Dave Angel wrote: > On 06/22/2013 07:37 PM, Chris Angelico wrote: >>> On the contrary, i18n should be done with config files. The format >>> string > > > **as specified in the physical program** > > >>> is the key to the actual string which is located in the file/

Re: n00b question on spacing

2013-06-22 Thread Dave Angel
On 06/22/2013 07:37 PM, Chris Angelico wrote: On Sun, Jun 23, 2013 at 9:28 AM, Dave Angel wrote: On 06/22/2013 07:12 PM, Chris Angelico wrote: On Sun, Jun 23, 2013 at 1:24 AM, Rick Johnson wrote: _fmtstr = "Item wrote to MongoDB database {0}, {1}" msg = _fmtstr.format(_arg1, _arg2)

Re: n00b question on spacing

2013-06-22 Thread Chris Angelico
On Sun, Jun 23, 2013 at 9:28 AM, Dave Angel wrote: > On 06/22/2013 07:12 PM, Chris Angelico wrote: >> >> On Sun, Jun 23, 2013 at 1:24 AM, Rick Johnson >> wrote: >>> >>>_fmtstr = "Item wrote to MongoDB database {0}, {1}" >>>msg = _fmtstr.format(_arg1, _arg2) >> >> >> As a general rule, I d

Re: n00b question on spacing

2013-06-22 Thread Dave Angel
On 06/22/2013 07:12 PM, Chris Angelico wrote: On Sun, Jun 23, 2013 at 1:24 AM, Rick Johnson wrote: _fmtstr = "Item wrote to MongoDB database {0}, {1}" msg = _fmtstr.format(_arg1, _arg2) As a general rule, I don't like separating format strings and their arguments. That's one of the more

Re: n00b question on spacing

2013-06-22 Thread Chris Angelico
On Sun, Jun 23, 2013 at 1:24 AM, Rick Johnson wrote: > _fmtstr = "Item wrote to MongoDB database {0}, {1}" > msg = _fmtstr.format(_arg1, _arg2) As a general rule, I don't like separating format strings and their arguments. That's one of the more annoying costs of i18n. Keep them in a single e

Re: How can i fix this?

2013-06-22 Thread Ian Kelly
On Sat, Jun 22, 2013 at 3:50 PM, Борислав Бориславов wrote: > this doesent help me at all It shows you how to include multiple statements in the body of the if block. If you're having trouble getting it to work, then please copy and paste the exact code that you're running for us along with the

Re: How can i fix this?

2013-06-22 Thread Борислав Бориславов
23 юни 2013, неделя, 00:46:37 UTC+3, Peter Otten написа: > Борислав Бориславов wrote: > > > > > while 1: > > > name=raw_input("What is your name? ") > > > if name == "bobi": print "Hello Master!" and break > > > else: print "error" > > > > > I want if my conditions are met to d

Re: How can i fix this?

2013-06-22 Thread Mark Lawrence
On 22/06/2013 22:31, Борислав Бориславов wrote: while 1: name=raw_input("What is your name? ") if name == "bobi": print "Hello Master!" and break else: print "error" I want if my conditions are met to do a couple of things and i cant do that You most certainly can :) while 1:

Re: How can i fix this?

2013-06-22 Thread Peter Otten
Борислав Бориславов wrote: > while 1: > name=raw_input("What is your name? ") > if name == "bobi": print "Hello Master!" and break > else: print "error" > I want if my conditions are met to do a couple of things and i cant do > that > while 1: > name=raw_input("What is your name?

How can i fix this?

2013-06-22 Thread Борислав Бориславов
while 1: name=raw_input("What is your name? ") if name == "bobi": print "Hello Master!" and break else: print "error" I want if my conditions are met to do a couple of things and i cant do that -- http://mail.python.org/mailman/listinfo/python-list

Re: Default Value

2013-06-22 Thread MRAB
On 22/06/2013 03:32, Rick Johnson wrote: On Friday, June 21, 2013 8:54:50 PM UTC-5, MRAB wrote: On 22/06/2013 00:51, Rick Johnson wrote: > On Friday, June 21, 2013 5:49:51 PM UTC-5, MRAB wrote: > My argument has always been that mutables should not be > passed into subroutines as default argumen

Re: n00b question on spacing

2013-06-22 Thread Ned Deily
In article , Mark Janssen wrote: > > Also remember when entering long lines of text that strings concatenate > > within parenthesis. > > So, > > ("a, b, c" > > "d, e, f" > > "g, h, i") > > > > Is the same as ("a, b, cd, e, fg, h, i") > There was a recent discussion about this (under "implicit s

Re: Default Value

2013-06-22 Thread Ian Kelly
On Sat, Jun 22, 2013 at 10:49 AM, Dennis Lee Bieber wrote: > On Fri, 21 Jun 2013 19:27:42 -0600, Ian Kelly > declaimed the following: > >>While we're at it, I would like to petition for a function >>terminates(f, args) that I can use to determine whether a function >>will terminate before I actua

Re: Default Value

2013-06-22 Thread Rick Johnson
On Saturday, June 22, 2013 12:19:31 PM UTC-5, Rotwang wrote: > > On 22/06/2013 02:15, Rick Johnson wrote: > > IS ALL THIS REGISTERING YET? DO YOU UNDERSTAND? > > No, I don't. These two special cases are not sufficient > for me to determine what semantics you are proposing for > the general case.

Re: n00b question on spacing

2013-06-22 Thread Joshua Landau
On 22 June 2013 18:28, Alister wrote: > On Sat, 22 Jun 2013 17:11:00 +0100, Joshua Landau wrote: > >> On 22 June 2013 16:55, Rick Johnson >> wrote: >>> On Saturday, June 22, 2013 10:40:24 AM UTC-5, Joshua Landau wrote: > Plus, your use of the format syntax is incorrect. Wut? >>> >>> Wel

Re: n00b question on spacing

2013-06-22 Thread Mark Janssen
> Also remember when entering long lines of text that strings concatenate > within parenthesis. > So, > ("a, b, c" > "d, e, f" > "g, h, i") > > Is the same as ("a, b, cd, e, fg, h, i") There was a recent discussion about this (under "implicit string concatenation"). It seems this is a part of the

Re: n00b question on spacing

2013-06-22 Thread Alister
On Sat, 22 Jun 2013 17:11:00 +0100, Joshua Landau wrote: > On 22 June 2013 16:55, Rick Johnson > wrote: >> On Saturday, June 22, 2013 10:40:24 AM UTC-5, Joshua Landau wrote: >>> > Plus, your use of the format syntax is incorrect. >>> Wut? >> >> Well what i mean exactly is not that it's illegal, i

Re: Default Value

2013-06-22 Thread Rotwang
On 22/06/2013 03:01, I wrote: On 22/06/2013 02:15, Rick Johnson wrote: [...] This is what should happen: py> def foo(arg=[]): ... arg.append(1) ... print(arg) ... py> foo() [1] py> foo() [1] py> foo() [1] Yes, Yes, YES! That is intuiti

Re: Default Value

2013-06-22 Thread rusi
On Saturday, June 22, 2013 8:37:20 PM UTC+5:30, Rick Johnson wrote: > I sorry, but FP is not going to wash our sins clean. In > fact, if taken too seriously, FP leads to preaching > professors, intellectually unstimulated students, and > semesters of wasted time that could have been better spent >

Re: n00b question on spacing

2013-06-22 Thread Joshua Landau
On 22 June 2013 16:55, Rick Johnson wrote: > On Saturday, June 22, 2013 10:40:24 AM UTC-5, Joshua Landau wrote: >> > Plus, your use of the format syntax is incorrect. >> Wut? > > Well what i mean exactly is not that it's illegal, i just > find the use of the "getattr sugar", from WITHIN the format

Re: n00b question on spacing

2013-06-22 Thread Rick Johnson
On Saturday, June 22, 2013 10:40:24 AM UTC-5, Joshua Landau wrote: > > Plus, your use of the format syntax is incorrect. > Wut? Well what i mean exactly is not that it's illegal, i just find the use of the "getattr sugar", from WITHIN the format string, to be excessively noisy. In short, i don't

Re: n00b question on spacing

2013-06-22 Thread Joshua Landau
On 22 June 2013 14:36, Joshua Landau wrote: > My favourite way would be along the lines of: > > message = "Item wrote to MongoDB database " > message += "{0[MONGODB_DB]}/{0[MONGODB_COLLECTION]}".format(settings) > log.msg(message, level=log.DEBUG, spider=spider) To make a habit of replying to mys

Re: n00b question on spacing

2013-06-22 Thread Joshua Landau
On 22 June 2013 16:24, Rick Johnson wrote: > On Saturday, June 22, 2013 8:36:43 AM UTC-5, Joshua Landau wrote: >> message = "Item wrote to MongoDB database " >> message += "{0[MONGODB_DB]}/{0[MONGODB_COLLECTION]}".format(settings) >> log.msg(message, level=log.DEBUG, spider=spider) > > If you're g

Re: Default Value

2013-06-22 Thread rusi
On Saturday, June 22, 2013 8:37:20 PM UTC+5:30, Rick Johnson wrote: > > So for example, if the use-case contained a statement > > like: In order to safeguard customer-satisfaction, the > > ATM's performance shall not degrade beyond 3 seconds > > response time. > > So now - according to our methodol

Re: n00b question on spacing

2013-06-22 Thread Rick Johnson
On Saturday, June 22, 2013 8:36:43 AM UTC-5, Joshua Landau wrote: > message = "Item wrote to MongoDB database " > message += "{0[MONGODB_DB]}/{0[MONGODB_COLLECTION]}".format(settings) > log.msg(message, level=log.DEBUG, spider=spider) If you're going to whore out parts of the string to variables i

Re: Default Value

2013-06-22 Thread Rick Johnson
> See my blog [...] > for a history of wishes akin to yours and lessons not > learnt. In short the problems accruing from unconstrained > imperative programming are severe and the solutions are > hard. In the meanwhile, goals such as your 'keep- > procedures-stateless' can and should certainly be >

Re: Default Value

2013-06-22 Thread Antoon Pardon
Op 22-06-13 03:27, Ian Kelly schreef: On Fri, Jun 21, 2013 at 7:15 PM, Steven D'Aprano wrote: On Fri, 21 Jun 2013 23:49:51 +0100, MRAB wrote: On 21/06/2013 21:44, Rick Johnson wrote: [...] Which in Python would be the "MutableArgumentWarning". *school-bell* I notice that you've omitted

Re: n00b question on spacing

2013-06-22 Thread Mark Lawrence
On 22/06/2013 14:36, Joshua Landau wrote: On 21 June 2013 23:26, Gary Herron wrote: On 06/21/2013 02:17 PM, Yves S. Garret wrote: I have the following line of code: log.msg("Item wrote to MongoDB database %s/%s" %(settings['MONGODB_DB'], settings['MONGODB_COLLECTION']), level=log.DEBUG, spider

Re: n00b question on spacing

2013-06-22 Thread Joshua Landau
On 22 June 2013 14:36, Joshua Landau wrote: > message = "Item wrote to MongoDB database " Pedant's note: "Item *written* to MongoDB database" -- http://mail.python.org/mailman/listinfo/python-list

Re: n00b question on spacing

2013-06-22 Thread Joshua Landau
On 21 June 2013 23:26, Gary Herron wrote: > On 06/21/2013 02:17 PM, Yves S. Garret wrote: >> I have the following line of code: >> log.msg("Item wrote to MongoDB database %s/%s" %(settings['MONGODB_DB'], >> settings['MONGODB_COLLECTION']), level=log.DEBUG, spider=spider) <...> >> I was thinking of

Re: Simple I/O problem can't get solved

2013-06-22 Thread Peter Otten
Chris Angelico wrote: > On Fri, Jun 21, 2013 at 7:15 PM, Peter Otten <__pete...@web.de> wrote: >> Combining these modifications: >> >> for line in f: >> word = line.strip() >> if is_palindrome.is_palindrome(word): >> print word > > Minor quibble: I wouldn't use the name 'word' her

Re: Simple I/O problem can't get solved

2013-06-22 Thread Chris Angelico
On Fri, Jun 21, 2013 at 7:15 PM, Peter Otten <__pete...@web.de> wrote: > Combining these modifications: > > for line in f: > word = line.strip() > if is_palindrome.is_palindrome(word): > print word Minor quibble: I wouldn't use the name 'word' here, unless you're expecting the file

Re: Default Value

2013-06-22 Thread Mark Lawrence
On 22/06/2013 02:31, Steven D'Aprano wrote: On Sat, 22 Jun 2013 05:07:59 +1000, Chris Angelico wrote: Oh! I know. Function argument defaults will now be restricted to int/float/tuple. That would do it, right? Nobody would be bothered by little restrictions like that, would they. Alas, tuples

Re: n00b question on spacing

2013-06-22 Thread Ben Finney
"Yves S. Garret" writes: > I have the following line of code: > log.msg("Item wrote to MongoDB database %s/%s" %(settings['MONGODB_DB'], > settings['MONGODB_COLLECTION']), level=log.DEBUG, spider=spider) […] > Is this ok? Are there any rules in Python when it comes to breaking up > long lines of