Enum with nested classes or with types as members

2018-09-11 Thread Ethan Furman
Greetings! So the stdlib Enum has been around for a few years now. Has anyone written an enum that either had types as members: class Types(Enum): Int = int Str = str or that had nested classes: class Types(Enum): class Contained(Enum): circle = 1 squa

GUI, Python2.7- how to build a loop with a button + textbox

2018-09-11 Thread alon . najman
hi, on python 2.7 how do I build a loop with a button + textbox? for example: I want the user to enter is name and then press "ok" button, I want his name to be printed 5 times. thanks! :) you people are amazing it's almost better then stackoverflow :D -- https://mail.python.org/mailman/list

final thoughts on [Re: don't quite understand mailing list]

2018-09-11 Thread Ethan Furman
On 09/07/2018 05:07 PM, Steven D'Aprano wrote: On Fri, 07 Sep 2018 07:39:33 +0300, Marko Rauhamaa wrote: I'm with Ethan on this one. There was nothing in the original posting that merited ridicule. Then its a good thing there was nothing in the response that was ridicule. Ridicule may not

Re: "glob.glob('weirdness')" Any thoughts?

2018-09-11 Thread Dan Sommers
On 9/11/18 6:24 PM, Gilmeh Serda wrote: I think this is no different than RegEx matching, so the routine really shouldn't be called glob() but the_regex_variations_opus_five(). Maybe your version should be called crippled_glob. Globbing has a long history, longer than many of the people who u

Re: Python Probability

2018-09-11 Thread Gary Herron
On 09/11/2018 11:54 AM, end...@freemail.hu wrote: Hello, I am new to Python and I have an exercise which I struggle with. The question is: In the strategic board game called Risk, one player can attack up to three soldiers simultaneously, while the defending player can defend up to two. In th

Re: Python Probability

2018-09-11 Thread Gary Herron
On 09/11/2018 11:54 AM, end...@freemail.hu wrote: Hello, I am new to Python and I have an exercise which I struggle with. The question is: In the strategic board game called Risk, one player can attack up to three soldiers simultaneously, while the defending player can defend up to two. In th

Re: Python Probability

2018-09-11 Thread Peter Pearson
On Tue, 11 Sep 2018 20:54:23 +0200 (CEST), Bat erdene endzis wrote: [snip] > def dice(): > attacker_dice=[random.randint(1,6) for _ in range(3)] > defender_dice=[random.randint(1,6) for _ in range(2)] > a=max(attacker_dice) > b=max(defender_dice) > for i in range(1000): >

Python Probability

2018-09-11 Thread Bat erdene endzis
Hello, I am new to Python and I have an exercise which I struggle with. The question is: In the strategic board game called Risk, one player can attack up to three soldiers simultaneously, while the defending player can defend up to two. In the case of exactly three attackers and two defenders,

Re: Pretty printing dicts with compact=True

2018-09-11 Thread Nicolas Hug
To me it also seems to be the most sensible behaviour, since dictionaries with their keys and values are different from most other sequences. You've got a point but 1. That goes against the compact=True expected behaviour 2. Small dicts (e.g. /{x: x for x in range(5)}/) are still printed on a

Re: logging module - how to include method's class name when using %(funcName)

2018-09-11 Thread Peter Otten
Malcolm Greene wrote: > I'm using the Python logging module and looking for a way to include a > method's class name when using %(funcName). Is this possible? When you > have several related classes, just getting the function (method) name is > not enough information to provide context on the code

numpy use cases for where and out

2018-09-11 Thread duncan smith
Hello, I'm writing some code for sparse arrays that is intended to pretty much follow the numpy API. Because my arrays can have different default values there is an issue with using the 'out' keyword argument for functions. e.g. If I elementwise multiply 2 arrays with defaults a and b, then t

Re: Object-oriented philosophy

2018-09-11 Thread Abdur-Rahmaan Janhangeer
i know about the ban but since marko was getting it was wondering how thanks ! Abdur-Rahmaan Janhangeer https://github.com/Abdur-rahmaanJ Mauritius Ranting Rick is banned from posting to python-list. (And maybe also > from other Python project lists, I'm not sure about that.) > You can read abou

Re: Pretty printing dicts with compact=True

2018-09-11 Thread Max Zettlmeißl via Python-list
On Tue, Sep 11, 2018 at 1:58 PM, Nicolas Hug wrote: > pprint({x: x for x in range(15)}, compact=True) > > would be be printed in 15 lines while it could fit on 2. > > > Is this a bug or was this decided on purpose? It is on purpose as can be seen in the code for pprint [1], which calls _format [2

Re: Object-oriented philosophy

2018-09-11 Thread Abdur-Rahmaan Janhangeer
i did not see rick's mail on my gmail Abdur-Rahmaan Janhangeer https://github.com/Abdur-rahmaanJ Mauritius Rick Johnson : > > > Michael F. Stemper wrote: > >> Object-oriented philosophy > > [...] [...] [...] > > > > So, to make a long story short, you may want to do some > > googling... > > Long

Re: Object-oriented philosophy

2018-09-11 Thread Michael F. Stemper
On 2018-09-11 01:59, Marko Rauhamaa wrote: > Rick Johnson : > >> Michael F. Stemper wrote: >>> Object-oriented philosophy >> [...] [...] [...] >> >> So, to make a long story short, you may want to do some >> googling... > > Long story short, Michael, Rick is a masterful troll extraordinaire. Is

Re: Object-oriented philosophy

2018-09-11 Thread Marko Rauhamaa
Rick Johnson : > Michael F. Stemper wrote: >> Object-oriented philosophy > [...] [...] [...] > > So, to make a long story short, you may want to do some > googling... Long story short, Michael, Rick is a masterful troll extraordinaire. Highly amusing when you're in the mood. Marko -- https://m

Pretty printing dicts with compact=True

2018-09-11 Thread Nicolas Hug
Is there a reason why the 'compact' parameter is ignored when pretty printing a dict? For example: pprint({x: x for x in range(15)}, compact=True) would be be printed in 15 lines while it could fit on 2. Is this a bug or was this decided on purpose? Thank you! -- https://mail.python.org/mai

Re: Object-oriented philosophy

2018-09-11 Thread Antoon Pardon
On 07-09-18 22:08, Michael F. Stemper wrote: > >> try >>id = xmlmodel.attrib['name'] >> except KeyError: >>id = "constant power" > Never mind! After I continued testing, I realized that the above > should have been written as: > > if 'name' in xmlmodel.attrib: > id = xmlmodel.attrib

Verify pip's requirements.txt file at runtime?

2018-09-11 Thread Malcolm Greene
Is there a technique that would allow a script to verify its requirements.txt file before it runs? Use case: To detect unexpected changes to a script's runtime environment. Does the pip module expose any methods for this type of task? Thank you, Malcolm -- https://mail.python.org/mailman/listinfo/