Re: Newbie question. Are those different objects ?
Gregory Ewing greg.ew...@canterbury.ac.nz wrote: rusi wrote: Good idea. Only you were beaten to it by about 2 decades. More than 2, I think. Algol: x := y Wher := is pronounced 'becomes'. -- Duncan Booth http://kupuguy.blogspot.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Newbie question. Are those different objects ?
On 21/12/2013 2:00 AM, Mark Lawrence wrote: Shall I write a PEP asking for a language change which requires that that stupid = sign is replaced by a keyword reading something like thenameonthelefthandsideisassignedtheobjectontherighthandside ? I propose: tag obj with name -- https://mail.python.org/mailman/listinfo/python-list
Re: Newbie question. Are those different objects ?
On Fri, 20 Dec 2013 16:00:22 +, Mark Lawrence wrote: On 20/12/2013 15:34, rusi wrote: You are also assuming that the two horizontal lines sometimes called 'equals' have something to do with something called by the same name in math -- equations A good point. Shall I write a PEP asking for a language change which requires that that stupid = sign is replaced by a keyword reading something like thenameonthelefthandsideisassignedtheobjectontherighthandside ? That's an excellent idea, and I look forward to reading the PEP. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
Re: Newbie question. Are those different objects ?
On Sun, Dec 22, 2013 at 3:54 AM, Dennis Lee Bieber wlfr...@ix.netcom.com wrote: (heh, the spell-checker suggests that thefullyqualifiednameontheleftafteranysubexpressionshavebeenevaluatedisattachedt should be replaced with textually) The spell-checker was scratching its head and going I'm pretty sure this isn't right, but I don't know enough of what it says to be sure it's quite wrong! and eventually gave up trying to understand you, and just picked a word kinda like some of the letters and said Here, have this as a suggestion, I'm off to the pub. You don't pay me enough to check words like that.. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Newbie question. Are those different objects ?
On 21/12/2013 16:54, Dennis Lee Bieber wrote: On 21 Dec 2013 12:58:41 GMT, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info declaimed the following: On Fri, 20 Dec 2013 16:00:22 +, Mark Lawrence wrote: On 20/12/2013 15:34, rusi wrote: You are also assuming that the two horizontal lines sometimes called 'equals' have something to do with something called by the same name in math -- equations A good point. Shall I write a PEP asking for a language change which requires that that stupid = sign is replaced by a keyword reading something like thenameonthelefthandsideisassignedtheobjectontherighthandside ? That's an excellent idea, and I look forward to reading the PEP. -1 vote... It still has the problematic assigned term... I'd suggest: thefullyqualifiednameontheleftafteranysubexpressionshavebeenevaluatedisattachedtotheobjectresultingfromevaluationoftheexpressionontheright (heh, the spell-checker suggests that thefullyqualifiednameontheleftafteranysubexpressionshavebeenevaluatedisattachedt should be replaced with textually) Well you can write the PEP then :) -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: Newbie question. Are those different objects ?
On Saturday 21 December 2013 14:08:02 Chris Angelico did opine: On Sun, Dec 22, 2013 at 3:54 AM, Dennis Lee Bieber wlfr...@ix.netcom.com wrote: (heh, the spell-checker suggests that thefullyqualifiednameontheleftafteranysubexpressionshavebeenevaluated isattachedt should be replaced with textually) The spell-checker was scratching its head and going I'm pretty sure this isn't right, but I don't know enough of what it says to be sure it's quite wrong! and eventually gave up trying to understand you, and just picked a word kinda like some of the letters and said Here, have this as a suggestion, I'm off to the pub. You don't pay me enough to check words like that.. ChrisA Lurking on this list is worth it just for the entertainment value, thanks Chris. :) Cheers, Gene -- There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order. -Ed Howdershelt (Author) Genes Web page http://geneslinuxbox.net:6309/gene The heart is wiser than the intellect. A pen in the hand of this president is far more dangerous than 200 million guns in the hands of law-abiding citizens. -- https://mail.python.org/mailman/listinfo/python-list
Newbie question. Are those different objects ?
y = raw_input('Enter a number:') print type y y = float(raw_input('Enter a number:')) print type y I'm assuming that y is an object. I'm also assuming that the second and the first y are different objects because they have different types. The second time we type print type y, how does the program knows which one of the y's it refers to ? Is the first y object deleted ? thanks in advance. -- https://mail.python.org/mailman/listinfo/python-list
Re: Newbie question. Are those different objects ?
On Fri, Dec 20, 2013, at 10:16, dec...@msn.com wrote: The second time we type print type y, how does the program knows which one of the y's it refers to ? Is the first y object deleted ? y does not refer to the first object anymore after you've assigned the second object to it. In CPython, if there are no other references to the string object, yes it is deleted - other implementations may defer deletion to a later time. -- https://mail.python.org/mailman/listinfo/python-list
Re: Newbie question. Are those different objects ?
On Friday, December 20, 2013 8:46:31 PM UTC+5:30, dec...@msn.com wrote: y = raw_input('Enter a number:') print type y y = float(raw_input('Enter a number:')) print type y I'm assuming that y is an object. I'm also assuming that the second and the first y are different objects because they have different types. You are also assuming that the two horizontal lines sometimes called 'equals' have something to do with something called by the same name in math -- equations Lets unassume that and rewrite the code 1. y ! raw_input('Enter a number:') 2. print type y 3. y ! float(raw_input('Enter a number:')) 4. print type y Now read that 1 as first, 2 as second etc and read the '!' as 'MAKE'. (It may help to shout it) Now what was your question? -- https://mail.python.org/mailman/listinfo/python-list
Re: Newbie question. Are those different objects ?
On 20/12/2013 15:34, rusi wrote: On Friday, December 20, 2013 8:46:31 PM UTC+5:30, dec...@msn.com wrote: y = raw_input('Enter a number:') print type y y = float(raw_input('Enter a number:')) print type y I'm assuming that y is an object. I'm also assuming that the second and the first y are different objects because they have different types. You are also assuming that the two horizontal lines sometimes called 'equals' have something to do with something called by the same name in math -- equations A good point. Shall I write a PEP asking for a language change which requires that that stupid = sign is replaced by a keyword reading something like thenameonthelefthandsideisassignedtheobjectontherighthandside ? Lets unassume that and rewrite the code 1. y ! raw_input('Enter a number:') 2. print type y 3. y ! float(raw_input('Enter a number:')) 4. print type y Now read that 1 as first, 2 as second etc and read the '!' as 'MAKE'. (It may help to shout it) Now what was your question? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: Newbie question. Are those different objects ?
On 12/20/2013 10:16 AM, dec...@msn.com wrote: print type y That line will give you a syntax error. -- https://mail.python.org/mailman/listinfo/python-list
Re: Newbie question. Are those different objects ?
On Friday, December 20, 2013 9:30:22 PM UTC+5:30, Mark Lawrence wrote: On 20/12/2013 15:34, rusi wrote: On Friday, December 20, 2013 8:46:31 PM UTC+5:30, dec...@msn.com wrote: y = raw_input('Enter a number:') print type y y = float(raw_input('Enter a number:')) print type y I'm assuming that y is an object. I'm also assuming that the second and the first y are different objects because they have different types. You are also assuming that the two horizontal lines sometimes called 'equals' have something to do with something called by the same name in math -- equations A good point. Shall I write a PEP asking for a language change which requires that that stupid = sign is replaced by a keyword reading something like thenameonthelefthandsideisassignedtheobjectontherighthandside ? Good idea. Only you were beaten to it by about 2 decades. The language ABC calls it 'put' and corrects the unnecessary gratuitous right to left order. Reference http://homepages.cwi.nl/~steven/abc/qr.html#COMMANDS Examples http://homepages.cwi.nl/~steven/abc/types.html And what does that have to do with python? http://www.onlamp.com/lpt/a/2431 -- https://mail.python.org/mailman/listinfo/python-list
Re: Newbie question. Are those different objects ?
On 20/12/2013 17:10, rusi wrote: On Friday, December 20, 2013 9:30:22 PM UTC+5:30, Mark Lawrence wrote: On 20/12/2013 15:34, rusi wrote: On Friday, December 20, 2013 8:46:31 PM UTC+5:30, dec...@msn.com wrote: y = raw_input('Enter a number:') print type y y = float(raw_input('Enter a number:')) print type y I'm assuming that y is an object. I'm also assuming that the second and the first y are different objects because they have different types. You are also assuming that the two horizontal lines sometimes called 'equals' have something to do with something called by the same name in math -- equations A good point. Shall I write a PEP asking for a language change which requires that that stupid = sign is replaced by a keyword reading something like thenameonthelefthandsideisassignedtheobjectontherighthandside ? Good idea. Only you were beaten to it by about 2 decades. I can't find a PEP suggesting this, can you give me the number please? The language ABC calls it 'put' and corrects the unnecessary gratuitous right to left order. So does it go top to bottom or bottom to top? Or to really clarify things does it have putlr, putrl, puttb and putbt? Reference http://homepages.cwi.nl/~steven/abc/qr.html#COMMANDS Examples http://homepages.cwi.nl/~steven/abc/types.html And what does that have to do with python? http://www.onlamp.com/lpt/a/2431 -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: Newbie question. Are those different objects ?
On Saturday, December 21, 2013 1:10:37 AM UTC+8, rusi wrote: On Friday, December 20, 2013 9:30:22 PM UTC+5:30, Mark Lawrence wrote: On 20/12/2013 15:34, rusi wrote: On Friday, December 20, 2013 8:46:31 PM UTC+5:30, dec...@msn.com wrote: y = raw_input('Enter a number:') print type y y = float(raw_input('Enter a number:')) print type y I'm assuming that y is an object. I'm also assuming that the second and the first y are different objects because they have different types. Well, in Python the assignment operation = of a variable named y in the LHS to the object of the RHS result is more complicated than = in those register basd low level languages designed for fast execution speeds in compiled machine codes without an auto GC bundled with the interpreter in the run time. -- https://mail.python.org/mailman/listinfo/python-list
Re: Newbie question. Are those different objects ?
On 12/20/2013 08:16 AM, dec...@msn.com wrote: y = raw_input('Enter a number:') print type y y = float(raw_input('Enter a number:')) print type y I'm assuming that y is an object. Rather than thinking that y is an object, it is more accurate to think of it as: y is a name that is bound to (ie, refers to, points to) an object. So, raw_input() creates a string object and returns it. Your first assignment statement binds that string object to the name y. From now on, when you refer to y you will get that string object. When python executes your 3rd line, raw_input() creates a new string object, completely separate from the earlier one. This object is passed to float(). Float() reads it and creates a new float object and returns it. When python then executes your second assignment statement, it changes the binding of y to point to the float object; the old binding to the string object is lost. From now on, when you refer to y you will get the float object. I'm also assuming that the second and the first y are different objects because they have different types. Yes, they are different objects. But not because they have different types; they are different because every time python creates a new object it is distinct from other objects [*1]. The second time we type print type y, how does the program knows which one of the y's it refers to ? Because there is only one name y, and when python executed your second assignment statement, it changed the object that the name y pointed to from the first (string) object to the second (float) one. Is the first y object deleted ? thanks in advance. Yes. If there is no way that the first object can be accessed any more, then it will be deleted. The same thing happened to the string object return by raw_input() in your 3rd statement (which never had a name at all). [*1] My statement was an oversimplification. There are some cases where Python will return the same object such as interned objects and objects like None for which there is only ever a single instance in a Python program. -- https://mail.python.org/mailman/listinfo/python-list
Re: Newbie question. Are those different objects ?
On Dec 20, 2013, at 8:00 AM, Mark Lawrence breamore...@yahoo.co.uk wrote: A good point. Shall I write a PEP asking for a language change which requires that that stupid = sign is replaced by a keyword reading something like thenameonthelefthandsideisassignedtheobjectontherighthandside ? Or a symbol like :=. As a former Smalltalker, I still miss this as the assignment operator, and the “gets” verbiage that went along with it. One said: x := 4 as in “x gets 4” I always got a kick out of the following paragraph from http://james-iry.blogspot.com/2009/05/brief-incomplete-and-mostly-wrong.html. 1970 - Niklaus Wirth creates Pascal, a procedural language. Critics immediately denounce Pascal because it uses x := x + y syntax instead of the more familiar C-like x = x + y. This criticism happens in spite of the fact that C has not yet been invented. -- https://mail.python.org/mailman/listinfo/python-list
Re: Newbie question. Are those different objects ?
On 12/20/2013 10:16 AM, dec...@msn.com wrote: y = raw_input('Enter a number:') print type y y = float(raw_input('Enter a number:')) print type y I recommend starting with 3.3 unless your are forced to use 2.x. I also recommend trying code before posting it. I'm assuming that y is an object. The name 'y' is bound to an object. The second assignment rebinds 'y' to a different object. I'm also assuming that the second and the first y are different objects It depends on whether by 'y' you mean the name, which remains the same, or the object it is bound to, which changes. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Newbie question. Are those different objects ?
rusi wrote: Good idea. Only you were beaten to it by about 2 decades. More than 2, I think. Lisp: (setq x y) Algol: x := y Smalltalk: x - y (where - is a left arrow character) Cobol: MOVE X TO Y -- Greg -- https://mail.python.org/mailman/listinfo/python-list