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 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: 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: 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: 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: 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-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: 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: 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: 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: 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: 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: 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 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 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-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-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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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-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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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-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: ***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: 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: 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: 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: 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: 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: 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 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: 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: cute interview problem

2018-03-03 Thread Ian Kelly
On Sat, Mar 3, 2018 at 3:26 PM, Richard Damon wrote: > On 2/28/18 3:51 PM, Ian Kelly wrote: >> >> On Wed, Feb 28, 2018 at 12:55 PM, wrote: >>> >>> On Tuesday, 27 February 2018 00:42:02 UTC+1, Paul Rubin wrote: >>>> >>>> Ron Aaron post

Re: RFC: Proposal: Deterministic Object Destruction (Posting On Python-List Prohibited)

2018-03-03 Thread Ian Kelly
On Sat, Mar 3, 2018 at 9:19 AM, Richard Damon wrote: > One idea does come to mind though, would it be reasonable, and somewhat > Pythonic, for a class to define member functions like __ref__ and __unref__ > (or perhaps some other name) that if defined, would be called every time a > name was bound

Re: RFC: Proposal: Deterministic Object Destruction (Posting On Python-List Prohibited)

2018-03-03 Thread Ian Kelly
On Fri, Mar 2, 2018 at 9:57 PM, Gregory Ewing wrote: > Paul Rubin wrote: >> >> So you want the programmer to put more head scratching into figuring out >> which reference should be strong and which should be weak? > > > Also, sometimes weak references don't really solve the > problem, e.g. if you

Re: RFC: Proposal: Deterministic Object Destruction

2018-03-01 Thread Ian Kelly
On Thu, Mar 1, 2018 at 10:35 PM, Chris Angelico wrote: > On Fri, Mar 2, 2018 at 4:16 PM, Ian Kelly wrote: >> On Wed, Feb 28, 2018 at 8:00 PM, Chris Angelico wrote: >>> Not off hand, but I can provide an EXTREMELY real-world example of a >>> fairly tight loop: exc

Re: RFC: Proposal: Deterministic Object Destruction

2018-03-01 Thread Ian Kelly
On Wed, Feb 28, 2018 at 9:00 PM, ROGER GRAYDON CHRISTMAN wrote: > > On Wed, Feb 28, 2018, Rick Johnson wrote: > > On Wednesday, February 28, 2018 at 5:02:17 PM UTC-6, Chris Angelico wrote: >> >>> Here's one example: reference cycles. When do they get detected? >>> Taking a really simple situation:

Re: RFC: Proposal: Deterministic Object Destruction

2018-03-01 Thread Ian Kelly
On Wed, Feb 28, 2018 at 8:00 PM, Chris Angelico wrote: > On Thu, Mar 1, 2018 at 1:46 PM, Rick Johnson > wrote: >> On Wednesday, February 28, 2018 at 5:02:17 PM UTC-6, Chris Angelico wrote: >> >>> Here's one example: reference cycles. When do they get detected? >>> Taking a really simple situation

Re: cute interview problem

2018-02-28 Thread Ian Kelly
On Wed, Feb 28, 2018 at 12:55 PM, wrote: > On Tuesday, 27 February 2018 00:42:02 UTC+1, Paul Rubin wrote: >> Ron Aaron posted the below url on comp.lang.forth. It points to what I >> thought was a cute problem, along with his solution in his Forth dialect >> 8th: >> >> https://8th-dev.com/for

Re: help me ?

2018-02-27 Thread Ian Kelly
On Tue, Feb 27, 2018 at 2:50 PM, Andre Müller wrote: > Hello, > > it's a duplicate: > https://python-forum.io/Thread-Working-with-lists-homework-2 > > I have seen this more than one time. We don't like it. You keep people busy > with one question at different places. You assume that it was posted

Re: help me ?

2018-02-27 Thread Ian Kelly
On Tue, Feb 27, 2018 at 10:16 AM, Igor Korot wrote: > Congratulations! > You have an "A" for solving the problem and "F" for helping the guy cheat. > You should be expelled from the course. In my experience, this is what happens pretty much every time. Somebody posts a homework question asking fo

Re: matrix multiplication

2018-02-27 Thread Ian Kelly
On Tue, Feb 27, 2018 at 9:02 AM, Seb wrote: > That's right. I just tried this manipulation by replacing the last > block of code in my example, from the line above `for` loop with: > > ------ > # Alternative using `np.matmul` >

Re: matrix multiplication

2018-02-27 Thread Ian Kelly
On Tue, Feb 27, 2018 at 4:08 AM, Peter Otten <__pete...@web.de> wrote: > Seb wrote: > >> On Tue, 27 Feb 2018 12:25:30 +1300, >> Gregory Ewing wrote: >> >>> Seb wrote: I was wondering is whether there's a faster way of multiplying each row (1x3) of a matrix by another matrix (3x3), compar

Re: Are the critiques in "All the things I hate about Python" valid?

2018-02-26 Thread Ian Kelly
On Mon, Feb 26, 2018 at 8:55 PM, Ian Kelly wrote: > On Mon, Feb 26, 2018 at 8:09 PM, Steven D'Aprano > wrote: >> Yes you did: "the last second of every year" is always 23:59:59 of 31st >> December, and it is always the same time and date "every year"

Re: Are the critiques in "All the things I hate about Python" valid?

2018-02-26 Thread Ian Kelly
On Mon, Feb 26, 2018 at 8:09 PM, Steven D'Aprano wrote: > Yes you did: "the last second of every year" is always 23:59:59 of 31st > December, and it is always the same time and date "every year". Except when it's 23:59:60 or 23:59:61 (which hasn't yet happened but could). -- https://mail.python.

Re: matrix multiplication

2018-02-26 Thread Ian Kelly
On Mon, Feb 26, 2018 at 3:12 PM, Dan Stromberg wrote: > On Mon, Feb 26, 2018 at 2:07 PM, Ian Kelly wrote: >> Taking LMGTFY to a whole new level of rudeness by obviously not even >> bothering to read the entire paragraph before responding. > > Is LMGTFY rude? I think mayb

Re: matrix multiplication

2018-02-26 Thread Ian Kelly
On Mon, Feb 26, 2018 at 2:40 PM, Dan Stromberg wrote: > On Mon, Feb 26, 2018 at 8:53 AM, Seb wrote: >> On Sun, 25 Feb 2018 18:52:14 -0500, >> Terry Reedy wrote: >> >> [...] >> >>> numpy has a matrix multiply function and now the '@' matrix multiply >>> operator. >> >> Yes, but what I was wonderi

Re: Is there are good DRY fix for this painful design pattern?

2018-02-26 Thread Ian Kelly
On Mon, Feb 26, 2018 at 2:37 PM, Ian Kelly wrote: > On Mon, Feb 26, 2018 at 1:09 PM, wrote: >> def foo(self, *args, **kwargs): >> assert len(args) == 0 > > Better: > > def foo(self, **kwargs): > >> So, use the inspect module to detect t

Re: Is there are good DRY fix for this painful design pattern?

2018-02-26 Thread Ian Kelly
On Mon, Feb 26, 2018 at 1:09 PM, wrote: > def foo(self, *args, **kwargs): > assert len(args) == 0 Better: def foo(self, **kwargs): > So, use the inspect module to detect the valid arguments > from the class initializer. Then use **kwargs in every > class method. It would be nice if

Re: Is there are good DRY fix for this painful design pattern?

2018-02-26 Thread Ian Kelly
On Mon, Feb 26, 2018 at 8:06 AM, Chris Angelico wrote: > On Tue, Feb 27, 2018 at 1:41 AM, Steven D'Aprano > wrote: >> I have a class with a large number of parameters (about ten) assigned in >> `__init__`. The class then has a number of methods which accept >> *optional* arguments with the same n

Re: matrix multiplication

2018-02-26 Thread Ian Kelly
On Mon, Feb 26, 2018 at 9:53 AM, Seb wrote: > On Sun, 25 Feb 2018 18:52:14 -0500, > Terry Reedy wrote: > > [...] > >> numpy has a matrix multiply function and now the '@' matrix multiply >> operator. > > Yes, but what I was wondering is whether there's a faster way of > multiplying each row (1x3)

Re: For Loop Dilema [python-list]

2018-02-26 Thread Ian Kelly
On Sun, Feb 25, 2018 at 8:05 PM, INADA Naoki wrote: > https://docs.python.org/3.6/library/itertools.html#itertools.product I don't see how you would use itertools.product to do what the OP asked for. You could use itertools.chain.from_iterable, though: py> names = ['Jack', 'Susan'] py> list(chai

Re: For Loop Dilema [python-list]

2018-02-25 Thread Ian Kelly
On Sun, Feb 25, 2018 at 11:19 AM, wrote: > Why we don’t use: > > for _ in _ in _ > > Instead of > > for _ in _: > for _ in _: > > Ex: > > Names = ["Arya","Pupun"] > > for name in Names: >for c in name: >print(c) > > instead use: > > for c in name in Names: > print(c)

Re: How to make Python run as fast (or faster) than Julia

2018-02-22 Thread Ian Kelly
On Thu, Feb 22, 2018 at 12:55 PM, Jack Fearnley wrote: > I realize that this thread is about benchmarking and not really about > generating fibonacci numbers, but I hope nobody is using this code to > generate them on a 'production' basis, > > Fibonacci numbers, any linearly recursive sequence for

Re: Are the critiques in "All the things I hate about Python" valid?

2018-02-21 Thread Ian Kelly
On Tue, Feb 20, 2018 at 10:09 PM, Chris Angelico wrote: > On Wed, Feb 21, 2018 at 6:39 AM, Geldenhuys, J, Prof > wrote: >> I think your case illustrates the Python/Mathematica issue well: you found >> a job for which Mathematica was not the perfect tool and you used Python. >> At the end of

Re: Are the critiques in "All the things I hate about Python" valid?

2018-02-20 Thread Ian Kelly
On Tue, Feb 20, 2018 at 8:38 AM, Steven D'Aprano wrote: > On Tue, 20 Feb 2018 15:23:44 +0100, Antoon Pardon wrote: > >>> Okay. Now create a constraint on a name in C++ such that it can only >>> accept integers representing A.D. years which, on the Gregorian >>> calendar, are leap years. (Using a d

Re: Are the critiques in "All the things I hate about Python" valid?

2018-02-17 Thread Ian Kelly
On Fri, Feb 16, 2018 at 9:32 PM, Chris Angelico wrote: > You'd be surprised how rarely that kind of performance even matters. > The author of that article cites C# as a superior language, but in the > rewrite from C# to Python (the same one I mentioned in the other > post), I sped the program up i

Re: How to run script from interpreter?

2018-02-16 Thread Ian Kelly
On Fri, Feb 16, 2018 at 3:18 PM, windhorn wrote: > Yes, it's been covered, but not quite to my satisfaction. > > Here's an example simple script: > > # Very simple script > bar = 123 > > I save this as "foo.py" somewhere Python can find it > import foo bar > Traceback (most recent call l

Re: What F strings should have been

2018-02-15 Thread Ian Kelly
On Wed, Feb 14, 2018 at 2:24 PM, D'Arcy Cain wrote: > A recent post by Terry Jan Reedy got me thinking about formatting. I > like the new(ish) format method for strings and I see some value in F > strings but it only works well with locals. Anything more starts > getting messier than format() an

Re: Does anyone know ni?

2018-02-06 Thread Ian Kelly
It was used for package support and is no longer needed from Python 1.5. http://legacy.python.org/doc/essays/packages.html On Tue, Feb 6, 2018 at 1:27 PM, Roel Schroeven wrote: > I'm having a look at py-iso8211 from > https://sourceforge.net/projects/py-iso8211/ to see if I can get it to work > w

Re: Python "Bad syntax"

2018-02-05 Thread Ian Kelly
On Mon, Feb 5, 2018 at 10:13 AM, wrote: > > Hi, I have a problem in continuing the function. > > I'm a beginner, I'm learning from a textbook. I'm going to put the following > examples from a textbook that displays "wrong syntax" It would be very helpful if you would copy/paste the exact error m

Re: Why no '|' operator for dict?

2018-02-05 Thread Ian Kelly
On Mon, Feb 5, 2018 at 12:35 AM, Frank Millman wrote: > So I have 2 questions - > > 1. Is there any particular reason why '|' is not supported? '|' is the set union operation, roughly equivalent to the set.union method. Dicts don't have a union operation. If they did, and the same key were found

Re: Problem with coroutines old-style / new-style usage and features

2018-02-01 Thread Ian Kelly
On Thu, Feb 1, 2018 at 5:38 AM, Yahya Abou 'Imran via Python-list wrote: > Hi guys. > > I am discovering coroutines and asynchronous programming, and I have a little > problem with a little example I'm coding myself as an excercice. > > Let say you take two guys in the street: Dave and Bryan. > Y

Re: Create an alias to an attribute on superclass

2018-02-01 Thread Ian Kelly
On Thu, Feb 1, 2018 at 11:44 AM, Sean DiZazzo wrote: > On Thursday, February 1, 2018 at 10:37:32 AM UTC-8, Chris Angelico wrote: >> On Fri, Feb 2, 2018 at 5:22 AM, Sean DiZazzo wrote: >> > Hi! >> > >> > I basically just want to create an alias to an attribute on an item's >> > superclass. So th

Re: [OT] Dutch Reach [was Re: Where has the practice of sending screen shots as source code come from?]

2018-01-30 Thread Ian Kelly
On Tue, Jan 30, 2018 at 9:24 AM, Grant Edwards wrote: > On 2018-01-30, Steven D'Aprano wrote: >> On Tue, 30 Jan 2018 15:48:29 +, Matt Wheeler wrote: >> >>> Checking the side mirrors isn't particularly helpful advice if you're >>> sitting in any seat other than the driver's seat, however. >> >

Re: Spectre/Meltdown bug affecting Python ?

2018-01-06 Thread Ian Kelly
On Sat, Jan 6, 2018, 4:45 PM Grant Edwards wrote: > On 2018-01-06, Etienne Robillard wrote: > > > > > > Le 2018-01-06 à 15:49, J.O. Aho a écrit : > >> On 01/06/18 13:43, Etienne Robillard wrote: > >>> My understanding of this vulnerability is that speculative indirect > >>> calls in Linux kernel

Re: is comp.lang.python still the pinnacle of the py community ?

2018-01-05 Thread Ian Kelly
On Fri, Jan 5, 2018 at 2:06 PM, Kim of K. wrote: > > post frequency is down to a precarious level It's true that compared to ten years ago, the quantity of posts here has diminished by a significant fraction, maybe even by an order of magnitude. This is still a great place for discussion however,

Re: has sourceforge exposed the dirty little secret ?

2018-01-05 Thread Ian Kelly
On Fri, Jan 5, 2018 at 9:27 AM, Kim of K. wrote: > > "Background > > We feel that the world still produces way too much software that is > frankly substandard. The reasons for this are pretty simple: software > producers do not pay enough attention [...]" > > > quote from http://texttest.sourcefor

Re: Goto (Posting On Python-List Prohibited)

2017-12-30 Thread Ian Kelly
On Sat, Dec 30, 2017 at 8:41 AM, bartc wrote: > (I had introduced a special language feature just for this kind of thing, > but it was unsatisfactory. Goto was simpler and understood by everyone. And > portable to any other language - that hasn't done away with goto. But it > worked like this (not

Re: What is the meaning of @@?

2017-12-24 Thread Ian Kelly
On Sun, Dec 24, 2017 at 7:33 PM, Peng Yu wrote: > See for example this file. > > https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/ops/rnn_cell.py > > On Sat, Dec 23, 2017 at 12:03 AM, Steve D'Aprano > wrote: >> On Sat, 23 Dec 2017 04:38 pm, Peng Yu wrote: >> >>> Hi, I only c

Re: What is the meaning of @@?

2017-12-22 Thread Ian Kelly
@@ is a syntax error. Where did you encounter this? On Fri, Dec 22, 2017 at 10:38 PM, Peng Yu wrote: > Hi, I only can find the doc for @. What does @@ mean in python? > > -- > Regards, > Peng > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/

Re: property decorator?

2017-12-20 Thread Ian Kelly
On Wed, Dec 20, 2017 at 5:56 PM, Irv Kalb wrote: > My questions about this are really historical. From my reading, it looks > like using an @property decorator is a reference to an older approach using a > built in "property" function. But here goes: > > 1) Why were these decorator names chose

Re: asyncio awaitable object

2017-12-08 Thread Ian Kelly
On Fri, Dec 8, 2017 at 2:08 AM, ast wrote: > Hello, > > According to: https://www.python.org/dev/peps/pep-0492/#await-expression > an awaitable object is: > > - A native coroutine object returned from a native coroutine function > - A generator-based coroutine object returned from a function decor

Re: Politeness (was: we want python software)

2017-12-06 Thread Ian Kelly
On Wed, Dec 6, 2017 at 10:56 AM, Gene Heskett wrote: > On Wednesday 06 December 2017 12:14:32 Ian Kelly wrote: > >> On Wed, Dec 6, 2017 at 9:42 AM, Gene Heskett > wrote: >> > On Wednesday 06 December 2017 11:28:22 Random832 wrote: >> >> The third possibility i

Re: Politeness (was: we want python software)

2017-12-06 Thread Ian Kelly
On Wed, Dec 6, 2017 at 9:42 AM, Gene Heskett wrote: > On Wednesday 06 December 2017 11:28:22 Random832 wrote: >> The third possibility is that he believes that this list is official >> in some corporate sense, that if he asks for the software and it is >> not free he will receive a price quote. >

Re: Lies (was: we want python software)

2017-12-06 Thread Ian Kelly
On Wed, Dec 6, 2017 at 5:53 AM, Rustom Mody wrote: > I was at first surprised and even a bit shocked when people called me > right-wing. > Over time Ive come to accept that lies (left-wing) is upstream of hate > (right-wing). And to the extent that effects must be stemmed from causes, > the wo

Re: How to shut down a TCPServer serve_forever() loop?

2017-11-28 Thread Ian Kelly
On Tue, Nov 28, 2017 at 11:54 AM, Marko Rauhamaa wrote: > Chris Angelico : >> Would the OP have been trivially able to send a signal to the >> process? Yes. > >Python signal handlers are always executed in the main Python thread, >even if the signal was received in another thread. This mea

Re: asyncio loop.call_soon()

2017-11-28 Thread Ian Kelly
On Tue, Nov 28, 2017 at 8:30 AM, ast wrote: > Hello > > Python's doc says about loop.call_soon(callback, *arg): > > Arrange for a callback to be called as soon as possible. The callback is > called after call_soon() returns, when control returns to the event loop. > > But it doesn't seem to be tru

Re: How to shut down a TCPServer serve_forever() loop?

2017-11-27 Thread Ian Kelly
On Sat, Nov 25, 2017 at 7:10 AM, John Pote wrote: > Hi all, > > My problem in summary is that my use of the shutdown() method only shuts > down a server after the next TCP request is received. > > I have a TCP server created in the run() method of a thread. > > class TCPlistener( Thread ): >

Re: connect four (game)

2017-11-27 Thread nospam . Ian Kelly
On Nov 27, 2017 7:08 AM, "Chris Angelico" wrote: In every compiler, interpreter, and CPU that I've ever used, the remainder has been well-defined. In what situation was it ill-defined, such that different compilers could do different things? In C89 the result of integer division and modulo wit

Re: connect four (game)

2017-11-27 Thread Ian Kelly
On Nov 27, 2017 7:08 AM, "Chris Angelico" wrote: In every compiler, interpreter, and CPU that I've ever used, the remainder has been well-defined. In what situation was it ill-defined, such that different compilers could do different things? In C89 the result of integer division and modulo wit

Re: connect four (game)

2017-11-25 Thread Ian Kelly
On Sat, Nov 25, 2017 at 10:02 AM, Chris Angelico wrote: > On Sun, Nov 26, 2017 at 3:36 AM, Ian Kelly wrote: >> On Sat, Nov 25, 2017 at 6:00 AM, bartc wrote: >>> Where are your unittests for these unittests? >> >> No, the point of having unit tests is to build

Re: connect four (game)

2017-11-25 Thread Ian Kelly
On Sat, Nov 25, 2017 at 6:00 AM, bartc wrote: > Where are your unittests for these unittests? Taking this question more seriously than it deserves: the tests for the unittest module itself are at https://hg.python.org/cpython/file/tip/Lib/unittest/test. Yes, unittest has tests of itself. As for

Re: connect four (game)

2017-11-24 Thread Ian Kelly
On Fri, Nov 24, 2017 at 7:05 PM, wrote: > On Friday, November 24, 2017 at 12:13:18 PM UTC-8, Terry Reedy wrote: > >> Since you did not start with tests or write tests as you wrote code, ... > > why on earth would you assume that? instantiate "window" and you'll see it > works exactly as i intend

<    1   2   3   4   5   6   7   8   9   10   >