python a set of all numeric types.do pop(),not output randomly [duplicate]










1
















This question already has an answer here:



  • Set.pop() isn't random?

    2 answers



当一个集合中的全部类型为数值时,pop()将升序输出,这一点不明白,集合不是无序的吗?



translation:



When all the types in a collection are numeric, pop() will output in ascending order.I don't know why, isn't the set unordered?




s = 2,5,3,7,0
for i in range(5):
print(s.pop())



output:
0
2
3
5
7










share|improve this question













marked as duplicate by B. M., jpp python
Users with the  python badge can single-handedly close python questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 14 '18 at 14:37


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















  • I have found a similar question in this topic, it could help you stackoverflow.com/questions/1867861/…

    – Baptiste Gavalda
    Nov 14 '18 at 14:22






  • 1





    See stackoverflow.com/questions/21017188/set-pop-isnt-random

    – B. M.
    Nov 14 '18 at 14:34















1
















This question already has an answer here:



  • Set.pop() isn't random?

    2 answers



当一个集合中的全部类型为数值时,pop()将升序输出,这一点不明白,集合不是无序的吗?



translation:



When all the types in a collection are numeric, pop() will output in ascending order.I don't know why, isn't the set unordered?




s = 2,5,3,7,0
for i in range(5):
print(s.pop())



output:
0
2
3
5
7










share|improve this question













marked as duplicate by B. M., jpp python
Users with the  python badge can single-handedly close python questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 14 '18 at 14:37


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















  • I have found a similar question in this topic, it could help you stackoverflow.com/questions/1867861/…

    – Baptiste Gavalda
    Nov 14 '18 at 14:22






  • 1





    See stackoverflow.com/questions/21017188/set-pop-isnt-random

    – B. M.
    Nov 14 '18 at 14:34













1












1








1









This question already has an answer here:



  • Set.pop() isn't random?

    2 answers



当一个集合中的全部类型为数值时,pop()将升序输出,这一点不明白,集合不是无序的吗?



translation:



When all the types in a collection are numeric, pop() will output in ascending order.I don't know why, isn't the set unordered?




s = 2,5,3,7,0
for i in range(5):
print(s.pop())



output:
0
2
3
5
7










share|improve this question















This question already has an answer here:



  • Set.pop() isn't random?

    2 answers



当一个集合中的全部类型为数值时,pop()将升序输出,这一点不明白,集合不是无序的吗?



translation:



When all the types in a collection are numeric, pop() will output in ascending order.I don't know why, isn't the set unordered?




s = 2,5,3,7,0
for i in range(5):
print(s.pop())



output:
0
2
3
5
7





This question already has an answer here:



  • Set.pop() isn't random?

    2 answers







python






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 14 '18 at 14:05









WangTanxuWangTanxu

214




214




marked as duplicate by B. M., jpp python
Users with the  python badge can single-handedly close python questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 14 '18 at 14:37


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by B. M., jpp python
Users with the  python badge can single-handedly close python questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 14 '18 at 14:37


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • I have found a similar question in this topic, it could help you stackoverflow.com/questions/1867861/…

    – Baptiste Gavalda
    Nov 14 '18 at 14:22






  • 1





    See stackoverflow.com/questions/21017188/set-pop-isnt-random

    – B. M.
    Nov 14 '18 at 14:34

















  • I have found a similar question in this topic, it could help you stackoverflow.com/questions/1867861/…

    – Baptiste Gavalda
    Nov 14 '18 at 14:22






  • 1





    See stackoverflow.com/questions/21017188/set-pop-isnt-random

    – B. M.
    Nov 14 '18 at 14:34
















I have found a similar question in this topic, it could help you stackoverflow.com/questions/1867861/…

– Baptiste Gavalda
Nov 14 '18 at 14:22





I have found a similar question in this topic, it could help you stackoverflow.com/questions/1867861/…

– Baptiste Gavalda
Nov 14 '18 at 14:22




1




1





See stackoverflow.com/questions/21017188/set-pop-isnt-random

– B. M.
Nov 14 '18 at 14:34





See stackoverflow.com/questions/21017188/set-pop-isnt-random

– B. M.
Nov 14 '18 at 14:34












1 Answer
1






active

oldest

votes


















0














It doesn't occur if the numbers are higher



>>> l=list(range(655360, 6553600))
>>> for _ in range(20):
... el = ra.choice(l)
... s.add(el)
... print(el)
...
3589721
2762448
1543072
4489208
5381194
4181645
1470069
6256052
5833067
6288785
3707357
1414093
3347945
1358111
1754489
4503096
3424305
2233038
4817376
3941735
>>> for _ in range(10):
... print(s.pop())
...
4181645
6288785
1358111
1543072
3424305
6256052
4503096
5381194
1414093
2233038


It's a Python implementation detail and you should not rely on it.



As recommended in the comments, please see this answer






share|improve this answer































    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    It doesn't occur if the numbers are higher



    >>> l=list(range(655360, 6553600))
    >>> for _ in range(20):
    ... el = ra.choice(l)
    ... s.add(el)
    ... print(el)
    ...
    3589721
    2762448
    1543072
    4489208
    5381194
    4181645
    1470069
    6256052
    5833067
    6288785
    3707357
    1414093
    3347945
    1358111
    1754489
    4503096
    3424305
    2233038
    4817376
    3941735
    >>> for _ in range(10):
    ... print(s.pop())
    ...
    4181645
    6288785
    1358111
    1543072
    3424305
    6256052
    4503096
    5381194
    1414093
    2233038


    It's a Python implementation detail and you should not rely on it.



    As recommended in the comments, please see this answer






    share|improve this answer





























      0














      It doesn't occur if the numbers are higher



      >>> l=list(range(655360, 6553600))
      >>> for _ in range(20):
      ... el = ra.choice(l)
      ... s.add(el)
      ... print(el)
      ...
      3589721
      2762448
      1543072
      4489208
      5381194
      4181645
      1470069
      6256052
      5833067
      6288785
      3707357
      1414093
      3347945
      1358111
      1754489
      4503096
      3424305
      2233038
      4817376
      3941735
      >>> for _ in range(10):
      ... print(s.pop())
      ...
      4181645
      6288785
      1358111
      1543072
      3424305
      6256052
      4503096
      5381194
      1414093
      2233038


      It's a Python implementation detail and you should not rely on it.



      As recommended in the comments, please see this answer






      share|improve this answer



























        0












        0








        0







        It doesn't occur if the numbers are higher



        >>> l=list(range(655360, 6553600))
        >>> for _ in range(20):
        ... el = ra.choice(l)
        ... s.add(el)
        ... print(el)
        ...
        3589721
        2762448
        1543072
        4489208
        5381194
        4181645
        1470069
        6256052
        5833067
        6288785
        3707357
        1414093
        3347945
        1358111
        1754489
        4503096
        3424305
        2233038
        4817376
        3941735
        >>> for _ in range(10):
        ... print(s.pop())
        ...
        4181645
        6288785
        1358111
        1543072
        3424305
        6256052
        4503096
        5381194
        1414093
        2233038


        It's a Python implementation detail and you should not rely on it.



        As recommended in the comments, please see this answer






        share|improve this answer















        It doesn't occur if the numbers are higher



        >>> l=list(range(655360, 6553600))
        >>> for _ in range(20):
        ... el = ra.choice(l)
        ... s.add(el)
        ... print(el)
        ...
        3589721
        2762448
        1543072
        4489208
        5381194
        4181645
        1470069
        6256052
        5833067
        6288785
        3707357
        1414093
        3347945
        1358111
        1754489
        4503096
        3424305
        2233038
        4817376
        3941735
        >>> for _ in range(10):
        ... print(s.pop())
        ...
        4181645
        6288785
        1358111
        1543072
        3424305
        6256052
        4503096
        5381194
        1414093
        2233038


        It's a Python implementation detail and you should not rely on it.



        As recommended in the comments, please see this answer







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 14 '18 at 14:49

























        answered Nov 14 '18 at 14:17









        PynchiaPynchia

        6,66232131




        6,66232131















            這個網誌中的熱門文章

            What does pagestruct do in Eviews?

            Dutch intervention in Lombok and Karangasem

            Channel Islands