Re: Convert '165.0' to int

2011-07-24 Thread Frank Millman
On Jul 25, 2:04 am, Gregory Ewing wrote: > Frank Millman wrote: > > I know I am flogging a dead horse here, but IMHO, '165', '165.', > > '165.0', and '165.00' are all valid string representations of the > > integer 165.[1] >

Re: Is this a safe use of eval?

2011-02-24 Thread Frank Millman
Thanks, Paul and Peter. It seemed like a good idea at the time. Thank you for straightening me out. Frank -- http://mail.python.org/mailman/listinfo/python-list

Re: 2to3 chokes on bad character

2011-02-24 Thread Frank Millman
"John Machin" wrote: On Feb 23, 7:47 pm, "Frank Millman" wrote: [snip lots of valuable info] The issue is not that 2to3 should handle this correctly, but that it should give a more informative error message to the unsuspecting user. Your Python 2.x code should be TE

Re: 2to3 chokes on bad character

2011-02-24 Thread Frank Millman
is the main lesson I have taken away from this. Frank -- http://mail.python.org/mailman/listinfo/python-list

Re: Is this a safe use of eval?

2011-02-24 Thread Frank Millman
rings or integers, so it looks as if this approach should be safe. Do you see any problem with it? Frank -- http://mail.python.org/mailman/listinfo/python-list

Problem with python 3.2 and circular imports

2011-02-27 Thread Frank Millman
t works, but it seems to be defeating the purpose of PEP 328, which I thought was an improvement. Any comments or suggestions will be appreciated. Frank Millman -- http://mail.python.org/mailman/listinfo/python-list

Re: issue on internal import in a package

2011-02-27 Thread Frank Millman
both windows and linux. It works using python 2.6. I can fix it by changing a.py from 'import b' to 'from . import b'. As I understand it, the reason is that python 3.x will no longer look for an absolute import in the current package - it will only look in sys.path. Frank Millman -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem with python 3.2 and circular imports

2011-02-27 Thread Frank Millman
"Ben Finney" wrote in message news:87aahh6401@benfinney.id.au... "Frank Millman" writes: Assume the following structure - main.py /pkg __init__.py mod1.py mod2.py main.py from pkg import mod1 mod1.py import mod2 mod2.py import mod1 What a

Re: issue on internal import in a package

2011-02-27 Thread Frank Millman
"人言落日是天涯,望极天涯不见家" wrote in message news:fa94323b-d859-4599-b236-c78a22b3d...@t19g2000prd.googlegroups.com... On Feb 27, 9:22 pm, "Frank Millman" wrote: This behavior is by design or just a bug for Python3.x ? Definitely by design. Have a look at PEP 328 - http://www

Re: issue on internal import in a package

2011-02-27 Thread Frank Millman
"人言落日是天涯,望极天涯不见家" wrote in message news:9529d52b-01b2-402c-a0a0-1e9240038...@l14g2000pre.googlegroups.com... On Feb 27, 9:38 pm, "Frank Millman" wrote: "人言落日是天涯,望极天涯不见家" wrote in message news:fa94323b-d859-4599-b236-c78a22b3d...@t19g2000prd.googlegroup

Re: Problem with python 3.2 and circular imports

2011-02-27 Thread Frank Millman
"Steven D'Aprano" wrote in message news:4d6a56aa$0$29972$c3e8da3$54964...@news.astraweb.com... On Sun, 27 Feb 2011 12:08:12 +0200, Frank Millman wrote: Assume the following structure - main.py /pkg __init__.py mod1.py mod2.py main.py from pkg impor

Re: Problem with python 3.2 and circular imports

2011-03-04 Thread Frank Millman
t runs with no errors. I even put a couple of print statements (or must I call them print functions now) into the modules being imported, and the messages do appear, so the modules are being imported. HTH Frank Millman -- http://mail.python.org/mailman/listinfo/python-list

Fun with 'str' and 'bytes'

2011-03-04 Thread Frank Millman
ot;' + session_id + b'"')) It works, but it is not pretty. Is there a more elegant solution? Thanks Frank Millman -- http://mail.python.org/mailman/listinfo/python-list

Re: Fun with 'str' and 'bytes'

2011-03-05 Thread Frank Millman
On Mar 4, 6:40 pm, nn wrote: > On Mar 4, 7:32 am, "Frank Millman" wrote: > > > Hi all > > > I want to create a cookie containing a session id. In python 2.6 I had the > > following - > > > from __future__ import unicode_literals > > session_id

Re: Problem with python 3.2 and circular imports

2011-03-06 Thread Frank Millman
"Rafael Durán Castañeda" wrote... Thank you for your answer Frank, I think I've found the problem. I was calling modules from inside subpackages, and I need to use them from outside, so I have package in PYTHONPATH. is that correct? But now I have another question: Can I ex

Re: organizing many python scripts, in a large corporate environment.

2011-03-13 Thread Frank Millman
in the search path. In your scripts you have to 'import' the package first, to ensure that these lines get executed. My 2c Frank Millman -- http://mail.python.org/mailman/listinfo/python-list

py32 on windows - input() includes trailing \r

2011-04-20 Thread Frank Millman
Hi all On linux, python 3.2 - x = input() xyz len(x) 3 x 'xyz' on windows, python 3.2 - x = input() xyz len(x) 4 x 'xyz\r' Is this expected behaviour? Frank Millman -- http://mail.python.org/mailman/listinfo/python-list

Re: py32 on windows - input() includes trailing \r

2011-04-20 Thread Frank Millman
"Peter Otten" <__pete...@web.de> wrote in message news:iomla6$p8f$1...@dough.gmane.org... Frank Millman wrote: On linux, python 3.2 - x = input() xyz len(x) 3 x 'xyz' on windows, python 3.2 - x = input() xyz len(x) 4 x 'xyz\r' Is this ex

Re: what is payload

2017-09-07 Thread Frank Millman
when you create your own class, you can give it any attributes you like, and call them whatever you like. If you changed 'payload' in the above to 'xyz', it would work exactly the same. Frank Millman -- https://mail.python.org/mailman/listinfo/python-list

Re: Old Man Yells At Cloud

2017-09-19 Thread Frank Millman
, in new pence, came to four figures. She then, talking to herself, did the next bit of the calculation. 'Lets see, there are 100 new pence in a pound, so divide the total by 100, ...'. She worked the whole thing out using just pencil and paper, and then when she had written down the result, exclaimed 'Oh, it’s the same!'. Frank Millman -- https://mail.python.org/mailman/listinfo/python-list

Re: Easy way to get a list of tuples.

2017-09-21 Thread Frank Millman
.append(('a', 'b', 'c')) x.append(('p', 'q', 'r')) x [('a', 'b', 'c'), ('p', 'q', 'r')] Does this help? Frank Millman -- https://mail.python.org/mailman/listinfo/python-list

Re: Textwrap doesn't honour NO-BREAK SPACE

2017-09-28 Thread Frank Millman
0ZZZ sed do euismod tempor incididunt' ... ' ut labore et dolore magna aliqua.') print(textwrap.fill(text, 59)) Lorum ipsum dolor sit amet, consectetur adipiscing elit ZZZ ZZZ sed do euismod tempor incididunt ut labore et dolore magna aliqua. It seems to have been fixed. Frank Millman -- https://mail.python.org/mailman/listinfo/python-list

Re: Textwrap doesn't honour NO-BREAK SPACE

2017-09-29 Thread Frank Millman
por incididunt ut labore et dolore magna aliqua. C:\Users\User>py -3.6 aib\aib\test_db100.py Lorum ipsum dolor sit amet, consectetur adipiscing elit ZZZ ZZZ sed do euismod tempor incididunt ut labore et dolore magna aliqua. It confirms that the problem was there in 3.5, but is fixed in 3.6

Re: The "loop and a half"

2017-10-04 Thread Frank Millman
T are necessary because it does not use indentation or braces to terminate blocks, it uses keywords. Frank Millman -- https://mail.python.org/mailman/listinfo/python-list

Why does asyncio.wait_for() need a timeout?

2017-11-23 Thread Frank Millman
the program hangs. If I add a timeout to the second one, it behaves the same as the first one. Is there a reason for this? I am using version 3.6.0. Thanks Frank Millman import asyncio from itertools import count async def counter1(): cnt = count(1) try: while True

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

2017-11-24 Thread Frank Millman
"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 timeout, the cancellation completes and the loop stops. If I use

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

2017-11-24 Thread Frank Millman
"Ian Kelly" wrote in message news:calwzidmrpfrr5mrejjyz+bdgtqlwy-sp+a_zc6zq7ebaz9g...@mail.gmail.com... 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 s

Re: While, If, Count Statements

2017-11-28 Thread Frank Millman
he 'while' loop? If not, give it a shot and see what happens. Frank Millman -- https://mail.python.org/mailman/listinfo/python-list

Re: While, If, Count Statements

2017-11-28 Thread Frank Millman
"Cai Gengyang" wrote in message news:a8335d2c-1fb9-4ba9-b752-418d19e57...@googlegroups.com... On Tuesday, November 28, 2017 at 4:18:04 PM UTC+8, Frank Millman wrote: > "Cai Gengyang" wrote in message > news:c2dfc9c4-3e16-480c-aebf-553081775...@googlegroups.com... &g

Re: Please tell me how to execute python file in Ubuntu by double clicking on file. (Posting On Python-List Prohibited)

2017-12-09 Thread Frank Millman
7;.pgp'. He did so, tried again, and said 'Ah, now it works'. Frank Millman -- https://mail.python.org/mailman/listinfo/python-list

Dunder variables

2018-01-08 Thread Frank Millman
upon? Thanks Frank Millman -- https://mail.python.org/mailman/listinfo/python-list

Re: Dunder variables

2018-01-09 Thread Frank Millman
"Peter Otten" wrote in message news:p31v3m$pji$1...@blaine.gmane.org... Frank Millman wrote: > Hi all > > I have read that one should not call dunder methods in application code. > > Does the same apply to dunder variables? I am thinking of the instance > attr

Re: Dunder variables

2018-01-09 Thread Frank Millman
"Frank Millman" wrote in message news:p321rb$9ct$1...@blaine.gmane.org... "Peter Otten" wrote in message news:p31v3m$pji$1...@blaine.gmane.org... Frank Millman wrote: > Hi all > > I have read that one should not call dunder methods in application code. >

Re: Dunder variables

2018-01-09 Thread Frank Millman
"Steven D'Aprano" wrote in message news:p32g4v$v88$2...@blaine.gmane.org... On Tue, 09 Jan 2018 11:28:03 +0200, Frank Millman wrote: > I have a class call Context containing only data, not methods. Instances > are passed around a lot in my application, with various method

Detecting a cycle in a graph

2018-01-14 Thread Frank Millman
rely on it being 'obvious'. Maybe there is no logical way of identifying it. I am sure you will need more details if you want to assist, but maybe there is some literature you can point me to that explains these things in more detail. Thanks Frank Millman -- https://mail.python.org/mailman/listinfo/python-list

Re: Detecting a cycle in a graph

2018-01-14 Thread Frank Millman
"Steven D'Aprano" wrote in message news:p3f9uh$ar4$1...@blaine.gmane.org... On Sun, 14 Jan 2018 10:30:31 +0200, Frank Millman wrote: > I can detect a cycle in a path. It is possible for there to be more than > one gateway in the path. I want to identify the gateway that

Re: Detecting a cycle in a graph

2018-01-14 Thread Frank Millman
"Christian Gollwitzer" wrote in message news:p3gh84$kfm$1...@dont-email.me... Am 14.01.18 um 22:04 schrieb Christian Gollwitzer: > Am 14.01.18 um 09:30 schrieb Frank Millman: >> I need to detect when a 'cycle' occurs - when a path loops back on >> itself and

Re: Detecting a cycle in a graph

2018-01-15 Thread Frank Millman
"MRAB" wrote in message news:1f67363c-4d2a-f5ac-7fa8-b6690ddba...@mrabarnett.plus.com... On 2018-01-15 06:15, Frank Millman wrote: > I start my cycle-detection with a node with 0 incoming connections. > > def find_cycle(node, path): > for output in node.outputs: &

Why no '|' operator for dict?

2018-02-04 Thread Frank Millman
ct([(k, v) for k, v in dict_1.items()] + [(k, v) for k, v in dict_2.items()]) {1: 'one', 2: 'two', 3: 'three'} So I have 2 questions - 1. Is there any particular reason why '|' is not supported? 2. Is there a better way to do what I want? Thanks Frank Millman -- https://mail.python.org/mailman/listinfo/python-list

Re: Why no '|' operator for dict?

2018-02-05 Thread Frank Millman
"Ian Kelly" wrote in message news:calwzidkp3ls4s-zi3ax6no-68kw4_xdozvwa-cj+oz+apqr...@mail.gmail.com... 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? '|&#x

list indices must be integers or slices, not str

2022-07-20 Thread Frank Millman
> >>> '{x[1]}'.format(**vars()) '1' >>> >>> '{x[-1]}'.format(**vars()) Traceback (most recent call last):   File "", line 1, in TypeError: list indices must be integers or slices, not str >>> Can anyone explain this

Re: list indices must be integers or slices, not str

2022-07-20 Thread Frank Millman
On 2022-07-20 11:37 AM, Chris Angelico wrote: On Wed, 20 Jul 2022 at 18:34, Frank Millman wrote: Hi all C:\Users\E7280>python Python 3.9.7 (tags/v3.9.7:1016ef3, Aug 30 2021, 20:19:38) [MSC v.1929 64 bit (AMD64)] on win32 Type "help", "copyright", "credits"

Re: list indices must be integers or slices, not str

2022-07-20 Thread Frank Millman
On 2022-07-20 12:31 PM, Frank Millman wrote: On 2022-07-20 11:37 AM, Chris Angelico wrote: On Wed, 20 Jul 2022 at 18:34, Frank Millman wrote: Hi all C:\Users\E7280>python Python 3.9.7 (tags/v3.9.7:1016ef3, Aug 30 2021, 20:19:38) [MSC v.1929 64 bit (AMD64)] on win32 Type "help"

Re: list indices must be integers or slices, not str

2022-07-21 Thread Frank Millman
://github.com/python/cpython/issues/95088 Frank -- https://mail.python.org/mailman/listinfo/python-list

Re: Trying to understand nested loops

2022-08-05 Thread Frank Millman
not, feel free to come back with more questions. BTW, there is an indentation error in your original post - line 5 should line up with line 4. It is preferable to copy/paste your code into any messages posted here rather than type it in, as that avoids the possibility of any typos. Frank Millman -- https://mail.python.org/mailman/listinfo/python-list

Re: To clarify how Python handles two equal objects

2023-01-14 Thread Frank Millman
largely independently of the names that are or are not referencing the objects. My 'aha' moment came when I understood that a python object has only three properties - a type, an id, and a value. It does *not* have a name. Frank Millman -- https://mail.python.org/mailman/listinfo/python-list

asyncio questions

2023-01-26 Thread Frank Millman
nner I have not figured out how to adapt my code to use this new approach. Any suggestions appreciated. Frank Millman P.S. Might it be better to ask these questions on the Async_SIG Discussion Forum? -- https://mail.python.org/mailman/listinfo/python-list

Re: asyncio questions

2023-01-27 Thread Frank Millman
On 2023-01-26 7:16 PM, Dieter Maurer wrote: Frank Millman wrote at 2023-1-26 12:12 +0200: I have written a simple HTTP server using asyncio. It works, but I don't always understand how it works, so I was pleased that Python 3.11 introduced some new high-level concepts that hide the gory de

Re: asyncio questions

2023-01-27 Thread Frank Millman
On 2023-01-27 2:14 PM, Frank Millman wrote: I have changed it to async, which I call with 'asyncio.run'. It now looks like this -     server = await asyncio.start_server(handle_client, host, port)     await setup_companies()     session_check = asyncio.create_task(     chec

Re: Changing the original SQLite version to the latest

2023-02-14 Thread Frank Millman
On 2023-02-15 5:59 AM, Thomas Passin wrote: > > "Download the latest release from http://www.sqlite.org/download.html > and manually copy sqlite3.dll into Python's DLLs subfolder." > I have done exactly this a number of times and it has worked for me. Frank Millman

Re: Bug 3.11.x behavioral, open file buffers not flushed til file closed.

2023-03-05 Thread Frank B
run from interpreter directly: f = open("abc", "w") for i in range(5):   f.write(str(i) + "\n") use with open("abc", "w") as f: for i in range(5): f.write(str(i) + "\n") and all is well Frank -- https://mail.python.org/mailman/listinfo/python-list

etree, gzip, and BytesIO

2021-01-20 Thread Frank Millman
ee.parse(gf) to convert to an etree object It works. But I don't know what goes on under the hood, so I don't know if this achieves anything. If any of the steps involves decompressing the data and storing the entire string in memory, I may as well stick to my present approach. Any

Re: name for a mutually inclusive relationship

2021-02-24 Thread Frank Millman
I use for this arrangement is 'sub-types'. Frank Millman -- https://mail.python.org/mailman/listinfo/python-list

Question about generators

2021-03-05 Thread Frank Millman
I expected. >>> >>> s = [] >>> s.append(((b, c) for b, c in a)) >>> s [ at 0x019FC3F863C0>] >>> I expected the same as the first one. I understand the concept that a generator does not return a value until you call next() on it, but I have

Re: Question about generators

2021-03-05 Thread Frank Millman
On 2021-03-06 8:21 AM, Frank Millman wrote: Hi all This is purely academic, but I would like to understand the following - >>> >>> a = [('x', 'y')] >>> >>> s = [] >>> for b, c in a: ...   s.append((b, c)) ... >>>

Re: Yield after the return in Python function.

2021-04-05 Thread Frank Millman
#x27;Calling' a generator function does not execute the function, it returns a generator object. You have to iterate over the generator object (e.g. by calling next() on it) in order to execute the function and return values. Frank Millman -- https://mail.python.org/mailman/listinfo/python-list

Re: Fun Generators

2021-04-22 Thread Frank Millman
y *fun* generators people may have seen or written? Not so much the cool or clever ones. Or the mathematical ones (e.g. fib). Something more inane and "fun". But still showcasing generators uniqueness. Short and simple is good. Thanks in advance! Have you looked at this? http://www.da

Negative subscripts

2021-11-26 Thread Frank Millman
item in x[:-y] if y else x: ...    [do stuff] But in my actual program, both x and y are fairly long expressions, so the result is pretty ugly. Are there any other techniques anyone can suggest, or is the only alternative to use if...then...else to cater for y = 0? Thanks Frank Millman -- ht

Re: Negative subscripts

2021-11-26 Thread Frank Millman
On 2021-11-26 11:17 AM, Frank Millman wrote: Hi all In my program I have a for-loop like this - >>> for item in x[:-y]: ...    [do stuff] 'y' may or may not be 0. If it is 0 I want to process the entire list 'x', but of course -0 equals 0, so it returns an empt

Re: Negative subscripts

2021-11-26 Thread Frank Millman
On 2021-11-26 11:24 PM, dn via Python-list wrote: On 26/11/2021 22.17, Frank Millman wrote: In my program I have a for-loop like this - for item in x[:-y]: ...    [do stuff] 'y' may or may not be 0. If it is 0 I want to process the entire list 'x', but of course -0 equ

A bit of nostalgia

2022-01-30 Thread Frank Millman
ing in assembler. I recall my boss telling me that the ICL assembler was called PLAN, which was an acronym, but I forget what it stood for. Frank Millman -- https://mail.python.org/mailman/listinfo/python-list

One-liner to merge lists?

2022-02-22 Thread Frank Millman
7;, 'fff', 'ggg'] I can also do this - >>> from itertools import chain >>> a = list(chain(*d.values())) >>> a ['aaa', 'bbb', 'ccc', 'fff', 'ggg'] >>> Is there a simpler way? Thanks Frank Millman -- https://mail.python.org/mailman/listinfo/python-list

Re: One-liner to merge lists?

2022-02-22 Thread Frank Millman
On 2022-02-22 11:30 AM, Chris Angelico wrote: On Tue, 22 Feb 2022 at 20:24, Frank Millman wrote: Hi all I think this should be a simple one-liner, but I cannot figure it out. I have a dictionary with a number of keys, where each value is a single list - >>> d = {1: ['aaa

Re: One-liner to merge lists?

2022-02-22 Thread Frank Millman
7;] Now that's what I was looking for. I am not saying that I will use it, but as an academic exercise I felt sure that there had to be a one-liner in pure python. I had forgotten about nested comprehensions. Thanks for the reminder. Frank -- https://mail.python.org/mailman/listinfo/python-list

Alternatives to XML?

2016-08-24 Thread Frank Millman
rgs: "_param.auto_party_id" not_exists: literal: _value: "" _src: "_param.auto_party_id" _op: is_not _tgt: "$None" This seems even worse from a readability point of view. The arguments to 'compare' are a long way away from the block to be executed. Can anyone offer an alternative which is closer to my original intention? Thanks Frank Millman -- https://mail.python.org/mailman/listinfo/python-list

Re: Alternatives to XML?

2016-08-24 Thread Frank Millman
"Frank Millman" wrote in message news:npkcnf$kq7$1...@blaine.gmane.org... Hi all I have mentioned in the past that I use XML for storing certain structures 'off-line', and I got a number of comments urging me to use JSON or YAML instead. Can anyone offer an alterna

Re: Alternatives to XML?

2016-08-24 Thread Frank Millman
"Chris Angelico" wrote in message news:CAPTjJmq2bcQPmQ9itVvZrBZJPcbYe5z6vDpKGYQj=8h+qkv...@mail.gmail.com... On Thu, Aug 25, 2016 at 3:33 PM, Frank Millman wrote: @Peter/Chris > I don't understand - please explain. > > If I store the business rule in Python code, ho

Re: Alternatives to XML?

2016-08-25 Thread Frank Millman
has yet convinced me that the alternatives are any better. I may eventually end up with an additional layer that prompts the user through their requirement in 'wizard' style, and generates the underlying XML (or whatever) automatically. Frank -- https://mail.python.org/mailman/listinfo/python-list

Re: Alternatives to XML?

2016-08-25 Thread Frank Millman
"Frank Millman" wrote in message news:nplvvl$ci2$1...@blaine.gmane.org... Hi all I have mentioned in the past that I use XML for storing certain structures 'off-line', and I got a number of comments urging me to use JSON or YAML instead. Can anyone offer an alterna

Re: Alternatives to XML?

2016-08-25 Thread Frank Millman
"Peter Otten" wrote in message news:npmti0$qvu$1...@blaine.gmane.org... Frank Millman wrote: > At the risk of disappointing some of you, this is how I am going to > proceed. 'Tis too late for me to stop ;) > The problem that prompted this thread was the

Re: Alternatives to XML?

2016-08-25 Thread Frank Millman
"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 to say so. H

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

Re: Alternatives to XML?

2016-08-26 Thread Frank Millman
;, "&") 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 some much better tested functions out there to escape text for storage in xml documents. Thanks very much, Joonas. I understand now, and it seems to work fine. As a bonus, I can now include '&' in my attributes in the future if the need arises. Much appreciated. Frank -- https://mail.python.org/mailman/listinfo/python-list

Re: [Bulk] Re: Alternatives to XML?

2016-08-26 Thread Frank Millman
treeElement, and step through it. Each 'tag' in the XML maps to a function name in the processing module - for xml in elem: await globals()[xml.tag](caller, xml) The built-in ElementTree would work for this, but I actually use lxml, because I use a little bit of xpath

How to extend a tuple of tuples?

2016-09-08 Thread Frank Millman
immutable, and that all of the above operations create a new tuple. Frank Millman -- https://mail.python.org/mailman/listinfo/python-list

Re: How to extend a tuple of tuples?

2016-09-09 Thread Frank Millman
"Frank Millman" wrote in message news:nqtlue$unj$1...@blaine.gmane.org... Assume you have a tuple of tuples - a = ((1, 2), (3, 4)) You want to add a new tuple to it, so that it becomes - ((1, 2), (3, 4), (5, 6)) Thanks all. The one I was looking for was a +=

Re: How to extend a tuple of tuples?

2016-09-09 Thread Frank Millman
"Ned Batchelder" wrote in message news:44e067ce-f499-4ca8-87bd-94b18dfc0...@googlegroups.com... On Friday, September 9, 2016 at 6:13:37 AM UTC-4, Frank Millman wrote: > "Frank Millman" wrote in message news:nqtlue$unj$1...@blaine.gmane.org... > > The one I was lo

Is it possible to use 'groupby' asynchronously?

2016-10-06 Thread Frank Millman
this is doable at all, or is groupby not designed for this. Thanks Frank Millman -- https://mail.python.org/mailman/listinfo/python-list

Re: function call questions

2016-10-19 Thread Frank Millman
;a': {}} id(t) 2542235910088 It has also rebound 'r' so that it now references the new empty dictionary that has been inserted. r {} id(r) 2542234429896 t['a'] {} id(t['a']) 2542234429896 Now continue this process with r = r.setdefault('b', {}), and watch what happens. Hopefully this will help you to understand. Feel free to ask further if not sure. Frank Millman -- https://mail.python.org/mailman/listinfo/python-list

Re: function call questions

2016-10-20 Thread Frank Millman
wrote in message news:01cfd810-0561-40b1-a834-95a73dad6...@googlegroups.com... 在 2016年10月20日星期四 UTC+8下午1:32:18,Frank Millman写道: wrote in message news:5506e4d8-bd1d-4e56-8d1b-f71fa8293...@googlegroups.com... > Let's see if I can explain. I am using 't' and 'r' i

Re: function call questions

2016-10-21 Thread Frank Millman
accessed by key 'a') that changes to {'b': {}} and t becomes {'a': {'b': {}}}. Yup, you have got it :-) Frank -- https://mail.python.org/mailman/listinfo/python-list

Re: function call questions

2016-10-22 Thread Frank Millman
wrote in message news:2853d778-857e-46fc-96a0-8d164c098...@googlegroups.com... 在 2016年10月20日星期四 UTC+8下午11:04:38,Frank Millman写道: wrote in message news:01cfd810-0561-40b1-a834-95a73dad6...@googlegroups.com... Hi Frank, thanks for your kind help. What confused me is at this line: >&

Re: function call questions

2016-10-22 Thread Frank Millman
mpty dictionary - r['x'] = 99 r {'x': 99} t['a'] {'x': 99} t {'a': {'x': 99}} I will pause at this point, and give you a moment to absorb that. Hopefully, the penny will drop and everything will become clear. If not, let us know whi

Is this pythonic?

2016-11-23 Thread Frank Millman
l_with_comp, perform the computation, then add the following - self.getval = self._getval return self._getval() What is the verdict? -1, 0, or +1? Frank Millman -- https://mail.python.org/mailman/listinfo/python-list

Re: Is this pythonic?

2016-11-23 Thread Frank Millman
"Marko Rauhamaa" wrote in message news:87inrer0dl@elektro.pacujo.net... "Frank Millman" : > What is the verdict? -1, 0, or +1? Perfectly cromulent, run-of-the-mill Python code. A new word to add to my vocabulary - thanks :-) Frank -- https://mail.pyth

Re: Is this pythonic?

2016-11-23 Thread Frank Millman
"Marko Rauhamaa" wrote in message news:87inrer0dl@elektro.pacujo.net... "Frank Millman" : > 3. When instantiating an object, check if it would need computation - >if computation_required: >self.getval = self._getval_with_comp >else: >

Re: Is this pythonic?

2016-11-23 Thread Frank Millman
"Frank Millman" wrote in message news:o13meh$p2g$1...@blaine.gmane.org... 3. When instantiating an object, check if it would need computation - if computation_required: self.getval = self._getval_with_comp else: self.getval = self._getval 4. In _getval

Re: Is this pythonic?

2016-11-23 Thread Frank Millman
"Chris Angelico" wrote in message news:CAPTjJmqGEwHPVyrR+Ti9bV=S5MsLt3nquF4TvE=xpees188...@mail.gmail.com... On Wed, Nov 23, 2016 at 11:27 PM, Frank Millman wrote: > > @Chris >> >> This strongly suggests that str(x) is the wrong way to get the >> informatio

Re: Is this pythonic?

2016-11-23 Thread Frank Millman
puted will return None, but that is ok for my purposes. 2. Write a separate method, retaining the calls to getval(), to be called independently using 'await' if I ever need to see the full result after computation. Frank -- https://mail.python.org/mailman/listinfo/python-list

Re: Is this pythonic?

2016-11-23 Thread Frank Millman
"Steven D'Aprano" wrote in message news:58368358$0$1513$c3e8da3$54964...@news.astraweb.com... On Thursday 24 November 2016 15:55, Frank Millman wrote: > "Steve D'Aprano" wrote in message > news:583653bb$0$1603$c3e8da3$54964...@news.astraweb.com...

async enumeration - possible?

2016-11-29 Thread Frank Millman
r\AppData\Local\Programs\Python\Python36\lib\asyncio\base_events.py", line 466, in run_until_complete return future.result() TypeError: 'async_generator' object is not iterable Is there any technical reason for this, or is it just that no-one has got around to writing an asyn

Re: async enumeration - possible?

2016-11-29 Thread Frank Millman
"Frank Millman" wrote in message news:o1k355$da5$1...@blaine.gmane.org... Hi all Python 3.6 has introduced Asynchronous Generators, which work very well. [...] However, it does not allow you to enumerate over the generator output - [...] Is there any technical reason for t

Re: async enumeration - possible?

2016-11-30 Thread Frank Millman
blocking the other users. I find that very powerful. Frank -- https://mail.python.org/mailman/listinfo/python-list

Re: async enumeration - possible?

2016-11-30 Thread Frank Millman
"Ian Kelly" wrote in message news:CALwzid=hrijtv4p1_6frkqub25-o1i8ouquxozd+aujgl7+...@mail.gmail.com... On Wed, Nov 30, 2016 at 1:29 AM, Frank Millman wrote: > > async def anext(aiter): >return await aiter.__anext__() Even simpler: def anext(aiter): return aite

Re: Asyncio -- delayed calculation

2016-12-02 Thread Frank Millman
users, something that I believe would not be possible with threading or multi-processing. Frank Millman -- https://mail.python.org/mailman/listinfo/python-list

asyncio question

2016-12-13 Thread Frank Millman
hem. It seems to work. This means that I have a background task running for each concurrent user. Each one will be idle most of the time. My gut-feel says that this will not cause a problem, even if there are hundreds of them, but any comments will be welcome. Thanks Frank Millman -- https://mail.python.org/mailman/listinfo/python-list

Re: asyncio question

2016-12-13 Thread Frank Millman
"Ian Kelly" wrote in message news:CALwzid=vdczAH18mHKaL7ryvDUB=7_y-JVUrTkRZ=gkz66p...@mail.gmail.com... On Tue, Dec 13, 2016 at 6:15 AM, Frank Millman wrote: > The client uses AJAX to send messages to the server. It sends the > message > and continues processing, whil

Re: Recipe request: asyncio "spin off coroutine"

2016-12-14 Thread Frank Millman
7;asyncio.ensure_future(self.close())'. Problem solved. Frank Millman -- https://mail.python.org/mailman/listinfo/python-list

Re: Recipe request: asyncio "spin off coroutine"

2016-12-14 Thread Frank Millman
"Marko Rauhamaa" wrote in message news:87vaulitxe@elektro.pacujo.net... "Frank Millman" : > I changed 'await self.close()', to > 'asyncio.ensure_future(self.close())'. > > Problem solved. A nice insight. However, shouldn'

Re: Recipe request: asyncio "spin off coroutine"

2016-12-15 Thread Frank Millman
troubleshooting when things go south. I know that you have vastly more experience in this area than I do, so I will take your advice to heart. Thanks Frank -- https://mail.python.org/mailman/listinfo/python-list

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