If the behaviour of * on a sequence is confusing, then isn't the following
behaviour also confusing for exactly the same reason?
>>> a = [[]]
>>> b = a + a
>>> b
[[], []]
>>> b[0].append(5)
>>> b
[[5], [5]]
And if so, shouldn't there also be a concatenation operator that perf
On Fri, 25 May 2018 09:58:19 -0700, Rob Gaddi wrote:
> I agree that it's non-obvious, but I disagree with your diagnosis.
A further data point:
"I was not properly appreciating that that these
repeated objects were the *same identical* objects
that were in the pre-replicated list."
On Sat, 26 May 2018 11:53:42 +0200, Christian Heimes wrote:
>> Why does weakref hate my Eggs class?
>
> Weakref needs some place to store reference information. It works if you
> add "__weakref__" to your slots:
>
> class Eggs:
> __slots__ = ['spanish_inquisition', '__weakref__']
Thanks!
Mike McClain writes:
> Steven D'Aprano and Ben Finney used these '_' and '__'.
> Steve said, "[[] for _ in range(5)]".
> Ben said, "[ [] for __ in range(5) ]".
>
> These aren't listed separately in the index
That's right, the names ‘_’ and ‘__’ have no special meaning in
Python-the-language
On 27May2018 09:46, Chris Angelico wrote:
On Sun, May 27, 2018 at 9:40 AM, Thomas Jollans wrote:
There's nothing special about _, it's just a possible name of a
variable, albeit a very short and entirely uninformative one. Normally,
it's not something you'd actually want to name a variable, of
On Sun, May 27, 2018 at 9:40 AM, Thomas Jollans wrote:
> On 27/05/18 01:19, Mike McClain wrote:
>> In their discussion of 'List replication operator'
>> Steven D'Aprano and Ben Finney used these '_' and '__'.
>> Steve said, "[[] for _ in range(5)]".
>> Ben said, "[ [] for __ in range(5) ]".
>>
On 27/05/18 01:19, Mike McClain wrote:
> In their discussion of 'List replication operator'
> Steven D'Aprano and Ben Finney used these '_' and '__'.
> Steve said, "[[] for _ in range(5)]".
> Ben said, "[ [] for __ in range(5) ]".
>
> These aren't listed separately in the index, where migh
In their discussion of 'List replication operator'
Steven D'Aprano and Ben Finney used these '_' and '__'.
Steve said, "[[] for _ in range(5)]".
Ben said, "[ [] for __ in range(5) ]".
These aren't listed separately in the index, where might I find
written discussion of these?
Thanks,
Mike
On Sat, May 26, 2018 at 10:21 PM, Chris Angelico wrote:
>
> I'm done. Argue with brick walls for the rest of eternity if you like.
I see you like me, but I can reciprocate your feelings.
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
--
https://mail.python.org/mailman/
On 26May2018 04:02, Subhabrata Banerjee wrote:
On Saturday, May 26, 2018 at 3:54:37 AM UTC+5:30, Cameron Simpson wrote:
It sounds like you want a more general purpose parser, and that depends upon
your purposes. If you're coding to learn the basics of breaking up text, what
you're doing is fine
On Sun, May 27, 2018 at 5:13 AM, Mikhail V wrote:
> On Sat, May 26, 2018 at 7:10 PM, Steven D'Aprano
>> temp = >>| Mikhail's syntax for {65290} is {65290}
>> Can you see the problem yet? How does your collapse function f()
>> distinguish between the escape code {65290} and the literal string
On Sat, May 26, 2018 at 7:10 PM, Steven D'Aprano
wrote:
> On Sat, 26 May 2018 18:22:15 +0300, Mikhail V wrote:
>
>>> Here is a string assigned to name `s` using Python's current syntax:
>>>
>>> s = "some\ncharacters\0abc\x01\ndef\uFF0A\nhere"
>>>
>>> How do you represent that assignment using your
On 05/26/2018 01:00 AM, Steven D'Aprano wrote:
I wish there was a simpler way to define symbols with identity but no
state or behaviour...
Check out the Constant class in aenum. You still might want to customize the
repr, though.
--
~Ethan~
--
https://mail.python.org/mailman/listinfo/pytho
Paul St George wrote:
> Thank you.
> You are very right. The show() method is intended for debugging purposes
> and is useful for that, but what method should I be using and is PIL the
> best imaging library for my purposes? I do not want to manipulate
> images, I only want to show images (full sc
On Sat, 26 May 2018 18:22:15 +0300, Mikhail V wrote:
>> Here is a string assigned to name `s` using Python's current syntax:
>>
>> s = "some\ncharacters\0abc\x01\ndef\uFF0A\nhere"
>>
>> How do you represent that assignment using your syntax?
>
> Hope its not mandatory to decipher your random exam
On Sat, 26 May 2018 23:54:51 +1000, Chris Angelico wrote:
> Seems pretty non-controversial, which means it's almost guaranteed to
> reach 100+ posts debating what the name should be.
Including:
* 27 posts declaring that using such singleton symbols is completely
un-Pythonic and is sure to doom
On Sat, May 26, 2018 at 10:55 AM, Steven D'Aprano
wrote:
> On Sat, 26 May 2018 08:09:51 +0300, Mikhail V wrote:
>
>> On Fri, May 25, 2018 at 1:15 PM, bartc wrote:
> [...]
>>> One problem here is how to deal with embedded non-printable characters:
>>> CR, LF and TAB might become part of the normal
Thank you.
You are very right. The show() method is intended for debugging purposes
and is useful for that, but what method should I be using and is PIL the
best imaging library for my purposes? I do not want to manipulate
images, I only want to show images (full screen) on an external display.
Steven D'Aprano wrote:
> On Fri, 25 May 2018 09:28:01 +0200, Peter Otten wrote:
>
>> Yet another arcanum to learn for beginners with little return. If you
>> cannot refrain from tinkering with the language at least concentrate on
>> the features with broad application. Thank you.
>
> Broader tha
On Sat, May 26, 2018 at 6:50 PM, Steven D'Aprano
wrote:
> On Sat, 26 May 2018 18:14:08 +1000, Chris Angelico wrote:
>
>> On Sat, May 26, 2018 at 6:00 PM, Steven D'Aprano
>> wrote:
>>> Actually I don't really need all the features of Enums, I might just
>>> define my own class:
>>>
>>>
>>> class M
On 2018-05-25, asa32s...@gmail.com wrote:
> here is the code, i keep getting an error, "break outside loop".
You get the "break outside loop" error because you're using the break
statement when you are not inside a loop.
> if it is false just exit function
You use the 'return' statement to exi
Steven D'Aprano wrote:
> Am I silly for wanting to make a single enum?
>
> I have a three-state flag, True, False or Maybe. Is is confusing or bad
> practice to make a single enum for the Maybe case?
>
>
> from enum import Enum
> class State(Enum):
> Maybe = 2
>
> Maybe = State.Maybe
> del
On Saturday, May 26, 2018 at 3:54:37 AM UTC+5:30, Cameron Simpson wrote:
> On 25May2018 04:23, Subhabrata Banerjee wrote:
> >On Friday, May 25, 2018 at 3:59:57 AM UTC+5:30, Cameron Simpson wrote:
> >> On 24May2018 03:13, wrote:
> >> >I have a text as,
> >> >
> >> >"Hawaii volcano generates toxic g
Ian Kelly :
> On Fri, May 25, 2018 at 11:00 PM, Chris Angelico wrote:
>> # Tri-state logic
>> Maybe = object()
>
> The enum has a nice __str__ though.
I use strings for enums:
class X:
HERE = "HERE"
THERE = "THERE"
EVERYWHERE = "EVERYWHERE"
def __init__(self):
26.05.18 08:07, Ian Kelly пише:
On Fri, May 25, 2018 at 11:00 PM, Chris Angelico wrote:
On Sat, May 26, 2018 at 2:46 PM, Steven D'Aprano
wrote:
Am I silly for wanting to make a single enum?
I have a three-state flag, True, False or Maybe. Is is confusing or bad
practice to make a single enum
junkaccoun...@outlook.com wrote:
> Hi,
>
> Python newbie here. I need help with the following two tasks I need to
> accomplish using Python:
>
>
>
> Creating a matrix of rolling variances
>
> I have a pandas data frame of six columns, I would like to iteratively
> comp
Steven D'Aprano wrote:
TypeError: cannot create weak reference to 'Eggs' object
Why does weakref hate my Eggs class?
Classes with __slots__ aren't automatically given a __weakref__ slot,
to save memory I suppose.
But you can give it one explicitly:
>>> class Eggs:
... __slots__ = ['spanish
On 2018-05-26 11:17, Steven D'Aprano wrote:
> Here is my code:
>
>
>
> cut here %<
>
> import weakref
> d = weakref.WeakValueDictionary()
>
> class Spam:
> pass
>
> class Eggs:
> __slots__ = ['spanish_inquisition']
>
> d['a'] = Spam() # Okay.
> d['b'] = Eggs() # Nobody wi
Here is my code:
cut here %<
import weakref
d = weakref.WeakValueDictionary()
class Spam:
pass
class Eggs:
__slots__ = ['spanish_inquisition']
d['a'] = Spam() # Okay.
d['b'] = Eggs() # Nobody will expect what happens next!
cut here %<
and the result I get is:
On Sat, 26 May 2018 18:14:08 +1000, Chris Angelico wrote:
> On Sat, May 26, 2018 at 6:00 PM, Steven D'Aprano
> wrote:
>> Actually I don't really need all the features of Enums, I might just
>> define my own class:
>>
>>
>> class Maybe:
>> def __repr__(self):
>> return "Maybe"
>>
>>
On Sat, May 26, 2018 at 6:00 PM, Steven D'Aprano
wrote:
> Actually I don't really need all the features of Enums, I might just
> define my own class:
>
>
> class Maybe:
> def __repr__(self):
> return "Maybe"
>
> Maybe = Maybe()
>
>
>
> I wish there was a simpler way to define symbols
On Fri, 25 May 2018 23:07:47 -0600, Ian Kelly wrote:
> On Fri, May 25, 2018 at 11:00 PM, Chris Angelico
> wrote:
>> On Sat, May 26, 2018 at 2:46 PM, Steven D'Aprano
>> wrote:
[...]
>>> Is there a better way of handling a three-state flag like this?
>>>
>>>
>> Does it need to have a value of 2? I
On Sat, 26 May 2018 08:09:51 +0300, Mikhail V wrote:
> On Fri, May 25, 2018 at 1:15 PM, bartc wrote:
[...]
>> One problem here is how to deal with embedded non-printable characters:
>> CR, LF and TAB might become part of the normal source text, but how
>> about anything else? Or would you only al
33 matches
Mail list logo