Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #62436 > unrolled thread
| Started by | dec135@msn.com |
|---|---|
| First post | 2013-12-20 07:16 -0800 |
| Last post | 2013-12-21 14:08 -0500 |
| Articles | 19 — 16 participants |
Back to article view | Back to comp.lang.python
Newbie question. Are those different objects ? dec135@msn.com - 2013-12-20 07:16 -0800
Re: Newbie question. Are those different objects ? random832@fastmail.us - 2013-12-20 10:24 -0500
Re: Newbie question. Are those different objects ? rusi <rustompmody@gmail.com> - 2013-12-20 07:34 -0800
Re: Newbie question. Are those different objects ? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-12-20 16:00 +0000
Re: Newbie question. Are those different objects ? rusi <rustompmody@gmail.com> - 2013-12-20 09:10 -0800
Re: Newbie question. Are those different objects ? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-12-20 17:29 +0000
Re: Newbie question. Are those different objects ? 88888 Dihedral <dihedral88888@gmail.com> - 2013-12-20 09:59 -0800
Re: Newbie question. Are those different objects ? Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2013-12-21 10:56 +1300
Re: Newbie question. Are those different objects ? Duncan Booth <duncan.booth@invalid.invalid> - 2013-12-23 08:19 +0000
Re: Newbie question. Are those different objects ? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-12-21 12:58 +0000
Re: Newbie question. Are those different objects ? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-12-21 11:54 -0500
Re: Newbie question. Are those different objects ? Chris Angelico <rosuav@gmail.com> - 2013-12-22 05:39 +1100
Re: Newbie question. Are those different objects ? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-12-21 19:17 +0000
Re: Newbie question. Are those different objects ? alex23 <wuwei23@gmail.com> - 2013-12-23 11:31 +1000
Re: Newbie question. Are those different objects ? Travis Griggs <travisgriggs@gmail.com> - 2013-12-20 10:24 -0800
Re: Newbie question. Are those different objects ? bob gailer <bgailer@gmail.com> - 2013-12-20 12:02 -0500
Re: Newbie question. Are those different objects ? rurpy@yahoo.com - 2013-12-20 10:06 -0800
Re: Newbie question. Are those different objects ? Terry Reedy <tjreedy@udel.edu> - 2013-12-20 16:56 -0500
Re: Newbie question. Are those different objects ? Gene Heskett <gheskett@wdtv.com> - 2013-12-21 14:08 -0500
| From | dec135@msn.com |
|---|---|
| Date | 2013-12-20 07:16 -0800 |
| Subject | Newbie question. Are those different objects ? |
| Message-ID | <af844bcf-ed55-42da-8a9f-b8270dcc4028@googlegroups.com> |
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.
[toc] | [next] | [standalone]
| From | random832@fastmail.us |
|---|---|
| Date | 2013-12-20 10:24 -0500 |
| Message-ID | <mailman.4435.1387553077.18130.python-list@python.org> |
| In reply to | #62436 |
On Fri, Dec 20, 2013, at 10:16, dec135@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.
[toc] | [prev] | [next] | [standalone]
| From | rusi <rustompmody@gmail.com> |
|---|---|
| Date | 2013-12-20 07:34 -0800 |
| Message-ID | <c2a5eae4-5caa-4ca1-b66d-5bbeb1edd261@googlegroups.com> |
| In reply to | #62436 |
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?
[toc] | [prev] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2013-12-20 16:00 +0000 |
| Message-ID | <mailman.4437.1387555241.18130.python-list@python.org> |
| In reply to | #62438 |
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
[toc] | [prev] | [next] | [standalone]
| From | rusi <rustompmody@gmail.com> |
|---|---|
| Date | 2013-12-20 09:10 -0800 |
| Message-ID | <e283ae0a-47c2-4579-b8c3-801798bdfce7@googlegroups.com> |
| In reply to | #62440 |
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
[toc] | [prev] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2013-12-20 17:29 +0000 |
| Message-ID | <mailman.4439.1387560627.18130.python-list@python.org> |
| In reply to | #62442 |
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
[toc] | [prev] | [next] | [standalone]
| From | 88888 Dihedral <dihedral88888@gmail.com> |
|---|---|
| Date | 2013-12-20 09:59 -0800 |
| Message-ID | <9a1b92a6-ab76-42ab-9ffc-b1f6a0b85a9c@googlegroups.com> |
| In reply to | #62442 |
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.
[toc] | [prev] | [next] | [standalone]
| From | Gregory Ewing <greg.ewing@canterbury.ac.nz> |
|---|---|
| Date | 2013-12-21 10:56 +1300 |
| Message-ID | <bhjsooFmprU1@mid.individual.net> |
| In reply to | #62442 |
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
[toc] | [prev] | [next] | [standalone]
| From | Duncan Booth <duncan.booth@invalid.invalid> |
|---|---|
| Date | 2013-12-23 08:19 +0000 |
| Message-ID | <XnsA29DC6900AE79duncanbooth@127.0.0.1> |
| In reply to | #62457 |
Gregory Ewing <greg.ewing@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
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2013-12-21 12:58 +0000 |
| Message-ID | <52b59081$0$6599$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #62440 |
On Fri, 20 Dec 2013 16:00:22 +0000, 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
[toc] | [prev] | [next] | [standalone]
| From | Dennis Lee Bieber <wlfraed@ix.netcom.com> |
|---|---|
| Date | 2013-12-21 11:54 -0500 |
| Message-ID | <mailman.4475.1387644850.18130.python-list@python.org> |
| In reply to | #62490 |
On 21 Dec 2013 12:58:41 GMT, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> declaimed the following:
>On Fri, 20 Dec 2013 16:00:22 +0000, 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")
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2013-12-22 05:39 +1100 |
| Message-ID | <mailman.4477.1387651158.18130.python-list@python.org> |
| In reply to | #62490 |
On Sun, Dec 22, 2013 at 3:54 AM, Dennis Lee Bieber <wlfraed@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
[toc] | [prev] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2013-12-21 19:17 +0000 |
| Message-ID | <mailman.4481.1387653458.18130.python-list@python.org> |
| In reply to | #62490 |
On 21/12/2013 16:54, Dennis Lee Bieber wrote: > On 21 Dec 2013 12:58:41 GMT, Steven D'Aprano > <steve+comp.lang.python@pearwood.info> declaimed the following: > >> On Fri, 20 Dec 2013 16:00:22 +0000, 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
[toc] | [prev] | [next] | [standalone]
| From | alex23 <wuwei23@gmail.com> |
|---|---|
| Date | 2013-12-23 11:31 +1000 |
| Message-ID | <l983pv$sp5$1@dont-email.me> |
| In reply to | #62440 |
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>
[toc] | [prev] | [next] | [standalone]
| From | Travis Griggs <travisgriggs@gmail.com> |
|---|---|
| Date | 2013-12-20 10:24 -0800 |
| Message-ID | <mailman.4443.1387563870.18130.python-list@python.org> |
| In reply to | #62438 |
On Dec 20, 2013, at 8:00 AM, Mark Lawrence <breamoreboy@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."
[toc] | [prev] | [next] | [standalone]
| From | bob gailer <bgailer@gmail.com> |
|---|---|
| Date | 2013-12-20 12:02 -0500 |
| Message-ID | <mailman.4438.1387558944.18130.python-list@python.org> |
| In reply to | #62436 |
On 12/20/2013 10:16 AM, dec135@msn.com wrote: > print type y That line will give you a syntax error.
[toc] | [prev] | [next] | [standalone]
| From | rurpy@yahoo.com |
|---|---|
| Date | 2013-12-20 10:06 -0800 |
| Message-ID | <a9b4dfa4-7941-4371-ba8c-c4700a3d4dda@googlegroups.com> |
| In reply to | #62436 |
On 12/20/2013 08:16 AM, dec135@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.
[toc] | [prev] | [next] | [standalone]
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Date | 2013-12-20 16:56 -0500 |
| Message-ID | <mailman.4445.1387576587.18130.python-list@python.org> |
| In reply to | #62436 |
On 12/20/2013 10:16 AM, dec135@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
[toc] | [prev] | [next] | [standalone]
| From | Gene Heskett <gheskett@wdtv.com> |
|---|---|
| Date | 2013-12-21 14:08 -0500 |
| Message-ID | <mailman.4484.1387661382.18130.python-list@python.org> |
| In reply to | #62436 |
On Saturday 21 December 2013 14:08:02 Chris Angelico did opine:
> On Sun, Dec 22, 2013 at 3:54 AM, Dennis Lee Bieber
>
> <wlfraed@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.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web