From musbur at posteo.org Wed Apr 1 08:42:45 2020 From: musbur at posteo.org (Musbur) Date: Wed, 01 Apr 2020 14:42:45 +0200 Subject: How to instantiate a custom Python class inside a C =?UTF-8?Q?extension=3F?= Message-ID: <346bb9b40303e9207807c78e186dffeb@posteo.de> Hi guys, I'm wondering how to create an instance of an extension class I wrote. There's a minimal self-contained C module at the bottom of this post which exports two things: 1) a class Series, and 2) a function make_series() which is supposed to create a Series object on the C side and return it. The make_series function uses PyObject_New() and PyObject_Init() to create the new instance, but all it produces is some kind of zombie instance which tends to crash the application with a segfault in real life. When instantiated from Python using Series(), I get a well-behaved instance. I've sprinkled the New, Init and Finalize functions with fprintf()s to see what happens to the object during its lifetime. When I run this test script: from series import * print("From Python") s1 = Series() del s1 print("\nFrom C") s2 = make_series() del s2 I get this output: From Python New Series at 0x7f89313f6660 Init Series at 0x7f89313f6660 Finalize Series at 0x7f89313f6660 From C Finalize Series at 0x7f89313f6678 So when created from C, neither the "new" nor the "init" functions are called on the object, only "finalize". No wonder I get segfaults in the real life application. So how is this done right? Here's the C module: #include typedef struct { PyObject_HEAD void *data; } Series; static PyObject *Series_new(PyTypeObject *type, PyObject *args, PyObject *kw) { Series *self; self = (Series *) type->tp_alloc(type, 0); self->data = NULL; fprintf(stderr, "New Series at %p\n", self); return (PyObject*)self; } static int Series_init(Series *self, PyObject *args, PyObject *kw) { fprintf(stderr, "Init Series at %p\n", self); return 0; } static void Series_finalize(PyObject *self) { fprintf(stderr, "Finalize Series at %p\n", self); } static PyMethodDef series_methods[] = { {NULL, NULL, 0, NULL} }; static PyTypeObject series_type = { PyVarObject_HEAD_INIT(NULL, 0) .tp_name = "_Series", .tp_basicsize = sizeof(Series), .tp_flags = 0 | Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, .tp_doc = "Series (msec, value) object", .tp_methods = series_methods, .tp_new = Series_new, .tp_init = (initproc) Series_init, .tp_dealloc = Series_finalize, }; /* To create a new Series object directly from C */ PyObject *make_series(void *data) { Series *pyseries; pyseries = PyObject_New(Series, &series_type); PyObject_Init((PyObject *)pyseries, &series_type); pyseries->data = data; return (PyObject *) pyseries; } static PyMethodDef module_methods[] = { {"make_series", (PyCFunction)make_series, METH_NOARGS, "Instantiate and return a new Series object."}, {NULL, NULL, 0, NULL} }; static PyModuleDef series_module = { PyModuleDef_HEAD_INIT, "series", "Defines the Series (time, value) class" , -1, module_methods }; PyMODINIT_FUNC PyInit_series(void) { PyObject *m; m = PyModule_Create(&series_module); if (PyType_Ready(&series_type) < 0) { return NULL; } PyModule_AddObject(m, "Series", (PyObject*)&series_type); return m; } From rhodri at kynesim.co.uk Wed Apr 1 09:01:34 2020 From: rhodri at kynesim.co.uk (Rhodri James) Date: Wed, 1 Apr 2020 14:01:34 +0100 Subject: How to instantiate a custom Python class inside a C extension? In-Reply-To: <346bb9b40303e9207807c78e186dffeb@posteo.de> References: <346bb9b40303e9207807c78e186dffeb@posteo.de> Message-ID: <49dba2a0-c5da-df3c-b271-02f8c4ca3cc5@kynesim.co.uk> On 01/04/2020 13:42, Musbur wrote: > So when created from C, neither the "new" nor the "init" functions are > called on the object, only "finalize". No wonder I get segfaults in the > real life application. > > So how is this done right? Here's the C module: I believe you do it in C as you would in Python: you call the Series class! pyseries = PyObject_CallObject((PyObject *)&series_type, NULL); -- Rhodri James *-* Kynesim Ltd From rshepard at appl-ecosys.com Wed Apr 1 12:34:50 2020 From: rshepard at appl-ecosys.com (Rich Shepard) Date: Wed, 1 Apr 2020 09:34:50 -0700 (PDT) Subject: Identifying tkinter version Message-ID: Here, on Slackware-14.2, Python3-3.8.2 is installed. I would like to learn which version of tkinter is provided with it. There's no local VERSION file and tkinter.version() returns nothing. How do I determine the installed version? Regards, Rich From lists at vanderhoff.org Wed Apr 1 12:43:29 2020 From: lists at vanderhoff.org (Tony van der Hoff) Date: Wed, 1 Apr 2020 17:43:29 +0100 Subject: Identifying tkinter version In-Reply-To: References: Message-ID: On 01/04/2020 17:34, Rich Shepard wrote: > Here, on Slackware-14.2, Python3-3.8.2 is installed. I would like to learn > which version of tkinter is provided with it. There's no local VERSION file > and tkinter.version() returns nothing. > > How do I determine the installed version? >>> import tkinter >>> tkinter.TkVersion 8.6 -- Tony van der Hoff | mailto:tony at vanderhoff.org Buckinghamshire, England | From rshepard at appl-ecosys.com Wed Apr 1 13:22:34 2020 From: rshepard at appl-ecosys.com (Rich Shepard) Date: Wed, 1 Apr 2020 10:22:34 -0700 (PDT) Subject: Identifying tkinter version [ANSWERED] In-Reply-To: References: Message-ID: On Wed, 1 Apr 2020, Tony van der Hoff wrote: >> How do I determine the installed version? >>>> import tkinter >>>> tkinter.TkVersion > 8.6 Thanks, Tony. I was close, but still too far away. Stay healthy, Rich From info at pwiehe.de Wed Apr 1 13:27:56 2020 From: info at pwiehe.de (Peter Wiehe) Date: Wed, 1 Apr 2020 19:27:56 +0200 Subject: Python3 module with financial accounts? Message-ID: Is there a Python3 module with financial accounts? -- Greetings Peter Wiehe From musbur at posteo.org Wed Apr 1 13:24:11 2020 From: musbur at posteo.org (Musbur) Date: Wed, 01 Apr 2020 19:24:11 +0200 Subject: How to instantiate a custom Python class inside a C =?UTF-8?Q?extension=3F?= In-Reply-To: <49dba2a0-c5da-df3c-b271-02f8c4ca3cc5@kynesim.co.uk> References: <346bb9b40303e9207807c78e186dffeb@posteo.de> <49dba2a0-c5da-df3c-b271-02f8c4ca3cc5@kynesim.co.uk> Message-ID: <15e723aae36b6517ab919003ca624fda@posteo.de> Am 01.04.2020 15:01 schrieb Rhodri James: > I believe you do it in C as you would in Python: you call the Series > class! > > pyseries = PyObject_CallObject((PyObject *)&series_type, NULL); Well, that dumps core just as everything else I tried. What does work, however, is calling PyType_Ready first: PyType_Ready(&series_type); pyseries = PyObject_New(Series, &series_type); PyObject_Init((PyObject *)pyseries, &series_type);o I don't understand, though, why I have to do that and when. Didn't that already happen when the module was imported? Do I need to do it whenever I create a new instance in C? From rhodri at kynesim.co.uk Wed Apr 1 13:41:49 2020 From: rhodri at kynesim.co.uk (Rhodri James) Date: Wed, 1 Apr 2020 18:41:49 +0100 Subject: How to instantiate a custom Python class inside a C extension? In-Reply-To: <15e723aae36b6517ab919003ca624fda@posteo.de> References: <346bb9b40303e9207807c78e186dffeb@posteo.de> <49dba2a0-c5da-df3c-b271-02f8c4ca3cc5@kynesim.co.uk> <15e723aae36b6517ab919003ca624fda@posteo.de> Message-ID: <6e94472d-8396-f5fd-7c76-1558703f8f0d@kynesim.co.uk> On 01/04/2020 18:24, Musbur wrote: > Am 01.04.2020 15:01 schrieb Rhodri James: > >> I believe you do it in C as you would in Python: you call the Series >> class! >> >> pyseries = PyObject_CallObject((PyObject *)&series_type, NULL); > > Well, that dumps core just as everything else I tried. > > What does work, however, is calling PyType_Ready first: > > ??? PyType_Ready(&series_type); > ??? pyseries = PyObject_New(Series, &series_type); > ??? PyObject_Init((PyObject *)pyseries, &series_type);o > > I don't understand, though, why I have to do that and when. Didn't that > already happen when the module was imported? Do I need to do it whenever > I create a new instance in C? It should have happened on your module being imported, the line was there in your code. Stick a breakpoint on your module init function and see if it is being called. (The "from thingy import *" always makes me nervous, but it shouldn't be responsible for this.) -- Rhodri James *-* Kynesim Ltd From pablogab at prodigy.net.mx Wed Apr 1 13:09:09 2020 From: pablogab at prodigy.net.mx (HERNANDEZ AGUIRRE JOSE GABRIEL DE LA DOLOROSA) Date: Wed, 01 Apr 2020 10:09:09 -0700 Subject: Fw: Python installation problem Message-ID: En Mar, 31 Marzo, 2020 en 18:48, yo escribi?: ? Para: python-list at python.org I? installed? the Python software , but I could not find the python.exe file with the Unscramble software What do you advise ? Regards From ansonfreer at gmail.com Wed Apr 1 13:13:34 2020 From: ansonfreer at gmail.com (anson freer) Date: Wed, 1 Apr 2020 10:13:34 -0700 Subject: about to resolve problem in installation In-Reply-To: References: Message-ID: Re: Calvin Spealman,Terry Reedyreading Kapuganti Rakesh post Terry Reedy said"You are re-running the installer. Hit 'start' in lower left corner andfind python under 'p'. Kapuganti Rakesh looks like he is refering to modify setup and cancel is the only otheroption no "p". Then Kapuganti Rakesh"I have already search in my pc but it is showing nothing and later isearched python and started that app.After some it showingI am getting confuse over this. pls help me"I did a Search user/"C" and found Anaconda2, Python2, jupyter and many applications for python.But what one to pick? I'm not versed with w10 but w8 is left click the four square box a menu popsup right click search then press "p" and it came right up!I self taught myself ms Access VBA and in my 80+ years I never assume I know everything,never place blameJust fix the problem.Everyone is ignonant until there not and can learn anything if they never give up.Now Anson Freer(me) had a simlar problem I used the Python web site asked a question and was rejected""Hello! I see you want to post a message to the Python List. Wewould be happy to help, but you must subscribe first:"I did now my mail has many "install" problems. It's OK as I did fix my issue by reading them.questions:Will Anaconda2, Python2, jupyter and many applications for python harm the 3.8.2?should I be in Python Tutor and in this one(current email)at the same time?I want to learn how to use PDF to read files that have racing form style forms(my hobbie is Horse handicapping)I know I need to"get" the correct modules.(trial an error)Youtube is Ok but I think your members and staff want all to succeed and for me I help others because it makes me feel good not the other way aroundI see boB Stepp nailed it Thank you for your time On Tue, Mar 31, 2020 at 6:59 PM boB Stepp wrote: > On Tue, Mar 31, 2020 at 12:02 PM Kapuganti Rakesh > wrote: > > > I have already search in my pc but it is showing nothing and later i > > searched python and started that app.After some it showing > > I am getting confuse over this. pls help me > > If you press your Windows key (or click on the Windows symbol on the > task bar) you will have an alphabetically arranged list of programs. > Scroll down till you reach Python 3.8. Expand that entry by clicking > on it. If you did a normal installation you should see "IDLE...", > "Python 3.8..." and "Python 3.8 Module Docs..." For your purposes you > probably would want to start with IDLE. It will take you to Python's > interactive interpreter. You will see a prompt that looks like ">>>" > You may type in Python statements after the prompt such as ">>> 3*2" > You can do more in IDLE (Much more), but you will need to have a > beginner's Python book or tutorial to guide you in what to do next. > > By the way, there is a Python Tutor list that exists to help newcomers > to Python and/or programming. Its subscription page may be found at: > > https://mail.python.org/mailman/listinfo/tutor > > Hope this helps you through your first steps! > > Cheers! > boB > -- > https://mail.python.org/mailman/listinfo/python-list > From python.list at tim.thechases.com Wed Apr 1 14:02:27 2020 From: python.list at tim.thechases.com (Tim Chase) Date: Wed, 1 Apr 2020 13:02:27 -0500 Subject: Python3 module with financial accounts? In-Reply-To: References: Message-ID: <20200401130227.076eb42d@bigbox.attlocal.net> On 2020-04-01 19:27, Peter Wiehe wrote: > Is there a Python3 module with financial accounts? You'd have to be more specific. For interacting with online accounts with financial institutions? For tracking financial data locally? There's beancount (http://furius.ca/beancount/ and written in Python) which does plaintext accounting (https://plaintextaccounting.org/) for wrangling financial account information using double-entry bookkeeping methods. -tkc From auriocus at gmx.de Wed Apr 1 14:47:23 2020 From: auriocus at gmx.de (Christian Gollwitzer) Date: Wed, 1 Apr 2020 20:47:23 +0200 Subject: Identifying tkinter version [ANSWERED] In-Reply-To: References: Message-ID: Am 01.04.20 um 19:22 schrieb Rich Shepard: > On Wed, 1 Apr 2020, Tony van der Hoff wrote: > >>> How do I determine the installed version? >>>>> import tkinter >>>>> tkinter.TkVersion >> 8.6 > > Thanks, Tony. I was close, but still too far away. This only shows you the major version. There have been many updates to Tcl/Tk in "minor" releases, including lots of rework on Tk internals. Therefore, you need the patchlevel. YOu can get this by root.eval('info patchlevel') Apfelkiste:Test chris$ python3 Python 3.6.1 |Anaconda 4.4.0 (x86_64)| (default, May 11 2017, 13:04:09) [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import tkinter >>> root=tkinter.Tk() >>> root.eval('info patchlevel') '8.5.9' >>> (urks, I'll have to upgrade. 8.5.9 on OSX is seriously broken) Christian From torriem at gmail.com Wed Apr 1 14:49:39 2020 From: torriem at gmail.com (Michael Torrie) Date: Wed, 1 Apr 2020 12:49:39 -0600 Subject: Fw: Python installation problem In-Reply-To: References: Message-ID: On 4/1/20 11:09 AM, HERNANDEZ AGUIRRE JOSE GABRIEL DE LA DOLOROSA wrote: > I? installed? the Python software , but I could not find the python.exe file with the Unscramble software What is this "Unscramble software?" After Python is installed, you probably will find the "Idle" integrated development environment in your start menu under "Python." Looks like recent versions of Python default to installing into your home directory under AppData\Local\Programs\Python-38-32 (or -64). Look in there for python.exe and pythonw.exe. Please note that Python is not like Visual Studio. It's an interpreter that is meant to be run from the command line with python script files you create in an editor. It may also be helpful to click the option in the installed to add Python to the PATH. That way you can just run python.exe from any command prompt. From torriem at gmail.com Wed Apr 1 14:55:09 2020 From: torriem at gmail.com (Michael Torrie) Date: Wed, 1 Apr 2020 12:55:09 -0600 Subject: Fw: Python installation problem In-Reply-To: References: Message-ID: <214f82e7-2418-d966-13d4-31a3c0cc55c6@gmail.com> On 4/1/20 11:09 AM, HERNANDEZ AGUIRRE JOSE GABRIEL DE LA DOLOROSA wrote: > Para: python-list at python.org > > I? installed? the Python software , but I could not find the python.exe file with the Unscramble software Actually in windows 10, Idle shows up in the start menu under the "I"s, not in a python folder. From hhmhonori at gmail.com Wed Apr 1 14:15:57 2020 From: hhmhonori at gmail.com (Honori R. Camacho) Date: Wed, 1 Apr 2020 14:15:57 -0400 Subject: Fwd: Problemas para ejecutar Python en windows 7 In-Reply-To: References: Message-ID: Ok. 1.- Necesitamos ayuda. No podemos ejecutar Python 3.5.4 en windows 7, se descargo la version Python 3.5.4 y se instalo correctamente.Y se corrigieron los path. Pero no permite ejecutar los .py ni los .pyw por acceso directo. gracias. * Usa (SL) Software Libre ...Twitter: @rhonoricBlog Spot: http://rhonoric.blogspot.com/ * ---------- Forwarded message --------- De: Honori R. Camacho Date: mi?., 1 abr. 2020 a las 13:45 Subject: Problemas para ejecutar Python en windows 7 To: 1.- Necesitamos ayuda. No podemos ejecutar Python 3.5.4 en windows 7, se descargo la version Python 3.5.4 y se instalo correctamente.Y se corrigieron los path. Pero no permite ejecutar los .py ni los .pyw por acceso directo. gracias. * Usa (SL) Software Libre ...Twitter: @rhonoricBlog Spot: http://rhonoric.blogspot.com/ * From ansonfreer at gmail.com Wed Apr 1 13:49:39 2020 From: ansonfreer at gmail.com (anson freer) Date: Wed, 1 Apr 2020 10:49:39 -0700 Subject: questions: Message-ID: Will Anaconda2, Python2, jupyter and many applications I have for python harm the 3.8.2? should I be in Python Tutor and in this one(current email)at the same time? Or is it one or the other not both I want to learn how to use PDF to read files that have racing form style forms(my hobbie is Horse handicapping) I know I need to"get" the correct modules.(trial an error)but I don't know all the correct terms yet Be kind I'm in my 80's bu t age is just a number my brain thinks like a teen my body refuses to listen. From info at pwiehe.de Wed Apr 1 14:08:56 2020 From: info at pwiehe.de (Peter Wiehe) Date: Wed, 1 Apr 2020 20:08:56 +0200 Subject: Python3 module with financial accounts? In-Reply-To: <20200401130227.076eb42d@bigbox.attlocal.net> References: <20200401130227.076eb42d@bigbox.attlocal.net> Message-ID: On 01.04.20 20:02, Tim Chase wrote: > On 2020-04-01 19:27, Peter Wiehe wrote: >> Is there a Python3 module with financial accounts? > You'd have to be more specific. For interacting with online accounts > with financial institutions? For tracking financial data locally? > > There's beancount (http://furius.ca/beancount/ and written in Python) > which does plaintext accounting (https://plaintextaccounting.org/) > for wrangling financial account information using double-entry > bookkeeping methods. > > -tkc > > > It's for tracking my own expenses and income, using double-entries. On first glance this is exactly what I was looking for! Thank you Peter From python at mrabarnett.plus.com Wed Apr 1 15:43:09 2020 From: python at mrabarnett.plus.com (MRAB) Date: Wed, 1 Apr 2020 20:43:09 +0100 Subject: How to instantiate a custom Python class inside a C extension? In-Reply-To: <346bb9b40303e9207807c78e186dffeb@posteo.de> References: <346bb9b40303e9207807c78e186dffeb@posteo.de> Message-ID: <7108be49-0b44-fc5e-d37e-6ec8e83a1c55@mrabarnett.plus.com> On 2020-04-01 13:42, Musbur wrote: > Hi guys, > > I'm wondering how to create an instance of an extension class I wrote. > There's a minimal self-contained C module at the bottom of this post > which exports two things: 1) a class Series, and 2) a function > make_series() which is supposed to create a Series object on the C side > and return it. The make_series function uses PyObject_New() and > PyObject_Init() to create the new instance, but all it produces is some > kind of zombie instance which tends to crash the application with a > segfault in real life. When instantiated from Python using Series(), I > get a well-behaved instance. > > I've sprinkled the New, Init and Finalize functions with fprintf()s to > see what happens to the object during its lifetime. > > When I run this test script: > > from series import * > > print("From Python") > s1 = Series() > del s1 > > print("\nFrom C") > s2 = make_series() > del s2 > > I get this output: > > From Python > New Series at 0x7f89313f6660 > Init Series at 0x7f89313f6660 > Finalize Series at 0x7f89313f6660 > > From C > Finalize Series at 0x7f89313f6678 > > So when created from C, neither the "new" nor the "init" functions are > called on the object, only "finalize". No wonder I get segfaults in the > real life application. > > So how is this done right? Here's the C module: > [snip] Try this instead: #include typedef struct { PyObject_HEAD void* data; } SeriesObject; static PyTypeObject SeriesType = { PyVarObject_HEAD_INIT(NULL, 0) .tp_name = "_Series", .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, .tp_doc = "SeriesObject (msec, value) object", }; PyObject* make_series(PyObject* unused) { SeriesObject* series; series = PyObject_New(SeriesObject, &SeriesType); series->data = NULL; fprintf(stderr, "New SeriesObject at %p\n", series); return (PyObject*)series; } static void Series_dealloc(PyObject* self_) { SeriesObject* self; self = (SeriesObject*)self_; fprintf(stderr, "Deallocate SeriesObject at %p\n", self); PyObject_DEL(self); } PyObject* Series_new(PyTypeObject* type, PyObject* args, PyObject* kwargs) { SeriesObject* self; self = (SeriesObject*)type->tp_alloc(type, 0); self->data = NULL; fprintf(stderr, "New Series at %p\n", self); return (PyObject*)self; } static PyMethodDef Series_methods[] = { {NULL, NULL, 0, NULL} }; static PyMethodDef module_methods[] = { {"make_series", (PyCFunction)make_series, METH_NOARGS, "Instantiate and return a new SeriesObject object."}, {NULL, NULL, 0, NULL} }; static PyModuleDef series_module = { PyModuleDef_HEAD_INIT, "series", "Defines the SeriesObject (time, value) class" , -1, module_methods }; PyMODINIT_FUNC PyInit_series(void) { PyObject* m; m = PyModule_Create(&series_module); SeriesType.tp_dealloc = Series_dealloc; SeriesType.tp_new = Series_new; SeriesType.tp_methods = Series_methods; if (PyType_Ready(&SeriesType) < 0) return NULL; PyModule_AddObject(m, "Series", (PyObject*)&SeriesType); return m; } From info at wingware.com Wed Apr 1 15:48:24 2020 From: info at wingware.com (Wingware) Date: Wed, 01 Apr 2020 15:48:24 -0400 Subject: ANN: Wing Python IDE version 7.2.2 released Message-ID: <5E84F008.2090206@wingware.com> Wing Python IDE version 7.2.2 introduces a How-To for using Wing Pro's remote development features with AWS, adds support for Python 3 enums, allows constraining Find Uses of imported symbols to only the current file, and makes a number of usability and stability improvements. == Downloads == Wing Pro: https://wingware.com/downloads/wing-pro/7.2/binaries Wing Personal: https://wingware.com/downloads/wing-personal/7.2/binaries Wing 101: https://wingware.com/downloads/wing-101/7.2/binaries Compare products: https://wingware.com/downloads == Upgrading == See https://wingware.com/doc/install/upgrading for details on upgrading from Wing 6 and earlier, and https://wingware.com/doc/install/migrating for a list of compatibility notes. == Details == For more information on this release please see https://wingware.com/news/2020-03-30 For more information on Wing Python IDE see https://wingware.com/ Thanks, Stephan Deibel Wing Python IDE | The Intelligent Development Environment for Python From arj.python at gmail.com Wed Apr 1 16:22:53 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Thu, 2 Apr 2020 00:22:53 +0400 Subject: How To Change Package Representation on Shell? Message-ID: Greetings list, I have a custom package. >>> import package >>> package '> what do i have to modify from my package to have like >>> package Hi! Thanks! Kind Regards, Abdur-Rahmaan Janhangeer compileralchemy.com | github Mauritius From rhodri at kynesim.co.uk Wed Apr 1 16:36:04 2020 From: rhodri at kynesim.co.uk (Rhodri James) Date: Wed, 1 Apr 2020 21:36:04 +0100 Subject: How To Change Package Representation on Shell? In-Reply-To: References: Message-ID: <1e9e28c6-c80f-c388-9a7a-dcd8dfdc7009@kynesim.co.uk> On 01/04/2020 21:22, Abdur-Rahmaan Janhangeer wrote: > Greetings list, > > I have a custom package. > >>>> import package >>>> package > '> > > what do i have to modify from my package to have like > >>>> package > Hi! Do you mean "How do I override the str() or repr() of a module"? I don't think you can. -- Rhodri James *-* Kynesim Ltd From rosuav at gmail.com Wed Apr 1 16:41:33 2020 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 2 Apr 2020 07:41:33 +1100 Subject: How To Change Package Representation on Shell? In-Reply-To: <1e9e28c6-c80f-c388-9a7a-dcd8dfdc7009@kynesim.co.uk> References: <1e9e28c6-c80f-c388-9a7a-dcd8dfdc7009@kynesim.co.uk> Message-ID: On Thu, Apr 2, 2020 at 7:37 AM Rhodri James wrote: > > On 01/04/2020 21:22, Abdur-Rahmaan Janhangeer wrote: > > Greetings list, > > > > I have a custom package. > > > >>>> import package > >>>> package > > '> > > > > what do i have to modify from my package to have like > > > >>>> package > > Hi! > > Do you mean "How do I override the str() or repr() of a module"? I > don't think you can. > Not easily. It is possible but only by replacing the module as you're importing it. Also, I'm not sure why you would even need/want to do this - Abdur, can you elaborate on the use-case here? ChrisA From arj.python at gmail.com Wed Apr 1 17:02:18 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Thu, 2 Apr 2020 01:02:18 +0400 Subject: How To Change Package Representation on Shell? In-Reply-To: References: <1e9e28c6-c80f-c388-9a7a-dcd8dfdc7009@kynesim.co.uk> Message-ID: Having fun with packages Since i don't master packaging completely thought there was a __repr__.py protocol nearby! Might be useful maybe to replace it by a help message Kind Regards, Abdur-Rahmaan Janhangeer compileralchemy.com | github Mauritius On Thu, Apr 2, 2020 at 12:41 AM Chris Angelico wrote: > On Thu, Apr 2, 2020 at 7:37 AM Rhodri James wrote: > > > > On 01/04/2020 21:22, Abdur-Rahmaan Janhangeer wrote: > > > Greetings list, > > > > > > I have a custom package. > > > > > >>>> import package > > >>>> package > > > '> > > > > > > what do i have to modify from my package to have like > > > > > >>>> package > > > Hi! > > > > Do you mean "How do I override the str() or repr() of a module"? I > > don't think you can. > > > > Not easily. It is possible but only by replacing the module as you're > importing it. > > Also, I'm not sure why you would even need/want to do this - Abdur, > can you elaborate on the use-case here? > > ChrisA > -- > https://mail.python.org/mailman/listinfo/python-list > From please_no at spam.it Wed Apr 1 17:07:25 2020 From: please_no at spam.it (Luca) Date: Wed, 1 Apr 2020 17:07:25 -0400 Subject: confused by matplotlib and subplots Message-ID: Hello Covid fighters and dodgers, I'm sort of confused by what I am seeing in a Pandas book. This works: fig = plt.figure() ax1 = fig.add_subplot(2,2,1) ax2 = fig.add_subplot(2,2,2) ax3 = fig.add_subplot(2,2,3) ax3.plot(np.random.randn(50).cumsum(), 'k--'); but also this works! fig = plt.figure() ax1 = fig.add_subplot(2,2,1) ax2 = fig.add_subplot(2,2,2) ax3 = fig.add_subplot(2,2,3) plt.plot(np.random.randn(50).cumsum(), 'k--'); (the second one is actually the example in the book). Why does it work? Isn't axX referring to one of the subplots and plt to the plot as a whole? Thanks From PythonList at DancesWithMice.info Wed Apr 1 17:12:05 2020 From: PythonList at DancesWithMice.info (DL Neil) Date: Thu, 2 Apr 2020 10:12:05 +1300 Subject: questions: In-Reply-To: References: Message-ID: <871a9104-9b57-68ef-2591-618325b2cc08@DancesWithMice.info> On 2/04/20 6:49 AM, anson freer wrote: > Will Anaconda2, Python2, jupyter and many applications I have for python > harm the 3.8.2? > should I be in Python Tutor and in this one(current email)at the same time? > Or is it one or the other not both > I want to learn how to use PDF to read files that have racing form style > forms(my hobbie is Horse handicapping) > I know I need to"get" the correct modules.(trial an error)but I don't know > all the correct terms yet > Be kind I'm in my 80's bu t age is just a number my brain thinks like a > teen my body refuses to listen. Welcome to the Python community! (To my knowledge/I am not ListAdmin) Someone may *belong* to both lists (and more). If not, you'll be able to light your cigar from me, as we both go-down-in-flames... *However,* posting the same question to both lists concurrently will not win you any friends! For 'beginner level' questions I recommend the Tutor list (per its stated objectives). That said, people do try to be helpful... and us 'silver surfers' need to stick-together (well, 2-meters apart, together) I'm not sure what you mean by "harm the 3.8.2". Is that the Python which your OpSys needs to operate? The "pythonic" way to separate multiple Python environments is "virtual environments" (aka venv). Because it is incumbent upon me to maintain client safety and security, I use separate Virtual Machines for each client/project. This is not typical. The Anaconda system is well-regarded as a convenient entry into the Python eco-system. It is designed to be self-contained and to avoid 'tainting' the underlying OpSys. They also try to 'shield' users from unfortunate gaffes and 'gotchas' in facilitating adding libraries from their own sources by providing their own mechanisms. Accordingly, it has a lot going for it - be aware of their 'freemium' business model. There are a few Python libraries to read .PDF files. The 'problem' is that sometimes .PDF 'pages' are actually graphics, ie a photograph/photo-copy of the ink-squiggles on an original page; and sometimes they contain text which has been nicely formatted for (printed) presentation. The latter are considerably easier to access. Graphics must be interpreted using an OCR process (Optical Character Recognition), and that will make life considerably more complicated. Take things slowly. Don't try to 'bite-off more than you can chew'. There are a number of good tutorials in book form, and on-line lectures which will help you to learn Python and pick-up the terminology. Such is a perennial question, answered many times on the Tutor discussion list and therefore accessible through those archives! Web.Refs: https://docs.python.org/3/tutorial/venv.html https://www.anaconda.com/distribution/ -- Regards =dn From arj.python at gmail.com Wed Apr 1 17:12:48 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Thu, 2 Apr 2020 01:12:48 +0400 Subject: How Does requests.get Work? Message-ID: Greetings list, I was viewing requests https://github.com/psf/requests I know we can do `requests.get` Found `get` defined in api.py I would appreciate an explanation as to how to configure the package so that we can use get directly. Thanks. Kind Regards, Abdur-Rahmaan Janhangeer compileralchemy.com | github Mauritius From barry at barrys-emacs.org Wed Apr 1 16:53:02 2020 From: barry at barrys-emacs.org (Barry Scott) Date: Wed, 1 Apr 2020 21:53:02 +0100 Subject: How to uninstall Python3.7 in Windows using cmd ? In-Reply-To: References: <95a77f78-f293-b4a2-32b4-bbc477b0706e@dewhirst.com.au> Message-ID: <4092F808-C6B4-47FD-BB92-E25CC75B1E5E@barrys-emacs.org> > On 30 Mar 2020, at 02:03, Dennis Lee Bieber wrote: > > On Sun, 29 Mar 2020 07:24:03 -0400, Terry Reedy > declaimed the following: > >> To clarify, the pydev/python.org installer does not use msi. I don't >> know that anyone else does. And if someone did, why do you think it >> would also uninstall the current installation? > > Because, if you did find an MSI installer, and installed the same > version /over/ the existing install (same directory), then the MSI > uninstall would be removing contents from that directory. And then you will have a registry that knows about 2 installs only one of which you can remove. This is not a good idea. Barry From junkone1 at gmail.com Wed Apr 1 20:29:31 2020 From: junkone1 at gmail.com (Rakesh Kapoor) Date: Wed, 1 Apr 2020 17:29:31 -0700 (PDT) Subject: why are the ticker and date column labels lower than High Low Open Close Message-ID: <6c13b449-db81-40f8-b624-f1af64a0518f@googlegroups.com> I am using this to download stock prices. But i find that the column names are not in same row. I am guessing i am missing something. import pandas as pd import numpy as np import datetime import pandas_datareader as pdr py.init_notebook_mode(connected=True) # we download the stock prices for each ticker and then we do a mapping between data and name of the ticker def get(tickers, startdate, enddate): def data(ticker): return (pdr.get_data_yahoo(ticker, start=startdate, end=enddate)) datas = map (data, tickers) return(pd.concat(datas, keys=tickers, names=['ticker', 'date'])) # Define the stocks to download. We'll download of Apple, Microsoft and the S&P500 index. tickers = ['AAPL','IBM'] # We would like all available data from 01/01/2000 until 31/12/2018. start_date = datetime.datetime(2016, 1, 1) end_date = datetime.datetime(2019, 12, 31) all_data = get(tickers, start_date, end_date) see screenshot https://i.imgur.com/Cmw20am.png From juergen at brendel.com Wed Apr 1 17:33:27 2020 From: juergen at brendel.com (Juergen Brendel) Date: Thu, 02 Apr 2020 10:33:27 +1300 Subject: How Does requests.get Work? In-Reply-To: References: Message-ID: <3ae9c540d31d00c80302242d11fc4fc9c9fc2b5a.camel@brendel.com> Hello! Can you elaborate on what you mean by "use directly"? Juergen On Thu, 2020-04-02 at 01:12 +0400, Abdur-Rahmaan Janhangeer wrote: > Greetings list, > > I was viewing requests https://github.com/psf/requests > > I know we can do `requests.get` > > Found `get` defined in api.py > > I would appreciate an explanation as to how to configure the package > so > that we can use get directly. Thanks. > > Kind Regards, > > Abdur-Rahmaan Janhangeer > compileralchemy.com | github > > Mauritius From PythonList at DancesWithMice.info Wed Apr 1 21:07:52 2020 From: PythonList at DancesWithMice.info (DL Neil) Date: Thu, 2 Apr 2020 14:07:52 +1300 Subject: Fwd: Problemas para ejecutar Python en windows 7 In-Reply-To: References: Message-ID: <450d416b-4541-1fe9-7fa1-56333a7602b1@DancesWithMice.info> On 2/04/20 7:15 AM, Honori R. Camacho wrote: > Ok. > 1.- Necesitamos ayuda. No podemos ejecutar Python 3.5.4 en windows 7, se > descargo la version Python 3.5.4 y se instalo correctamente.Y se > corrigieron los path. > Pero no permite ejecutar los .py ni los .pyw por acceso directo. gracias. Hola! Python installs differently to other MS-Windows packages. We expect to use it from the Command Line, although some components may be available from the Windows-Menu (varies by version of MS-Windows). You will find the primary installation advice at https://docs.python.org/3/using/index.html. However, there are some translations at https://wiki.python.org/moin/SpanishLanguage -- Regards =dn From jagmit.sandhu at gmail.com Wed Apr 1 21:40:33 2020 From: jagmit.sandhu at gmail.com (jagmit sandhu) Date: Wed, 1 Apr 2020 18:40:33 -0700 Subject: numpy array question Message-ID: python newbie. I can't understand the following about numpy arrays: x = np.array([[0, 1],[2,3],[4,5],[6,7]]) x array([[0, 1], [2, 3], [4, 5], [6, 7]]) x.shape (4, 2) y = x[:,0] y array([0, 2, 4, 6]) y.shape (4,) Why is the shape for y reported as (4,) ? I expected it to be a (4,1) array. thanks in advance From tjreedy at udel.edu Thu Apr 2 00:06:31 2020 From: tjreedy at udel.edu (Terry Reedy) Date: Thu, 2 Apr 2020 00:06:31 -0400 Subject: Identifying tkinter version [ANSWERED] In-Reply-To: References: Message-ID: On 4/1/2020 2:47 PM, Christian Gollwitzer wrote: > Am 01.04.20 um 19:22 schrieb Rich Shepard: >> On Wed, 1 Apr 2020, Tony van der Hoff wrote: >> >>>> How do I determine the installed version? >>>>>> import tkinter >>>>>> tkinter.TkVersion >>> 8.6 >> >> Thanks, Tony. I was close, but still too far away. > > This only shows you the major version. There have been many updates to > Tcl/Tk in "minor" releases, including lots of rework on Tk internals. > Therefore, you need the patchlevel. YOu can get this by > > root.eval('info patchlevel') > > Apfelkiste:Test chris$ python3 > Python 3.6.1 |Anaconda 4.4.0 (x86_64)| (default, May 11 2017, 13:04:09) > [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin > Type "help", "copyright", "credits" or "license" for more information. > >>> import tkinter > >>> root=tkinter.Tk() > >>> root.eval('info patchlevel') > '8.5.9' Or run IDLE, select Help > About IDLE and the patchlevel is displayed. -- Terry Jan Reedy From arj.python at gmail.com Thu Apr 2 02:11:05 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Thu, 2 Apr 2020 10:11:05 +0400 Subject: How Does requests.get Work? In-Reply-To: <3ae9c540d31d00c80302242d11fc4fc9c9fc2b5a.camel@brendel.com> References: <3ae9c540d31d00c80302242d11fc4fc9c9fc2b5a.camel@brendel.com> Message-ID: When dev a package, if you can do: >>> from package import x does not mean you can do >>> import package >>> package.x for requests i was wondering how requests package can have >>> requests.get while requests is defined in api.py Kind Regards, Abdur-Rahmaan Janhangeer https://www.compileralchemy.com https://www.github.com/Abdur-RahmaanJ Mauritius sent from gmail client on Android, that's why the signature is so ugly. On Thu, 2 Apr 2020, 01:33 Juergen Brendel, wrote: > > Hello! > > Can you elaborate on what you mean by "use directly"? > > Juergen > > > On Thu, 2020-04-02 at 01:12 +0400, Abdur-Rahmaan Janhangeer wrote: > > Greetings list, > > > > I was viewing requests https://github.com/psf/requests > > > > I know we can do `requests.get` > > > > Found `get` defined in api.py > > > > I would appreciate an explanation as to how to configure the package > > so > > that we can use get directly. Thanks. > > > > Kind Regards, > > > > Abdur-Rahmaan Janhangeer > > compileralchemy.com | github > > > > Mauritius > > From rosuav at gmail.com Thu Apr 2 02:15:18 2020 From: rosuav at gmail.com (Chris Angelico) Date: Thu, 2 Apr 2020 17:15:18 +1100 Subject: How Does requests.get Work? In-Reply-To: References: <3ae9c540d31d00c80302242d11fc4fc9c9fc2b5a.camel@brendel.com> Message-ID: On Thu, Apr 2, 2020 at 5:12 PM Abdur-Rahmaan Janhangeer wrote: > > When dev a package, if you can do: > > >>> from package import x > > does not mean you can do > > >>> import package > >>> package.x > > for requests i was wondering how requests package can have > > >>> requests.get > > while requests is defined in api.py > Did you have a look at __init__.py? https://github.com/psf/requests/blob/master/requests/__init__.py ChrisA From arj.python at gmail.com Thu Apr 2 02:27:52 2020 From: arj.python at gmail.com (Abdur-Rahmaan Janhangeer) Date: Thu, 2 Apr 2020 10:27:52 +0400 Subject: How Does requests.get Work? In-Reply-To: References: <3ae9c540d31d00c80302242d11fc4fc9c9fc2b5a.camel@brendel.com> Message-ID: Ah i get it from .api import request, get, head, post, patch, put, delete, options Whatever you import in __init__.py, you can access it directly. Thanks! Kind Regards, Abdur-Rahmaan Janhangeer compileralchemy.com | github Mauritius On Thu, Apr 2, 2020 at 10:15 AM Chris Angelico wrote: > On Thu, Apr 2, 2020 at 5:12 PM Abdur-Rahmaan Janhangeer > wrote: > > > > When dev a package, if you can do: > > > > >>> from package import x > > > > does not mean you can do > > > > >>> import package > > >>> package.x > > > > for requests i was wondering how requests package can have > > > > >>> requests.get > > > > while requests is defined in api.py > > > > Did you have a look at __init__.py? > > https://github.com/psf/requests/blob/master/requests/__init__.py > > ChrisA > -- > https://mail.python.org/mailman/listinfo/python-list > From edmondo.giovannozzi at gmail.com Thu Apr 2 04:18:28 2020 From: edmondo.giovannozzi at gmail.com (edmondo.giovannozzi at gmail.com) Date: Thu, 2 Apr 2020 01:18:28 -0700 (PDT) Subject: numpy array question In-Reply-To: References: Message-ID: <62e7332a-02ea-407f-a197-b7a884e6b5be@googlegroups.com> Il giorno gioved? 2 aprile 2020 06:30:22 UTC+2, jagmit sandhu ha scritto: > python newbie. I can't understand the following about numpy arrays: > > x = np.array([[0, 1],[2,3],[4,5],[6,7]]) > x > array([[0, 1], > [2, 3], > [4, 5], > [6, 7]]) > x.shape > (4, 2) > y = x[:,0] > y > array([0, 2, 4, 6]) > y.shape > (4,) > > Why is the shape for y reported as (4,) ? I expected it to be a (4,1) array. > thanks in advance Because is not Matlab where everything is at least a 2d array. If you fix a dimension that dimension disappear. It is the same behaviour as that of Fortran. Personally I think that the Python behaviour is more natural and obvious. As always it is a choice of who has written the library what will happen with a slice. From souvik.viksou at gmail.com Thu Apr 2 05:17:07 2020 From: souvik.viksou at gmail.com (Souvik Dutta) Date: Thu, 2 Apr 2020 14:47:07 +0530 Subject: how to specify trusted hosts in windows config file In-Reply-To: References: <3824255550@f38.n261.z1.binkp.net> <5123bc0f-2195-4086-b18b-5724824ffea3@googlegroups.com> <74b889d7-c1dd-45ae-adec-b73ddb215118@googlegroups.com> <81d807af-8c99-44f4-ba34-a52b7ea497d1@googlegroups.com> Message-ID: This is the ideal thing a hacker would do. Reports say that codes are a hacker's sweet spot. Because most of the time a random person would visit the code and copy and paste it because he has to get the job done in a limited time. Nothing could actually be 100% trusted in the internet. Because websites that might seem legitimate might be not. And true websites could be copied easily. On Tue, Mar 31, 2020, 11:44 PM Chris Angelico wrote: > On Wed, Apr 1, 2020 at 3:31 AM wrote: > > > > I don't have control over this, Chris. This is at my office. I'm not > the resource who manages network or other settings. And we have various > anti-spyware in place, that at leasts mitigates the risk. > > > > Then talk to the person who does. Ask if s/he is okay with you > downloading untrusted code from the internet and running it with your > full permissions. Then ask if it would be better to be able to trust > that code's origin. > > > What I'm doing isn't unprecedented. People get false positives all the > time on the web, and ask for this type of assistance. Maybe my results > were real evidence of something funky, but either way I have to get work > done. > > > > Yes, you have to get work done, so you ran random code from the > internet, downloaded on an unsecured connection, when the evidence > clearly showed that you were NOT getting it from the official source. > > > Thanks for trying to help, anyway. I'll do a compare of the refreshed > PIP files on the office PC, to a copy of pip elsewhere that I know is legit. > > > > Good luck. Chances are you won't know you've been hit with any spyware > or anything, so you'll feel confident. > > ChrisA > -- > https://mail.python.org/mailman/listinfo/python-list > From rshepard at appl-ecosys.com Thu Apr 2 08:41:16 2020 From: rshepard at appl-ecosys.com (Rich Shepard) Date: Thu, 2 Apr 2020 05:41:16 -0700 (PDT) Subject: Identifying tkinter version [ANSWERED] In-Reply-To: References: Message-ID: On Thu, 2 Apr 2020, Terry Reedy wrote: > Or run IDLE, select Help > About IDLE and the patchlevel is displayed. Terry, Interesting. I use emacs but I'll keep this in mind. Regards, Rich From rshepard at appl-ecosys.com Thu Apr 2 10:50:40 2020 From: rshepard at appl-ecosys.com (Rich Shepard) Date: Thu, 2 Apr 2020 07:50:40 -0700 (PDT) Subject: Widget common to multiple views: import from commonDlg? Message-ID: This application has 8 data entry/edit view modules of tkinter widgets and an additional module called commonDlg which is imported into each of the others. Each view module has a comments tk.Text widget: self.inputs['Notes'] = cd.LabelInput( taxoninfo, "notes", input_class = Tk.Text, input_args = {'width': 75, 'height': 10, 'wrap': 'word'} ) self.inputs['Notes'].grid(sticky = 'w', row=3, column= 0) # vertical scrollbar scroll_y = tk.Scrollbar(self, orient="vertical", command=notes.yview) scroll_y.grid(row=3, sticky='nsw') notes.configure(yscrollcommand=scroll_y.set) # horizontal scrollbar scroll_x = tk.Scrollbar(self, orient="horizontal", command=notes.xview) scroll_x.grid(row=3, sticky='wen') notes.configure(xscrollcommand=scroll_x.set) (I'm not confident I have the scrollbars correctly written.) Now, when I edit this data entry widge I do so in each of the eight data entry/edit modules. My question is whether I can put this one widget in the commonDlgs module and have it called in each module where it belongs. If so, what is the proper syntax? Rich From __peter__ at web.de Thu Apr 2 11:02:38 2020 From: __peter__ at web.de (Peter Otten) Date: Thu, 02 Apr 2020 17:02:38 +0200 Subject: numpy array question References: Message-ID: jagmit sandhu wrote: > python newbie. I can't understand the following about numpy arrays: > > x = np.array([[0, 1],[2,3],[4,5],[6,7]]) > x > array([[0, 1], > [2, 3], > [4, 5], > [6, 7]]) > x.shape > (4, 2) > y = x[:,0] > y > array([0, 2, 4, 6]) > y.shape > (4,) > > Why is the shape for y reported as (4,) ? I expected it to be a (4,1) > array. thanks in advance Why do you expect every array to be a 2D matrix? Why not 3D or 4D? In the shape of y the 4 could be followed by an infinite amount of ones (4, 1, 1, 1, 1, 1,...) Instead numpy uses as many dimensions as you provide: >>> import numpy as np >>> np.array(42).shape () >>> np.array([42]).shape (1,) >>> np.array([[42]]).shape (1, 1) >>> np.array([[[42]]]).shape (1, 1, 1) I think this is a reasonable approach. Dont you? From mal at europython.eu Thu Apr 2 12:12:59 2020 From: mal at europython.eu (M.-A. Lemburg) Date: Thu, 2 Apr 2020 18:12:59 +0200 Subject: EuroPython 2020: CFP for the Online Event Message-ID: Since we had started the CFP under the assumption of running an in-person conference and are now switching EuroPython 2020 to an online event, we will extend the CFP for another two weeks until April 12, to give everyone who would like to participate in this new format, a chance to submit a session proposal. * EuroPython 2020 Online - Call for Proposal * https://ep2020.europython.eu/call-for-proposals/ The online event will have this layout: - July 23 - 24 (Thursday, Friday): conference days - July 25 - 26 (Saturday, Sunday): sprint days Presenting at EuroPython ------------------------ For the conference days, we are looking for the following session types: - Talks of 35- or 45-minute duration (including 3-5 minutes for Q&A) - Posters - Help desks / Panels / Interactive sessions We will give out free tickets to the event for all selected speakers. For posters, we are planning to collect them on a gallery page, together with PDF versions to read during the event. The speaker will then be available during the poster session to answer questions and present more details using screen sharing. Help desks, panels and interactive sessions will be run using virtual rooms we?ll make available during the conference days. We will also have lightning talks for the online event, but those will be collected closer to the event using a separate form or Google sheet - similar to how we run this at the in-person conference. For submitting sprints, please check our sprints page. Note that unlike the conference days, the sprints day won?t require buying a ticket. https://ep2020.europython.eu/events/sprints/ Let?s make this an engaging event for everyone ---------------------------------------------- Even though we?re running an online event, our aim is to make the online event as engaging as possible, so we will provide ways for direct interaction with the speakers after their talk in separate virtual rooms and additionally a chat system for asynchronous interaction. The conference system will also allow live polls and text or audio/video based Q&A sessions, so please consider this when preparing your sessions and add any polls you?d like to run in the submission notes section (?Additional information for talk reviewers?). The conference will be held between 09:00 CEST and 20:00 CEST on the two conference days. We will try to schedule talks based on location and timezone of the speaker. Please indicate your timezone in submission notes. Help spread the word -------------------- Please help us spread this message by sharing it on your social networks as widely as possible. Thank you ! Link to the blog post: https://blog.europython.eu/post/614296142774173696/europython-2020-cfp-for-the-online-event Tweet: https://twitter.com/europython/status/1245723386329870339 Thanks, -- EuroPython 2020 Team https://ep2020.europython.eu/ https://www.europython-society.org/ From jorge.conforte at inpe.br Thu Apr 2 14:09:01 2020 From: jorge.conforte at inpe.br (J Conrado) Date: Thu, 2 Apr 2020 15:09:01 -0300 Subject: Python error Message-ID: Hi, I have the version of python installed: Python 3.7.6 and Python 3.8.1 If I type: python Python 3.7.6 (default, Jan ?8 2020, 19:59:22) [GCC 7.3.0] :: Anaconda, Inc. on linux Type "help", "copyright", "credits" or "license" for more information. >>> import numpy it is Ok, no error, but if I did: python3.8 Python 3.8.1 (default, Jan 31 2020, 15:49:05) [GCC 4.4.7 20120313 (Red Hat 4.4.7-23)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import numpy Traceback (most recent call last): ? File "", line 1, in ModuleNotFoundError: No module named 'numpy' Please, I would like to know why in the python3.8 version I have this error. Thanks, Conrado From mirkok.lists at googlemail.com Thu Apr 2 14:59:23 2020 From: mirkok.lists at googlemail.com (Mirko) Date: Thu, 2 Apr 2020 20:59:23 +0200 Subject: Python error In-Reply-To: References: Message-ID: <5E86360B.3050003@googlemail.com> Am 02.04.2020 um 20:09 schrieb J Conrado: > Hi, > > I have the version of python installed: > Python 3.7.6 and Python 3.8.1 > If I type: > python > Python 3.7.6 (default, Jan 8 2020, 19:59:22) > [GCC 7.3.0] :: Anaconda, Inc. on linux > Type "help", "copyright", "credits" or "license" for more information. >>>> import numpy > > it is Ok, no error, but if I did: > > python3.8 > > Python 3.8.1 (default, Jan 31 2020, 15:49:05) > [GCC 4.4.7 20120313 (Red Hat 4.4.7-23)] on linux > Type "help", "copyright", "credits" or "license" for more information. >>>> import numpy > > Traceback (most recent call last): > File "", line 1, in > ModuleNotFoundError: No module named 'numpy' > > Please, > I would like to know why in the python3.8 version I have this error. Because you installed numpy only for 3.7.6. All Python installations have their own module paths, so you need to install numpy for 3.8.1 too. Do it with: python3.8 -m pip install numpy From python at mrabarnett.plus.com Thu Apr 2 15:08:01 2020 From: python at mrabarnett.plus.com (MRAB) Date: Thu, 2 Apr 2020 20:08:01 +0100 Subject: Python error In-Reply-To: References: Message-ID: <6474d25b-d3c1-4873-ed7c-a1477b8e0f18@mrabarnett.plus.com> On 2020-04-02 19:09, J Conrado wrote: > Hi, > > I have the version of python installed: > Python 3.7.6 and Python 3.8.1 > If I type: > python > Python 3.7.6 (default, Jan ?8 2020, 19:59:22) > [GCC 7.3.0] :: Anaconda, Inc. on linux > Type "help", "copyright", "credits" or "license" for more information. > >>> import numpy > > it is Ok, no error, but if I did: > > python3.8 > > Python 3.8.1 (default, Jan 31 2020, 15:49:05) > [GCC 4.4.7 20120313 (Red Hat 4.4.7-23)] on linux > Type "help", "copyright", "credits" or "license" for more information. > >>> import numpy > > Traceback (most recent call last): > ? File "", line 1, in > ModuleNotFoundError: No module named 'numpy' > > Please, > I would like to know why in the python3.8 version I have this error. > > > Thanks, > It looks like you have the Anaconda distribution for Python 3.7 and the standard distribution for Python 3.8. The standard distribution comes with only the standard library. The Anaconda distribution comes with a lot of extra stuff, which includes numpy. From PythonList at danceswithmice.info Thu Apr 2 15:41:32 2020 From: PythonList at danceswithmice.info (DL Neil) Date: Fri, 3 Apr 2020 08:41:32 +1300 Subject: Fwd: Problemas para ejecutar Python en windows 7 In-Reply-To: References: <450d416b-4541-1fe9-7fa1-56333a7602b1@DancesWithMice.info> Message-ID: <90cd08bb-29b1-7e05-2648-16aee3216d87@DancesWithMice.info> On 2/04/20 7:24 PM, Honori R. Camacho wrote: > Gracias por atender esta solicitud. Si, no explique que antes se > ejecutaba correctamente, pero ocurio que por error se desinstalo un > *frameworks* y desde ahi consideramos, empezaron los problemas. Se > reinstalo el Python 3.5.4 desde los repositorios de Python.org y se > puede ejecutar utilizando Geany, pero si queremos ejecutarlo desde el > escritorio, mediante un acceso directo no lo permite. De echo en windows > 7 en "Ejecutar como". No nos permite colocar Python, ni PythonW y antes > se podia y se ejecutaba desde alli. gracias. Please respond to the Discussion List email address - others may be able to help (more quickly)! If the earlier reference to documentation in Spanish did not help, are you able to use https://docs.python.org/3/using/windows.html#python-launcher-for-windows ? Is there an Accessories > 'DOS box' or 'Command Line' option in the Start Menu? Please would someone else help? (I don't use Microsoft products) Am hoping this is one of those perennial questions. The issue (if I have understood it correctly) is that Python was damaged when a framework or library was removed. So, Python was re-installed from the official repository. However, whilst it will now start from Geany (editor) there is no (longer) a Windows-Desktop short-cut (which may mean, entry on the Start Menu or a 'box' in the Win-10 opening-screen Start Menu replacement-thingy). I'm not clear whether the "short-cut" is to access Python at the command-line, or if it is to start an application under Python. -- Regards =dn From joepareti54 at gmail.com Thu Apr 2 15:56:57 2020 From: joepareti54 at gmail.com (joseph pareti) Date: Thu, 2 Apr 2020 21:56:57 +0200 Subject: jupyter notebook permission denied Message-ID: I have installed anaconda on windows 10, and when launching jupyter notebook from the anaconda navigator, it works fine. However, I am bound to work on files within the folder c:\Users\username\... If I launch jupyter notebook from a windows 10 cmd prompt, I can cd to my project directory. However, a permission denied issue prevents loading/updating the *ipynb files. Any idea why? Same happens if I do it as Administrator. -- Regards, Joseph Pareti - Artificial Intelligence consultant Joseph Pareti's AI Consulting Services https://www.joepareti54-ai.com/ cell +49 1520 1600 209 cell +39 339 797 0644 From souvik.viksou at gmail.com Thu Apr 2 21:27:56 2020 From: souvik.viksou at gmail.com (Souvik Dutta) Date: Fri, 3 Apr 2020 06:57:56 +0530 Subject: Fwd: Problemas para ejecutar Python en windows 7 In-Reply-To: <90cd08bb-29b1-7e05-2648-16aee3216d87@DancesWithMice.info> References: <450d416b-4541-1fe9-7fa1-56333a7602b1@DancesWithMice.info> <90cd08bb-29b1-7e05-2648-16aee3216d87@DancesWithMice.info> Message-ID: If you can read English. The same problem occurred with me some times ago. The cause of it was that windows thought that my .py files where trojans and I had to delete them permanently which solved the problem. Try this once. Something is better than nothing. Thank you. If you cannot read English. El mismo problema ocurri? conmigo algunas veces. La causa de esto fue que Windows pens? que mis archivos .py eran troyanos y tuve que eliminarlos permanentemente, lo que resolvi? el problema. Intenta esto una vez. Algo es mejor que nada. Gracias. On Fri, Apr 3, 2020, 1:12 AM DL Neil via Python-list wrote: > On 2/04/20 7:24 PM, Honori R. Camacho wrote: > > Gracias por atender esta solicitud. Si, no explique que antes se > > ejecutaba correctamente, pero ocurio que por error se desinstalo un > > *frameworks* y desde ahi consideramos, empezaron los problemas. Se > > reinstalo el Python 3.5.4 desde los repositorios de Python.org y se > > puede ejecutar utilizando Geany, pero si queremos ejecutarlo desde el > > escritorio, mediante un acceso directo no lo permite. De echo en windows > > 7 en "Ejecutar como". No nos permite colocar Python, ni PythonW y antes > > se podia y se ejecutaba desde alli. gracias. > > Please respond to the Discussion List email address - others may be able > to help (more quickly)! > > If the earlier reference to documentation in Spanish did not help, are > you able to use > https://docs.python.org/3/using/windows.html#python-launcher-for-windows ? > > Is there an Accessories > 'DOS box' or 'Command Line' option in the > Start Menu? > > > Please would someone else help? > (I don't use Microsoft products) > > Am hoping this is one of those perennial questions. > > The issue (if I have understood it correctly) is that Python was damaged > when a framework or library was removed. So, Python was re-installed > from the official repository. However, whilst it will now start from > Geany (editor) there is no (longer) a Windows-Desktop short-cut (which > may mean, entry on the Start Menu or a 'box' in the Win-10 > opening-screen Start Menu replacement-thingy). > > I'm not clear whether the "short-cut" is to access Python at the > command-line, or if it is to start an application under Python. > > -- > Regards =dn > -- > https://mail.python.org/mailman/listinfo/python-list > From frank.scarpa at gmail.com Fri Apr 3 06:19:17 2020 From: frank.scarpa at gmail.com (frank.scarpa at gmail.com) Date: Fri, 3 Apr 2020 03:19:17 -0700 (PDT) Subject: Python version and Apache mod_python mismatching version Message-ID: <651f8e78-442c-4748-8881-df8a641f091c@googlegroups.com> Hello, I have a Centos7 web server with python 2.7 installed and I want Apache to serve python scripts so I figure I have to install mod_python: i know that this module is deprecated, but I need it only for internal pourposes. Is the mod_python version (which is 3.5 with Python 3 support) somehow related to the python interpreter the web server? Is there any problem if the mod_python version and python version didn't match? From stephen_tucker at sil.org Fri Apr 3 07:08:33 2020 From: stephen_tucker at sil.org (Stephen Tucker) Date: Fri, 3 Apr 2020 12:08:33 +0100 Subject: Exceptions versus Windows ERRORLEVEL Message-ID: Hi, I have found that raising an exception in a Python 2.7.10 program running under Windows does not set ERRORLEVEL. I realise that Python 2.x is no longer supported. Does an exception raised by a Python 3.x program on a Windows machine set ERRORLEVEL? If not, are there plans for it to do so? Stephen. From jcasale at activenetwerx.com Fri Apr 3 08:32:57 2020 From: jcasale at activenetwerx.com (Joseph L. Casale) Date: Fri, 3 Apr 2020 12:32:57 +0000 Subject: policy based variable composition Message-ID: <9791ddb3bd5c40b38e91719ab8ee1c91@activenetwerx.com> I am looking to replace a home built solution which allows a program to derive a series of variable values through configuration or policy. The existing facility allows dependences so one of the requested variables can depend on another, they are ordered and computed. It also allows callbacks so code can be executed. For example, you would send in a list with any required parameters and out the other end comes the derived values, eg: input = [ ['PROPERTY_FOO', 'PROPERTY_BAR', 'SOME_OTHER_FIELD'], { 'key_a': 42, 'key_b': 'foo', 'key_c': 'some text' } ] output = { 'PROPERTY_FOO': ['foo_42', 99], 'PROPERTY_BAR': ['some_static_value'], 'SOME_OTHER_FIELD': ['foo_42__some_static_value'] } The existing code base works, however the code is utterly abysmal. Does such a thing exist that is well maintained? Thanks, jlc From ansonfreer at gmail.com Fri Apr 3 15:02:37 2020 From: ansonfreer at gmail.com (anson freer) Date: Fri, 3 Apr 2020 12:02:37 -0700 Subject: A PDF journey to find all python PDF Message-ID: This forum mentioned the Tutor forum so I signed up I waited a day or 2 heard nothing so I sent msg got Post by non-member to a members-only list replied to apologized and received auto msg part of which gave do's and don't's of forum then I realized I asked a really lame question Might take years for a answer When all fails YOUTUBE A youtube 3part vidio said I need a PDFParser= pdfminer or pdf 2020 4.1 PDFDocument=a text file like notes??? PDFPageInterpreter= no reslts PDFDevice+?????? Then I found Pycon 2018! Looked at the 30min+ forums and understood 0 then little by little learned about REGEX and test and Asychronous So.. I needed a PDF text reader found Python Software Foundation [US] pypi.org/project/pdfminer/#files then there is Search Projects I typed pdf and many pop up pdf 2020.4.1 = Python library for parsing PDFs I can find anything PDF It seems like Pdf is a mother with many children all with different fathers But no kid knows or talk to each other There are questions Do I make new DIR just for python and its results? Does the dnload go in my programs like 3.8.2 does warning on Python Software Foundation "Download the file for your platform. If you're not sure which to choose, learn more about installing packages." Is my platform python? pdf 2020 4.1 is newer than pdfminer which one? Best practices for python? short ver The journey All forums want to help I did horse handicapping and Access fourms At first a few gave all the VBA code I needed 40+years ago Then I was reminded I needed to do the work Then I got questions and understood what those kind coders meant AND YET I ASKED A LAME QUESTION! thank you for being patient From torriem at gmail.com Sat Apr 4 00:06:42 2020 From: torriem at gmail.com (Michael Torrie) Date: Fri, 3 Apr 2020 22:06:42 -0600 Subject: A PDF journey to find all python PDF In-Reply-To: References: Message-ID: On 4/3/20 1:02 PM, anson freer wrote: > This forum mentioned the Tutor forum so I signed up > I waited a day or 2 heard nothing so I sent msg > got Post by non-member to a members-only list > replied to apologized and > received auto msg > part of which gave do's and don't's of forum > then I realized I asked a really lame question > Might take years for a answer Did you sign up for the Tutors list? Just head on over to https://mail.python.org/mailman/listinfo/tutor and sign your email address up, just like you did for this list. Once you do that you won't get any more moderator messages saying you're posting to a members-only list. Unfortunately your question was very unclear. What exactly are you trying to accomplish? Python is a wonderful language, but for it to be useful to you, even in working with existing code, you have to learn how to code in it generally, like you did with VBA. You may wish to google for some Python tutorials to work through to learn the language first. From souvik.viksou at gmail.com Sat Apr 4 01:13:39 2020 From: souvik.viksou at gmail.com (Souvik Dutta) Date: Sat, 4 Apr 2020 10:43:39 +0530 Subject: A PDF journey to find all python PDF In-Reply-To: References: Message-ID: Python is not a platform your platform is the os. Choose the newer PDF reader it often comprises more features than older ones (might be a bit unstable though). There are lots of books and free online tutorials to learn python. Check them out first. If you have problem with English you can use your native language. We would still help. Don't try to bite more than you can chew. Souvik flutter dev On Sat, Apr 4, 2020, 2:26 AM anson freer wrote: > This forum mentioned the Tutor forum so I signed up > I waited a day or 2 heard nothing so I sent msg > got Post by non-member to a members-only list > replied to apologized and > received auto msg > part of which gave do's and don't's of forum > then I realized I asked a really lame question > Might take years for a answer > When all fails YOUTUBE > A youtube 3part vidio said I need a > PDFParser= pdfminer or pdf 2020 4.1 > PDFDocument=a text file like notes??? > PDFPageInterpreter= no reslts > PDFDevice+?????? > Then > I found Pycon 2018! > Looked at the 30min+ forums and understood 0 > then little by little learned about REGEX and test and Asychronous > So.. > I needed a PDF text reader > found > Python Software Foundation [US] pypi.org/project/pdfminer/#files > then there is Search Projects > I typed pdf and many pop up > pdf 2020.4.1 = > Python library for parsing PDFs > I can find anything PDF > It seems like Pdf is a mother with many children all with different fathers > But no kid knows or talk to each other > There are questions > Do I make new DIR just for python and its results? > Does the dnload go in my programs like 3.8.2 does > warning on Python Software Foundation > "Download the file for your platform. If you're not sure which to choose, > learn more about installing packages." > Is my platform python? > pdf 2020 4.1 is newer than pdfminer > which one? > Best practices for python? short ver > The journey > All forums want to help > I did horse handicapping and Access fourms > At first a few gave all the VBA code I needed 40+years ago > Then I was reminded I needed to do the work > Then I got questions and understood what those kind coders meant > AND YET I ASKED A LAME QUESTION! > thank you for being patient > -- > https://mail.python.org/mailman/listinfo/python-list > From antoon.pardon at rece.vub.ac.be Sat Apr 4 08:40:42 2020 From: antoon.pardon at rece.vub.ac.be (Antoon Pardon) Date: Sat, 4 Apr 2020 14:40:42 +0200 Subject: Better use a class decorator or a metaclass?(was: super not behaving as I expected) In-Reply-To: References: <982a3bb5-36e3-d727-8169-df846f7e0c2f@rece.vub.ac.be> Message-ID: <89df68d1-9fbb-219b-5d74-910c98830a39@rece.vub.ac.be> Op 29/03/20 om 16:49 schreef Peter Otten: > Antoon Pardon wrote: > >> >> I have the following program >> >> class slt: >> __slots__ = () >> ... >> >> class slt1 (slt): >> __slots__ = 'fld1', 'fld2' >> ... >> >> class slt2(slt1): >> __slots__ = 'fld3', >> .... > Anyway, here's my attempt to collect inherited slots: > > @classmethod > def get_slots(cls): > all_slots = set() > for C in cls.__mro__: > try: > slots = C.__slots__ > except AttributeError: > assert C is object > else: > all_slots.update(slots) > return all_slots > I have been thinking about this. AFAIU the slots are static data. So it seems a bit odd to calculate them with a (class) method. This seems a reasonable opportunity to use a class decorator or a metaclass. But I am in doubt about which would be the better solution here. -- Antoon Pardon. From souvik.viksou at gmail.com Sat Apr 4 09:30:03 2020 From: souvik.viksou at gmail.com (Souvik Dutta) Date: Sat, 4 Apr 2020 19:00:03 +0530 Subject: Better use a class decorator or a metaclass?(was: super not behaving as I expected) In-Reply-To: <89df68d1-9fbb-219b-5d74-910c98830a39@rece.vub.ac.be> References: <982a3bb5-36e3-d727-8169-df846f7e0c2f@rece.vub.ac.be> <89df68d1-9fbb-219b-5d74-910c98830a39@rece.vub.ac.be> Message-ID: I think this should help https://stackoverflow.com/questions/1779372/python-metaclasses-vs-class-decorators On Sat, 4 Apr, 2020, 6:12 pm Antoon Pardon, wrote: > Op 29/03/20 om 16:49 schreef Peter Otten: > > Antoon Pardon wrote: > > > >> > >> I have the following program > >> > >> class slt: > >> __slots__ = () > >> > ... > >> > >> class slt1 (slt): > >> __slots__ = 'fld1', 'fld2' > >> > ... > >> > >> class slt2(slt1): > >> __slots__ = 'fld3', > >> > .... > > Anyway, here's my attempt to collect inherited slots: > > > > @classmethod > > def get_slots(cls): > > all_slots = set() > > for C in cls.__mro__: > > try: > > slots = C.__slots__ > > except AttributeError: > > assert C is object > > else: > > all_slots.update(slots) > > return all_slots > > > > I have been thinking about this. AFAIU the slots are static data. So it > seems a bit odd to calculate them with a (class) method. > > This seems a reasonable opportunity to use a class decorator or a > metaclass. But I am in doubt about which would be the better solution here. > > -- > Antoon Pardon. > -- > https://mail.python.org/mailman/listinfo/python-list > From luuk34 at gmail.com Sat Apr 4 10:43:57 2020 From: luuk34 at gmail.com (Luuk) Date: Sat, 4 Apr 2020 16:43:57 +0200 Subject: Exceptions versus Windows ERRORLEVEL In-Reply-To: <3962720292@f38.n261.z1.binkp.net> References: <3962720292@f38.n261.z1.binkp.net> Message-ID: On 3-4-2020 02:08, Stephen Tucker (Stephen Tucker) wrote: > Hi, > > I have found that raising an exception in a Python 2.7.10 program running under > Windows does not set ERRORLEVEL. > > I realise that Python 2.x is no longer supported. > > Does an exception raised by a Python 3.x program on a Windows machine set > ERRORLEVEL? > Yes, it does. > If not, are there plans for it to do so? > > Stephen. > From rshepard at appl-ecosys.com Sat Apr 4 10:59:52 2020 From: rshepard at appl-ecosys.com (Rich Shepard) Date: Sat, 4 Apr 2020 07:59:52 -0700 (PDT) Subject: Adding tkinter modules to notebook tabs Message-ID: My Python3-3.8.2 application has 8 modules with subject-specific data entry/editing widgets and I want to display each module on a ttk.Notebook. Each notebook resource I've found in my reference books and on the web describe how to create a notebook and tabs and add labels to the tabs; a few describe how to place individual widgets on a tab. But I've not found how to place a widget-filled module on a notebook tab. I am asking for references I can read to learn how to do this. Thanks in advance ... and stay healthy, Rich From ansonfreer at gmail.com Sat Apr 4 11:08:28 2020 From: ansonfreer at gmail.com (anson freer) Date: Sat, 4 Apr 2020 08:08:28 -0700 Subject: A PDF journey to find all python PDF In-Reply-To: References: Message-ID: Thanks, I'll check them out. tutor sent "The reason it is being held: Post by non-member to a members-only list". could I be on both lists? I did unsubscribe I am trying learn how to use a PDF text editor The info I have states I need: pdfminer PyPI python3 only PDFParser PDFDocument PDFPageInterpreter PDFDevice They all look the same If I choose one do I make a new DIR or leave in DLOADS I have 3 choices pdfminer,pdfminer3,pdfminer.6 pdfminer.6 is the latest ver. Stack Overflow has good info for me(more concise) GitHub is where many get their dnlds GitHub is for pros so do you think it's OK to get mine also? Thank you for your time Anson On Fri, Apr 3, 2020 at 10:13 PM Souvik Dutta wrote: > Python is not a platform your platform is the os. Choose the newer PDF > reader it often comprises more features than older ones (might be a bit > unstable though). There are lots of books and free online tutorials to > learn python. Check them out first. If you have problem with English you > can use your native language. We would still help. Don't try to bite more > than you can chew. > > Souvik flutter dev > > On Sat, Apr 4, 2020, 2:26 AM anson freer wrote: > >> This forum mentioned the Tutor forum so I signed up >> I waited a day or 2 heard nothing so I sent msg >> got Post by non-member to a members-only list >> replied to apologized and >> received auto msg >> part of which gave do's and don't's of forum >> then I realized I asked a really lame question >> Might take years for a answer >> When all fails YOUTUBE >> A youtube 3part vidio said I need a >> PDFParser= pdfminer or pdf 2020 4.1 >> PDFDocument=a text file like notes??? >> PDFPageInterpreter= no reslts >> PDFDevice+?????? >> Then >> I found Pycon 2018! >> Looked at the 30min+ forums and understood 0 >> then little by little learned about REGEX and test and Asychronous >> So.. >> I needed a PDF text reader >> found >> Python Software Foundation [US] pypi.org/project/pdfminer/#files >> then there is Search Projects >> I typed pdf and many pop up >> pdf 2020.4.1 = >> Python library for parsing PDFs >> I can find anything PDF >> It seems like Pdf is a mother with many children all with different >> fathers >> But no kid knows or talk to each other >> There are questions >> Do I make new DIR just for python and its results? >> Does the dnload go in my programs like 3.8.2 does >> warning on Python Software Foundation >> "Download the file for your platform. If you're not sure which to choose, >> learn more about installing packages." >> Is my platform python? >> pdf 2020 4.1 is newer than pdfminer >> which one? >> Best practices for python? short ver >> The journey >> All forums want to help >> I did horse handicapping and Access fourms >> At first a few gave all the VBA code I needed 40+years ago >> Then I was reminded I needed to do the work >> Then I got questions and understood what those kind coders meant >> AND YET I ASKED A LAME QUESTION! >> thank you for being patient >> -- >> https://mail.python.org/mailman/listinfo/python-list >> > From jorge.conforte at inpe.br Sat Apr 4 11:45:10 2020 From: jorge.conforte at inpe.br (jorge.conforte at inpe.br) Date: Sat, 04 Apr 2020 12:45:10 -0300 Subject: Window and position of figure Message-ID: <363f81844b0ca9a2a9d002aa9d0e4826@inpe.br> Hi, I already use the IDL software. Now I`m using Python. In IDL I havethe vector position=(xo,yo,x1,y1) to set where Iwnat to plot my figure in my window. I have an 2d array with x and y dimensition equal 5224. when I plot my figure, using contourtf it takes up a small part of my window. What can I do to have my figure occupy a larger area in my window. Thanks, Conrado From lokender.bhim at gmail.com Sat Apr 4 12:19:25 2020 From: lokender.bhim at gmail.com (lokender.bhim at gmail.com) Date: Sat, 4 Apr 2020 09:19:25 -0700 (PDT) Subject: Latest python Cheatsheet Message-ID: <59a0317b-6241-4cd0-aed9-82610277e8b6@googlegroups.com> Python Cheatsheet - learn the basics of Python without any book and course or brush up the basic concepts Cheatsheet link - https://cheatsheets.tutorials24x7.com/programming/python From souvik.viksou at gmail.com Sat Apr 4 12:46:46 2020 From: souvik.viksou at gmail.com (Souvik Dutta) Date: Sat, 4 Apr 2020 22:16:46 +0530 Subject: Latest python Cheatsheet In-Reply-To: <59a0317b-6241-4cd0-aed9-82610277e8b6@googlegroups.com> References: <59a0317b-6241-4cd0-aed9-82610277e8b6@googlegroups.com> Message-ID: Did you post this on the tutor list? It should be more welcomed there. Souvik flutter dev On Sat, Apr 4, 2020, 9:50 PM wrote: > Python Cheatsheet - learn the basics of Python without any book and course > or brush up the basic concepts > > Cheatsheet link - > https://cheatsheets.tutorials24x7.com/programming/python > -- > https://mail.python.org/mailman/listinfo/python-list > From torriem at gmail.com Sat Apr 4 15:00:45 2020 From: torriem at gmail.com (Michael Torrie) Date: Sat, 4 Apr 2020 13:00:45 -0600 Subject: A PDF journey to find all python PDF In-Reply-To: References: Message-ID: On 4/4/20 9:08 AM, anson freer wrote: > Thanks, I'll check them out. > tutor sent "The reason it is being held: > > Post by non-member to a members-only list". > > could I be on both lists? I did unsubscribe Yes you can subscribe to both lists of course. But you have to subscribe to each list individually. Always be sure to post to a list from the same email address that you signed up. > I am trying learn how to use a PDF text editor Okay, but what is your goal and purpose? What problem are you trying to solve. If you just want to edit a PDF file, I can think of far easier methods than using any Python module. For example LibreOffice can import and edit PDFs using the Draw component. If you want to parse data from a PDF then one of the modules you mention below could work. > The info I have states I need: > > pdfminer PyPI python3 only > > PDFParser > > PDFDocument > > PDFPageInterpreter > > PDFDevice > > They all look the same They may all do similar things with PDFs. Which one is appropriate for your use depends on your needs, which still are not clear. I also repeat my earlier suggestion that before you can use any of these modules, you must learn Python first, at least to the degree where you are comfortable creating code in Python to manipulate variables, if statements, functions, etc. From auriocus at gmx.de Sat Apr 4 15:06:30 2020 From: auriocus at gmx.de (Christian Gollwitzer) Date: Sat, 4 Apr 2020 21:06:30 +0200 Subject: Adding tkinter modules to notebook tabs In-Reply-To: References: Message-ID: Am 04.04.20 um 16:59 schrieb Rich Shepard: > My Python3-3.8.2 application has 8 modules with subject-specific data > entry/editing widgets and I want to display each module on a ttk.Notebook. > Each notebook resource I've found in my reference books and on the web > describe how to create a notebook and tabs and add labels to the tabs; a > few > describe how to place individual widgets on a tab. But I've not found > how to > place a widget-filled module on a notebook tab. I'm not sure I fully understand it, because a "module" is not defined in the language of tkinter. Is it correct, you want to know how to place more than one widget - a arrangement of widgets - onto a notebook tab? This is achieved by a ttk.Frame() widget, which holds all the other stuff, and then you place the frame onto the notebook: n=ttk.Notebook() f1=ttk.Frame() # put all your stuff into f1 n.add(f1, text="Module1") # repeat for your other "modules" Christian From rshepard at appl-ecosys.com Sat Apr 4 16:31:30 2020 From: rshepard at appl-ecosys.com (Rich Shepard) Date: Sat, 4 Apr 2020 13:31:30 -0700 (PDT) Subject: Adding tkinter modules to notebook tabs In-Reply-To: References: Message-ID: On Sat, 4 Apr 2020, Christian Gollwitzer wrote: > I'm not sure I fully understand it, because a "module" is not defined in the > language of tkinter. Christian, True, but it is in Python: a file ending in .py which, in this case, contains a class of tkinter widgets. > Is it correct, you want to know how to place more than one widget - a > arrangement of widgets - onto a notebook tab? Yes, as they are defined and laid out in separate files/modules. > This is achieved by a ttk.Frame() widget, which holds all the other stuff, > and then you place the frame onto the notebook: > > n=ttk.Notebook() > f1=ttk.Frame() > # put all your stuff into f1 > n.add(f1, text="Module1") > # repeat for your other "modules" This looks to me like it's adding the text, "Module1" to the tab. Here: nb = ttk.Notebook(Main) ... page3 = ttk.Frame(nb) ... # add titles to tabs nb.add(page3, text='Biota') ... This puts the text on each notebook tab, correct? If so, how do I add class BiotaDataForm(Tk.Frame): which defines all the widgets in the module in views/biota.py into the body of the notebook's page3? Thanks, Rich From auriocus at gmx.de Sat Apr 4 16:53:42 2020 From: auriocus at gmx.de (Christian Gollwitzer) Date: Sat, 4 Apr 2020 22:53:42 +0200 Subject: Adding tkinter modules to notebook tabs In-Reply-To: References: Message-ID: Am 04.04.20 um 22:31 schrieb Rich Shepard: > On Sat, 4 Apr 2020, Christian Gollwitzer wrote: > >> I'm not sure I fully understand it, because a "module" is not defined >> in the language of tkinter. > > Christian, > > True, but it is in Python: a file ending in .py which, in this case, > contains a class of tkinter widgets. > >> Is it correct, you want to know how to place more than one widget - a >> arrangement of widgets - onto a notebook tab? > > Yes, as they are defined and laid out in separate files/modules. > >> This is achieved by a ttk.Frame() widget, which holds all the other >> stuff, and then you place the frame onto the notebook: >> >> n=ttk.Notebook() >> f1=ttk.Frame() >> # put all your stuff into f1 >> n.add(f1, text="Module1") >> # repeat for your other "modules" > > This looks to me like it's adding the text, "Module1" to the tab. Yes and no. It puts the empty frame in the notebook and labels it with "Module1" so that when you click the label, the frame is raised. Of course, not very interesting, because the frame is empty. > > Here: > > nb = ttk.Notebook(Main) > ??? ... > ??? page3 = ttk.Frame(nb) > ??? ... > ??? # add titles to tabs > ??? nb.add(page3, text='Biota') > ??? ... > > This puts the text on each notebook tab, correct? It adds an empty frame, as above. > > If so, how do I add > > class BiotaDataForm(Tk.Frame): > > which defines all the widgets in the module in views/biota.py into the body > of the notebook's page3? Add that thing instead of the frame. blabla=BioDataForm() # whatever args it needs, maybe parent=nb nb.add(blabla, text="Biodata") Christian PS: I suggest to change all Tk widgets to ttk widgets for optical reasons, but that's a side note. From PythonList at DancesWithMice.info Sat Apr 4 18:38:23 2020 From: PythonList at DancesWithMice.info (DL Neil) Date: Sun, 5 Apr 2020 10:38:23 +1200 Subject: Window and position of figure In-Reply-To: <363f81844b0ca9a2a9d002aa9d0e4826@inpe.br> References: <363f81844b0ca9a2a9d002aa9d0e4826@inpe.br> Message-ID: <9b296140-6544-78cd-e507-b652b492e814@DancesWithMice.info> > I already use the IDL software. Now I`m using Python. In IDL I > havethe vector position=(xo,yo,x1,y1) to set where Iwnat to plot my > figure in my window. > > I have an 2d array with x and y dimensition equal > 5224. when I plot my figure, using contourtf it takes up a small part of > my window. What can I do to have > my figure occupy a larger area in my > window. Is this a matter of scaling? ie if the figure is only 10-units wide and the x-axis is 5224-units, then it will occupy only 0.2% of the (positive) width. (I don't use IDL) When the axes are also plotted, do they appear in the middle of the screen, ie half of each axis is for negative values. If the vector and figure lie in positive space (for example), why include either/both negative domains? -- Regards =dn From please_no at spam.it Sat Apr 4 19:00:23 2020 From: please_no at spam.it (Luca) Date: Sat, 4 Apr 2020 19:00:23 -0400 Subject: print small DataFrame to STDOUT and read it back into dataframe Message-ID: possibly a stupid question. Let's say I have a (small) dataframe: import pandas as pd dframe = pd.DataFrame({'A': ['a0','a1','a2','a3'], 'B': ['b0','b1','b2','b3'], 'C': ['c0','c1','c2','c3'], 'D': ['d0','d1','d2','d3']}, index=[0,1,2,3]) Is there a way that I can ask this dataframe to "print itself" in a way that I can copy that output and easily rebuild the original dataframe with index, columns and all? dframe.to_string gives: Can I evaluate this string to obtain a new dataframe like the one that generated it? Thanks From grant.b.edwards at gmail.com Sat Apr 4 16:16:01 2020 From: grant.b.edwards at gmail.com (Grant Edwards) Date: Sat, 4 Apr 2020 20:16:01 -0000 (UTC) Subject: A PDF journey to find all python PDF References: Message-ID: On 2020-04-04, Michael Torrie wrote: > On 4/4/20 9:08 AM, anson freer wrote: >> Thanks, I'll check them out. >> tutor sent "The reason it is being held: >> >> Post by non-member to a members-only list". >> >> could I be on both lists? I did unsubscribe > > Yes you can subscribe to both lists of course. But you have to subscribe > to each list individually. Always be sure to post to a list from the > same email address that you signed up. > >> I am trying learn how to use a PDF text editor > > Okay, but what is your goal and purpose? What problem are you trying > to solve. If you just want to edit a PDF file, I can think of far > easier methods than using any Python module. For example LibreOffice > can import and edit PDFs using the Draw component. The only real interactive PDF editor I know of for Linux is PDFStudio: https://www.qoppa.com/pdfstudio/ I've been using it for many years, and can recommed it highly. It's got nothing to do with Python though. If you want command-line stuff, there's pdf toolkit: https://packages.gentoo.org/packages/app-text/pdftk If, OTOH, you want to programmatically generate PDF from Python, that's something entirely different. I'd look at Reportlab https://www.reportlab.com/opensource/ pyfpdf https://pyfpdf.readthedocs.io/en/latest/#fpdf-for-python pypdf https://pythonhosted.org/PyPDF2/ -- Grant From tjreedy at udel.edu Sat Apr 4 23:21:36 2020 From: tjreedy at udel.edu (Terry Reedy) Date: Sat, 4 Apr 2020 23:21:36 -0400 Subject: Adding tkinter modules to notebook tabs In-Reply-To: References: Message-ID: On 4/4/2020 10:59 AM, Rich Shepard wrote: > My Python3-3.8.2 application has 8 modules with subject-specific data > entry/editing widgets and I want to display each module on a ttk.Notebook. > Each notebook resource I've found in my reference books and on the web > describe how to create a notebook and tabs and add labels to the tabs; a > few > describe how to place individual widgets on a tab. But I've not found > how to > place a widget-filled module on a notebook tab. IDLE's currently-working Settings dialog uses a ttl.Notebook with 5 tabs. To see it, run IDLE and on the top menu, select Options => Configure IDLE. Each tab displays a ttk.Frame with multiple widgets. Where there is a choice, ttk widgets are used. They make the most different on macOS and least difference on Windows (because the tk widgets look pretty good there). The code is in idlelib/configdialog.py. ConfigDialog creates a window and notebook and adds the tab frames. As Christian indicated, the notebook itself takes very little code. Each of the tab frames is a separate Frame subclass in the same file, but they could be in separate files. -- Terry Jan Reedy From hjp-python at hjp.at Sun Apr 5 06:13:07 2020 From: hjp-python at hjp.at (Peter J. Holzer) Date: Sun, 5 Apr 2020 12:13:07 +0200 Subject: how to specify trusted hosts in windows config file In-Reply-To: References: <3824255550@f38.n261.z1.binkp.net> <5123bc0f-2195-4086-b18b-5724824ffea3@googlegroups.com> <74b889d7-c1dd-45ae-adec-b73ddb215118@googlegroups.com> Message-ID: <20200405101307.GA7947@hjp.at> On 2020-03-31 08:35:35 +1100, Chris Angelico wrote: > On Tue, Mar 31, 2020 at 8:21 AM wrote: > > For pypi.org alone, my dns lookup differs from yours: 151.101.128.223. > > Ahh, I think I see what's happening. Something's interfering with your > DNS - that's a Fastly IP address. The four addresses you got were also Fastly addresses: | pypi.org. 86278 IN A 151.101.192.223 | pypi.org. 86278 IN A 151.101.64.223 | pypi.org. 86278 IN A 151.101.128.223 | pypi.org. 86278 IN A 151.101.0.223 And in fact the address dcwhatthe gets (151.101.128.223) is one of those four. So it doesn't look like something is interfering with DNS. But maybe something intercepts the SSL connection? Since he wrote that he's at the office, I'm guessing its some kind of malware protection, probably at the corporate firewall. A simple way to check this is to open the URL (here https://pypi.org) in the browser and check the certificate. For me it says (in Firefox, other browsers may format the information slightly different): Certificate issued to: Python Software Foundation Wolfeboro New Hampshire, US Verified by: DigiCert, Inc. dcwhatthe will probably see something different there. hp -- _ | Peter J. Holzer | Story must make more sense than reality. |_|_) | | | | | hjp at hjp.at | -- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From rosuav at gmail.com Sun Apr 5 06:49:54 2020 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 5 Apr 2020 20:49:54 +1000 Subject: how to specify trusted hosts in windows config file In-Reply-To: <20200405101307.GA7947@hjp.at> References: <3824255550@f38.n261.z1.binkp.net> <5123bc0f-2195-4086-b18b-5724824ffea3@googlegroups.com> <74b889d7-c1dd-45ae-adec-b73ddb215118@googlegroups.com> <20200405101307.GA7947@hjp.at> Message-ID: On Sun, Apr 5, 2020 at 8:22 PM Peter J. Holzer wrote: > > On 2020-03-31 08:35:35 +1100, Chris Angelico wrote: > > On Tue, Mar 31, 2020 at 8:21 AM wrote: > > > For pypi.org alone, my dns lookup differs from yours: 151.101.128.223. > > > > Ahh, I think I see what's happening. Something's interfering with your > > DNS - that's a Fastly IP address. > > The four addresses you got were also Fastly addresses: > > | pypi.org. 86278 IN A 151.101.192.223 > | pypi.org. 86278 IN A 151.101.64.223 > | pypi.org. 86278 IN A 151.101.128.223 > | pypi.org. 86278 IN A 151.101.0.223 > > And in fact the address dcwhatthe gets (151.101.128.223) is one of those > four. > > So it doesn't look like something is interfering with DNS. Oh, good point, I missed that. Though the fact that it gives different results _at all_ was the surprising part to me. > But maybe something intercepts the SSL connection? Since he wrote that > he's at the office, I'm guessing its some kind of malware protection, > probably at the corporate firewall. Yeah, that's exactly what I'm worried about. In fact, this is *exactly* what SSL is supposed to protect against. ChrisA From sathvikveligatla at gmail.com Sun Apr 5 08:22:45 2020 From: sathvikveligatla at gmail.com (Sathvik Babu Veligatla) Date: Sun, 5 Apr 2020 05:22:45 -0700 (PDT) Subject: python script to give a list of prime no. Message-ID: <162d9564-6b89-4207-b8b9-20fbb2babe6b@googlegroups.com> hi, I am new to python, and i am trying to output the prime numbers beginning from 3 and i cannot get the required output. It stops after giving the output "7" and that's it. CODE: a = 3 l = [] while True: for i in range(2,a): if a%i == 0: l.append(1) else: l.append(0) if l.count(1) == 0: print(a) a = a + 2 elif l.count(1) >> 0: a = a + 2 Any help is appreciated, Thank you. From orges.leka at gmail.com Sun Apr 5 08:33:53 2020 From: orges.leka at gmail.com (Orges Leka) Date: Sun, 5 Apr 2020 14:33:53 +0200 Subject: python script to give a list of prime no. In-Reply-To: <162d9564-6b89-4207-b8b9-20fbb2babe6b@googlegroups.com> References: <162d9564-6b89-4207-b8b9-20fbb2babe6b@googlegroups.com> Message-ID: You can try the following: It is based on trial division and very slow, compared to the state of the art: import math def is_prime(n): if int(math.sqrt(n))**2 == n: return(False) for i in range(2,int(math.ceil(math.sqrt(n)))): if n%i==0: return(False) return(True) then: primes = [x for x in range(1,1000) if is_prime(x)] print(primes) Kind regards, Orges Am So., 5. Apr. 2020 um 14:27 Uhr schrieb Sathvik Babu Veligatla < sathvikveligatla at gmail.com>: > hi, > I am new to python, and i am trying to output the prime numbers beginning > from 3 and i cannot get the required output. > It stops after giving the output "7" and that's it. > > CODE: > a = 3 > l = [] > while True: > for i in range(2,a): > if a%i == 0: > l.append(1) > else: > l.append(0) > > if l.count(1) == 0: > print(a) > a = a + 2 > elif l.count(1) >> 0: > a = a + 2 > > > > Any help is appreciated, > Thank you. > -- > https://mail.python.org/mailman/listinfo/python-list > -- Mit freundlichen Gr??en Herr Dipl. Math. Orges Leka Mobil: 015751078391 Email: orges.leka at googlemail.com Holzheimerstra?e 25 65549 Limburg From rosuav at gmail.com Sun Apr 5 08:38:37 2020 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 5 Apr 2020 22:38:37 +1000 Subject: python script to give a list of prime no. In-Reply-To: <162d9564-6b89-4207-b8b9-20fbb2babe6b@googlegroups.com> References: <162d9564-6b89-4207-b8b9-20fbb2babe6b@googlegroups.com> Message-ID: On Sun, Apr 5, 2020 at 10:26 PM Sathvik Babu Veligatla wrote: > > hi, > I am new to python, and i am trying to output the prime numbers beginning from 3 and i cannot get the required output. > It stops after giving the output "7" and that's it. > > CODE: > a = 3 > l = [] > while True: > for i in range(2,a): > if a%i == 0: > l.append(1) > else: > l.append(0) > > if l.count(1) == 0: > print(a) > a = a + 2 > elif l.count(1) >> 0: > a = a + 2 > > Firstly, good job on several points: you posted your code, you said what the purpose is, and you said how the output differs from that. Unfortunately not everyone does that :) Secondly, though: What does "some_number >> 0" mean? Play around with that in the interactive interpreter and see what results you get. You may want to consider using a simple 'else'. When you have exactly two possibilities, you don't need to say "else, if". For instance, suppose you say "If today is a weekday, go to work; otherwise, play games", you don't need to word it as "otherwise, if today is a weekend, play games" - you just say "otherwise". You can simplify this code the same way. Something worth remembering is that all code can be buggy, so writing less code usually means you have less bugs. Try to write your program with less code rather than more. :) All the best! ChrisA From rosuav at gmail.com Sun Apr 5 08:41:00 2020 From: rosuav at gmail.com (Chris Angelico) Date: Sun, 5 Apr 2020 22:41:00 +1000 Subject: python script to give a list of prime no. In-Reply-To: References: <162d9564-6b89-4207-b8b9-20fbb2babe6b@googlegroups.com> Message-ID: On Sun, Apr 5, 2020 at 10:35 PM Orges Leka wrote: > > You can try the following: > It is based on trial division and very slow, compared to the state of the > art: > I think it's more helpful to assist the OP in learning coding, rather than provide a completely different function to do a similar purpose :) I strongly suspect that the OP is doing this prime number finder as part of learning Python, not as a means of actually finding prime numbers. BTW, you may want to be careful of mixing floats and ints. It's generally safest to stick to just integers - fewer things to have to think about. ChrisA From rshepard at appl-ecosys.com Sun Apr 5 08:45:10 2020 From: rshepard at appl-ecosys.com (Rich Shepard) Date: Sun, 5 Apr 2020 05:45:10 -0700 (PDT) Subject: Adding tkinter modules to notebook tabs In-Reply-To: References: Message-ID: On Sat, 4 Apr 2020, Terry Reedy wrote: > IDLE's currently-working Settings dialog uses a ttl.Notebook with 5 tabs. > To see it, run IDLE and on the top menu, select Options => Configure IDLE. > Each tab displays a ttk.Frame with multiple widgets. Where there is a > choice, ttk widgets are used. They make the most different on macOS and > least difference on Windows (because the tk widgets look pretty good > there). > > The code is in idlelib/configdialog.py. ConfigDialog creates a window and > notebook and adds the tab frames. As Christian indicated, the notebook > itself takes very little code. Each of the tab frames is a separate Frame > subclass in the same file, but they could be in separate files. Thanks, Terry. Regards, Rich From sathvikveligatla at gmail.com Sun Apr 5 09:01:07 2020 From: sathvikveligatla at gmail.com (Sathvik Babu Veligatla) Date: Sun, 5 Apr 2020 06:01:07 -0700 (PDT) Subject: python script to give a list of prime no. In-Reply-To: References: <162d9564-6b89-4207-b8b9-20fbb2babe6b@googlegroups.com> Message-ID: <4586548e-bdc8-440c-b6ba-c99763f26527@googlegroups.com> On Sunday, April 5, 2020 at 6:04:20 PM UTC+5:30, Orges Leka wrote: > You can try the following: > It is based on trial division and very slow, compared to the state of the > art: > > import math > def is_prime(n): > if int(math.sqrt(n))**2 == n: > return(False) > for i in range(2,int(math.ceil(math.sqrt(n)))): > if n%i==0: > return(False) > return(True) > > then: > > primes = [x for x in range(1,1000) if is_prime(x)] > > print(primes) > > Kind regards, > Orges > > Am So., 5. Apr. 2020 um 14:27 Uhr schrieb Sathvik Babu Veligatla < > sathvikveligatla at gmail.com>: > > > hi, > > I am new to python, and i am trying to output the prime numbers beginning > > from 3 and i cannot get the required output. > > It stops after giving the output "7" and that's it. > > > > CODE: > > a = 3 > > l = [] > > while True: > > for i in range(2,a): > > if a%i == 0: > > l.append(1) > > else: > > l.append(0) > > > > if l.count(1) == 0: > > print(a) > > a = a + 2 > > elif l.count(1) >> 0: > > a = a + 2 > > > > > > > > Any help is appreciated, > > Thank you. > > -- > > https://mail.python.org/mailman/listinfo/python-list > > > > > -- > Mit freundlichen Gr??en > Herr Dipl. Math. Orges Leka > > Mobil: 015751078391 > Email: orges.leka at googlemail.com > Holzheimerstra?e 25 > 65549 Limburg umm, first of all, thank you for the quick response. But, I am basically trying to get the output using the simplest means possible(beginner's trial :-)). So can you try to run it tell me, why it isn't working? thank you. From sathvikveligatla at gmail.com Sun Apr 5 09:08:24 2020 From: sathvikveligatla at gmail.com (Sathvik Babu Veligatla) Date: Sun, 5 Apr 2020 06:08:24 -0700 (PDT) Subject: python script to give a list of prime no. In-Reply-To: References: <162d9564-6b89-4207-b8b9-20fbb2babe6b@googlegroups.com> Message-ID: <98d45e21-a3b8-40ad-b7df-bfeb03646cab@googlegroups.com> On Sunday, April 5, 2020 at 6:09:04 PM UTC+5:30, Chris Angelico wrote: > On Sun, Apr 5, 2020 at 10:26 PM Sathvik Babu Veligatla > wrote: > > > > hi, > > I am new to python, and i am trying to output the prime numbers beginning from 3 and i cannot get the required output. > > It stops after giving the output "7" and that's it. > > > > CODE: > > a = 3 > > l = [] > > while True: > > for i in range(2,a): > > if a%i == 0: > > l.append(1) > > else: > > l.append(0) > > > > if l.count(1) == 0: > > print(a) > > a = a + 2 > > elif l.count(1) >> 0: > > a = a + 2 > > > > > > Firstly, good job on several points: you posted your code, you said > what the purpose is, and you said how the output differs from that. > Unfortunately not everyone does that :) > > Secondly, though: What does "some_number >> 0" mean? Play around with > that in the interactive interpreter and see what results you get. > > You may want to consider using a simple 'else'. When you have exactly > two possibilities, you don't need to say "else, if". For instance, > suppose you say "If today is a weekday, go to work; otherwise, play > games", you don't need to word it as "otherwise, if today is a > weekend, play games" - you just say "otherwise". You can simplify this > code the same way. > > Something worth remembering is that all code can be buggy, so writing > less code usually means you have less bugs. Try to write your program > with less code rather than more. :) > > All the best! > > ChrisA yeah bro, tried as said. But still no luck... :-( i cannot understand the issue in the code. From barry at barrys-emacs.org Sun Apr 5 09:22:13 2020 From: barry at barrys-emacs.org (Barry Scott) Date: Sun, 5 Apr 2020 14:22:13 +0100 Subject: Windows python 3.8 module finder problem. Message-ID: <867BF2D7-AB74-499D-8854-ABF69BA5DB3D@barrys-emacs.org> I have code that uses the modulefinder: mf = modulefinder.ModuleFinder() mf.run_script( self.main_program ) with python 3.7 all works without problems. But python 3.8 tracebacks (TB), here is the end of the TB: File "C:\Python38.Win64\lib\modulefinder.py", line 326, in import_module m = self.load_module(fqname, fp, pathname, stuff) File "C:\Python38.Win64\lib\modulefinder.py", line 344, in load_module co = compile(fp.read()+'\n', pathname, 'exec') File "C:\Python38.Win64\lib\encodings\cp1252.py", line 23, in decode return codecs.charmap_decode(input,self.errors,decoding_table)[0] UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 308: character maps to I added this debug print in both the 3.7 and 3.8 code of modulefinder.py: def load_module(self, fqname, fp, pathname, file_info): print('QQQ load_module(%r, %r, %r, %r)' % (fqname, fp, pathname, file_info)) The file that causes the TB is functools.py as there is text that is non-ASCII at offset 308. The debug shows this for functools.py: QQQ load_module('functools', <_io.TextIOWrapper name='C:\\Python37.win64\\lib\\functools.py' mode='r' encoding='utf-8'>, 'C:\\Python37.win64\\lib\\functools.py', ('.py', 'r', 1)) QQQ load_module('functools', <_io.TextIOWrapper name='C:\\Python38.Win64\\lib\\functools.py' mode='r' encoding='cp1252'>, 'C:\\Python38.Win64\\lib\\functools.py', ('.py', 'r', 1)) In 3.7 the fp is opened with encoding UTF-8, but on 3.8 its cp1252. The code in modulefinder does not seem to handle encoding when opening .py files. Adding an explicit coding comment to functools.py did not work. So the default encoding will be used; which is locale.getpreferredencoding(False) according to the docs for open(). How did modulefinder end up wth utf-8 encoding being used? It does seem to look at chcp setting. On both 3.7 and 3.8 I see that locale.getpreferredencoding(False) returns 'cp1252'. I have not figured out how the 3.7 code manages to use utf-8 that is required to get things working. I can workaround this by setting PYTHONUTF8=1, but I want to change the behavour from within python. I have failed to find a way to change what is returned by locale.getpreferredencoding(False) from within python. Is the only way to set the PYTHONUTF8? Barry From barry at barrys-emacs.org Sun Apr 5 09:28:21 2020 From: barry at barrys-emacs.org (Barry Scott) Date: Sun, 5 Apr 2020 14:28:21 +0100 Subject: python script to give a list of prime no. In-Reply-To: <98d45e21-a3b8-40ad-b7df-bfeb03646cab@googlegroups.com> References: <162d9564-6b89-4207-b8b9-20fbb2babe6b@googlegroups.com> <98d45e21-a3b8-40ad-b7df-bfeb03646cab@googlegroups.com> Message-ID: <19075009-F3AE-422F-9E55-6B4D03D6C261@barrys-emacs.org> > On 5 Apr 2020, at 14:08, Sathvik Babu Veligatla wrote: > > On Sunday, April 5, 2020 at 6:09:04 PM UTC+5:30, Chris Angelico wrote: >> On Sun, Apr 5, 2020 at 10:26 PM Sathvik Babu Veligatla >> wrote: >>> >>> hi, >>> I am new to python, and i am trying to output the prime numbers beginning from 3 and i cannot get the required output. >>> It stops after giving the output "7" and that's it. >>> >>> CODE: >>> a = 3 >>> l = [] >>> while True: >>> for i in range(2,a): >>> if a%i == 0: >>> l.append(1) >>> else: >>> l.append(0) >>> >>> if l.count(1) == 0: >>> print(a) >>> a = a + 2 >>> elif l.count(1) >> 0: >>> a = a + 2 >>> >>> >> >> Firstly, good job on several points: you posted your code, you said >> what the purpose is, and you said how the output differs from that. >> Unfortunately not everyone does that :) >> >> Secondly, though: What does "some_number >> 0" mean? Play around with >> that in the interactive interpreter and see what results you get. >> >> You may want to consider using a simple 'else'. When you have exactly >> two possibilities, you don't need to say "else, if". For instance, >> suppose you say "If today is a weekday, go to work; otherwise, play >> games", you don't need to word it as "otherwise, if today is a >> weekend, play games" - you just say "otherwise". You can simplify this >> code the same way. >> >> Something worth remembering is that all code can be buggy, so writing >> less code usually means you have less bugs. Try to write your program >> with less code rather than more. :) >> >> All the best! >> >> ChrisA > > yeah bro, tried as said. But still no luck... :-( > i cannot understand the issue in the code. You need to figure out what the code is doing. One way to do this is to add some more print statements to show the values of your variables as the code runs. What is the value of i for example in the for loop? What does the list l look like? Also try printing the values that you use the if statments. print( l.count(1) == 0) etc. Barry > -- > https://mail.python.org/mailman/listinfo/python-list From hjp-python at hjp.at Sun Apr 5 10:07:44 2020 From: hjp-python at hjp.at (Peter J. Holzer) Date: Sun, 5 Apr 2020 16:07:44 +0200 Subject: python script to give a list of prime no. In-Reply-To: <162d9564-6b89-4207-b8b9-20fbb2babe6b@googlegroups.com> References: <162d9564-6b89-4207-b8b9-20fbb2babe6b@googlegroups.com> Message-ID: <20200405140744.GA2183@hjp.at> On 2020-04-05 05:22:45 -0700, Sathvik Babu Veligatla wrote: > I am new to python, and i am trying to output the prime numbers > beginning from 3 and i cannot get the required output. It stops after > giving the output "7" and that's it. A technique I learned when I started programming (back in the days when computers were made from bones and rocks), is to "play computer": Grab a piece of paper and a pencil. Make a column for each variable (a, l, and i in your case). Then walk through the code line by line, think about what each line does, and every time a new value is assigned to a variable, note the new value on your paper. Do the values of the variables change the way you expect them to? If not, why not? hp PS: You can also single-step through the program in a debugger, but I think doing this by hand on a piece of paper is very useful, especially for a beginner, since it forces you to think what happens (The downside is of course that you may make mistakes - but then you can learn from them). -- _ | Peter J. Holzer | Story must make more sense than reality. |_|_) | | | | | hjp at hjp.at | -- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From inhahe at gmail.com Sun Apr 5 10:32:53 2020 From: inhahe at gmail.com (inhahe) Date: Sun, 5 Apr 2020 10:32:53 -0400 Subject: Fwd: python script to give a list of prime no. In-Reply-To: References: <162d9564-6b89-4207-b8b9-20fbb2babe6b@googlegroups.com> Message-ID: On Sun, Apr 5, 2020 at 8:26 AM Sathvik Babu Veligatla < sathvikveligatla at gmail.com> wrote: > hi, > I am new to python, and i am trying to output the prime numbers beginning > from 3 and i cannot get the required output. > It stops after giving the output "7" and that's it. > > CODE: > a = 3 > l = [] > while True: > for i in range(2,a): > if a%i == 0: > l.append(1) > else: > l.append(0) > > if l.count(1) == 0: > print(a) > a = a + 2 > elif l.count(1) >> 0: > a = a + 2 > > > > Any help is appreciated, > Thank you. > -- > https://mail.python.org/mailman/listinfo/python-list "l = []" needs to go inside the "while True" loop. as it is, it keeps adding 1's and 0's to the list with each new "a" value, and then counts the 1's and 0's, without ever resetting the list back to empty, so once it gets to 9 the list has a 1 in it and l.count(1) will never be false again. 3, 5 and 7 are prime so a 1 doesn't get added yet with those values, which is why 7 is the highest it gets to. so with "l = []" inside the while loop, "l" would be reset to empty with each new "a" value. btw, this is a very inefficient way to compute prime numbers. for example, why add the 0's to the list? you never count the number of 0's so it's unnecessary. another example.. why use a list at all? all that matters is that it find *one* result where a%i==0, it doesn't matter how many results it found after that, so all you need is a boolean. and you might as well stop testing a%i for *all* i values up to i, because once it finds the first result that's 0, you know it's prime so you can just go to the next number. and you don't need i to go all the way to a, because a%i will always be > 0 for any i over a/2. and since you're not testing evens, it's actually any i over a/3. in actuality, though, computing any a%i where i > the square root of a is redundant because for each factor of a above the square root of a, you've already tested its cofactor, say a is 100. the square root of 100 is 10. if you're testing 100%20, that's unnecessary because 100/20 is 5 and you've already tested 100%5. From rshepard at appl-ecosys.com Sun Apr 5 11:54:34 2020 From: rshepard at appl-ecosys.com (Rich Shepard) Date: Sun, 5 Apr 2020 08:54:34 -0700 (PDT) Subject: Adding tkinter modules to notebook tabs [RESOLVED] Message-ID: On Sat, 4 Apr 2020, Christian Gollwitzer wrote: > Add that thing instead of the frame. > > blabla=BioDataForm() # whatever args it needs, maybe parent=nb > > nb.add(blabla, text="Biodata") Christian, This clarifies my uncertainty and answers my question. Thanks. > PS: I suggest to change all Tk widgets to ttk widgets for optical reasons, > but that's a side note. I thought I had all as ttk; I'll check and correct as necessary. Best regards, Rich From sathvikveligatla at gmail.com Sun Apr 5 12:51:09 2020 From: sathvikveligatla at gmail.com (Sathvik Babu Veligatla) Date: Sun, 5 Apr 2020 09:51:09 -0700 (PDT) Subject: python script to give a list of prime no. In-Reply-To: References: <162d9564-6b89-4207-b8b9-20fbb2babe6b@googlegroups.com> Message-ID: <3c76cba5-f4a2-43a5-adf6-cc1ca7d3a3f8@googlegroups.com> On Sunday, April 5, 2020 at 8:03:19 PM UTC+5:30, inhahe wrote: > On Sun, Apr 5, 2020 at 8:26 AM Sathvik Babu Veligatla < > sathvikveligatla at gmail.com> wrote: > > > hi, > > I am new to python, and i am trying to output the prime numbers beginning > > from 3 and i cannot get the required output. > > It stops after giving the output "7" and that's it. > > > > CODE: > > a = 3 > > l = [] > > while True: > > for i in range(2,a): > > if a%i == 0: > > l.append(1) > > else: > > l.append(0) > > > > if l.count(1) == 0: > > print(a) > > a = a + 2 > > elif l.count(1) >> 0: > > a = a + 2 > > > > > > > > Any help is appreciated, > > Thank you. > > -- > > https://mail.python.org/mailman/listinfo/python-list > > > > "l = []" needs to go inside the "while True" loop. as it is, it keeps > adding 1's and 0's to the list with each new "a" value, and then counts the > 1's and 0's, without ever resetting the list back to empty, so once it gets > to 9 the list has a 1 in it and l.count(1) will never be false again. 3, 5 > and 7 are prime so a 1 doesn't get added yet with those values, which is > why 7 is the highest it gets to. so with "l = []" inside the while loop, > "l" would be reset to empty with each new "a" value. > > btw, this is a very inefficient way to compute prime numbers. for example, > why add the 0's to the list? you never count the number of 0's so it's > unnecessary. another example.. why use a list at all? all that matters is > that it find *one* result where a%i==0, it doesn't matter how many results > it found after that, so all you need is a boolean. and you might as well > stop testing a%i for *all* i values up to i, because once it finds the > first result that's 0, you know it's prime so you can just go to the next > number. and you don't need i to go all the way to a, because a%i will > always be > 0 for any i over a/2. and since you're not testing evens, it's > actually any i over a/3. in actuality, though, computing any a%i where i > > the square root of a is redundant because for each factor of a above the > square root of a, you've already tested its cofactor, say a is 100. the > square root of 100 is 10. if you're testing 100%20, that's unnecessary > because 100/20 is 5 and you've already tested 100%5. yeah, I get that. Initially, i put the else columns empty and had a somewhat different code. I thought maybe that's messing up with the code and added the 'l.append(0)' line and some other things. Thank you for the feedback :-) From sathvikveligatla at gmail.com Sun Apr 5 13:26:48 2020 From: sathvikveligatla at gmail.com (Sathvik Babu Veligatla) Date: Sun, 5 Apr 2020 10:26:48 -0700 (PDT) Subject: python script to give a list of prime no. In-Reply-To: References: <162d9564-6b89-4207-b8b9-20fbb2babe6b@googlegroups.com> Message-ID: <29b7fec1-af61-4a9a-a48e-6221a836bf3b@googlegroups.com> On Sunday, April 5, 2020 at 8:03:19 PM UTC+5:30, inhahe wrote: > On Sun, Apr 5, 2020 at 8:26 AM Sathvik Babu Veligatla < > sathvikveligatla at gmail.com> wrote: > > > hi, > > I am new to python, and i am trying to output the prime numbers beginning > > from 3 and i cannot get the required output. > > It stops after giving the output "7" and that's it. > > > > CODE: > > a = 3 > > l = [] > > while True: > > for i in range(2,a): > > if a%i == 0: > > l.append(1) > > else: > > l.append(0) > > > > if l.count(1) == 0: > > print(a) > > a = a + 2 > > elif l.count(1) >> 0: > > a = a + 2 > > > > > > > > Any help is appreciated, > > Thank you. > > -- > > https://mail.python.org/mailman/listinfo/python-list > > > > "l = []" needs to go inside the "while True" loop. as it is, it keeps > adding 1's and 0's to the list with each new "a" value, and then counts the > 1's and 0's, without ever resetting the list back to empty, so once it gets > to 9 the list has a 1 in it and l.count(1) will never be false again. 3, 5 > and 7 are prime so a 1 doesn't get added yet with those values, which is > why 7 is the highest it gets to. so with "l = []" inside the while loop, > "l" would be reset to empty with each new "a" value. > > btw, this is a very inefficient way to compute prime numbers. for example, > why add the 0's to the list? you never count the number of 0's so it's > unnecessary. another example.. why use a list at all? all that matters is > that it find *one* result where a%i==0, it doesn't matter how many results > it found after that, so all you need is a boolean. and you might as well > stop testing a%i for *all* i values up to i, because once it finds the > first result that's 0, you know it's prime so you can just go to the next > number. and you don't need i to go all the way to a, because a%i will > always be > 0 for any i over a/2. and since you're not testing evens, it's > actually any i over a/3. in actuality, though, computing any a%i where i > > the square root of a is redundant because for each factor of a above the > square root of a, you've already tested its cofactor, say a is 100. the > square root of 100 is 10. if you're testing 100%20, that's unnecessary > because 100/20 is 5 and you've already tested 100%5. thank you buddy, it worked... From pieter-l at vanoostrum.org Sun Apr 5 13:46:00 2020 From: pieter-l at vanoostrum.org (Pieter van Oostrum) Date: Sun, 05 Apr 2020 19:46:00 +0200 Subject: python script to give a list of prime no. References: <162d9564-6b89-4207-b8b9-20fbb2babe6b@googlegroups.com> Message-ID: Sathvik Babu Veligatla writes: > hi, > I am new to python, and i am trying to output the prime numbers beginning from 3 and i cannot get the required output. > It stops after giving the output "7" and that's it. > > CODE: > a = 3 > l = [] > while True: > for i in range(2,a): > if a%i == 0: > l.append(1) > else: > l.append(0) > > if l.count(1) == 0: > print(a) > a = a + 2 > elif l.count(1) >> 0: > a = a + 2 > > > > Any help is appreciated, > Thank you. As others have already noticed, the l.count(1) >> 0: is faulty. You probably meant l.count(1) > 0:, but else would be simpler. But then, once there is a 1 in l that never disappears, so after that it will never print any more numbers. You should put the l = [] AFTER the while True, so that you start with a new empty list every cycle. And then, putting 0 an 1's in a list and then counting how many 1's there are is quite inefficient. Just counting from the beginning would be more efficient. Like: a = 3 while True: count = 0 for i in range(2,a): if a%i == 0: count += 1 if count == 0: print(a) a = a + 2 else: a = a + 2 Which can be simplified to: a = 3 while True: count = 0 for i in range(2,a): if a%i == 0: count += 1 if count == 0: print(a) a = a + 2 And you effectively use the counter as a boolean, so replace is by a boolean. a = 3 while True: is_prime = True for i in range(2,a): if a%i == 0: is_prime = False # once we found a divisor, it is no use to continue break if is_prime: print(a) a = a + 2 Further optimizations are possible, for example use range(2,a/2) or even range (2, sqrt(a)). -- Pieter van Oostrum www: http://pieter.vanoostrum.org/ PGP key: [8DAE142BE17999C4] From 2QdxY4RzWzUUiLuE at potatochowder.com Sun Apr 5 14:14:39 2020 From: 2QdxY4RzWzUUiLuE at potatochowder.com (Dan Sommers) Date: Sun, 5 Apr 2020 14:14:39 -0400 Subject: python script to give a list of prime no. In-Reply-To: References: <162d9564-6b89-4207-b8b9-20fbb2babe6b@googlegroups.com> Message-ID: <20200405141439.f9183a74925c6c3c66f82fdb@potatochowder.com> On Sun, 05 Apr 2020 19:46:00 +0200 Pieter van Oostrum wrote: > Sathvik Babu Veligatla writes: > > > hi, > > I am new to python, and i am trying to output the prime numbers > > beginning from 3 and i cannot get the required output. It stops > > after giving the output "7" and that's it. > > CODE: > > a = 3 > > l = [] > > while True: > > for i in range(2,a): > > if a%i == 0: > > l.append(1) > > else: > > l.append(0) > > > > if l.count(1) == 0: > > print(a) > > a = a + 2 > > elif l.count(1) >> 0: > > a = a + 2 [intervening optimizations omitted to conserve electrons] > And you effectively use the counter as a boolean, so replace is by a boolean. > > a = 3 > while True: > is_prime = True > for i in range(2,a): > if a%i == 0: > is_prime = False > # once we found a divisor, it is no use to continue > break > if is_prime: > print(a) > a = a + 2 > > Further optimizations are possible, for example use range(2,a/2) or > even range (2, sqrt(a)). Now if only there were a way to get rid of that extraneous flag and build some sort of "if the loop ran to completion" construct.... a = 3 while True: for i in range(2,a): if a%i == 0: # once we found a divisor, it is no use to continue break else: # magic here! print(a) a = a + 2 The Time Machine Strikes Again, Dan From dcwhatthe at gmail.com Sun Apr 5 15:03:09 2020 From: dcwhatthe at gmail.com (dcwhatthe at gmail.com) Date: Sun, 5 Apr 2020 12:03:09 -0700 (PDT) Subject: how to specify trusted hosts in windows config file In-Reply-To: <2567003710@f38.n261.z1.binkp.net> References: <2567003710@f38.n261.z1.binkp.net> Message-ID: <2514b98b-1245-4df3-b95d-3c9d7f97a1f2@googlegroups.com> On Sunday, April 5, 2020 at 2:15:21 PM UTC-4, Peter J. Holzer wrote: > --yrj/dFKFPuw6o+aM > Content-Type: text/plain; charset=us-ascii > Content-Disposition: inline > Content-Transfer-Encoding: quoted-printable > > On 2020-03-31 08:35:35 +1100, Chris Angelico wrote: > > On Tue, Mar 31, 2020 at 8:21 AM dc wrote: > > > For pypi.org alone, my dns lookup differs from yours: 151.101.128.223. > >=20 > > Ahh, I think I see what's happening. Something's interfering with your > > DNS - that's a Fastly IP address. > > The four addresses you got were also Fastly addresses: > > | pypi.org. 86278 IN A 151.101.192.223 | pypi.org. 86278 IN A 151.101.64.223 | > pypi.org. 86278 IN A 151.101.128.223 | pypi.org. 86278 IN A 151.101.0.223 > > And in fact the address dcwhatthe gets (151.101.128.223) is one of those four. > > So it doesn't look like something is interfering with DNS.=20 > > But maybe something intercepts the SSL connection? Since he wrote that he's at > the office, I'm guessing its some kind of malware protection, probably at the > corporate firewall. > > A simple way to check this is to open the URL (here https://pypi.org) in the > browser and check the certificate. For me it says (in Firefox, other browsers > may format the information slightly different): > > Certificate issued to: > > Python Software Foundation > Wolfeboro > New Hampshire, US > > Verified by: DigiCert, Inc. > > dcwhatthe will probably see something different there. > > hp > > --=20 > _ | Peter J. Holzer | Story must make more sense than reality. > |_|_) | | > | | | hjp | -- Charles Stross, "Creative writing > __/ | http://www.hjp.at/ | challenge!" > > --yrj/dFKFPuw6o+aM > Content-Type: application/pgp-signature; name="signature.asc" > > -----BEGIN PGP SIGNATURE----- > > iQIzBAABCgAdFiEETtJbRjyPwVTYGJ5k8g5IURL+KF0FAl6Jry4ACgkQ8g5IURL+ > KF0TnRAAp3r4DxFh24jsXmuLlUykG9Yd4wOloVyGKyajRJjYqQ0AgkTgZrTz6A5N > 0YVvUnINlY65kkJXA703fb+f7mS7Ij6V3/UvxHGxitLatDauHvlkENTD1GzJzf7l > Lg05G3krkEpb41S+GLFYO3MVFbeBPV9jUKoHJs96UHxi5tHiTe3IA14xmgooeS32 > 3/JI+wAFV5pR5ICM8sTcRu+9wrNNEtbdg8sNfodIh5d9j3kY7s4SV0srPI3hBRUE > F949/YAPCA8rH5RcCkM3JQuJeI24hOCBvMXXknjY3pcC4ocAPAXHznTAgNtn8dKd > Z3uzFkql/7Sd1FK5qIKIvsBUS3TlOvVfbAm8rxZZPitbMEa/GWhDEQq3J5GGrPDx > 7Sty4TegLa292TJZcEJqDcFEAMjVETGeYRTEkqXdHfbVT8KYy4Lwyka1fLjpFiCC > mvZdeV2KppO3Kae0ow0mgAOXrLO719ZrgxLrzENA/K4Foq+iOZxozSyGiqjjVzO8 > W7icMQt7sPDCfDfAXxkeEr58yehRdKD6K8gpmQ2inEwk7jAVtauPIUuwlfZzIllm > 5B6LRAtF7FbZsL1KRzYKtZi2TCPTND/2jW8nUQGaTCEW6W/fa0VLkHhr3sZFmmYA > I0I3XHyh/At5RCv9XgTtcpchgXvEJlD2D27X08TQNb1k2U7DL6w= > =crJH > -----END PGP SIGNATURE----- > > --yrj/dFKFPuw6o+aM-- Thanks, Peter. For the time being, I'm dealing with this by doing the development on my personal laptop, including the generation of the executable. We're all working from home and logging in during the pandemic, anyway. When this is done and I have the time, I'll try & trace this down, while trying to avoid office politics. Regards, DC From python at bdurham.com Sun Apr 5 18:35:58 2020 From: python at bdurham.com (Malcolm Greene) Date: Sun, 05 Apr 2020 16:35:58 -0600 Subject: =?UTF-8?Q?Is_there_a_difference_between_python_