Re: Metaclasses - magic functions

2016-12-23 Thread Ian Kelly
On Fri, Dec 23, 2016 at 5:14 AM, Mr. Wrobel wrote: > Hi,thanx for answers, let's imagine that we want to add one class attribute > for newly created classess with using __init__ in metaclass, here's an > example: > > #!/usr/bin/env python > > class MetaClass(type): > # __init__ manipulation: >

Re: sorting strings numerically while dealing with missing values

2016-12-28 Thread Ian Kelly
On Wed, Dec 28, 2016 at 2:14 PM, Larry Martell wrote: > > I have a list containing a list of strings that I want to sort > numerically by one of the fields. I am doing this: > > sorted(rows, key=float(itemgetter(sortby))) I'm guessing that you left out a lambda here since the key argument takes a

Re: sorting strings numerically while dealing with missing values

2016-12-28 Thread Ian Kelly
On Wed, Dec 28, 2016 at 2:43 PM, Ian Kelly wrote: > On Wed, Dec 28, 2016 at 2:14 PM, Larry Martell > wrote: >> >> I have a list containing a list of strings that I want to sort >> numerically by one of the fields. I am doing this: >> >> sorted(rows, ke

Re: learning and experimenting python.

2016-12-30 Thread Ian Kelly
On Fri, Dec 30, 2016 at 11:50 AM, wrote: > Hello everyone, > I am the new comer and learner of python. > I have a doubt that when I type python and press enter it shows a prompt like > But why it is >>> ? > Is there any special reason? > Why it is not setted as @,& or any other special chara

Re: learning and experimenting python.

2016-12-30 Thread Ian Kelly
On Dec 30, 2016 4:42 PM, wrote: Yes, I am not confusing you all, rather I thought that this is the best place to solve any doubts, soy only question for you is Why python uses >>> instead of >, or any other special characters? Do you know about this, if yes then please answer it. I will be so mu

Re: learning and experimenting python.

2016-12-30 Thread Ian Kelly
On Fri, Dec 30, 2016 at 6:05 PM, wrote: > But in his website, he recommended that post your questions here, he will > answer it. > But still as you told me I will send him an personal e-mail. This is a good place for asking questions about Python, but you should know that Guido himself doesn't

Re: Problem with running python 3.6.0 on a 32 bit windows 7 ultimate operating system.

2016-12-30 Thread Ian Kelly
On Fri, Dec 30, 2016 at 10:53 PM, Sagar Utlas wrote: > I am new to python, I've been using C++ as as a student till last 3 years. > To expand my knowledge, I installed Python 3.6.0 and when tried to open it, > a pop up window appeared saying- "The program can't start because > api-ms-win-crt-runti

Re: learning and experimenting python.

2016-12-31 Thread Ian Kelly
On Dec 31, 2016 1:48 AM, "mm0fmf" wrote: On 30/12/2016 17:50, einstein1...@gmail.com wrote: > Hello everyone, > I am the new comer and learner of python. > I have a doubt that when I type python and press enter it shows a prompt > like > >> But why it is >>> ? > Is there any special reason?

Re: learning and experimenting python.

2016-12-31 Thread Ian Kelly
On Dec 31, 2016 3:12 AM, wrote: That's true. Please include quoted context in your replies. I have no idea who or what you're responding to. -- https://mail.python.org/mailman/listinfo/python-list

Re: New re feature in 3.6: local flags and example use

2017-01-01 Thread Ian Kelly
On Sun, Jan 1, 2017 at 8:25 PM, Terry Reedy wrote: \> 3.6 added syntax for 'local flags'. > ''' > (?imsx-imsx:...) > > (Zero or more letters from the set 'i', 'm', 's', 'x', optionally > followed by '-' followed by one or more letters from the same set.) The > letters set or removes the corres

Re: learning and experimenting python.

2017-01-01 Thread Ian Kelly
On Sun, Jan 1, 2017 at 11:30 AM, Grant Edwards wrote: > On 2016-12-31, Ian Kelly wrote: >> On Dec 31, 2016 3:12 AM, wrote: >> >> That's true. >> >> Please include quoted context in your replies. I have no idea who or what >> you're respon

Re: learning and experimenting python.

2017-01-01 Thread Ian Kelly
On Mon, Jan 2, 2017 at 12:15 AM, Ian Kelly wrote: > Since they're unlikely to do that however, Then again, I see that einstein1410 made a couple of rather aggressive posts 11 hours ago that haven't made it to my email, so maybe he did manage to get himself banned. -- https://ma

Re: learning and experimenting python.

2017-01-02 Thread Ian Kelly
On Jan 2, 2017 10:57 AM, "Wildman via Python-list" wrote: On Sun, 01 Jan 2017 23:02:34 -0800, einstein1410 wrote: > I really don't care the person like you. > Leave my posts, if don't like it. > Why wasting your as well as my time. > Just get lost man, or shut up. [Obscene gesture trimmed] Way

Re: Is there an peekable similar to peekable but in additional allowing one to put some data to it?

2017-01-11 Thread Ian Kelly
On Wed, Jan 11, 2017 at 8:51 AM, Peng Yu wrote: > Hi, peekable from more-itertools only allow peeking an iterator. But > sometimes, one may want to take a look at an element, manipulate it, > then put it back to the iterator. Is there a class in python that can > help do this? Not that I'm aware

Re: Is there an peekable similar to peekable but in additional allowing one to put some data to it?

2017-01-11 Thread Ian Kelly
On Wed, Jan 11, 2017 at 10:07 AM, Ian Kelly wrote: > On Wed, Jan 11, 2017 at 8:51 AM, Peng Yu wrote: >> Hi, peekable from more-itertools only allow peeking an iterator. But >> sometimes, one may want to take a look at an element, manipulate it, >> then put it back to the

Re: Byte-run: a Python interpreter written in Python

2017-01-13 Thread Ian Kelly
On Fri, Jan 13, 2017 at 3:46 AM, Steve D'Aprano wrote: > > http://aosabook.org/en/500L/a-python-interpreter-written-in-python.html Neat. But not really surprising IMO that it can fit into 500 lines, since it doesn't handle compiling Python into bytecode (which is the hard part) and doesn't includ

Re: Byte-run: a Python interpreter written in Python

2017-01-13 Thread Ian Kelly
On Fri, Jan 13, 2017 at 11:07 AM, BartC wrote: > Even when it turns out that the actual code on github is 1000 lines rather > than 500! Maybe it grew a bit since the 500 lines was quoted. I assume they're excluding blank lines, comments and docstrings. And I don't know whether the 500 lines is a

Re: How can I make a sentinel value NOT be initialized in a class/method - OOP?

2017-01-13 Thread Ian Kelly
On Jan 13, 2017 3:33 PM, wrote: The issue I am having is that when i enter the sentinel value of QUIT, it gets initialized as the name and printed out. How can I get around this? I hope this makes sense. Hard to say for certain without seeing your code, but the most likely cause of this is th

Re: Python, asyncio, and systemd

2017-01-17 Thread Ian Kelly
On Tue, Jan 17, 2017 at 9:57 AM, Chris Angelico wrote: > If I write a web server using asyncio (and the aiohttp package), I can > spin up the server with: > > await loop.create_server(app.make_handler(), "0.0.0.0", 8080) > > This works fine for a high port, but if I want to bind to port 80, I > ne

Re: With class as contextmanager

2017-01-24 Thread Ian Kelly
On Tue, Jan 24, 2017 at 2:31 PM, This Wiederkehr wrote: > Hellou > > having a class definition: > > class Test(): > > @classmethod > def __enter__(cls): > pass > > @classmethod > def __exit__(cls, exception_type, execption_value, callback): > pass > > now using this as a contextmanager doe

Re: Need reviews for my book on introductory python

2017-01-27 Thread Ian Kelly
On Jan 27, 2017 2:13 PM, "bob gailer" wrote: On 1/26/2017 8:05 PM, Sandeep Nagar wrote: > Hi > > As I mentioned, a scaled down version is available for free at > bookmuft.Com which can be used to judge in this case. > Maybe I am blind, but I don't see any mention of bookmuft.Co. I pulled up th

Re: Overriding True and False ?

2017-01-30 Thread Ian Kelly
On Jan 30, 2017 2:00 AM, "Chris Angelico" wrote: (Interestingly, Ellipsis is not included in that.) Perhaps because it's rather unusual for a program to depend upon the value of Ellipsis. -- https://mail.python.org/mailman/listinfo/python-list

Re: Overriding True and False ?

2017-01-30 Thread Ian Kelly
On Jan 30, 2017 1:32 AM, "Irv Kalb" wrote: I teach intro to programming using Python. In my first assignment, students are asked to assign variables of different types and print out the values. One student (who really did not understand Booleans) turned in the following for his/her interpretati

Re: Overriding True and False ?

2017-01-30 Thread Ian Kelly
On Jan 30, 2017 6:07 PM, "Steve D'Aprano" wrote: > Hey Ian, > > Your news reader or mail client has stopped quoting the text you are > quoting, so it appears as if you have written it. > > See: > > https://mail.python.org/pipermail/python-list/2017-January/719015.html Well, nuts. It looks fine in

Re: What are your opinions on .NET Core vs Python?

2017-01-31 Thread Ian Kelly
On Jan 30, 2017 11:32 PM, "Gregory Ewing" wrote: > That's the thing I find most frustrating about both C# and Java, > the lack of anything like Python's "from ... import ...". You get > a choice of either effectively doing "import *" on the contents > of a whole class and polluting your namespace,

Re: What are your opinions on .NET Core vs Python?

2017-01-31 Thread Ian Kelly
On Jan 30, 2017 8:00 PM, "Michael Torrie" wrote: > In any case, partial classes seems like a misfeature of C# to me but > apparently they are used when making Windows Forms GUI-based apps. > Apparently VS autogenerates the class that backs the form, and then the > developer creates a partial class

Re: Python doesn't catch exceptions ?

2017-02-01 Thread Ian Kelly
On Wed, Feb 1, 2017 at 8:11 AM, Ivo Bellin Salarin wrote: > This code generates instead the messages: > ``` > ERROR 47.135[bigquery.py.create_table:362] caught exception: HttpError, > defined in server/libs/googleapiclient/errors.pyc. we are in > /Users/nilleb/dev/gae-sample-project/app > ERROR 47

Re: Python3 using requests to grab HTTP Auth Data

2017-02-01 Thread Ian Kelly
On Wed, Feb 1, 2017 at 2:51 PM, Νίκος Βέργος wrote: > Τη Τετάρτη, 1 Φεβρουαρίου 2017 - 11:41:28 μ.μ. UTC+2, ο χρήστης Michael > Torrie έγραψε: >> On 02/01/2017 01:51 PM, Νίκος Βέργος wrote: >> > as well as input() for both user & pass combo but iam not getting in >> > chrome the basic pop-up HTT

Re: Python3 using requests to grab HTTP Auth Data

2017-02-02 Thread Ian Kelly
On Wed, Feb 1, 2017 at 5:22 PM, Νίκος Βέργος wrote: > > # Give user the file requested > > print(''' content="5;url=http://superhost.gr/data/files/%s";>''' % realfile) > > authuser = os.environ.get( 'REMOTE_USER', 'Άγνωστος' ) > print( authuser ) >

Re: Make synchronous generator from an asynchronous generator

2018-03-16 Thread Ian Kelly
On Thu, Mar 15, 2018 at 1:35 PM, Julien Salort wrote: > Because I wanted to keep the synchronous function for scripts which used it, > without unnecessarily duplicating the code, I built also a synchronous > function from this new asynchronous one, like that: > > def acquire_to_files(self, *args

Re: Accessing parent objects

2018-03-25 Thread Ian Kelly
On Sun, Mar 25, 2018 at 5:46 AM, Steven D'Aprano wrote: > On Sun, 25 Mar 2018 06:11:53 -0500, D'Arcy Cain wrote: >> It accesses the parent class. I want to access the parent object. > > Ah. Well, no wonder it doesn't work: you're confusing the OO inheritance > concept of "parent" (a superclass) w

Re: Accessing parent objects

2018-03-25 Thread Ian Kelly
On Sun, Mar 25, 2018 at 9:01 AM, Jugurtha Hadjar wrote: > > On 03/25/2018 03:25 PM, Terry Reedy wrote: >> >> On 3/25/2018 7:42 AM, Jugurtha Hadjar wrote: >> >>> class C2(object): >>> def __init__(self, parent=None): >>> self.parent = parent >> >> >> Since parent is required, it shoul

Re: Accessing parent objects

2018-03-25 Thread Ian Kelly
On Sun, Mar 25, 2018 at 9:01 AM, Jugurtha Hadjar wrote: > > On 03/25/2018 03:25 PM, Terry Reedy wrote: >> None.foo will raise AttributeError. >> > > Right.. As I said, I tried to assume as little as possible about OP's code > and namespace. Didn't want to include C1 in __init__ signature because I

Re: A question related to the PYTHONPATH

2018-03-26 Thread Ian Kelly
On Mon, Mar 26, 2018 at 1:24 PM, Dan Stromberg wrote: > On Sun, Mar 25, 2018 at 11:10 PM, dieter wrote: >> adrien oyono writes: >>> I have recently read the documentation about how imports work on python, >>> and I was wondering why, when you execute a python file, the current >>> directory is n

Re: To super or not to super (Re: Accessing parent objects)

2018-03-27 Thread Ian Kelly
On Tue, Mar 27, 2018 at 12:21 AM, Gregory Ewing wrote: > The idea that super() is *always* the right way to call > inherited methods in a multiple inheritance environment > seems to have been raised by some people to the level > of religous dogma. > > I don't buy it. In order for it to work, the f

Re: To super or not to super (Re: Accessing parent objects)

2018-03-27 Thread Ian Kelly
On Tue, Mar 27, 2018 at 8:47 AM, Ian Kelly wrote: > On Tue, Mar 27, 2018 at 12:21 AM, Gregory Ewing > wrote: >> The trouble is, those conditions don't always hold. >> Often when overriding a method, you want to do something >> *instead* of what the base method doe

Re: please test the new PyPI (now in beta)

2018-03-27 Thread Ian Kelly
On Mon, Mar 26, 2018 at 4:16 PM, Sumana Harihareswara wrote: > The new Python Package Index at https://pypi.org is now in beta. > > This means the site is robust, but we anticipate needing more user > testing and changes before it is "production-ready" and can fully > replace https://pypi.python.

Re: ***URGENT CONTRACT OPPORTUNITY***

2018-03-28 Thread Ian Kelly
On Wed, Mar 28, 2018 at 9:02 AM, Tobiah wrote: > > When should I apply? The ad said ASAP, so I guess that now it's already too late. -- https://mail.python.org/mailman/listinfo/python-list

Re: Python Developer Survey: Python 3 usage overtakes Python 2 usage

2018-03-30 Thread Ian Kelly
On Fri, Mar 30, 2018 at 7:10 PM, Rick Johnson wrote: > On Friday, March 30, 2018 at 7:44:40 PM UTC-5, Steven D'Aprano wrote: > [...] >> Reddit's /ruby subreddit: 40,571 subscribers. >> >> Reddit's /python subreddit: 230,858 subscribers. > > Those numbers mean nothing unless you can prove all two-

Re: Python Developer Survey: Python 3 usage overtakes Python 2 usage

2018-03-30 Thread Ian Kelly
On Fri, Mar 30, 2018 at 8:43 PM, Ian Kelly wrote: > You really think that 90% of the active users are trolls? And yet the > subreddit remains usable despite that allegedly terrible > signal-to-noise ratio. I'm now laughing at the image of a large community of trolls sitting around

Re: Python Developer Survey: Python 3 usage overtakes Python 2 usage

2018-03-31 Thread Ian Kelly
On Sat, Mar 31, 2018 at 6:29 AM, Rick Johnson wrote: > On Friday, March 30, 2018 at 8:59:16 PM UTC-5, Chris Angelico wrote: >> Wanna provide some competing information showing that other >> languages are more used? > > Chris, here is how debate works: > > PersonA asserts X. > > PersonB dem

Re: Unified async/sync interface

2018-04-01 Thread Ian Kelly
On Sat, Mar 31, 2018 at 7:44 PM, Demian Brecht wrote: > I might be entirely off my face, but figured I'd ask anyways given I > haven't figured out a clean solution to this problem myself yet: > > I'm trying to write a REST API client that supports both async and > synchronous HTTP transports (init

Re: In asyncio, does the event_loop still running after run_until_complete returned?

2018-04-02 Thread Ian Kelly
On Mon, Apr 2, 2018 at 5:32 AM, wrote: > I am new to the asyncio subject, just trying to figure out how to use it. > Below is the script I use for testing: > - > # asyncio_cancel_task2.py > > import asyncio > > @asyncio.coroutine > def task_func(): > print('in

Re: In asyncio, does the event_loop still running after run_until_complete returned?

2018-04-02 Thread Ian Kelly
On Mon, Apr 2, 2018 at 9:01 PM, wrote: > I also do a quick check, with call_later delay keeps at 1.5, to see what the > event loop status is after run_until_complete returns. Strangely, both > is_closed and is_running return a False. > > try: > event_loop.run_until_complete(main(eve

Re: Python aliases under Windows?

2018-04-03 Thread Ian Kelly
On Tue, Apr 3, 2018 at 3:24 AM, Kirill Balunov wrote: > Perhaps this is a silly question but still...There is PEP 394 "The "python" > Command on Unix-Like Systems" which I find very reasonable, no matter how > it is respected. Why was not _somewhat_ the same done for Windows? PEP 394 is meant to

Re: Python aliases under Windows?

2018-04-03 Thread Ian Kelly
On Tue, Apr 3, 2018 at 9:00 AM, Kirill Balunov wrote: > In fact, I do not really understand why the _py launcher_ way is easier or > better than `python3` or `python3.6` way even on Windows. There are already > `pip.exe`, `pip3.exe`, `pip3.6.exe` which solve the same problem, but they > are all r

Re: In asyncio, does the event_loop still running after run_until_complete returned?

2018-04-03 Thread Ian Kelly
On Tue, Apr 3, 2018 at 9:20 PM, wrote: > What's the purpose of resetting self._stopping back to False in finally > clause? Presumably so that the loop won't immediately stop again if you restart it. -- https://mail.python.org/mailman/listinfo/python-list

Re: try-except syntax

2018-04-05 Thread Ian Kelly
On Thu, Apr 5, 2018 at 3:04 PM, ElChino wrote: > I'm trying to simplify a try-except construct. E.g. how come > this: > try: > _x, pathname, _y = imp.find_module (mod, mod_path) > return ("%s" % pathname) > except ImportError: > pass > except RuntimeError: > pass > return

Re: RE newbie question

2018-04-18 Thread Ian Kelly
On Wed, Apr 18, 2018 at 1:57 PM, Rob Gaddi wrote: > On 04/18/2018 12:37 PM, TUA wrote: >> >> import re >> >> compval = 'A123456_8' >> regex = '[a-zA-Z]\w{0,7}' >> >> if re.match(regex, compval): >> print('Yes') >> else: >> print('No') >> >> >> My intention is to implement a max. length of

Re: itemgetter with default arguments

2018-05-04 Thread Ian Kelly
On Fri, May 4, 2018 at 7:01 AM, Steven D'Aprano wrote: > Here are the specifications: > > * you must use lambda, not def; Why? This seems like an arbitrary constraint. > * the lambda must take a single function, the sequence you want to > extract an item from; > > * you can hard-code the index

Re: itemgetter with default arguments

2018-05-04 Thread Ian Kelly
On Fri, May 4, 2018 at 11:04 AM, Steven D'Aprano wrote: > On Fri, 04 May 2018 09:17:14 -0600, Ian Kelly wrote: > >> On Fri, May 4, 2018 at 7:01 AM, Steven D'Aprano >> wrote: >>> Here are the specifications: >>> >>> * you must use l

Re: itemgetter with default arguments

2018-05-05 Thread Ian Kelly
On Fri, May 4, 2018 at 5:34 PM, Thomas Jollans wrote: > On 04/05/18 22:38, Ian Kelly wrote: >> The real thing is written in C. >> > > Is it though? > > https://github.com/python/cpython/blob/a1fc949b5ab8911a803eee691e6eea55cec43eeb/Lib/operator.py#L265 It is. First, n

Re: seeking deeper (language theory) reason behind Python design choice

2018-05-08 Thread Ian Kelly
On Tue, May 8, 2018 at 9:48 PM, Python wrote: > On Tue, May 08, 2018 at 12:45:29AM +, Steven D'Aprano wrote: >> since = in a statement on its own is not dangerous. People *almost never* >> intend to write == for the side-effects only: > > Seriously? I do this--not every day, but more than occ

Re: Leading 0's syntax error in datetime.date module (Python 3.6)

2018-05-10 Thread Ian Kelly
On Thu, May 10, 2018 at 5:49 AM, D'Arcy Cain wrote: > On 2018-05-10 07:28 AM, Skip Montanaro wrote: >> https://www.python.org/dev/peps/pep-3127/#removal-of-old-octal-syntax > > Funny stuff: > > Python could either: > > 1. silently do the wrong thing... > 2. immediately disabuse him... >

Re: Leading 0's syntax error in datetime.date module (Python 3.6)

2018-05-10 Thread Ian Kelly
On Thu, May 10, 2018 at 10:36 AM, bartc wrote: > What, 0O100 instead of 0100? Yeah that's a big improvement... > > Fortunately octal doesn't get used much. The PEP discusses this: """ Proposed syntaxes included things like arbitrary radix prefixes, such as 16r100 (256 in hexadecimal), and radix

Re: seeking deeper (language theory) reason behind Python design choice

2018-05-10 Thread Ian Kelly
On Tue, May 8, 2018 at 11:50 PM, Chris Angelico wrote: > On Wed, May 9, 2018 at 3:36 PM, Ian Kelly wrote: >> >> while True: >> if we_are_done(): >> break >> # do some stuff >> ... >> if error_occurred(): >> bre

Re: seeking deeper (language theory) reason behind Python design choice

2018-05-10 Thread Ian Kelly
On Thu, May 10, 2018 at 7:10 PM, Chris Angelico wrote: > On Fri, May 11, 2018 at 10:29 AM, Marko Rauhamaa wrote: >> Chris Angelico : >> >>> But for the loop itself, you absolutely CAN write this more logically. >>> I'll take your second version as a template: >>> >>> def split_cmd(self, cmd):

Re: Leading 0's syntax error in datetime.date module (Python 3.6)

2018-05-10 Thread Ian Kelly
On Thu, May 10, 2018 at 9:21 PM, Steven D'Aprano wrote: > On Thu, 10 May 2018 11:03:54 -0600, Ian Kelly wrote about proposed > prefixes for octal: > >> Personally I would have preferred the "t". > > "t" for octal, hey? > > That would be annoyi

Re: Suggestion for a "data" object syntax

2018-05-10 Thread Ian Kelly
On Thu, May 10, 2018 at 6:34 PM, Mikhail V wrote: > On Wed, May 9, 2018 at 6:25 AM, Steven D'Aprano > wrote: >> On Tue, 08 May 2018 23:16:23 +0300, Mikhail V wrote: >> > >>> but I propose Tab-separated elements. >> >> We already have tab-separated elements in Python. It is allowed to use >> tabs

Re: Suggestion for a "data" object syntax

2018-05-10 Thread Ian Kelly
On Mon, May 7, 2018 at 9:45 PM, Mikhail V wrote: > Here is an idea for 'data object' a syntax. > For me it is interesting, how would users find such syntax. > I personally find that this should be attractive from users > perspective. > Main aim is more readable presenting of typical data chunks >

Re: seeking deeper (language theory) reason behind Python design choice

2018-05-10 Thread Ian Kelly
On Thu, May 10, 2018 at 11:17 PM, Steven D'Aprano wrote: > To answer your question from a later post: > > In what way does "while True" in the general case pretend > to be an infinite loop? > > It doesn't *pretend* to be an infinite loop. It *is* an infinite loop > which breaks out early.

Re: seeking deeper (language theory) reason behind Python design choice

2018-05-10 Thread Ian Kelly
On Thu, May 10, 2018 at 11:45 PM, Steven D'Aprano wrote: > To be honest, I'm having trouble thinking of a good use-case for "while > True", now that we have infinite iterators. Most cases of > > while True: > x = get_item() > if not x: break > process(x) > > are better

Re: seeking deeper (language theory) reason behind Python design choice

2018-05-11 Thread Ian Kelly
On Fri, May 11, 2018 at 12:03 AM, Steven D'Aprano wrote: > On Thu, 10 May 2018 20:38:39 -0600, Ian Kelly wrote: > >> Would you also contend that generator functions are wrong because they >> pretend to be normal functions? > > You're going to need to be more

Re: seeking deeper (language theory) reason behind Python design choice

2018-05-11 Thread Ian Kelly
On Fri, May 11, 2018 at 1:06 AM, Chris Angelico wrote: > On Fri, May 11, 2018 at 4:54 PM, Ian Kelly wrote: >> On Thu, May 10, 2018 at 11:45 PM, Steven D'Aprano >> wrote: >>> To be honest, I'm having trouble thinking of a good use-case for "while >>

Re: seeking deeper (language theory) reason behind Python design choice

2018-05-11 Thread Ian Kelly
On Fri, May 11, 2018 at 1:01 AM, Chris Angelico wrote: > On Fri, May 11, 2018 at 12:38 PM, Ian Kelly wrote: >> Would you also contend that generator functions are wrong because they >> pretend to be normal functions? >> >> def totally_not_a_generator(n): >>

Re: seeking deeper (language theory) reason behind Python design choice

2018-05-11 Thread Ian Kelly
On Fri, May 11, 2018 at 7:40 AM, Chris Angelico wrote: > So, yes, your function's name is outright lying. But there's nothing > about it that is *pretending* to be a normal function. It IS a normal > function. The detail of whether it's a generator function affects the function's execution and ma

Re: Leading 0's syntax error in datetime.date module (Python 3.6)

2018-05-11 Thread Ian Kelly
On Fri, May 11, 2018 at 12:19 AM, Steven D'Aprano wrote: > On Thu, 10 May 2018 23:23:33 -0600, Ian Kelly wrote: > >> On Thu, May 10, 2018 at 9:21 PM, Steven D'Aprano >> wrote: >>> On Thu, 10 May 2018 11:03:54 -0600, Ian Kelly wrote about proposed >>

Re: Leading 0's syntax error in datetime.date module (Python 3.6)

2018-05-11 Thread Ian Kelly
On Fri, May 11, 2018 at 10:35 AM, Ian Kelly wrote: > On Fri, May 11, 2018 at 12:19 AM, Steven D'Aprano > wrote: >> On Thu, 10 May 2018 23:23:33 -0600, Ian Kelly wrote: >> >>> On Thu, May 10, 2018 at 9:21 PM, Steven D'Aprano >>> wrote: >>&g

Re: Suggestion for a "data" object syntax

2018-05-12 Thread Ian Kelly
On Fri, May 11, 2018 at 5:26 PM, Mikhail V wrote: > On Fri, May 11, 2018 at 9:12 AM, Ian Kelly wrote: >> On Thu, May 10, 2018 at 6:34 PM, Mikhail V wrote: >>> Do you understand that basically any python code sent by e-mail converts >>> tabs to >>> spaces,

Re: seeking deeper (language theory) reason behind Python design choice

2018-05-14 Thread Ian Kelly
On Mon, May 14, 2018 at 9:20 AM, Python wrote: > On Sun, May 13, 2018 at 02:42:48PM +1000, Chris Angelico wrote: >> On Sun, May 13, 2018 at 2:31 PM, Python wrote: >> >> Yes, and I'd go further: I *am* too stupid to get this right. >> > >> > No, you are not. Do you ever say "dog" when you mean "d

Re: seeking deeper (language theory) reason behind Python design choice

2018-05-14 Thread Ian Kelly
On Mon, May 14, 2018 at 9:38 AM, Python wrote: > Absolutely correct. If you're not doing THOROUGH code reviews, and > not thoroughly testing your code, your job is only half done. You > should be your own first reviewer, and then have a second someone > competent review it after you do. One sho

Re: syntax oddities

2018-05-15 Thread Ian Kelly
On Tue, May 15, 2018 at 1:10 PM, Tobiah wrote: > Why is it len(object) instead of object.len? > > Why is it getattr(object, item) rather then object.getattr(item)? http://effbot.org/pyfaq/why-does-python-use-methods-for-some-functionality-e-g-list-index-but-functions-for-other-e-g-len-list.htm --

Re: seeking deeper (language theory) reason behind Python design choice

2018-05-16 Thread Ian Kelly
On Tue, May 15, 2018, 6:36 PM bartc wrote: > On 16/05/2018 01:04, Steven D'Aprano wrote: > > > I'm not a C coder, but I think that specific example would be immune to > > the bug we are discussing, since (I think) you can't chain assignments in > > C. Am I right? > > Assignments can be chained in

Re: seeking deeper (language theory) reason behind Python design choice

2018-05-16 Thread Ian Kelly
On Wed, May 16, 2018 at 10:06 AM, bartc wrote: > On 16/05/2018 16:09, Ian Kelly wrote: >> >> On Tue, May 15, 2018, 6:36 PM bartc wrote: >> >>> On 16/05/2018 01:04, Steven D'Aprano wrote: >>> >>>> I'm not a C coder, but I think

Re: syntax oddities

2018-05-16 Thread Ian Kelly
On Tue, May 15, 2018, 6:00 PM Steven D'Aprano < steve+comp.lang.pyt...@pearwood.info> wrote: > On Tue, 15 May 2018 12:10:07 -0700, Tobiah wrote: > > > Why is it len(object) instead of object.len? > > Because we're not serfs in the Kingdom of Nouns: > > https://steve-yegge.blogspot.com/2006/03/exec

Re: what does := means simply?

2018-05-17 Thread Ian Kelly
On Thu, May 17, 2018 at 9:06 AM, Chris Angelico wrote: > On Fri, May 18, 2018 at 12:30 AM, bartc wrote: >> Anyway, try this: >> >> def showarg(x): print(x) >> >> def dummy(*args,**kwargs): pass >> >> dummy(a=showarg(1),*[showarg(2),showarg(3)]) >> >> This displays 2,3,1 showing that e

Re: Re: why does list's .remove() does not return an object?

2018-05-17 Thread Ian Kelly
On Thu, May 17, 2018 at 3:27 PM, Karsten Hilbert wrote: >> On 5/17/18 11:57 AM, Abdur-Rahmaan Janhangeer wrote: >> > x = [0,1] >> > x.remove(0) >> > new_list = x >> > >> > instead i want in one go >> > >> > x = [0,1] >> > new_list = x.remove(0) # here a way for it to return the modified list by >>

Re: what does := means simply?

2018-05-17 Thread Ian Kelly
On Thu, May 17, 2018, 7:50 PM Steven D'Aprano < steve+comp.lang.pyt...@pearwood.info> wrote: > > If you want to *really* see code that is hard to port, you should try > porting an Inform 7 program to another language. Any other language. > How about Z-code? *ducks* > -- https://mail.python.org

Re: "Data blocks" syntax specification draft

2018-05-20 Thread Ian Kelly
On Sun, May 20, 2018 at 4:28 PM, Mikhail V wrote: > "Markdown" is too vague - there dozens of markdown styles and > also they include subsets of HTML. It is just plain text with tags The whole point of Markdown is that it's readable as plain text precisely because it *doesn't* use obvious tags li

Re: "Data blocks" syntax specification draft

2018-05-22 Thread Ian Kelly
On Tue, May 22, 2018 at 8:25 AM, Chris Angelico wrote: > On Tue, May 22, 2018 at 8:25 PM, bartc wrote: >> Note that Python tuples don't always need a start symbol: >> >>a = 10,20,30 >> >> assigns a tuple to a. > > The tuple has nothing to do with the parentheses, except for the > special case

Re: "Data blocks" syntax specification draft

2018-05-22 Thread Ian Kelly
On Tue, May 22, 2018 at 9:22 AM, Ian Kelly wrote: > On Tue, May 22, 2018 at 8:25 AM, Chris Angelico wrote: >> On Tue, May 22, 2018 at 8:25 PM, bartc wrote: >>> Note that Python tuples don't always need a start symbol: >>> >>>a = 10,20,30 >>

Re: "Data blocks" syntax specification draft

2018-05-22 Thread Ian Kelly
On Tue, May 22, 2018 at 9:34 AM, Chris Angelico wrote: > On Wed, May 23, 2018 at 1:22 AM, Ian Kelly wrote: >> On Tue, May 22, 2018 at 8:25 AM, Chris Angelico wrote: >>> On Tue, May 22, 2018 at 8:25 PM, bartc wrote: >>>> Note that Python tuples don't always

Re: "Data blocks" syntax specification draft

2018-05-22 Thread Ian Kelly
On Tue, May 22, 2018 at 11:32 PM, Christian Gollwitzer wrote: > Am 23.05.18 um 07:22 schrieb Chris Angelico: >> >> On Wed, May 23, 2018 at 9:51 AM, bartc wrote: >>> >>> Sorry, but I don't think you're right at all. unless the official >>> references >>> for the language specifically say that comm

Re: "Data blocks" syntax specification draft

2018-05-22 Thread Ian Kelly
On Wed, May 23, 2018 at 12:01 AM, Ian Kelly wrote: > On Tue, May 22, 2018 at 11:32 PM, Christian Gollwitzer > wrote: >> Am 23.05.18 um 07:22 schrieb Chris Angelico: >>> >>> On Wed, May 23, 2018 at 9:51 AM, bartc wrote: >>>> >>>> Sorry, but

Re: "Data blocks" syntax specification draft

2018-05-23 Thread Ian Kelly
On Wed, May 23, 2018 at 12:49 AM, Steven D'Aprano wrote: > On Tue, 22 May 2018 09:43:55 -0600, Ian Kelly wrote: > >> In other words, the rule is not really as simple as "commas make >> tuples". I stand by what I wrote. > > Being pedantic is great, but if

Re: Indented multi-line strings (was: "Data blocks" syntax specification draft)

2018-05-23 Thread Ian Kelly
On Wed, May 23, 2018 at 10:25 AM, Peter J. Holzer wrote: > How about this? > > x = > Here is a multi-line string > with > indentation. > > > This would be equivalent to > > x = 'Here is a multi-line string\nwith\n indentation.' > > Rules

Re: Enums: making a single enum

2018-05-25 Thread 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 for the Maybe case?

Re: Indented multi-line strings (was: "Data blocks" syntax specification draft)

2018-05-29 Thread Ian Kelly
On Tue, May 29, 2018 at 3:19 AM, Peter J. Holzer wrote: > On 2018-05-23 11:08:48 -0600, Ian Kelly wrote: >> >> How about we instead just use the rules from PEP 257 so that there >> aren't two different sets of multi-line string indentation rules to >&g

Re: Re: The PIL show() method looks for the default viewer. How do I change this to a different viewer (of my choice)?

2018-05-29 Thread Ian Kelly
On Sat, May 26, 2018 at 9:17 AM, 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 on

Re: a Python bug report

2018-05-29 Thread Ian Kelly
On Tue, May 29, 2018 at 7:07 PM, Ruifeng Guo wrote: > Hello, > We encountered a bug in Python recently, we checked the behavior for Python > version 2.7.12, and 3.1.1, both version show the same behavior. Please see > below the unexpected behavior in "red text". > > Thanks, > Ruifeng Guo > > Fro

Re: OFF-TOPIC Good sig [was Re: What is the "Unpacking Arguments List" rule?]

2018-06-13 Thread Ian Kelly
On Wed, Jun 13, 2018 at 10:10 AM Steven D'Aprano wrote: > > On Wed, 13 Jun 2018 12:43:12 +, Alister via Python-list wrote: > > > I have a theory that it's impossible to prove anything, but I can't > > prove it. > > Heh, that reminds me of Stephen Pinker's comment from "Enlightenment Now": > >

Re: syntax difference

2018-06-18 Thread Ian Kelly
On Mon, Jun 18, 2018 at 9:17 AM Rick Johnson wrote: > > Chris Angelico wrote: > [...] > > What was the quote before that? > > > > > "Type-hint comments" would allow: > > > (3) and those who utterly *HATE* them, to write a simpl[e] > > > little function which will strip them from any and all >

Re: syntax difference (type hints)

2018-06-18 Thread Ian Kelly
FYI, Python type hints aren't "proposed"; they're already here. The function annotation syntax was added in 3.0, without any imposition of semantic meaning or requirements on it, and allowed to simmer for several years for third-party frameworks to find uses for. Python 3.5 added the typing module

Re: syntax difference

2018-06-18 Thread Ian Kelly
On Mon, Jun 18, 2018 at 11:39 AM Jim Lee wrote: > On 06/18/2018 07:03 AM, Steven D'Aprano wrote: > > As a human programmer, you surely perform your own ad hoc type checking > > when you write and debug code. > Of course. And, I use linting tools and other forms of static type > checking. What I

Re: syntax difference

2018-06-18 Thread Ian Kelly
On Mon, Jun 18, 2018 at 11:27 AM Rick Johnson wrote: > > Ian wrote: > > > Uh, yes, they do. They're defined in PEP 484, and Mypy uses them for > > type-checking Python 2 code, where the annotations don't exist. > > So when will the interleaved type-hints be removed from the language > specificati

Re: syntax difference

2018-06-18 Thread Ian Kelly
On Mon, Jun 18, 2018 at 10:19 AM Rick Johnson wrote: > And even from the POV of a programmer, comments can be more > useful if they are ignored than if they are not. Some > programmers lack the skill required to properly explain the > workings of an algorithm in natural language, and thus, the > r

Re: syntax difference

2018-06-19 Thread Ian Kelly
On Tue, Jun 19, 2018 at 3:14 AM Steven D'Aprano wrote: > > On Mon, 18 Jun 2018 10:01:58 -0700, Rick Johnson wrote: > > > Steven D'Aprano wrote: > > [...] > >> particular at DropBox, which is (I believe) funding a lot of Guido's > >> time on this, because they need it. > > > > And now we get to the

Re: syntax difference

2018-06-19 Thread Ian Kelly
On Mon, Jun 18, 2018 at 2:57 PM Rick Johnson wrote: > > On Monday, June 18, 2018 at 2:48:58 PM UTC-5, Ian wrote: > > I would also note that none of this applies to type hinting > > in any case. Type hints don't require the programmer to be > > able to explain anything in natural language, nor are

Re: syntax difference

2018-06-19 Thread Ian Kelly
On Tue, Jun 19, 2018 at 1:42 PM Rick Johnson wrote: > > On Tuesday, June 19, 2018 at 1:02:52 PM UTC-5, Ian wrote: > > On Mon, Jun 18, 2018 at 2:57 PM Rick Johnson > > It's a "burden" (actually, a helpful tool) to the > > programmer either way: whether it's in a comment or an > > annotation, it's t

Re: Should nested classes in an Enum be Enum members?

2018-06-28 Thread Ian Kelly
On Thu, Jun 28, 2018 at 4:38 AM Ben Finney wrote: > > Ethan Furman writes: > > > Consider the following Enum definition: > > > > class Color(Enum): > > RED = 1 > > GREEN = 2 > > BLUE = 3 > > @property > > def lower(self): > > return self.name.lower() > >

<    8   9   10   11   12   13   14   15   16   17   >