Re: referring to package scope from module, using relative import?

2011-05-21 Thread Ian Kelly
On Sat, May 21, 2011 at 1:28 PM, Irmen de Jong wrote: > Hi, > > I have a package with several modules in it. The package also has some > objects created > in the package scope (done in the package __init__.py). > > Is it possible to access those package scope objects from the modules, with > rel

Re: Writing multiple files with with-context

2011-05-23 Thread Ian Kelly
On Sun, May 22, 2011 at 8:48 PM, Shunichi Wakabayashi wrote: > One idea is using contextlib.nested(), > > from contextlib import nested > > with nested(*[open('list_%d.txt' % i, 'w') for i in range(LIST_LEN)]) as > fobjlist: >  for i in range(1000): >    fobjlist[random.randrange(LIST_LEN)].write

Re: Unit testing beginner question

2011-05-23 Thread Ian Kelly
On Mon, May 23, 2011 at 4:30 PM, Andrius wrote: > and I am expecting test to pass, but I am getting exception: > Traceback (most recent call last): >    self.assertRaises(TypeError, self.testListNone[:1]) > TypeError: 'NoneType' object is unsubscriptable > > I thought that assertRaises will pass s

Re: super() in class defs?

2011-05-25 Thread Ian Kelly
On Wed, May 25, 2011 at 11:54 AM, Jess Austin wrote: > So I guess that when super() is called in the context of a class def > rather than that of a method def, it doesn't have the information it > needs. Now I'll probably just say: > >    do_GET = do_decorate(CGIHTTPRequestHandler.do_GET) > > but

Re: Python 3.2 bug? Reading the last line of a file

2011-05-25 Thread Ian Kelly
On Wed, May 25, 2011 at 2:00 PM, MRAB wrote: > You're opening the file in text mode, and seeking relative to the end > of the file is not allowed in text mode, presumably because the file > contents have to be decoded, and, in general, seeking to an arbitrary > position within a sequence of encode

Re: super() in class defs?

2011-05-25 Thread Ian Kelly
On Wed, May 25, 2011 at 3:40 PM, Steven D'Aprano wrote: > If you actually read that article, carefully, without being fooled by the > author's provocative ex-title and misleading rhetoric, you will discover > that super is not harmful. What is harmful is making unjustified > assumptions about what

Re: Python 3.2 bug? Reading the last line of a file

2011-05-25 Thread Ian Kelly
On Wed, May 25, 2011 at 3:52 PM, MRAB wrote: > What do you mean by "may include the decoder state in its return value"? > > It does make sense that the values returned from tell() won't be in the > middle of an encoded sequence of bytes. If you take a look at the source code, tell() returns a lon

Re: Python's super() considered super!

2011-05-26 Thread Ian Kelly
On Thu, May 26, 2011 at 12:13 PM, Dotan Cohen wrote: > On Thu, May 26, 2011 at 19:39, Raymond Hettinger wrote: >>> It would also be great if some of you would upvote it on HackerNews. >> >> >> Here's a link to the super() how-to-guide and commentary:  bit.ly/ >> iFm8g3 >> > > Is that the same lin

Re: Python's super() considered super!

2011-05-27 Thread Ian Kelly
On Thu, May 26, 2011 at 10:31 AM, Raymond Hettinger wrote: > I just posted a tutorial and how-to guide for making effective use of > super(). I posted this already on the HackerNews thread but it seems to have largely gone unnoticed, so I'm reposting it here. It seems to me that the example of c

Re: Beginner needs advice

2011-05-29 Thread Ian Kelly
On Sat, May 28, 2011 at 8:33 PM, harrismh777 wrote: > In this present case the straw-man was not "me," rather the straw-man was > the python language itself. You chose a code-snippet (one small puny dangle > that doesn't prove a thing) and used it to speak for the entire language! >  As though one

Re: scope of function parameters

2011-05-29 Thread Ian Kelly
On Sun, May 29, 2011 at 12:38 PM, Chris Angelico wrote: > I thought it basically functioned top-down. You get a different error > on the print line if there's a "bar = 42" *after* it. This could make > debugging quite confusing. > > Guess it's just one of the consequences of eschewing variable > d

Re: searching in list

2011-05-30 Thread Ian Kelly
On Mon, May 30, 2011 at 7:41 AM, Chris Angelico wrote: > If you're always going to look them up by the argument, the best way > would be to use a dictionary: > cache={arg1: res1, arg2: res2, ...} > > Then you can search with a simple: cache[arg135] > > You can add things with: cache[arg135]=res135

Re: Beginner needs advice

2011-05-30 Thread Ian Kelly
On Mon, May 30, 2011 at 6:43 PM, harrismh777 wrote: >> I realize you are now asserting that compatibility is a boolean >> condition, and that "totally incompatible" is a redundant phrase that >> you tossed out as a joke.  I don't know whether you're sincere or >> backpedaling, but in any case this

Re: Something is rotten in Denmark...

2011-05-31 Thread Ian Kelly
On Tue, May 31, 2011 at 12:48 AM, harrismh777 wrote: >     What is going on with the binding in the first construct... this seems > to reduce the usefulness of lambda to a considerable extent? I don't see why; as you've shown there are a couple of simple ways to avoid this problem. The trick is

Re: scope of function parameters (take two)

2011-05-31 Thread Ian Kelly
On Tue, May 31, 2011 at 1:38 AM, Daniel Kluev wrote: > @decorator.decorator > def copy_args(f, *args, **kw): >    nargs = [] >    for arg in args: >        nargs.append(copy.deepcopy(arg)) >    nkw = {} >    for k,v in kw.iteritems(): >        nkw[k] = copy.deepcopy(v) >    return f(*nargs, **nkw)

Re: scope of function parameters (take two)

2011-05-31 Thread Ian Kelly
On Tue, May 31, 2011 at 10:34 AM, Chris Kaynor wrote: > Is there any reason not to simplify this to: > def copy_args(f): >    @functools.wraps(f) >    def wrapper(*args, **kw): >        nargs = copy.deepcopy(args) >        nkw = copy.deepcopy(kw) >        return f(*nargs, **nkw) >    return wrappe

Re: Beginner needs advice

2011-05-31 Thread Ian Kelly
On Tue, May 31, 2011 at 11:56 AM, Dotan Cohen wrote: >>  If you disagree, then I invite you to list one example of two >> different things that are compatible. >> > > Men and women. This is a slightly different sense of the word compatible than we have been discussing: able to work together to pe

Re: Something is rotten in Denmark...

2011-05-31 Thread Ian Kelly
On Tue, May 31, 2011 at 3:14 PM, Martin Manns wrote: > $ python > Python 2.6.6 (r266:84292, Apr 20 2011, 11:58:30) > [GCC 4.5.2] on linux2 > Type "help", "copyright", "credits" or "license" for more information. fs=[] fs = [(lambda n: i + n) for i in range(10)] [fs[i](1) for i in ra

Re: Something is rotten in Denmark...

2011-05-31 Thread Ian Kelly
On Tue, May 31, 2011 at 2:18 PM, harrismh777 wrote: > If I'm understanding that correctly, then that means lambda is working as > designed, and that there are very subtle nuances to be aware of. In my > little case > >   (lambda n: i + n) > >   ... if the  i  goes out of scope before the anonymous

Re: scope of function parameters (take two)

2011-05-31 Thread Ian Kelly
On Tue, May 31, 2011 at 6:04 PM, Daniel Kluev wrote: > On Wed, Jun 1, 2011 at 3:16 AM, Ian Kelly wrote: >> >> There is no "decorator" module in the standard library.  This must be >> some third-party module.  The usual way to do this would be: > > Yes, b

Re: Updated blog post on how to use super()

2011-06-01 Thread Ian Kelly
On Wed, Jun 1, 2011 at 7:03 AM, Billy Mays wrote: > I read this when it was on HN the other day, but I still don't see what is > special about super().  It seems (from your post) to just be a stand in for > the super class name?  Is there something special I missed? It's not a stand-in for the su

Re: Updated blog post on how to use super()

2011-06-01 Thread Ian Kelly
On Wed, Jun 1, 2011 at 10:46 AM, Billy Mays wrote: > What it does is clear to me, but why is it interesting or special isn't. >  This looks like a small feature that would be useful in a handful of cases. Well, I agree with you there. The complexity introduced by super typically outweighs the be

Re: Comparison operators in Python

2011-06-01 Thread Ian Kelly
On Wed, Jun 1, 2011 at 12:50 PM, Anirudh Sivaraman wrote: > Hi > > I am a relative new comer to Python. I see that typing is strongly > enforced in the sense you can't concatenate or add a string and an > integer. However comparison between a string and an integer seems to > be permitted. Is there

Re: tictactoe script - commented - may have pedagogical value

2017-09-05 Thread Ian Kelly
On Mon, Sep 4, 2017 at 9:26 PM, wrote: > > """ > this program makes an optimal tictactoe move by answering the following > questions > in their given order until it is told where to put its mark: > > 1) can you win the game? > if so then do it > 2) could your opponent win the game if it was

Re: Please improve these comprehensions (was meaning of [ ])

2017-09-06 Thread Ian Kelly
On Wed, Sep 6, 2017 at 1:37 AM, Marko Rauhamaa wrote: > > Which reminds me of this puzzle I saw a couple of days ago: > >1 + 4 = 5 >2 + 5 = 12 >3 + 6 = 21 >8 + 11 = ? > > A mathematician immediately comes up with a "wrong" answer. There are no "wrong" answers with these kinds of p

Re: tictactoe script - commented - may have pedagogical value

2017-09-06 Thread Ian Kelly
On Tue, Sep 5, 2017 at 6:15 PM, Stefan Ram wrote: > Ian Kelly writes: >>Usually I've seen Tic Tac Toe implemented using the Minimax algorithm >>since the decision tree for Tic Tac Toe is quite shallow. > > This thread made me want to write a tic-tac-toe game. > &g

Re: tictactoe script - commented - may have pedagogical value

2017-09-07 Thread Ian Kelly
On Thu, Sep 7, 2017 at 2:05 AM, Chris Angelico wrote: > On Thu, Sep 7, 2017 at 5:11 PM, Steven D'Aprano >> I don't know why it places *two* pairs of crosses and naughts instead of >> one. Maybe the page is broken. > > I think it is, as part of being on the Internet Archive. To get a > working vers

Re: tictactoe script - commented - may have pedagogical value

2017-09-07 Thread Ian Kelly
On Thu, Sep 7, 2017 at 6:21 AM, Chris Angelico wrote: > On Thu, Sep 7, 2017 at 10:07 PM, Steve D'Aprano > wrote: >> As a practical technique, naturally using a lookup table of pre-computed >> values >> is a good solution to many problems. But you cannot say you are performing >> general computat

Re: detaching comprehensions

2017-09-08 Thread Ian Kelly
On Fri, Sep 8, 2017 at 2:24 PM, Stefan Ram wrote: > Maybe you all know this, but to me this is something new. > I learnt it by trial and error in the Python 3.6.0 console. > > Most will know list comprehensions: > > |>>> [ i for i in range( 3, 5 )] > |[3, 4] > > I found out that the compre

Re: detaching comprehensions

2017-09-08 Thread Ian Kelly
On Fri, Sep 8, 2017 at 3:03 PM, Peter Otten <__pete...@web.de> wrote: *"bar", > ('b', 'a', 'r') Now that just makes my eyes hurt. -- https://mail.python.org/mailman/listinfo/python-list

Re: Not appending ("lib") to sys.path breaks tests.

2017-09-08 Thread Ian Kelly
On Fri, Sep 8, 2017 at 3:18 PM, Leam Hall wrote: > A kind soul pointed out that my code uses a sys.path.append("lib") to get > files to be imported: > > sys.path.append("lib") > from character_tools import * > > He noted that having an __init__.py in lib and using: > > from

Re: Not appending ("lib") to sys.path breaks tests.

2017-09-08 Thread Ian Kelly
On Fri, Sep 8, 2017 at 3:54 PM, Leam Hall wrote: > On 09/08/2017 05:41 PM, Ian Kelly wrote: > >> I'm confused about where the character_tools import is made. If that's >> within a module in the lib package, it should be fine. > > >> It looks like it'

Re: Using Python 2

2017-09-10 Thread Ian Kelly
On Sat, Sep 9, 2017 at 9:26 PM, Rick Johnson wrote: > On Friday, September 8, 2017 at 8:57:56 AM UTC-5, Ned Batchelder wrote: >> On 9/8/17 6:12 AM, Leam Hall wrote: >> > I've read comments about Python 3 moving from the Zen of Python. I'm a >> > "plain and simple" person myself. Complexity to supp

Re: Using Python 2

2017-09-10 Thread Ian Kelly
On Sun, Sep 10, 2017 at 10:06 AM, Rick Johnson wrote: > Ian wrote: >> Rick Johnson wrote: >> > Ned Batchelder wrote: >> > > Leam Hall wrote: >> > > > >> > > > I've read comments about Python 3 moving from the Zen of >> > > > Python. I'm a "plain and simple" person myself. >> > > > Complexity to su

Re: Simple game board GUI framework

2017-09-11 Thread Ian Kelly
On Mon, Sep 11, 2017 at 10:36 AM, ROGER GRAYDON CHRISTMAN wrote: > I would echo the recommendation of teaching something you are already > familiar with doing. Perhaps you can find a different class hierarchy to > work > with. > > I remember that the first time I really began to grok OOP was in

Re: Simple game board GUI framework

2017-09-11 Thread Ian Kelly
On Mon, Sep 11, 2017 at 6:26 PM, Dennis Lee Bieber wrote: > I used to have a character on Furtoonia whose "tail" was described as > having a naked singularity at the tip (the tail was an object that > automatically followed the character around) -- the character's "home" was > inside said

Re: Simple board game GUI framework

2017-09-13 Thread Ian Kelly
On Tue, Sep 12, 2017 at 10:39 PM, Rick Johnson wrote: >> > board[r,c] = lbl > > Dude, that tuple is naked! And nudity in public places is > not cool; unless of course your code is a Ms. America model, > or it resides in a nudist colony (Hey, don't forget your > "sitting towel"!), whic

Re: String to Dictionary conversion in python

2017-09-14 Thread Ian Kelly
On Fri, Sep 15, 2017 at 12:01 AM, wrote: > Hi, > > Can anyone help me in the below issue. > > I need to convert string to dictionary > > string = " 'msisdn': '7382432382', 'action': 'select', 'sessionId': '123', > 'recipient': '7382432382', 'language': 'english'" > > Can anyone help me with the

Re: Research paper "Energy Efficiency across Programming Languages: How does energy, time, and memory relate?"

2017-09-16 Thread Ian Kelly
On Sat, Sep 16, 2017 at 8:01 PM, Steve D'Aprano wrote: > On Sun, 17 Sep 2017 09:04 am, breamore...@gmail.com wrote: > >> I thought some might find this >> https://sites.google.com/view/energy-efficiency-languages/ interesting. > > "Made with the new Google Sites, an effortless way to create beauti

Re: Project Euler 20.

2017-09-24 Thread Ian Kelly
On Sun, Sep 24, 2017 at 4:35 PM, Paul Rubin wrote: > > "Robert L." writes: > >> Find the sum of the digits in the number 100! > > In Python? > > So you have come to plague us here too. > > >>> sum(ord(c)-ord('0') for c in str(reduce(lambda a,b: a*b, range(1,101),1))) > 648 Or for any Python 2.6

Re: Looking for an algorithm - calculate ingredients for a set of recipes

2017-09-25 Thread Ian Kelly
On Mon, Sep 25, 2017 at 6:49 AM, Paul Moore wrote: > I'm trying to work out a good algorithm to code a calculation I need > to do. I can see brute force ways of handling the problem, but I keep > getting bogged down in details, and the question seems like it's > something that should have been sol

Re: on a very slow function

2017-10-02 Thread Ian Kelly
On Sun, Oct 1, 2017 at 8:14 PM, Steve D'Aprano wrote: > > On Mon, 2 Oct 2017 12:00 pm, Ben Bacarisse wrote: > > > >> Better: > >> > >> last = (pow(last, 2, N) + (2 % N)) % N > > > > You meant c rather than 2, I think. > > Oops, yes, that was a typo. > > > > And I'm not convinced all the %Ns > > ar

Re: newb question about @property

2017-10-02 Thread Ian Kelly
On Mon, Oct 2, 2017 at 1:32 PM, Bill wrote: > @property def circumference(self): > return 2 * math.pi *self.radius Of course the *proper* formula here is just math.tau * self.radius. -- https://mail.python.org/mailman/listinfo/python-list

Re: newb question about @property

2017-10-03 Thread Ian Kelly
On Tue, Oct 3, 2017 at 4:41 AM, Steve D'Aprano wrote: > On Tue, 3 Oct 2017 06:51 am, Bill wrote: > >> Can you inspire me with a good decorator problem (standard homework >> exercise-level will be fine)? > > > Here is a nice even dozen problems for you. Please ask for clarification if > any > are

Re: newb question about @property

2017-10-03 Thread Ian Kelly
On Tue, Oct 3, 2017 at 9:16 AM, Jorge Gimeno wrote: > No, I see this as teaching the skills involved to drive a car. Practicing a > turn, scanning gauges, and checking blind spots are all a part of driving. > When one is learning, it's easier to learn these in isolation so when the > problem must

Re: newb question about @property

2017-10-04 Thread Ian Kelly
On Wed, Oct 4, 2017 at 5:07 AM, bartc wrote: > It is just being elitist. I have a preference for keeping things simple and > avoiding unnecessary complexity. But with programming languages many do have > a penchant for the latter. > > As an example, a recent discussion on comp.lang.c was about imp

Re: Constants [was Re: newb question about @property]

2017-10-04 Thread Ian Kelly
On Wed, Oct 4, 2017 at 9:08 AM, Steve D'Aprano wrote: > But in large projects, especially those where you cannot trust every module in > the project to obey the naming convention, I can see that this lack might > contribute to the perception, if not the fact, of Python being a bit too > unsafe for

Re: The "loop and a half"

2017-10-08 Thread Ian Kelly
On Sun, Oct 8, 2017 at 10:49 PM, Chris Angelico wrote: > On Mon, Oct 9, 2017 at 3:35 PM, Mikhail V wrote: >>> Have you ever worked on a slow remote session where a GUI is >>> completely impracticable (or maybe even unavailable), and redrawing >>> the screen is too expensive to do all the time? >>

Re: An endless loop

2017-10-16 Thread Ian Kelly
On Sat, Oct 14, 2017 at 8:10 PM, Stefan Ram wrote: > I made an error I made a thousand times before. > > I had programmed an endless loop. > > But never did I see before so clear why it's called > an endless loop. (Tested in IDLE.) > > from turtle import * > > reset(); reset(); shape( 'tur

Re: Cooperative class tree filtering

2017-10-16 Thread Ian Kelly
On Thu, Oct 12, 2017 at 5:07 PM, Alberto Berti wrote: > Now, what i ideally want is to get rid of that super() call at the end of > the methods in classes B and c and to code that "fallback to what my > superclass says" coded into A's implementation, where it kicks in if the > method in the target

Re: Cooperative class tree filtering

2017-10-16 Thread Ian Kelly
On Mon, Oct 16, 2017 at 8:20 PM, Ian Kelly wrote: > On Thu, Oct 12, 2017 at 5:07 PM, Alberto Berti > wrote: >> I would really like to find a way to do this that doesn't involve >> decorating the methods in A subclasses to free the final developer to >> remember to i

Re: multiprocessing shows no benefit

2017-10-18 Thread Ian Kelly
On Wed, Oct 18, 2017 at 9:46 AM, Jason wrote: > #When I change line19 to True to use the multiprocessing stuff it all slows > down. > > from multiprocessing import Process, Manager, Pool, cpu_count > from timeit import default_timer as timer > > def f(a,b): > return dict_words[a]-b Since

Re: multiprocessing shows no benefit

2017-10-18 Thread Ian Kelly
On Wed, Oct 18, 2017 at 10:13 AM, Ian Kelly wrote: > On Wed, Oct 18, 2017 at 9:46 AM, Jason wrote: >> #When I change line19 to True to use the multiprocessing stuff it all slows >> down. >> >> from multiprocessing import Process, Manager, Pool, cpu_count >> fr

Re: multiprocessing shows no benefit

2017-10-18 Thread Ian Kelly
On Wed, Oct 18, 2017 at 10:21 AM, Jason wrote: > On Wednesday, October 18, 2017 at 12:14:30 PM UTC-4, Ian wrote: >> On Wed, Oct 18, 2017 at 9:46 AM, Jason wrote: >> > #When I change line19 to True to use the multiprocessing stuff it all >> > slows down. >> > >> > from multiprocessing import Proc

Re: Searching For Old Posts On Python

2017-10-18 Thread Ian Kelly
On Mon, Oct 16, 2017 at 10:42 PM, Cai Gengyang wrote: > https://duckduckgo.com/html/?q=%22Cai%20Gengyang%22%20python This > seems to be the only method that works, using DuckDuckGo Or any search engine, really. https://www.google.com/search?q=site%3Apython.org+cai+gengyang -- https://mail.p

Re: Compression of random binary data

2017-10-23 Thread Ian Kelly
On Mon, Oct 23, 2017 at 1:42 PM, wrote: > Wow, do programmers actually use zscii. That is huge. So much wated space. Not really. ZSCII is only relevant if you're writing Z-code or a Z-code interpreter. Those in turn are only relevant if you're writing Infocom games. -- https://mail.python.org/m

Re: Compression of random binary data

2017-10-24 Thread Ian Kelly
On Tue, Oct 24, 2017 at 12:20 AM, Gregory Ewing wrote: > danceswithnumb...@gmail.com wrote: >> >> I did that quite a while ago. 352,954 kb. > > > Are you sure? Does that include the size of all the > code, lookup tables, etc. needed to decompress it? My bet is that danceswithnumbers does indeed h

Re: Compression of random binary data

2017-10-25 Thread Ian Kelly
On 10/24/17, Richard Damon wrote: > My understanding of the 'Random Data Comprehensibility' challenge is > that is requires that the compression take ANY/ALL strings of up to N > bits, and generate an output stream no longer than the input stream, and > sometime less. That's incorrect, at least o

Re: Compression of random binary data

2017-10-26 Thread Ian Kelly
On Thu, Oct 26, 2017 at 2:38 PM, wrote: > > Thomas Jollans > > On 2017-10-25 23:22, danceswi...@gmail.com wrote: >> With every transform the entropy changes, > > That's only true if the "transform" loses or adds information. > > If it loses information, that's lossy compression, which is only use

Re: Compression of random binary data

2017-10-27 Thread Ian Kelly
On Thu, Oct 26, 2017 at 8:19 PM, wrote: > It looks like that averages my two examples. I don't know how you can look at two numbers and then look at a third number that is larger than both of them and conclude it is the average. > H by the way that equation is really coolwhy does it ret

Re: Compression of random binary data

2017-10-27 Thread Ian Kelly
On Thu, Oct 26, 2017 at 8:48 PM, wrote: > Shouldn't that be? > > py> 16 * (-7/16 * math.log2(7/16) - 6/16 * math.log2(6/16)) = No, that's failing to account for 3/16 of the probability space. -- https://mail.python.org/mailman/listinfo/python-list

Re: Just a quick question about main()

2017-10-27 Thread Ian Kelly
In addition to what others have answered, if the code in question has any variables then I'll prefer to put it inside a function and call the function. This ensures that the variables are local and not going. It's a minor code hygiene point, but a good practice in my opinion. -- https://mail.pytho

Re: Just a quick question about main()

2017-10-27 Thread Ian Kelly
On Oct 27, 2017 5:38 PM, "Ian Kelly" wrote: In addition to what others have answered, if the code in question has any variables then I'll prefer to put it inside a function and call the function. This ensures that the variables are local and not going. It's a minor code hygie

Re: Compression of random binary data

2017-10-28 Thread Ian Kelly
On Oct 28, 2017 10:30 AM, "Stefan Ram" wrote: > Well, then one can ask about the entropy of a data source > thatt only is emitting this message. (If it needs to be endless: > thatt only is emitting this message repeatedly.) If there is only one possible message then the entropy is zero. -1.0 * l

Re: Compression of random binary data

2017-10-29 Thread Ian Kelly
On Oct 28, 2017 5:53 PM, "Chris Angelico" wrote: > One bit. It might send the message, or it might NOT send the message. Not sending the message is equivalent to having a second possible message. -- https://mail.python.org/mailman/listinfo/python-list

Re: Thread safety issue (I think) with defaultdict

2017-11-01 Thread Ian Kelly
On Tue, Oct 31, 2017 at 11:38 AM, Israel Brewster wrote: > A question that has arisen before (for example, here: > https://mail.python.org/pipermail/python-list/2010-January/565497.html > ) is > the question of "is defaultd

Re: Thread safety issue (I think) with defaultdict

2017-11-03 Thread Ian Kelly
On Thu, Nov 2, 2017 at 10:27 AM, Israel Brewster wrote: > >> On Nov 1, 2017, at 4:53 PM, Steve D'Aprano >> wrote: >> >> On Thu, 2 Nov 2017 05:53 am, Israel Brewster wrote: >> >> [...] >>> So the end result is that the thread that "updates" the dictionary, and the >>> thread that initially *popul

Re: replacing `else` with `then` in `for` and `try`

2017-11-03 Thread Ian Kelly
On Fri, Nov 3, 2017 at 8:32 AM, Chris Angelico wrote: > On Fri, Nov 3, 2017 at 10:49 PM, Jon Ribbens > wrote: >> On 2017-11-03, Steve D'Aprano wrote: >>> On Fri, 3 Nov 2017 03:31 am, Jon Ribbens wrote: No, it's an obvious bug. You have a 'for...else' with no 'break'. Like I said, that

Re: replacing `else` with `then` in `for` and `try`

2017-11-03 Thread Ian Kelly
On Fri, Nov 3, 2017 at 3:25 PM, Stefan Ram wrote: > Jon Ribbens writes: >>No, it's an obvious bug. You have a 'for...else' with no 'break'. >>Like I said, that should probably be a syntax error. > > It should make the syntax of Python much more complicated, > when one would try to encode this

Re: Ideas about how software should behave (was: replacing `else` with `then` in `for` and `try`)

2017-11-07 Thread Ian Kelly
On Fri, Nov 3, 2017 at 11:55 PM, Ben Finney wrote: > Ian Kelly writes: > >> Please stop defending the use of incivility on this list. > > Please stop conflating people, who deserve civility, with ideas. We must > not allow the civility deserved by people, to prevent us f

Re: Ideas about how software should behave (was: replacing `else` with `then` in `for` and `try`)

2017-11-07 Thread Ian Kelly
On Sat, Nov 4, 2017 at 6:40 AM, Chris Angelico wrote: > On Sat, Nov 4, 2017 at 11:25 PM, Jon Ribbens > wrote: >> On 2017-11-04, Ben Finney wrote: >>> To respond to the criticism of an idea – criticism containing no mention >>> of the person – as though it “clearly refers to the [person]”, is of

Re: Ideas about how software should behave (was: replacing `else` with `then` in `for` and `try`)

2017-11-07 Thread Ian Kelly
On Tue, Nov 7, 2017 at 12:10 PM, Chris Angelico wrote: > On Wed, Nov 8, 2017 at 4:28 AM, Ian Kelly wrote: >> On Sat, Nov 4, 2017 at 6:40 AM, Chris Angelico wrote: >>> Maybe we're not defending the abuse of other contributors. Maybe we're >>> defending a legi

Re: Ideas about how software should behave (was: replacing `else` with `then` in `for` and `try`)

2017-11-07 Thread Ian Kelly
On Tue, Nov 7, 2017 at 4:28 PM, Steve D'Aprano wrote: > On Wed, 8 Nov 2017 04:28 am, Ian Kelly wrote: > >> Steve's manufactured interactive example ("manufactured" because >> who really uses for-else interactively? If I really care that much >> abou

Re: Ideas about how software should behave (was: replacing `else` with `then` in `for` and `try`)

2017-11-08 Thread Ian Kelly
On Tue, Nov 7, 2017 at 2:42 PM, Chris Angelico wrote: > On Wed, Nov 8, 2017 at 8:16 AM, Ian Kelly wrote: >>> Not one of these is syntactically invalid. Why should "else without >>> break" be trapped by the parser? Your other examples mostly have good >>&g

Re: Ideas about how software should behave (was: replacing `else` with `then` in `for` and `try`)

2017-11-08 Thread Ian Kelly
On Wed, Nov 8, 2017 at 9:31 AM, Chris Angelico wrote: > On Thu, Nov 9, 2017 at 3:19 AM, Ian Kelly wrote: >> I was not referring to the possible future use of yield from for async >> generators; I was referring to the possibility *today* of using "yield >> from" a

Re: Ideas about how software should behave (was: replacing `else` with `then` in `for` and `try`)

2017-11-08 Thread Ian Kelly
On Wed, Nov 8, 2017 at 11:12 AM, Chris Angelico wrote: > On Thu, Nov 9, 2017 at 5:05 AM, Ian Kelly wrote: >> On Wed, Nov 8, 2017 at 9:31 AM, Chris Angelico wrote: >>> On Thu, Nov 9, 2017 at 3:19 AM, Ian Kelly wrote: >>>> I was not referring to the possible futu

Re: Ideas about how software should behave (was: replacing `else` with `then` in `for` and `try`)

2017-11-08 Thread Ian Kelly
On Wed, Nov 8, 2017 at 11:34 AM, Chris Angelico wrote: > On Thu, Nov 9, 2017 at 5:20 AM, Ian Kelly wrote: >> On Wed, Nov 8, 2017 at 11:12 AM, Chris Angelico wrote: >>> Except that "yield from" is used by generators to delegate to other >>> generators,

Re: What is the future of the PEP 467?

2017-11-10 Thread Ian Kelly
On Fri, Nov 10, 2017 at 7:16 AM, Kirill Balunov wrote: > What is the future of the PEP 467 ("Minor API improvements for binary > sequences")? It was not accepted and was not rejected, although there was a > rather active discussion. I don't know. This is probably a question for python-dev. > In

Re: Benefits of unicode identifiers (was: Allow additional separator in identifiers)

2017-11-23 Thread Ian Kelly
On Thu, Nov 23, 2017 at 1:04 PM, Karsten Hilbert wrote: > On Thu, Nov 23, 2017 at 08:46:01PM +0100, Thomas Jollans wrote: > >> > I mean for a real practical situation - for example for an average >> > Python programmer or someone who seeks a programmer job. >> > And who does not have a 500-key key

Re: Benefits of unicode identifiers (was: Allow additional separator in identifiers)

2017-11-23 Thread Ian Kelly
On Thu, Nov 23, 2017 at 2:19 PM, Richard Damon wrote: > The Unicode Standard provides a fairly good classification of the > characters, and it would make sense to define that an character that is > defined as a 'Letter' or a 'Number', and some classes of Punctuation > (connector and dash) be allow

Re: Why does asyncio.wait_for() need a timeout?

2017-11-24 Thread Ian Kelly
On Fri, Nov 24, 2017 at 6:31 AM, Frank Millman wrote: > "Frank Millman" wrote in message news:ov5v3s$bv7$1...@blaine.gmane.org... > >> Below is a simple asyncio loop that runs two background tasks. >> > [...] >> >> >> Both take an optional timeout. >> >> If I use the first method without a timeou

Re: Why does asyncio.wait_for() need a timeout?

2017-11-24 Thread Ian Kelly
On Fri, Nov 24, 2017 at 9:35 AM, Ian Kelly wrote: > On Fri, Nov 24, 2017 at 6:31 AM, Frank Millman wrote: >> "Frank Millman" wrote in message news:ov5v3s$bv7$1...@blaine.gmane.org... >> >>> Below is a simple asyncio loop that runs two background tasks. >

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

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-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-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: 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: 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-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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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

<    6   7   8   9   10   11   12   13   14   15   >