On Mon, Sep 21, 2020 at 10:14 PM Serhiy Storchaka wrote:
>
> 18.09.20 03:55, Chris Angelico пише:
> > On Fri, Sep 18, 2020 at 10:53 AM Grant Edwards
> > wrote:
> >> Yea, the syntax for tuple literals has always been a bit of an ugly
> >> spot in Python. If ASCII had only had one more set of open
18.09.20 03:55, Chris Angelico пише:
> On Fri, Sep 18, 2020 at 10:53 AM Grant Edwards
> wrote:
>> Yea, the syntax for tuple literals has always been a bit of an ugly
>> spot in Python. If ASCII had only had one more set of open/close
>> brackets...
>
> ... then I'd prefer them to be used for set
On 20Sep2020 20:33, Avi Gross wrote:
>('M','R','A','B') is correct. I appreciate the correction. I did not look to
>see the content of what I created, just the type!
>
a = tuple("first")
a
>('f', 'i', 'r', 's', 't')
type(a)
>
>
>But I thought adding a comma would help and it does no
iterator is iterating at a different level.
>>> d = ["first"]
>>> tuple(d)
('first',)
>>> tuple(["first"])
('first',)
I understand the design choice and can imagine there may be another function
that initializes a tuple more directly in
On 21/09/20 10:59 am, Avi Gross wrote:
a=tuple("first")
type(a)
That seems more explicit than adding a trailing comma.
It doesn't do what you want, though:
>>> a = tuple("first")
>>> print(a)
('f', 'i', 'r', 's', 't')
If you really want to use tuple() to create a 1-tuple without
using a tr
On 2020-09-20 23:59, Avi Gross via Python-list wrote:
There is a simple and obvious way to make sure you have a tuple by invoking the
keyword/function in making it:
a=('first')
type(a)
a=("first",)
type(a)
a=tuple("first")
type(a)
That seems more explicit than adding a trailing comm
t seems more explicit than adding a trailing comma. It also is a simple way
to make an empty tuple but is there any penalty for using the function tuple()?
-Original Message-
From: Python-list On
Behalf Of "???"
Sent: Saturday, September 19, 2020 11:39 PM
To: python-list
> #+BEGIN_SRC: python
> for n in ('first',):
> print n
> #+BEGIN_SRC
The last 'BEGIN_SRC' should be 'END_SRC' so sorry ;;;
--
^고맙습니다 _救濟蒼生_ 감사합니다_^))//
--
https://mail.python.org/mailman/listinfo/python-list
William Pearson writes:
> ...
> for n in ('first'):
> print n
>
>
> ... but "f","i","r","s","t" in the second.
#+BEGIN_SRC: python
for n in ('first',):
print n
#+BEGIN_SRC
Then, that will print 'first'. And please use Python3...
Sincerely, Byung-Hee
--
^고맙습니다 _救濟蒼生_ 감사합니다_^))//
--
h
On 19/09/20 6:49 am, Grant Edwards wrote:
There must be a few more sets of brackets in Unicode...
Quite a lot, actually. The character browser in MacOSX is currently
showing me 17, not including the ones that are built up from
multiple characters.
Some of them could be easily confused with no
On 2020-09-18, Chris Angelico wrote:
> On Fri, Sep 18, 2020 at 10:53 AM Grant Edwards
> wrote:
>>
>> On 2020-09-17, MRAB wrote:
>> >> The only time the parentheses are required for tuple building is when
>> >> they would otherwise not be interpreted that way:
>> >>
>> > They're needed for the emp
On Fri, Sep 18, 2020 at 10:53 AM Grant Edwards
wrote:
>
> On 2020-09-17, MRAB wrote:
> >> The only time the parentheses are required for tuple building is when
> >> they would otherwise not be interpreted that way:
> >>
> > They're needed for the empty tuple, which doesn't have a comma.
> >
> >>
On 2020-09-17, MRAB wrote:
>> The only time the parentheses are required for tuple building is when
>> they would otherwise not be interpreted that way:
>>
> They're needed for the empty tuple, which doesn't have a comma.
>
>> some_func('first', 'second') # some_func called with two str args
>>
On 9/17/20 10:43 AM, MRAB wrote:
On 2020-09-17 17:47, Ethan Furman wrote:
The only time the parentheses are required for tuple building is when
they would otherwise not be interpreted that way:
They're needed for the empty tuple, which doesn't have a comma.
Ah, right. Thanks.
--
~Ethan~
On 2020-09-17 17:47, Ethan Furman wrote:
On 9/17/20 8:24 AM, William Pearson wrote:
I am puzzled by the reason for this difference between lists and tuples.
A list of with multiple strings can be reduced to a list with one string with
the expected results:
for n in ['first']:
print n
On 9/17/20 11:24 AM, William Pearson wrote:
> I am puzzled by the reason for this difference between lists and tuples.
>
> A list of with multiple strings can be reduced to a list with one string with
> the expected results:
>
> for n in ['first','second']:
> print n
>
> for n in ['first']:
>
On 9/17/20 8:24 AM, William Pearson wrote:
I am puzzled by the reason for this difference between lists and tuples.
A list of with multiple strings can be reduced to a list with one string with
the expected results:
for n in ['first']:
print n
['first'] is a list.
for n in ('first'
On 2020-09-17 at 09:24:57 -0600,
William Pearson wrote:
> for n in ('first'):
That's not a tuple. That's a string.
Try it this way:
for n in ('first',): # note the trailing comma
print n
Dan
--
https://mail.python.org/mailman/listinfo/python-list
18 matches
Mail list logo