Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #91044 > unrolled thread
| Started by | Steven D'Aprano <steve@pearwood.info> |
|---|---|
| First post | 2015-05-23 00:58 +1000 |
| Last post | 2015-05-22 21:33 -0600 |
| Articles | 17 on this page of 77 — 24 participants |
Back to article view | Back to comp.lang.python
Ah Python, you have spoiled me for all other languages Steven D'Aprano <steve@pearwood.info> - 2015-05-23 00:58 +1000
Re: Ah Python, you have spoiled me for all other languages Chris Angelico <rosuav@gmail.com> - 2015-05-23 01:29 +1000
Re: Ah Python, you have spoiled me for all other languages wxjmfauth@gmail.com - 2015-05-22 10:57 -0700
Re: Ah Python, you have spoiled me for all other languages Tim Daneliuk <tundra@tundraware.com> - 2015-05-22 16:40 -0500
Re: Ah Python, you have spoiled me for all other languages Tim Daneliuk <tundra@tundraware.com> - 2015-05-22 16:40 -0500
Re: Ah Python, you have spoiled me for all other languages Terry Reedy <tjreedy@udel.edu> - 2015-05-22 21:54 -0400
Re: Ah Python, you have spoiled me for all other languages Tim Daneliuk <tundra@tundraware.com> - 2015-05-23 06:12 -0500
Re: Ah Python, you have spoiled me for all other languages Tim Daneliuk <tundra@tundraware.com> - 2015-05-23 06:12 -0500
Re: Ah Python, you have spoiled me for all other languages Terry Reedy <tjreedy@udel.edu> - 2015-05-23 13:26 -0400
Re: Ah Python, you have spoiled me for all other languages Michael Torrie <torriem@gmail.com> - 2015-05-22 21:31 -0600
Re: Ah Python, you have spoiled me for all other languages Johannes Bauer <dfnsonfsduifb@gmx.de> - 2015-05-23 08:55 +0200
Re: Ah Python, you have spoiled me for all other languages Tim Daneliuk <tundra@tundraware.com> - 2015-05-23 06:21 -0500
Re: Ah Python, you have spoiled me for all other languages Johannes Bauer <dfnsonfsduifb@gmx.de> - 2015-05-23 15:24 +0200
Re: Ah Python, you have spoiled me for all other languages Marko Rauhamaa <marko@pacujo.net> - 2015-05-23 20:05 +0300
Re: Ah Python, you have spoiled me for all other languages Johannes Bauer <dfnsonfsduifb@gmx.de> - 2015-05-24 20:29 +0200
Re: Ah Python, you have spoiled me for all other languages Marko Rauhamaa <marko@pacujo.net> - 2015-05-23 15:44 +0300
Re: Ah Python, you have spoiled me for all other languages Johannes Bauer <dfnsonfsduifb@gmx.de> - 2015-05-23 15:17 +0200
Re: Ah Python, you have spoiled me for all other languages Steven D'Aprano <steve@pearwood.info> - 2015-05-24 00:00 +1000
Re: Ah Python, you have spoiled me for all other languages Marko Rauhamaa <marko@pacujo.net> - 2015-05-23 19:53 +0300
Re: Ah Python, you have spoiled me for all other languages Chris Angelico <rosuav@gmail.com> - 2015-05-24 03:41 +1000
Re: Ah Python, you have spoiled me for all other languages Marko Rauhamaa <marko@pacujo.net> - 2015-05-23 22:02 +0300
Re: Ah Python, you have spoiled me for all other languages Steven D'Aprano <steve@pearwood.info> - 2015-05-24 20:26 +1000
Re: Ah Python, you have spoiled me for all other languages Marko Rauhamaa <marko@pacujo.net> - 2015-05-24 18:26 +0300
Re: Ah Python, you have spoiled me for all other languages Chris Angelico <rosuav@gmail.com> - 2015-05-25 01:35 +1000
Re: Ah Python, you have spoiled me for all other languages Marko Rauhamaa <marko@pacujo.net> - 2015-05-25 09:57 +0300
Re: Ah Python, you have spoiled me for all other languages Laura Creighton <lac@openend.se> - 2015-05-25 11:39 +0200
Re: Ah Python, you have spoiled me for all other languages Chris Angelico <rosuav@gmail.com> - 2015-05-25 21:09 +1000
Re: Ah Python, you have spoiled me for all other languages Michael Torrie <torriem@gmail.com> - 2015-05-23 21:00 -0600
Re: Ah Python, you have spoiled me for all other languages Marko Rauhamaa <marko@pacujo.net> - 2015-05-24 11:23 +0300
Re: Ah Python, you have spoiled me for all other languages Ian Kelly <ian.g.kelly@gmail.com> - 2015-05-22 22:10 -0600
Re: Ah Python, you have spoiled me for all other languages amber <amber.of.luxor@gmail.com> - 2015-05-23 04:11 +0000
Re: Ah Python, you have spoiled me for all other languages Tim Daneliuk <tundra@tundraware.com> - 2015-05-23 06:11 -0500
Re: Ah Python, you have spoiled me for all other languages Tim Daneliuk <tundra@tundraware.com> - 2015-05-23 06:11 -0500
Re: Ah Python, you have spoiled me for all other languages Ben Finney <ben+python@benfinney.id.au> - 2015-05-23 14:20 +1000
Re: Ah Python, you have spoiled me for all other languages Michael Torrie <torriem@gmail.com> - 2015-05-22 22:30 -0600
Re: Ah Python, you have spoiled me for all other languages Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2015-05-23 11:10 +0000
Re: Ah Python, you have spoiled me for all other languages Tim Chase <python.list@tim.thechases.com> - 2015-05-23 06:34 -0500
Re: Ah Python, you have spoiled me for all other languages Chris Angelico <rosuav@gmail.com> - 2015-05-23 21:40 +1000
Re: Ah Python, you have spoiled me for all other languages Michael Torrie <torriem@gmail.com> - 2015-05-23 20:57 -0600
Re: Ah Python, you have spoiled me for all other languages Ian Kelly <ian.g.kelly@gmail.com> - 2015-05-24 01:22 -0600
Re: Ah Python, you have spoiled me for all other languages Ian Kelly <ian.g.kelly@gmail.com> - 2015-05-22 22:29 -0600
Re: Ah Python, you have spoiled me for all other languages Ian Kelly <ian.g.kelly@gmail.com> - 2015-05-22 22:49 -0600
Re: Ah Python, you have spoiled me for all other languages Chris Angelico <rosuav@gmail.com> - 2015-05-23 14:49 +1000
Re: Ah Python, you have spoiled me for all other languages Tim Daneliuk <tundra@tundraware.com> - 2015-05-23 06:29 -0500
Re: Ah Python, you have spoiled me for all other languages Chris Angelico <rosuav@gmail.com> - 2015-05-23 14:55 +1000
Re: Ah Python, you have spoiled me for all other languages Chris Angelico <rosuav@gmail.com> - 2015-05-23 14:28 +1000
Re: Ah Python, you have spoiled me for all other languages Chris Angelico <rosuav@gmail.com> - 2015-05-23 14:21 +1000
Re: Ah Python, you have spoiled me for all other languages Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-05-23 14:33 +0200
Re: Ah Python, you have spoiled me for all other languages Steven D'Aprano <steve@pearwood.info> - 2015-05-23 23:01 +1000
Re: Ah Python, you have spoiled me for all other languages Chris Angelico <rosuav@gmail.com> - 2015-05-23 23:12 +1000
Re: Ah Python, you have spoiled me for all other languages wxjmfauth@gmail.com - 2015-05-23 23:37 -0700
Re: Ah Python, you have spoiled me for all other languages Ned Batchelder <ned@nedbatchelder.com> - 2015-05-23 06:35 -0700
Re: Ah Python, you have spoiled me for all other languages Steven D'Aprano <steve@pearwood.info> - 2015-05-24 00:09 +1000
Re: Ah Python, you have spoiled me for all other languages Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-06-07 10:21 +0200
Re: Ah Python, you have spoiled me for all other languages Steven D'Aprano <steve@pearwood.info> - 2015-06-07 21:42 +1000
Re: Ah Python, you have spoiled me for all other languages Chris Angelico <rosuav@gmail.com> - 2015-06-07 22:08 +1000
Re: Ah Python, you have spoiled me for all other languages Steven D'Aprano <steve@pearwood.info> - 2015-06-07 23:24 +1000
Re: Ah Python, you have spoiled me for all other languages Chris Angelico <rosuav@gmail.com> - 2015-06-08 00:47 +1000
Re: Ah Python, you have spoiled me for all other languages random832@fastmail.us - 2015-06-07 10:58 -0400
Re: Ah Python, you have spoiled me for all other languages Steven D'Aprano <steve@pearwood.info> - 2015-06-08 02:28 +1000
Re: Ah Python, you have spoiled me for all other languages Tony the Tiger <tony@tiger.invalid> - 2015-05-22 16:31 +0000
Re: Ah Python, you have spoiled me for all other languages Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-05-22 17:57 +0100
Re: Ah Python, you have spoiled me for all other languages Tim Daneliuk <tundra@tundraware.com> - 2015-05-22 16:41 -0500
Re: Ah Python, you have spoiled me for all other languages Tony the Tiger <tony@tiger.invalid> - 2015-05-23 20:25 +0000
Re: Ah Python, you have spoiled me for all other languages Grant Edwards <invalid@invalid.invalid> - 2015-05-22 17:47 +0000
Re: Ah Python, you have spoiled me for all other languages Chris Angelico <rosuav@gmail.com> - 2015-05-23 04:11 +1000
Re: Ah Python, you have spoiled me for all other languages mm0fmf <none@mailinator.com> - 2015-05-22 19:19 +0100
Re: Ah Python, you have spoiled me for all other languages Laura Creighton <lac@openend.se> - 2015-05-22 21:14 +0200
Re: Ah Python, you have spoiled me for all other languages Steven D'Aprano <steve@pearwood.info> - 2015-05-23 11:36 +1000
Re: Ah Python, you have spoiled me for all other languages MRAB <python@mrabarnett.plus.com> - 2015-05-22 20:34 +0100
Re: Ah Python, you have spoiled me for all other languages Ian Kelly <ian.g.kelly@gmail.com> - 2015-05-22 13:56 -0600
Re: Ah Python, you have spoiled me for all other languages Marko Rauhamaa <marko@pacujo.net> - 2015-05-22 23:34 +0300
Re: Ah Python, you have spoiled me for all other languages Tim Chase <python.list@tim.thechases.com> - 2015-05-22 15:55 -0500
Re: Ah Python, you have spoiled me for all other languages Ethan Furman <ethan@stoneleaf.us> - 2015-05-22 14:15 -0700
Re: Ah Python, you have spoiled me for all other languages Ian Kelly <ian.g.kelly@gmail.com> - 2015-05-22 15:20 -0600
Re: Ah Python, you have spoiled me for all other languages Paul Rubin <no.email@nospam.invalid> - 2015-05-22 16:00 -0700
Re: Ah Python, you have spoiled me for all other languages Michael Torrie <torriem@gmail.com> - 2015-05-22 21:33 -0600
Page 4 of 4 — ← Prev page 1 2 3 [4]
| From | Tony the Tiger <tony@tiger.invalid> |
|---|---|
| Date | 2015-05-22 16:31 +0000 |
| Message-ID | <ORI7x.668201$dj1.141793@fx03.am4> |
| In reply to | #91044 |
On Sat, 23 May 2015 00:58:17 +1000, Steven D'Aprano wrote:
> I get after a couple of hours is that Javascript tries really hard to do
> everything it can for you except what you actually want.
You just described a certain operating system, which shall remain
nameless.
/Grrr
--
___ ___
(\_--_/) | _ ._ _|_|_ _ |o _ _ ._
( 9 9 ) |(_)| |\/ |_| |(/_ ||(_|(/_|
stripes are forever - as overripe ferrets
[toc] | [prev] | [next] | [standalone]
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2015-05-22 17:57 +0100 |
| Message-ID | <mailman.224.1432313886.17265.python-list@python.org> |
| In reply to | #91046 |
On 22/05/2015 17:31, Tony the Tiger wrote: > On Sat, 23 May 2015 00:58:17 +1000, Steven D'Aprano wrote: > >> I get after a couple of hours is that Javascript tries really hard to do >> everything it can for you except what you actually want. > > You just described a certain operating system, which shall remain > nameless. > > > /Grrr > It could be any of *nix, OSX or Windows as VMS is still vastly superior. -- 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 | Tim Daneliuk <tundra@tundraware.com> |
|---|---|
| Date | 2015-05-22 16:41 -0500 |
| Message-ID | <555FA277.8060203@tundraware.com> |
| In reply to | #91046 |
On 05/22/2015 11:31 AM, Tony the Tiger wrote: > On Sat, 23 May 2015 00:58:17 +1000, Steven D'Aprano wrote: > >> I get after a couple of hours is that Javascript tries really hard to do >> everything it can for you except what you actually want. > > You just described a certain operating system, which shall remain > nameless. > > > /Grrr > CP/M ? -- ---------------------------------------------------------------------------- Tim Daneliuk tundra@tundraware.com PGP Key: http://www.tundraware.com/PGP/
[toc] | [prev] | [next] | [standalone]
| From | Tony the Tiger <tony@tiger.invalid> |
|---|---|
| Date | 2015-05-23 20:25 +0000 |
| Message-ID | <Im58x.720223$LW6.104278@fx09.am4> |
| In reply to | #91079 |
On Fri, 22 May 2015 16:41:11 -0500, Tim Daneliuk wrote:
> CP/M ?
That, too. Inventor was an asshole, and the rest is history.
/Grrr
--
___ ___
(\_--_/) | _ ._ _|_|_ _ |o _ _ ._
( 9 9 ) |(_)| |\/ |_| |(/_ ||(_|(/_|
stripes are forever - as overripe ferrets
[toc] | [prev] | [next] | [standalone]
| From | Grant Edwards <invalid@invalid.invalid> |
|---|---|
| Date | 2015-05-22 17:47 +0000 |
| Message-ID | <mjnq3r$p48$1@reader1.panix.com> |
| In reply to | #91044 |
On 2015-05-22, Steven D'Aprano <steve@pearwood.info> wrote:
> But Javascript...
>
> Javascript also lacks a standard assert mechanism, but that wasn't
> too hard to fix. It also has two different equality operators, each
> of which are so complicated and confusing that apparently there are
> two-year Masters degrees on them[2], and yet with neither of these
> operators does the array [1, 2] equal the array [1, 2].
Yep, Javascript has a few warts.
* Implicit conversions. A problem common to many languages, so most
of us have learned to deal with it.
* The attempt to make semicolons optional was a failure and should
have been abandoned.
* Lack of block-scope. For some reason, it doesn't bother me in
Python, but it does in Javascript. That probably has something to do
with...
* Hoisting. Hoisting isn't intrinsically bad, but there's something
just a bit off about Javascript's hoisting. I can't quite put my
finger on why, but it trips me up.
* The == operator. It rarely does what you want. Just don't use it.
* When used in a browser, the rather odd meanings of 'this' in
certain situations.
I do like the use of closures.
And of course, the truly _great_ thing about Javascript is...
It's not PHP!
--
Grant Edwards grant.b.edwards Yow! Am I having fun yet?
at
gmail.com
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2015-05-23 04:11 +1000 |
| Message-ID | <mailman.232.1432318291.17265.python-list@python.org> |
| In reply to | #91057 |
On Sat, May 23, 2015 at 3:47 AM, Grant Edwards <invalid@invalid.invalid> wrote: > * When used in a browser, the rather odd meanings of 'this' in > certain situations. Yes. Closures can retain state exactly the way you'd expect them to, yet what Python would call a bound method (another way of retaining state, specifically the object before the dot) is just... a function. I find this nothing but bizarre. It basically demotes 'this' to the position of any other argument, only it's implicit. ChrisA
[toc] | [prev] | [next] | [standalone]
| From | mm0fmf <none@mailinator.com> |
|---|---|
| Date | 2015-05-22 19:19 +0100 |
| Message-ID | <RqK7x.792916$AG5.722230@fx34.am4> |
| In reply to | #91057 |
On 22/05/2015 18:47, Grant Edwards wrote: > And of course, the truly_great_ thing about Javascript is... > > It's not PHP! ROTFL ;-)
[toc] | [prev] | [next] | [standalone]
| From | Laura Creighton <lac@openend.se> |
|---|---|
| Date | 2015-05-22 21:14 +0200 |
| Message-ID | <mailman.235.1432322051.17265.python-list@python.org> |
| In reply to | #91057 |
The first time you discover that in javascript typeof(null) is 'object' and not 'null' you will scream. I wonder how many home versions of typeof to replace the system one exist out in the wild? Laura
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve@pearwood.info> |
|---|---|
| Date | 2015-05-23 11:36 +1000 |
| Message-ID | <555fd9a3$0$12990$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #91064 |
On Sat, 23 May 2015 05:14 am, Laura Creighton wrote:
> The first time you discover that in javascript typeof(null) is 'object'
> and
> not 'null' you will scream. I wonder how many home versions of typeof
> to replace the system one exist out in the wild?
What weirds me out is that that Javascript provides syntax for creating
arrays and associative arrays (in Python terms, lists and dicts) but
there's no standard way to check them for equality.
What weirds me out is that setting properties on non-objects silently fails:
js> var a = 1;
js> a.foo = "something";
something
js> print(a.foo);
undefined
except when it doesn't:
js> b = null;
null
js> b.foo = "something";
js: "<stdin>", line 16: uncaught JavaScript runtime exception: TypeError:
Cannot set property "foo" of null to "something"
at <stdin>:16
What weirds me out is how useless the tracebacks printed are, at least using
Rhino. There's no stack trace, so if there's an error in a function call,
you cannot see what called the function.
What weirds me out is that all numbers are floats, even if they pretend to
be ints. So:
js> Math.pow(2, 53)
9007199254740992
js> Math.pow(2, 53) + 1
9007199254740992
What weirds me out is that iterating over an array gives the indexes, not
the values:
js> arr = [10,20,30];
10,20,30
js> for (a in arr) {print(a)}
0
1
2
What weirds me out is that while false is falsey, and Boolean(false) is
falsey, new Boolean(false) is truthy:
js> arr = [false, Boolean(false), new Boolean(false)];
false,false,false
js> for (i = 0; i < arr.length; ++i) {
> print(arr[i]);
> if (arr[i]) {print("Surprise!")} }
false
false
false
Surprise!
It's going to take a lot to get past the first impression that Javascript is
nearly as horrible as PHP.
--
Steven
[toc] | [prev] | [next] | [standalone]
| From | MRAB <python@mrabarnett.plus.com> |
|---|---|
| Date | 2015-05-22 20:34 +0100 |
| Message-ID | <mailman.236.1432323282.17265.python-list@python.org> |
| In reply to | #91057 |
On 2015-05-22 20:14, Laura Creighton wrote:
> The first time you discover that in javascript typeof(null) is 'object' and
> not 'null' you will scream. I wonder how many home versions of typeof
> to replace the system one exist out in the wild?
>
I don't think that typeof(null) should be 'null'.
If the type of an integer instance is the integer type and the type of
a string instance is the string type, then the type of null should be
the null type, not a null instance.
I suppose that you could consider that what JavaScript is doing is
equivalent to saying in Python that:
None = object()
like you sometimes do when you want a unique sentinel because None
itself would be an acceptable value.
[toc] | [prev] | [next] | [standalone]
| From | Ian Kelly <ian.g.kelly@gmail.com> |
|---|---|
| Date | 2015-05-22 13:56 -0600 |
| Message-ID | <mailman.238.1432324665.17265.python-list@python.org> |
| In reply to | #91057 |
On Fri, May 22, 2015 at 1:34 PM, MRAB <python@mrabarnett.plus.com> wrote:
> On 2015-05-22 20:14, Laura Creighton wrote:
>>
>> The first time you discover that in javascript typeof(null) is 'object'
>> and
>> not 'null' you will scream. I wonder how many home versions of typeof
>> to replace the system one exist out in the wild?
>>
> I don't think that typeof(null) should be 'null'.
>
> If the type of an integer instance is the integer type and the type of
> a string instance is the string type, then the type of null should be
> the null type, not a null instance.
>
> I suppose that you could consider that what JavaScript is doing is
> equivalent to saying in Python that:
>
> None = object()
>
> like you sometimes do when you want a unique sentinel because None
> itself would be an acceptable value.
If only it were that logical. null in Javascript is a primitive type.
Here's what typeof returns on some other primitive types:
js> typeof(4)
"number"
js> typeof(4.5)
"number"
js> typeof('hello')
"string"
js> typeof(true)
"boolean"
js> typeof(undefined)
"undefined"
An "object" in Javascript is basically just a collection of
properties. For example:
js> typeof([1, 2, 3])
"object"
js> typeof({a: 1, b: 2, c: 3})
"object"
Here's what happens when you try to access a property on null:
js> null.foo
typein:18:0 TypeError: null has no properties
We can conclude that null is not an object. Even the MDN reference
page for the typeof operator refers to this as "bogus". There was a
proposal to fix this in ECMAScript 5.1, but it was rejected because it
caused too much breakage.
[toc] | [prev] | [next] | [standalone]
| From | Marko Rauhamaa <marko@pacujo.net> |
|---|---|
| Date | 2015-05-22 23:34 +0300 |
| Message-ID | <87k2w0mjvc.fsf@elektro.pacujo.net> |
| In reply to | #91069 |
Ian Kelly <ian.g.kelly@gmail.com>:
> An "object" in Javascript is basically just a collection of
> properties. For example:
>
> js> typeof([1, 2, 3])
> "object"
> js> typeof({a: 1, b: 2, c: 3})
> "object"
>
> Here's what happens when you try to access a property on null:
>
> js> null.foo
> typein:18:0 TypeError: null has no properties
That's not all that different from Python, where object() returns a
fresh instance at each invocation. However:
>>> object().x = 3
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'object' object has no attribute 'x'
Why are object instances immutable in Python?
Marko
[toc] | [prev] | [next] | [standalone]
| From | Tim Chase <python.list@tim.thechases.com> |
|---|---|
| Date | 2015-05-22 15:55 -0500 |
| Message-ID | <mailman.242.1432328491.17265.python-list@python.org> |
| In reply to | #91072 |
On 2015-05-22 23:34, Marko Rauhamaa wrote: > >>> object().x = 3 > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > AttributeError: 'object' object has no attribute 'x' > > Why are object instances immutable in Python? I've wondered this on multiple occasions, as I've wanted to just make an attribute bag and have to do something like class AttrBag(object): pass ab = AttrBag() ab.x = 42 ab.y = "some other value" because just doing ab = object() raises the AttributeError Marko highlights. :-/ -tkc
[toc] | [prev] | [next] | [standalone]
| From | Ethan Furman <ethan@stoneleaf.us> |
|---|---|
| Date | 2015-05-22 14:15 -0700 |
| Message-ID | <mailman.243.1432329332.17265.python-list@python.org> |
| In reply to | #91072 |
On 05/22/2015 01:34 PM, Marko Rauhamaa wrote:
> Ian Kelly <ian.g.kelly@gmail.com>:
>
>> An "object" in Javascript is basically just a collection of
>> properties. For example:
>>
>> js> typeof([1, 2, 3])
>> "object"
>> js> typeof({a: 1, b: 2, c: 3})
>> "object"
>>
>> Here's what happens when you try to access a property on null:
>>
>> js> null.foo
>> typein:18:0 TypeError: null has no properties
>
> That's not all that different from Python, where object() returns a
> fresh instance at each invocation. However:
>
> >>> object().x = 3
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> AttributeError: 'object' object has no attribute 'x'
>
> Why are object instances immutable in Python?
# psuedo-code
class object:
__slots__ = ()
class bad_object:
"__slots__ not specified, so automatically gets a __dict__"
class tuple(...) <- object or bad_object? hint: the clue is in the name ;)
__slots__ = ()
If tuple is based on bad_object, it will get a __dict__ and be very-mutable.
In order to have slightly-mutable or immutable objects, the base class has to not have a __dict__, so object does not.
Mind you, I don't know if that's the reason why it was decided to be like that, or just a nice consequence of the choice to do it that way.
--
~Ethan~
[toc] | [prev] | [next] | [standalone]
| From | Ian Kelly <ian.g.kelly@gmail.com> |
|---|---|
| Date | 2015-05-22 15:20 -0600 |
| Message-ID | <mailman.244.1432329652.17265.python-list@python.org> |
| In reply to | #91072 |
On Fri, May 22, 2015 at 2:55 PM, Tim Chase <python.list@tim.thechases.com> wrote: > I've wondered this on multiple occasions, as I've wanted to just make > an attribute bag and have to do something like > > class AttrBag(object): pass > ab = AttrBag() > ab.x = 42 > ab.y = "some other value" > > because just doing > > ab = object() > > raises the AttributeError Marko highlights. :-/ This is what types.SimpleNamespace is for.
[toc] | [prev] | [next] | [standalone]
| From | Paul Rubin <no.email@nospam.invalid> |
|---|---|
| Date | 2015-05-22 16:00 -0700 |
| Message-ID | <874mn4z07p.fsf@jester.gateway.sonic.net> |
| In reply to | #91044 |
Steven D'Aprano <steve@pearwood.info> writes: > the impression I get after a couple of hours is that Javascript tries > really hard to do everything it can for you except what you actually want. Javascript is like C++ in that it's a lot of layers of legacy cruft, but if you ignore the ugly parts, the good parts that are left are fine to program in, though there are still stupid issues of type confusion. If you like Haskell you should look at Purescript (purescript.org), which is a Haskell-resembling language with strict evaluation, designed to compile straightforwardly into Javascript and interoperate with it. Several other backends are also available or in progress.
[toc] | [prev] | [next] | [standalone]
| From | Michael Torrie <torriem@gmail.com> |
|---|---|
| Date | 2015-05-22 21:33 -0600 |
| Message-ID | <mailman.251.1432352002.17265.python-list@python.org> |
| In reply to | #91081 |
On 05/22/2015 05:00 PM, Paul Rubin wrote: > Steven D'Aprano <steve@pearwood.info> writes: >> the impression I get after a couple of hours is that Javascript tries >> really hard to do everything it can for you except what you actually want. > > Javascript is like C++ in that it's a lot of layers of legacy cruft, but > if you ignore the ugly parts, the good parts that are left are fine to > program in, though there are still stupid issues of type confusion. > > If you like Haskell you should look at Purescript (purescript.org), > which is a Haskell-resembling language with strict evaluation, designed > to compile straightforwardly into Javascript and interoperate with it. > Several other backends are also available or in progress. Or if you are a rare one that likes Python, you can use PyJS, which translates Python into Javascript.
[toc] | [prev] | [standalone]
Page 4 of 4 — ← Prev page 1 2 3 [4]
Back to top | Article view | comp.lang.python
csiph-web