Re: How to debug an unfired tkinter event?

2017-10-19 Thread Peter Otten
jf...@ms4.hinet.net wrote: > Peter Otten at 2017-10-19 UTC+8 PM 3:24:30 wrote: >> It's not clear to me what you mean with this. Did you place the table >> from the recipe elsewhere inside a window that you created or did you >> make changes in the recipe's code? &g

Re: Efficient counting of results

2017-10-19 Thread Peter Otten
Israel Brewster wrote: > >> On Oct 19, 2017, at 10:02 AM, Stefan Ram wrote: >> >> Israel Brewster writes: >>> t10 = {'daily': 0, 'WTD': 0, 'MTD': 0, 'YTD': 0,} >>> increment the appropriate bin counts using a bunch of if statements. >> >> I can't really completely comprehend your requirement

Re: How to debug an unfired tkinter event?

2017-10-19 Thread Peter Otten
jf...@ms4.hinet.net wrote: > Peter Otten於 2017年10月19日星期四 UTC+8下午6時04分39秒寫道: >> jf...@ms4.hinet.net wrote: >> >> > Peter Otten at 2017-10-19 UTC+8 PM 3:24:30 wrote: >> >> It's not clear to me what you mean with this. Did you place the table >> >&g

Re: Compression of random binary data

2017-10-24 Thread Peter Pearson
On Tue, 24 Oct 2017 14:51:37 +1100, Steve D'Aprano wrote: On Tue, 24 Oct 2017 01:27 pm, danceswithnumb...@gmail.com wrote: > Yes! Decode reverse is easy..sorry so excited i could shout. Then this should be easy for you: http://marknelson.us/2012/10/09/the-random-compression-challenge-

Re: Objects with __name__ attribute

2017-10-25 Thread Peter Otten
ast wrote: > Hi, > > I know two Python's objects which have an intrinsic > name, classes and functions. > > def f(): > pass > f.__name__ > 'f' g = f g.__name__ > 'f' > > class Test: > pass > Test.__name__ > 'Test' Test2 = Test Test2.__name__ > 'Test' > >

Re: h5py.File() gives error message

2017-10-25 Thread Peter Otten
C W wrote: > Oh, I was running a debug file, that's why the path is different. > > The file is here, > https://www.dropbox.com/s/6jx4rzyg9xwl95m/train_catvnoncat.h5?dl=0 > > Is anyone able to get it working? Thank you! Hm, that file seems to contain HTML and that causes an OSError here, too: $

Re: Compression of random binary data

2017-10-28 Thread Peter Pearson
On Thu, 26 Oct 2017 19:26:11 -0600, Ian Kelly wrote: > > . . . Shannon entropy is correctly calculated for a data source, > not an individual message . . . Thank you; I was about to make the same observation. When people talk about the entropy of a particular message, you can bet they're headed

Re: from packaging import version as pack_version ImportError: No module named packaging

2017-10-30 Thread Peter Otten
David Gabriel wrote: > Dears, > > When I run this command I got this error message: > > ubuntu@orchestrateur:/tmp/pack$ virtualenv -p $(which python3.5) . > Running virtualenv with interpreter /usr/local/sbin/. > Traceback (most recent call last): > File "/usr/bin/virtualenv", line 3, in >

Re: Reading a remove csv file

2017-11-02 Thread Peter Otten
ROGER GRAYDON CHRISTMAN wrote: > Just a quick question on how best to read a remote CSV file. > So far, I tried: > > filelink = urllib.request.urlopen(path) > dictread = csv.DictReader(filelink) > for row in dictread:... > But I'm running into the difference between strings and bytes. > I'd

Re: Read Firefox sqlite files with Python

2017-11-04 Thread Peter Otten
Steve D'Aprano wrote: > I'm trying to dump a Firefox IndexDB sqlite file to text using Python 3.5. > > > import sqlite3 > con = sqlite3.connect('foo.sqlite') > with open('dump.sql', 'w') as f: > for line in con.iterdump(): > f.write(line + '\n') > > > The error I get is: > > Trace

Re: Python Mailing list moderators

2017-11-06 Thread Peter Pearson
On Sun, 5 Nov 2017 17:28:05 -0500, Terry Reedy wrote: > On 11/5/2017 4:14 PM, Cameron Simpson wrote: >> On 05Nov2017 13:09, Στέφανος Σωφρονίου >> wrote: >>> Folks, >>> More and more nonsense are coming in and I find it really difficult to >>> follow any new post that may come and I have to eith

Re: I am trying to delete duplicates but the job just finishes with an exit code 0

2017-11-07 Thread Peter Otten
tysondog...@gmail.com wrote: > I am trying to delete duplicates but the job just finishes with an exit > code 0 and does not delete any duplicates. > > The duplicates for the data always exist in Column F and I am desiring to > delete the entire row B-I > > Any ideas? > > > import openpyxl > w

Re: What happens to module's variables after a "from module import" ?

2017-11-07 Thread Peter Otten
ast wrote: > Hello > > Here is my module tmp.py: > > a=0 > > def test(): > global a > print(a) > a+=1 > > If I import function "test" from module "tmp" with: > from tmp import test > > it works > test() > 0 test() > 1 > > But where variable "a" is located ? I can

Re: dictionary comparing int keys and joins their values if two key are within a certain distance

2017-11-08 Thread Peter Otten
Daiyue Weng wrote: > I have a nested dictionary of defaultdict(dict) whose sub dict have int > keys and lists (list of ints) as values, > > 'A' = {2092: [1573], 2093: [1576, 1575], 2094: [1577], 2095: > [1574]}'B' = {2098: [1], 2099: [2, 3], 2101: [4], 2102: [5]}'C' = > {2001: [6], 2003: [7, 8],

Re: All the list getting appended of a dict if you are updating only first element list of dict

2017-11-15 Thread Peter Otten
Radhey Parashar wrote: > I am facing 1 issue with python related to append command in a list > class CITY: > > num = 0 > > connectivity = [] The way you wrote it the connectivity list is shared between all instances of the CITY class. Consult a Python tutorial to learn why. To get p

Re: Artificial creating of [Lists], is it possible? the best way...

2017-11-16 Thread Peter Pearson
On Thu, 16 Nov 2017 10:47:53 -0800 (PST), jakub.raj...@gmail.com wrote: > Hello, im working on school project, its deck game Sorry! > I need to create specific lists: > My idea is about to using for > For i in range (n): >i=[] This will create n different empty lists, in succession, and di

Re: Time travel - how to simplify?

2017-11-18 Thread Peter Otten
Andrew Z wrote: > well, yeah, it's unidirectional and final destination is always the same > and have little to do with the question. > > Say, i have a dict: > > fut_suffix ={ 1 : 'F', > 2 : 'G', > 3 : 'H', > 4 : 'J', > 5 : 'K', >

Re: Problem in defining multidimensional array matrix and regression

2017-11-19 Thread Peter Otten
shalu.ash...@gmail.com wrote: > Hi, All, > > I have 6 variables in CSV file. One is rainfall (dependent, at y-axis) and > others are predictors (at x). I want to do multiple regression and create > a correlation matrix between rainfall (y) and predictors (x; n1=5). Thus I > want to read rainfall

Re: Argh!! Can't wrap my head around this Python stuff!

2017-11-26 Thread Peter Otten
Greg Tibbet wrote: > > I'm an old timer, have programmed in Fortran, C, C++, Perl, and a bit > of Java and trying to learn this new-fangled Python language! > > I've got a small program that uses PIL to create an image, draw some > primitives (rectanges, ellipses, etc...) and save it. Works fin

Re: nospam ** infinity?

2017-11-28 Thread Peter Otten
Skip Montanaro wrote: >> I'm 99.5% certain it's not gate_news. > > A funny thing. All messages I have looked at so far with the "nospam" > thing have a Message-ID from binkp.net. (They are also all Usenet > posts.) For example: > > Newsgroups: comp.lang.python > Subject: Re: I have anaconda, but

Re: How to get the redirected URL only but not the actual content?

2017-12-01 Thread Peter Otten
Peng Yu wrote: > Hi, > > Does anybody know how only get the redirected URL but not the actual > content? > > I guess the request module probably should be used. But I am not sure > how to do it exactly. > > Can somebody show me the best way to request > (https://doi.org/10.1109/5.771073) and ge

Re: How to get the redirected URL only but not the actual content?

2017-12-02 Thread Peter Otten
Paul Moore wrote: > On 2 December 2017 at 03:32, Peng Yu wrote: >> Where is `?reload=true` from? How to just get the redict URL that one >> would get from the browser? Thanks. >> >>> 'http://ieeexplore.ieee.org:80/document/771073/?reload=true' > > The reload=true comes because > http://ieeexplor

Re: Python-list Digest, Vol 171, Issue 7

2017-12-06 Thread Peter Otten
Chris Angelico wrote: > On Thu, Dec 7, 2017 at 3:56 AM, Dennis Lee Bieber > wrote: >> Granted, the statistics module in newer Python releases makes the >> entire assignment trivial... >> >> ClgubaJva 3.5.3 (qrsnhyg, Wha 26 2017, 16:17:54) [ZFP i.1900 64 ovg >> (NZQ64)] ba jva32. > > Is t

Re: Stackoverflow question: Is there a built-in identity function in Python?

2017-12-07 Thread Peter Otten
Ethan Furman wrote: > The simple answer is No, and all the answers agree on that point. > > It does beg the question of what an identity function is, though. > > My contention is that an identity function is a do-nothing function that > simply returns what it was given: > > --> identity(1) > 1

Re: Stackoverflow question: Is there a built-in identity function in Python?

2017-12-07 Thread Peter Otten
Ethan Furman wrote: > On 12/07/2017 10:53 AM, Peter Otten wrote: >> Ethan Furman wrote: >> >>> The simple answer is No, and all the answers agree on that point. >>> >>> It does beg the question of what an identity function is, though. >>> >

Re: Processing Game Help

2017-12-11 Thread Peter Otten
Lauren Porter wrote: > Hello all! I've been trying to create a game in Python Processing where a > spaceship moves horizontally in order to miss a collision with an > asteroid. I'm having difficulty making it so that the game quits when an > asteroid hits the spaceship, could anybody help? Here is

Re: Processing Game Help

2017-12-11 Thread Peter Otten
Chris Angelico wrote: > On Tue, Dec 12, 2017 at 5:46 AM, Peter Otten <__pete...@web.de> wrote: >> You can test for a collision and exit if an asteroid is close to a >> spaceship with >> >> for s in spaceship: >> for a in asteroid: >>

Re: [TKinter]How to set LabelFrames font and color from option file

2017-12-14 Thread Peter Otten
Beppe wrote: > I don't succeed in planning the value of the font and color in the > LabelFrames using the option_db file, such as > > *LabelFrame*font: Helvetica 14 > *LabelFrame*foreground: red > > exist a list of the keywordses to use? >>> import tkinter as tk >>> root = tk.Tk() >>> lf = tk.L

Re: [TKinter]How to set LabelFrames font and color from option file

2017-12-14 Thread Peter Otten
Beppe wrote: > Il giorno giovedì 14 dicembre 2017 15:18:31 UTC+1, Peter Otten ha scritto: >> Beppe wrote: >> >> > I don't succeed in planning the value of the font and color in the >> > LabelFrames using the option_db file, such as >> > >&

Re: Problem with timeit

2017-12-15 Thread Peter Otten
Thomas Jollans wrote: > On 2017-12-15 11:36, ast wrote: >> Hi >> >> Time measurment with module timeit seems to work with some statements >> but not with some other statements on my computer. >> >> Python version 3.6.3 >> >> from timeit import Timer >> > Timer("'-'.join([str(i) for i in ra

Re: Repeated Names (Repeated Names)

2017-12-16 Thread Peter Pearson
On Sat, 16 Dec 2017 12:56:07 +1300, Gregory Ewing wrote: > Anyone else now getting duplicate posts with the sender's > name repeated in parentheses? Yes. Both of the posts on this thread appear twice, once with and once without the parenthesized name. In each pair, the Date field differed by one

Re: argparse.ArgumentParser formatter_class argument

2017-12-17 Thread Peter Otten
Seb wrote: > As far as I can see it is currently impossible to apply more than one > class to an ArgumentParser. For example, I'd like to use both > RawDescriptionHelpFormatter *and* ArgumentDefaultsHelpFormatter in an > ArgumentParser, but it seems that's impossible, as one can only choose a > s

Re: __contains__ classmethod?

2017-12-18 Thread Peter Otten
Tim Chase wrote: > Playing around, I had this (happens to be Py2, but gets the same > result in Py3) code > > class X(object): > ONE = "one" > TWO = "two" > _ALL = frozenset(v for k,v in locals().items() if k.isupper()) > @classmethod > def __contains__(cls, v): > return v in cls._A

Re: __contains__ classmethod?

2017-12-18 Thread Peter Otten
Peter Otten wrote: > Tim Chase wrote: > >> Playing around, I had this (happens to be Py2, but gets the same >> result in Py3) code >> >> class X(object): >> ONE = "one" >> TWO = "two" >> _ALL = frozenset(v for k,v in loca

Re: Python bug report

2017-12-22 Thread Peter Pearson
On Thu, 21 Dec 2017 23:54:17 +0100, Ranya wrote: > Hi, > Am trying to use clr.AddReference and clr.AddReferenceToFile, but > python(2.7) keeps making this error: > > Traceback (most recent call last): > File "", line 1, in > clr.AddReference("UnityEngine")AttributeError: 'module' object has

Re: RegExp - please help me!

2017-12-26 Thread Peter Pearson
On Tue, 26 Dec 2017 05:14:55 -0800 (PST), szykc...@gmail.com wrote: [snip] > So: I develop regexp which to my mind should work, but it doesn't and > I don't know why. The broken regexp is like this: > struct (.+)\s*{\s*(.+)\s*}; [snip] You'll probably get better help faster if you can present you

Re: CFG Python

2017-12-30 Thread Peter Otten
Ranya wrote: > Let's say I vreated my own CFG in python, How can I check now if a > sentence match this grammar (return true) or it doesn't match it (return > false and the wrong element in the grammar), How can I do this ? Remember, context free grammars may be fine, but context free questions

Re: Where did csv.parser() go?

2018-01-02 Thread Peter Otten
ja...@apkudo.com wrote: > I need record the starting offsets of csv rows in a database for fast > seeking later. Unfortunately, using any csv.reader() (or DictReader) tries > to cache, which means: example_Data = "'data > 0123456789ABCDE > 1123456789ABCDE > 2123456789ABCDE > 3123456789ABCDE > ...

Re: Dunder variables

2018-01-09 Thread Peter Otten
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 > attribute __dict__, which allows access to the contents of the instance. > > I only want to read from __dict__,

Re: Generating SVG from turtle graphics

2018-01-14 Thread Peter Otten
Steven D'Aprano wrote: > I'd like to draw something with turtle, then generate a SVG file from it. > > Is this possible? If this is a one-off job consider creating Postscript from the underlying Canvas: >>> import turtle >>> for i in range(12): ... turtle.forward(100) ... turtle.left(1

Re: Why does pylint give this warning?

2018-01-14 Thread Peter Otten
breamore...@gmail.com wrote: > Why does pylint give this warning? No idea. > The warning is 'C0103:Method name "__len__" doesn't conform to > '_?_?[a-z][A-Za-z0-9]{1,30}$' pattern' but it doesn't complain about > __repr__ or __str__. If there is an explanation out in the wild my search > fu has

Re: Can utf-8 encoded character contain a byte of TAB?

2018-01-15 Thread Peter Otten
Peng Yu wrote: > Can utf-8 encoded character contain a byte of TAB? Yes; ascii is a subset of utf8. Python 2.7.6 (default, Nov 23 2017, 15:49:48) [GCC 4.8.4] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> ascii = "".join(map(chr, range(128))) >>> uni = asci

Why does random.choice() reject sets? was Re: Speeding up the implementation of Stochastic Gradient Ascent in Python

2018-01-17 Thread Peter Otten
Chris Angelico wrote: > On Thu, Jan 18, 2018 at 6:28 AM, Ned Batchelder > wrote: >> You'll have to replace random.choice() with >> random.choice(list(...)), since you can't random.choice from a set. >> > > Side point: why can't you? You can random.sample from a set, I'm not sure this was a goo

Re: Why is there no functional xml?

2018-01-21 Thread Peter Otten
Rustom Mody wrote: > Looking around for how to create (l)xml one sees typical tutorials like > this: > > https://www.blog.pythonlibrary.org/2013/04/30/python-101-intro-to-xml-parsing-with-elementtree/ > > > > Given the requirement to build up this xml: > > > 1181251680 >

Re: Why is there no functional xml?

2018-01-23 Thread Peter Otten
Rustom Mody wrote: > Its obviously easier in python to put optional/vararg parameters on the > right side rather than on the left of a parameter list. > But its not impossible to get it in the desired order — one just has to > 'hand-parse' the parameter list received as a *param > Thusly: > appoi

Re: Why is there no functional xml?

2018-01-23 Thread Peter Otten
Rustom Mody wrote: > On Sunday, January 21, 2018 at 4:51:34 PM UTC+5:30, Peter Otten wrote: >> Personally I'd probably avoid the extra layer and write a function that >> directly maps dataclasses or database records to xml using the >> conventional elementtree API.

Re: Why is there no functional xml?

2018-01-24 Thread Peter Otten
Rustom Mody wrote: >> To generalize that to handle arbitrarily nested lists and namedtuples a >> bit more effort is needed, but I can't see where lxml.objectify could >> make that much easier. > > You really mean that?? > Well sure in the programming world and even more so in the python world > “

xpath prob, was Re: Why is there no functional xml?

2018-01-24 Thread Peter Otten
Rustom Mody wrote: > With > # Read above xml with open('soap_response.xml') as f: inp = etree.parse(f) > # namespace dict nsd = {'soap': "http://schemas.xmlsoap.org/soap/envelope/";, 'locns': "http://example.com/"} > > The following behavior is observed — actual responses elided in

Re: How to diagnose this, fails on 3.6.3, works on 3.5.2?

2018-01-24 Thread Peter Otten
Chris Green wrote: > I have a fairly simple little python program to automate starting an > editor on a wiki page. It works fine on the system where I wrote it > (xubuntu 16.04, python 3 version 3.5.2) but it comes up with the > following error on a newer system (xubuntu 17.10, python 3 version >

Re: Please help on print string that contains 'tab' and 'newline'

2018-01-28 Thread Peter Otten
Jason Qian via Python-list wrote: > HI > >I have a string that contains \r\n\t > >[Ljava.lang.Object; does not exist*\r\n\t*at >[com.livecluster.core.tasklet > > >I would like to print it as : > > [Ljava.lang.Object; does not exist > tat com.livecluster.core.tasklet > >

Re: Compression of random binary data

2018-01-28 Thread Peter Pearson
On Sat, 27 Jan 2018 21:26:06 -0800 (PST), pendrysamm...@gmail.com wrote: > If it is then show him this > > 387,420,489 >= > 00110011 00111000 00110111 00101100 00110100 00110010 0011 0 ... To save the casual reader a moment of disorientation, the above binary string is just the ASCII represent

Re: Where has the practice of sending screen shots as source code come from?

2018-01-29 Thread Peter Pearson
On Sun, 28 Jan 2018 20:24:55 -0800, Dan Stromberg wrote: [snip] > > Is it really true that OCR appeared long before Neural Networks > (NN's)? I first heard of NN's in the 80's, but OCR more like the > 90's. In 1964, the IBM exhibit at the World's Fair in New York demonstrated a system that read

Re: New to Python and understanding problem

2018-01-29 Thread Peter Otten
Michelle Konzack wrote: > Hello *, > > because I am runing into problems with SOME python based programs, I the > this as opportunity to learn python (after ASM, C, BaSH, CP/M, COBOL, > JS, PHP and perl). > > > OK, I tried to install "blueman" (Bluetooth Manager) on my Debian 9.2 > (Stret

Re: checksum problem

2018-01-30 Thread Peter Pearson
On Tue, 30 Jan 2018 11:24:07 +0100, jak wrote: > Hello everybody, > I'm using python 2.7.14 and calculating the checksum with the sha1 > algorithm and this happens: the checksum is wrong until I read the whole > file in one shot. Here is a test program: > > import hashlib > > def Checksum(fname,

Re: Where has the practice of sending screen shots as source code come from?

2018-01-30 Thread Peter Pearson
On Mon, 29 Jan 2018 14:46:59 -0500, Dennis Lee Bieber wrote: > On 29 Jan 2018 17:26:32 GMT, Peter Pearson > declaimed the following: > >> >>In 1964, the IBM exhibit at the World's Fair in New York demonstrated >>a system that read dates that visitors wrote by hand

Re: What F strings should have been

2018-02-15 Thread Peter Otten
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() and it is supposed to be cleaner.

Re: [Tkinter]Validation to multiple Entry widgets

2018-02-17 Thread Peter Otten
Beppe wrote: > I would validate values input, on key, in multiple Entry widgets create at > run time > > I wrote this snip but even if the entry are created and the callback work > well the relative value is missing > my_list = (2.14,18.3,76.4,2.38,0.425,2.68,1.09,382,8.59,0.495)

Re: Writing some floats in a file in an efficient way

2018-02-21 Thread Peter Otten
ast wrote: > Is there a way to write a float with only 8 bytes ? If you want to write the values one-by-one convert them to bytes with struct.pack() and then write the result. To write many values at once use array.array.tofile() or numpy.array.tofile(). -- https://mail.python.org/mailman/l

Re: Writing some floats in a file in an efficient way

2018-02-21 Thread Peter Heitzer
. >Is there a way to write a float with only 8 bytes ? Use struct.pack() -- Dipl.-Inform(FH) Peter Heitzer, peter.heit...@rz.uni-regensburg.de -- https://mail.python.org/mailman/listinfo/python-list

Re: help me ?

2018-02-26 Thread Peter Otten
Christian Gollwitzer wrote: > Am 26.02.18 um 10:40 schrieb sotaro...@gmail.com: >> Define 2 lists. The first one must contain the integer values 1, 2 and 3 >> and the second one the string values a, b and c. Iterate through both >> lists to create another list that contains all the combinations of

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

2018-02-26 Thread Peter Otten
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 names as the constructor/initialiser > parameters. If those arguments are None, the defaults are

Re: matrix multiplication

2018-02-27 Thread Peter Otten
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), compared to looping >>> through the matrix row by row as shown in the code. > >> Jus

Re: Tuple unpacking inside lambda expressions

2022-04-21 Thread Peter Otten
On 20/04/2022 13:01, Sam Ezeh wrote: I went back to the code recently and I remembered what the problem was. I was using multiprocessing.Pool.pmap which takes a callable (the lambda here) so I wasn't able to use comprehensions or starmap Is there anything for situations like these? Hm, I don'

Re: EAFP

2022-05-16 Thread Peter Otten
On 13/05/2022 18:37, bryangan41 wrote: Is the following LBYL:foo = 123if foo < 200:    do()If so, how to change to EAFP?Thanks!Sent from Samsung tablet. The distinction between look-before-you-leap and easier-to-ask-forgiveness-than-permission is weaker than yo might expect. When you write f

Re: oop issue

2022-05-23 Thread Peter Otten
On 23/05/2022 22:54, Tola Oj wrote: i just finished learning oop as a beginner and trying to practice with it but i ran into this typeerror issue, help please. Traceback (most recent call last): File "c:\Users\ojomo\OneDrive\Desktop\myexcel\oop_learn.py\myExperiment.py\mainMain.py", line 36,

Re: Filtering XArray Datasets?

2022-06-07 Thread Peter Otten
On 07/06/2022 00:28, Israel Brewster wrote: I have some large (>100GB) datasets loaded into memory in a two-dimensional (X and Y) NumPy array backed XArray dataset. At one point I want to filter the data using a boolean array created by performing a boolean operation on the dataset that is, I

Re: PYLAUNCH_DEBUG not printing info

2022-06-09 Thread Peter Otten
On 09/06/2022 00:53, Richard David wrote: Why am I not getting debug output on my windows 10 machine: C:\temp>\Windows\py.exe -0 -V:3.11 *Python 3.11 (64-bit) -V:3.10 Python 3.10 (64-bit) C:\temp>set PYLAUNCH_DEBUG=1 C:\temp>\Windows\py.exe Python 3.11.0b3 (main, Jun 1 20

Re: PYLAUNCH_DEBUG not printing info

2022-06-09 Thread Peter Otten
On 09/06/2022 00:53, Richard David wrote: Why am I not getting debug output on my windows 10 machine: C:\temp>\Windows\py.exe -0 -V:3.11 *Python 3.11 (64-bit) -V:3.10 Python 3.10 (64-bit) C:\temp>set PYLAUNCH_DEBUG=1 C:\temp>\Windows\py.exe Python 3.11.0b3 (main, Jun 1 20

Re: python Store text file in mangodb

2022-06-13 Thread Peter Otten
On 12/06/2022 14:40, Ayesha Tassaduq wrote: Hi i am trying to store a text file into MongoDB but i got the error . "failing because no such method exists." % self.__name.split(".")[-1] TypeError: 'Collection' object is not callable. If you meant to call the 'insert' method on a 'Collection' obje

Re: fill out bulletins

2022-06-14 Thread Peter Pearson
On Tue, 14 Jun 2022 00:41:07 +0200, jak wrote: [snip] > > If you are interested in seeing what I called "post office bulletin" > (English is not my language and I don't know the name, sorry), you can > find a sample pdf (fillable) but it works badly here: > > https://www.guardiacostiera.gov.it/ven

Re: Creating lambdas inside generator expression

2022-06-30 Thread Peter Otten
On 29/06/2022 23:17, Chris Angelico wrote: On Thu, 30 Jun 2022 at 02:49, Johannes Bauer wrote: But now consider what happens when we create the lambdas inside a list comprehension (in my original I used a generator expresison, but the result is the same). Can you guess what happens when we crea

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

2022-07-20 Thread Peter Otten
On 20/07/2022 11:37, 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" or "license" for more information. >>

Re: Object in List : how?

2022-07-24 Thread Peter Otten
On 23/07/2022 06:28, Khairil Sitanggang wrote: Hello Expert: I just started using python. Below is a simple code. I was trying to check if, say, NO1 is not in the NODELIST[:].NO How can I achieve this purpose? Regards, -Irfan class Node: def __init__(self): self.NO = 0

Re: Object in List : how?

2022-07-25 Thread Peter Otten
On 25/07/2022 02:47, Khairil Sitanggang wrote: Regarding your comment : " *However, usually object creation and initialization iscombined by allowing arguments to the initializer:*" , so which one of the two classes Node1, Node2 below is more common in practice? Option 2, I guess. Thanks, # opt

mailbox misbehavior with non-ASCII

2022-07-29 Thread Peter Pearson
The following code produces a nonsense result with the input described below: import mailbox box = mailbox.Maildir("/home/peter/Temp/temp",create=False) x = box.values()[0] h = x.get("X-DSPAM-Factors") print(type(h)) # The output is the desired "str" when the m

Re: Mutating an HTML file with BeautifulSoup

2022-08-21 Thread Peter Otten
On 22/08/2022 05:30, Chris Angelico wrote: On Mon, 22 Aug 2022 at 10:04, Buck Evan wrote: I've had much success doing round trips through the lxml.html parser. https://lxml.de/lxmlhtml.html I ditched bs for lxml long ago and never regretted it. If you find that you have a bunch of invalid h

Re: Python3.6 tkinter bug?

2022-09-22 Thread Peter Smith
On Wednesday, February 1, 2017 at 11:55:35 AM UTC, Terry Reedy wrote: > On 2/1/2017 1:37 AM, Christian Gollwitzer wrote: > > Am 01.02.17 um 00:02 schrieb MRAB: > >> On 2017-01-31 22:34, Christian Gollwitzer wrote: > .!frame.!checkbutton > .!frame.!checkbutton2 > .!frame2.!checkb

Re: Python3.6 tkinter bug?

2022-09-22 Thread Peter Smith
On Wednesday, February 1, 2017 at 11:55:35 AM UTC, Terry Reedy wrote: > On 2/1/2017 1:37 AM, Christian Gollwitzer wrote: > > Am 01.02.17 um 00:02 schrieb MRAB: > >> On 2017-01-31 22:34, Christian Gollwitzer wrote: > .!frame.!checkbutton > .!frame.!checkbutton2 > .!frame2.!checkb

Re: Typing: Is there a "cast operator"?

2022-10-26 Thread Peter Otten
On 24/10/2022 05:19, Chris Angelico wrote: On Mon, 24 Oct 2022 at 14:15, Dan Stromberg wrote: I've found that mypy understands simple assert statements. So if you: if f is not None: assert f is not None os.write(f, ...) You might be in good shape. Why can't it simply under

Re: Fwd: A typing question

2022-10-30 Thread Peter Otten
On 30/10/2022 14:37, Peter J. Holzer wrote: On 2022-10-30 09:23:27 -0400, Thomas Passin wrote: On 10/30/2022 6:26 AM, Peter J. Holzer wrote: On 2022-10-29 23:59:44 +0100, Paulo da Silva wrote: The funny thing is that if I replace foos by Foos it works because it gets known by the initial

Re: typing: property/setter and lists?

2022-11-03 Thread Peter Otten
On 03/11/2022 04:24, Paulo da Silva wrote: Hi! And a typing problem again!!! ___ class C: def __init__(self):     self.__foos=5*[0] @property def foos(self) -> list[int]:     return self.__foos @foos.setter def foos(self,v:

Re: How to convert a raw string r'\xdd' to '\xdd' more gracefully?

2022-12-07 Thread Peter Otten
On 07/12/2022 03:23, Jach Feng wrote: s0 = r'\x0a' At this moment it was done by def to1byte(matchobj): return chr(int('0x' + matchobj.group(1), 16)) s1 = re.sub(r'\\x([0-9a-fA-F]{2})', to1byte, s0) But, is it that difficult on doing this simple thing? >>> import codecs >>>

Re: How to convert a raw string r'\xdd' to '\xdd' more gracefully?

2022-12-08 Thread Peter Otten
On 08/12/2022 02:17, Jach Feng wrote: Peter Otten 在 2022年12月8日 星期四清晨5:17:59 [UTC+8] 的信中寫道: On 07/12/2022 03:23, Jach Feng wrote: s0 = r'\x0a' At this moment it was done by def to1byte(matchobj): return chr(int('0x' + matchobj.group(1), 16)) s1 = re.sub(r'\\x([0-9

Re: Top level of a recursive function

2022-12-15 Thread Peter Otten
On 13/12/2022 15:46, Michael F. Stemper wrote: It's easy enough -- in fact necessary -- to handle the bottom level of a function differently than the levels above it. What about the case where you want to handle something differently in the top level than in lower levels? Is there any way to tell

Re: Keeping a list of records with named fields that can be updated

2022-12-15 Thread Peter Otten
On 14/12/2022 19:50, songbird wrote: I'm relatively new to python but not new to programming in general. The program domain is accounting and keeping track of stock trades and other related information (dates, cash accounts, interest, dividends, transfers of funds, etc.) Assume that

Re: Keeping a list of records with named fields that can be updated

2022-12-19 Thread Peter Otten
On 17/12/2022 20:45, Albert-Jan Roskam wrote: On Dec 15, 2022 10:21, Peter Otten <__pete...@web.de> wrote: >>> from collections import namedtuple >>> Row = namedtuple("Row", "foo bar baz") >>> row = Row(1, 2, 3) &g

Re: Keeping a list of records with named fields that can be updated

2022-12-19 Thread Peter Otten
On 18/12/2022 16:44, songbird wrote: Peter Otten wrote: ... While I think what you need is a database instead of the collection of csv files the way to alter namedtuples is to create a new one: from collections import namedtuple Row = namedtuple("Row", "foo bar baz") ro

Re: Custom help format for a choice argparse argument

2023-01-30 Thread Peter Otten
On 27/01/2023 21:31, Ivan "Rambius" Ivanov wrote: Hello, I am developing a script that accepts a time zone as an option. The time zone can be any from pytz.all_timezones. I have def main(): parser = argparse.ArgumentParser() parser.add_argument("-z", "--zone", choices=pytz.all_timezon

Python: How to use the 'trace' module programmatically?

2023-02-15 Thread Peter Slížik
able to do, when I set count=1, I was able to catch the coverage data with tracer.results() and write them to a file. But the tracing information was not generated even in this case. Am I doing anything wrong? Peter -- https://mail.python.org/mailman/listinfo/python-list

Re: Python: How to use the 'trace' module programmatically?

2023-02-16 Thread Peter Slížik
Gerard - I did not use the filtering options. Thank you for bringing them to my attention. Barry - thank you for the insight. Now the tracing works as expected. I'm not sure why it didn't work before... Maybe the program redirected stdout? Thank you guys, Peter On Thu, Feb 16, 2023

Re: Precision Tail-off?

2023-02-16 Thread Peter Pearson
On Tue, 14 Feb 2023 11:17:20 +, Oscar Benjamin wrote: > On Tue, 14 Feb 2023 at 07:12, Stephen Tucker wrote: [snip] >> I have just produced the following log in IDLE (admittedly, in Python >> 2.7.10 and, yes I know that it has been superseded). >> >> It appears to show a precision tail-off as t

Re: Precision Tail-off?

2023-02-17 Thread Peter Pearson
On Fri, 17 Feb 2023 10:27:08, Stephen Tucker wrote:[Head-posting undone.] > On Thu, Feb 16, 2023 at 6:49 PM Peter Pearson > wrote: >> On Tue, 14 Feb 2023 11:17:20 +, Oscar Benjamin wrote: >> > On Tue, 14 Feb 2023 at 07:12, Stephen Tucker >> wrote: >> [sni

Re: When is logging.getLogger(__name__) needed?

2023-03-31 Thread Peter Otten
nt call last): File "", line 1, in use_name() File "", line 2, in use_name print(name) NameError: name 'name' is not defined Binding (=assigning to) a name inside a function makes it local to that function. If you want a global (module-level) name you h

Re: Question regarding unexpected behavior in using __enter__ method

2023-04-21 Thread Peter Otten
On 21/04/2023 00:44, Lorenzo Catoni wrote: Dear Python Mailing List members, I am writing to seek your assistance in understanding an unexpected behavior that I encountered while using the __enter__ method. I have provided a code snippet below to illustrate the problem: ``` class X: ... _

Re: What do these '=?utf-8?' sequences mean in python?

2023-05-08 Thread Peter Pearson
On Sat, 6 May 2023 14:50:40 +0100, Chris Green wrote: [snip] > So, what do those =?utf-8? and ?= sequences mean? Are they part of > the string or are they wrapped around the string on output as a way to > show that it's utf-8 encoded? Yes, "=?utf-8?" signals "MIME header encoding". I've only bl

Re: getting rid of the recursion in __getattribute__

2023-05-25 Thread Peter Otten
On 24/05/2023 15:37, A KR wrote: It is perfectly explained in the standards here [1] saying that: In order to avoid infinite recursion in this method, its implementation should always call the base class method with the same name to access any attributes it needs, for example, object.__getatt

Re: A beginning beginner's question about input, output and . . .

2021-01-13 Thread Peter Pearson
On Mon, 11 Jan 2021 15:37:58 -0500, DonK wrote: [snip] > > I've seen some Python gui frameworks like Tkinter, PyQt, etc. but they > look kinda like adding a family room onto a 1986 double wide mobile > home, Agreed. Browsergui is not widely popular (I don't think anybody but me has mentioned it

Re: A beginning beginner's question about input, output and . . .

2021-01-14 Thread Peter Pearson
On Wed, 13 Jan 2021 21:46:08 - (UTC), Grant Edwards wrote: > On 2021-01-13, Peter Pearson wrote: [snip] >> Browsergui is not widely popular (I don't think anybody but me has >> mentioned it on this newsgroup), but it was written to be simple and >> Python

Re: count consecutive elements

2021-01-17 Thread Peter Otten
On 17/01/2021 02:15, Dan Stromberg wrote: IMO a good set of tests is much more important than type annotations ;) def get_longest(string: str) -> typing.Tuple[int, typing.List[str]]: """Get the longest run of a single consecutive character.""" May I ask why you artificially limit th

Re: count consecutive elements

2021-01-19 Thread Peter Otten
On 19/01/2021 04:45, Bischoop wrote: I sat to it again and solved it. Congratulations! > lil = tuple(set(s)) # list of characters in s > > li=[0,0,0,0,0,0] # list for counted repeats I see a minor problem here. What happens if s contains more than len(li) characters? import timeit Since

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