Re: [Bulk] Re: Alternatives to XML?

2016-08-26 Thread Frank Millman
"Roland Koebler" wrote in message news:20160826140213.GA17438@localhost... Hi, OMG! So, you have a fileformat, which looks like XML, but actually isn't XML, and will break if used with some "real" XML. I don't want to pursue this too much further, but I would like to point out that my fo

Re: PEP 492: isn't the "await" redundant?

2016-08-26 Thread Marko Rauhamaa
Gregory Ewing : > Marko Rauhamaa wrote: >> How about making *every* function *always* and async, >> unconditionally? That way *every* function would be an async and >> every function call would be an await. > > 1. Many people regard it as a feature that you can see where > potential suspension poi

Re: Does This Scare You?

2016-08-26 Thread eryk sun
On Fri, Aug 26, 2016 at 11:28 AM, Jon Ribbens wrote: > On 2016-08-24, Chris Angelico wrote: >> On Thu, Aug 25, 2016 at 7:00 AM, eryk sun wrote: >>> I discovered why "Logs/con.txt" isn't working right in Windows 7, >>> while "Logs/nul.txt" does get redirected correctly to r"\\.\nul". >>> Prior to

Re: PEP 492: isn't the "await" redundant?

2016-08-26 Thread Gregory Ewing
Marko Rauhamaa wrote: How about making *every* function *always* and async, unconditionally? That way *every* function would be an async and every function call would be an await. 1. Many people regard it as a feature that you can see where potential suspension points are. 2. Doing this would

Re: Python script for searching variable strings between two constant strings

2016-08-26 Thread Steve D'Aprano
On Sat, 27 Aug 2016 08:33 am, ddream.mercha...@gmail.com wrote: > My log file has several sections starting with START and ending > with END . Um. Is this relevant? Are you saying that you only wish to search the file between those lines, and ignore anything outside of them?

multiprocessing.pool.Pool.map should take more than one iterable

2016-08-26 Thread ycm . jason
Hello all, The official doc describes `Pool.map(func, iterable[, chunksize])` as "A parallel equivalent of the map() built-in function.". Since the function signature of `map` is `map(function, iterable, ...)`, I hereby suggest that `Pool.map` should change its function signature to `Pool.map

Re: Python 3 raising an error where Python 2 did not

2016-08-26 Thread Terry Reedy
On 8/26/2016 4:50 AM, d...@forestfield.co.uk wrote: In a program I'm converting to Python 3 I'm examining a list of divisor values, some of which can be None, to find the first with a value greater than 1. Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win32 Type

Re: Alternatives to XML?

2016-08-26 Thread Roland Koebler
Hi, after reading the mails of this thread, I would recommend one of the following ways: 1. Use a computer-readable format and some small editor for humans. The file-format could then be very simple -- I would recommend JSON. Or some kind of database (e.g. SQLite). For humans, you w

Re: Alternatives to XML?

2016-08-26 Thread Marko Rauhamaa
"Frank Millman" : > "Joonas Liik" wrote in message > news:cab1gnptp0gd4s4kx07r1ujrnuxtoij4vf5unye1cfr_y0xv...@mail.gmail.com... >> i should note tho that this example is very ad-hoc, i'm no xml expert >> just know a bit about xml entities. if you decide to go this route >> there are probably som

RE: wxPython Cookbook

2016-08-26 Thread Gonzales, Dean
Very cool! Thanks for doing this. I can't wait to dig into your cookbook. Regards, Dean Gonzales -Original Message- From: Python-announce-list [mailto:python-announce-list-bounces+dean.gonzales=amd@python.org] On Behalf Of Mike Driscoll Sent: Wednesday, August 24, 2016 12:57 PM To:

Re: [Bulk] Re: Alternatives to XML?

2016-08-26 Thread Roland Koebler
Hi, > It is *my* XML, and I know that I only use the offending characters inside > attributes, and attributes are the only place where double-quote marks are > allowed. > > So this is my conversion routine - > > lines = string.split('"') # split on attributes > for pos, line in enumerate(lines)

Re: Alternatives to XML?

2016-08-26 Thread Frank Millman
"Joonas Liik" wrote in message news:cab1gnptp0gd4s4kx07r1ujrnuxtoij4vf5unye1cfr_y0xv...@mail.gmail.com... something like.. (untested) def escape(untrusted_string): ''' Use on the user provided strings to render them inert for storage escaping & ensures that the user cant type sth lik

Re: Alternatives to XML?

2016-08-26 Thread Joonas Liik
On 26 August 2016 at 17:58, Joonas Liik wrote: > On 26 August 2016 at 16:10, Frank Millman wrote: >> "Joonas Liik" wrote in message >> news:cab1gnpqnjdenaa-gzgt0tbcvwjakngd3yroixgyy+mim7fw...@mail.gmail.com... >> >>> On 26 August 2016 at 08:22, Frank Millman wrote: >>> > >>> > So this is my con

Re: Alternatives to XML?

2016-08-26 Thread Joonas Liik
On 26 August 2016 at 16:10, Frank Millman wrote: > "Joonas Liik" wrote in message > news:cab1gnpqnjdenaa-gzgt0tbcvwjakngd3yroixgyy+mim7fw...@mail.gmail.com... > >> On 26 August 2016 at 08:22, Frank Millman wrote: >> > >> > So this is my conversion routine - >> > >> > lines = string.split('"') #

Re: Python 3 raising an error where Python 2 did not

2016-08-26 Thread d...@forestfield.co.uk
Thanks for the replies. My example seems to be from the fairly harmless end of a wedge of behaviours that are being handled much more sensibly in Python 3. -- https://mail.python.org/mailman/listinfo/python-list

Re: Alternatives to XML?

2016-08-26 Thread Frank Millman
"Joonas Liik" wrote in message news:cab1gnpqnjdenaa-gzgt0tbcvwjakngd3yroixgyy+mim7fw...@mail.gmail.com... On 26 August 2016 at 08:22, Frank Millman wrote: > > So this is my conversion routine - > > lines = string.split('"') # split on attributes > for pos, line in enumerate(lines): >if p

Re: Does This Scare You?

2016-08-26 Thread Jon Ribbens
On 2016-08-24, Chris Angelico wrote: > On Thu, Aug 25, 2016 at 7:00 AM, eryk sun wrote: >> I discovered why "Logs/con.txt" isn't working right in Windows 7, >> while "Logs/nul.txt" does get redirected correctly to r"\\.\nul". >> Prior to Windows 8 the console doesn't use an NT device, so the base

datetime, time zone and xs:datetime

2016-08-26 Thread Nagy László Zsolt
Hello, I'm having problems finding the "preferrably one" way to convert a datetime instance into an xs:datetime string. Here is an example datetime instance with is format: dt = datetime.now() print(dt.isoformat()) # prints "2016-08-26 12:41:13.426081+02:00" print(dt.strftime('%Y-%m-%dT%H:%M:

Re: a *= b not equivalent to a = a*b

2016-08-26 Thread Chris Angelico
On Fri, Aug 26, 2016 at 8:20 PM, mlz wrote: > I believe there are languages that preserve exact accuracy in this way for > rational fractions. I don't know if Python is one of them. It is, but only if you explicitly request it (due to the performance impact). Just import it: #!/usr/bin/python2

Re: PEP 492: isn't the "await" redundant?

2016-08-26 Thread Chris Angelico
(Did you mean to send this to the list? I hope so; I'm replying to the list.) On Fri, Aug 26, 2016 at 8:30 PM, Milan Krčmář wrote: >> Two reasons. One is that Python allows you to call any function and >> inspect its return value - async functions are no different, and they >> do return something

Re: a *= b not equivalent to a = a*b

2016-08-26 Thread Jussi Piitulainen
mlz writes: > It's true that a*(b/c) yields fractions which would probably accrue > accuracy errors depending on how those values are implemented. For > example, it is possible to represent 1/3 internally as two numbers, > numerator and denominator, thus avoiding the repeating decimal (or > binima

Re: Alternatives to XML?

2016-08-26 Thread Joonas Liik
On 26 August 2016 at 08:22, Frank Millman wrote: > "Peter Otten" wrote in message news:npn25e$s5n$1...@blaine.gmane.org... > > Frank Millman wrote: > >>> As you have to keep the "<", why bother? >> >> >> If you mean why don't I convert the '<' to '<', the answer is that I do >> - I just omitted t

Re: a *= b not equivalent to a = a*b

2016-08-26 Thread mlz
It's true that a*(b/c) yields fractions which would probably accrue accuracy errors depending on how those values are implemented. For example, it is possible to represent 1/3 internally as two numbers, numerator and denominator, thus avoiding the repeating decimal (or binimal, or whatever it's

Re: a *= b not equivalent to a = a*b

2016-08-26 Thread mlz
Partly it's the layout, but mathematically speaking the two should be equal. (a*b)/c should equal a*(b/c) The fact that they're not is surprising, because python 2 so seamlessly supports big integers in a mathematically correct way. I consider such surprising behavior to be abstraction leak, wh

Re: PEP 492: isn't the "await" redundant?

2016-08-26 Thread Marko Rauhamaa
Chris Angelico : > On Fri, Aug 26, 2016 at 7:41 PM, Marko Rauhamaa wrote: >> How about making *every* function *always* and async, >> unconditionally? That way *every* function would be an async and >> every function call would be an await. > > If you want threading, you know where to find it. Ul

Re: a *= b not equivalent to a = a*b

2016-08-26 Thread mlz
Aha. That's interesting. On Friday, August 26, 2016 at 2:11:32 AM UTC-7, Peter Otten wrote: > mlz wrote: > > > Yes, I just worked that out. It's the integer math that's the problem. > > > > I guess this has been fixed in python 3, but unfortunately it seems that > > most people are still using

Re: PEP 492: isn't the "await" redundant?

2016-08-26 Thread Chris Angelico
On Fri, Aug 26, 2016 at 7:41 PM, Marko Rauhamaa wrote: > How about making *every* function *always* and async, unconditionally? > That way *every* function would be an async and every function call > would be an await. If you want threading, you know where to find it. ChrisA -- https://mail.pyt

Re: a *= b not equivalent to a = a*b

2016-08-26 Thread BartC
On 26/08/2016 08:14, mlzarathus...@gmail.com wrote: However, precedence wasn't the problem in this case, it was the type conversion. I think it was. I was puzzled as well. But apparently if you have: x * = expr That's like: x = x * (expr)# note the parentheses which may not al

Re: PEP 492: isn't the "await" redundant?

2016-08-26 Thread Marko Rauhamaa
Kouli : > We now have explicit syntax with keyword 'async' so why should we use > yet the additional keyword 'await'? This is an important question. > This way, one would not have to differentiate between function and > coroutine "call" from within a coroutine... You'd still need to remember to

Re: Python 3 raising an error where Python 2 did not

2016-08-26 Thread Peter Otten
d...@forestfield.co.uk wrote: > In a program I'm converting to Python 3 I'm examining a list of divisor > values, some of which can be None, to find the first with a value greater > than 1. > > Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] > on win32 Type "help", "copy

Re: PEP 492: isn't the "await" redundant?

2016-08-26 Thread Chris Angelico
On Fri, Aug 26, 2016 at 6:55 PM, Kouli wrote: > recently, I have discovered Python's coroutines and enjoyed the whole > asyncio system a lot. But I ask you to make me understand one thing in > Python's coroutines design: why do we have to use "await" (or "yield > from") in coroutines? Why can coro

Re: a *= b not equivalent to a = a*b

2016-08-26 Thread Peter Otten
mlzarathus...@gmail.com wrote: > Yes, I just worked that out. It's the integer math that's the problem. > > I guess this has been fixed in python 3, but unfortunately it seems that > most people are still using python 2. Note that you can get Python 3's default behaviour in Python 2 with from _

Re: Python 3 raising an error where Python 2 did not

2016-08-26 Thread Chris Angelico
On Fri, Aug 26, 2016 at 6:50 PM, d...@forestfield.co.uk wrote: > In a program I'm converting to Python 3 I'm examining a list of divisor > values, some of which can be None, to find the first with a value greater > than 1. > > Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Int

PEP 492: isn't the "await" redundant?

2016-08-26 Thread Kouli
Hello, recently, I have discovered Python's coroutines and enjoyed the whole asyncio system a lot. But I ask you to make me understand one thing in Python's coroutines design: why do we have to use "await" (or "yield from") in coroutines? Why can coroutines etc. not be used _from_coroutines_ (desi

Python 3 raising an error where Python 2 did not

2016-08-26 Thread d...@forestfield.co.uk
In a program I'm converting to Python 3 I'm examining a list of divisor values, some of which can be None, to find the first with a value greater than 1. Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more i

Re: a *= b not equivalent to a = a*b

2016-08-26 Thread Christian Gollwitzer
Am 26.08.16 um 09:53 schrieb Erik: On 26/08/16 08:44, mlzarathus...@gmail.com wrote: Here's the key: $ python2 Python 2.7.10 ... 1/2 0 $ python Python 3.5.1 ... 1/2 0.5 1//2 0 I read about this awhile ago, but it's not until it bites you that you remember fully. How is this rela

Re: Holding until next value change

2016-08-26 Thread Arshpreet Singh
On Saturday, 20 August 2016 11:38:03 UTC+5:30, Steve D'Aprano wrote: > state = ignore_negative # DON'T call the function yet > for value in main_call(): > print(value) # for testing > if state(value): > print("changing state") > state = TABLE[state] Above code works at

Re: a *= b not equivalent to a = a*b

2016-08-26 Thread Erik
On 26/08/16 08:14, mlzarathus...@gmail.com wrote: I was being facetious, but behind it is a serious point. Neither the APL nor the J languages use precedence even though their inventor, Ken Iverson, was a mathematician. That was to support functional programming dating back to the 1970's. P

Re: a *= b not equivalent to a = a*b

2016-08-26 Thread Erik
On 26/08/16 08:44, mlzarathus...@gmail.com wrote: Here's the key: $ python2 Python 2.7.10 ... 1/2 0 $ python Python 3.5.1 ... 1/2 0.5 1//2 0 I read about this awhile ago, but it's not until it bites you that you remember fully. How is this related to your question? The example e

Re: a *= b not equivalent to a = a*b

2016-08-26 Thread mlzarathustra
Here's the key: $ python2 Python 2.7.10 ... >>> 1/2 0 >>> $ python Python 3.5.1 ... >>> 1/2 0.5 >>> 1//2 0 >>> I read about this awhile ago, but it's not until it bites you that you remember fully. -- https://mail.python.org/mailman/listinfo/python-list

Re: a *= b not equivalent to a = a*b

2016-08-26 Thread Jussi Piitulainen
mlzarathus...@gmail.com writes: > Yes, I just worked that out. It's the integer math that's the problem. > > I guess this has been fixed in python 3 [- -] Note that division in Python 3 produces approximate results (floating point numbers). This may or may not be what you want in this exercise. I

Re: a *= b not equivalent to a = a*b

2016-08-26 Thread mlzarathustra
I was being facetious, but behind it is a serious point. Neither the APL nor the J languages use precedence even though their inventor, Ken Iverson, was a mathematician. That was to support functional programming dating back to the 1970's. However, precedence wasn't the problem in this case, i

Re: a *= b not equivalent to a = a*b

2016-08-26 Thread mlzarathustra
Yes, I just worked that out. It's the integer math that's the problem. I guess this has been fixed in python 3, but unfortunately it seems that most people are still using python 2. Thanks for all the help! -- https://mail.python.org/mailman/listinfo/python-list