Re: Python3 - How do I import a class from another file

2019-12-10 Thread R.Wieser
DL, > I went through this cycle of thinking, first using if __name__... to > 'hide' testing, then adding test functions within the module, and now keep > test code quite separate from 'the real thing'. :-) The normal newbie progression, off of which I'm in phase #1. Having a working program

[RELEASE] Python 3.8.1rc1 is now available for testing

2019-12-10 Thread Ɓukasz Langa
Python 3.8.1rc1 is the release candidate of the first maintenance release of Python 3.8. The Python 3.8 series is the newest feature release of the Python language, and it contains many new features and optimizations. You can find Python 3.8.1rc1 here: https://www.python.org/downloads/release/

Re: Python3 - How do I import a class from another file

2019-12-10 Thread Greg Ewing
On 10/12/19 9:45 pm, R.Wieser wrote: In my case deleting the instance was needed to release its hold on something that was taken when the instance was initialised (in my case a GPIO pin on a Raspberry Pi). I did not even think of garbage collection. In that case, it was only working by accid

The file method read does not "see" CR

2019-12-10 Thread Stephen Tucker
I am running Python 2.7.10 on a Windows 10 machine. I have written a Python program that counts occurrences of bytes in a text file and have run it on a small test file. This file has CR-LF sequences at the ends of its lines. The Python program counted the LF bytes, but didn't count any CR bytes. G

Re: More efficient/elegant branching

2019-12-10 Thread Python
Musbur wrote: Hello, I have a function with a long if/elif chain that sets a couple of variables according to a bunch of test expressions, similar to function branch1() below. I never liked that approach much because it is clumsy and repetetive, and pylint thinks so as well. I've come up with

Re: The file method read does not "see" CR

2019-12-10 Thread Chris Angelico
On Tue, Dec 10, 2019 at 9:17 PM Stephen Tucker wrote: > > I am running Python 2.7.10 on a Windows 10 machine. I have written a Python > program that counts occurrences of bytes in a text file and have run it on > a small test file. This file has CR-LF sequences at the ends of its lines. > The Pyth

Re: Python3 - How do I import a class from another file

2019-12-10 Thread R.Wieser
Greg, > In that case, it was only working by accident. I don't think so. Or you must be thinking that the __del__ method of an instance is only called by the garbage collector - which would be rather daft (just think of a file thats created when initialising an instance, but not closes until t

Re: Python3 - How do I import a class from another file

2019-12-10 Thread Chris Angelico
On Tue, Dec 10, 2019 at 9:51 PM R.Wieser wrote: > > Greg, > > > In that case, it was only working by accident. > > I don't think so. > > Or you must be thinking that the __del__ method of an instance is only > called by the garbage collector - which would be rather daft (just think of > a file tha

Re: More efficient/elegant branching

2019-12-10 Thread Musbur
I like it! I think it's a cute exercise but it doesn't really solve any problem. The if/elif chain can accomplish the same thing (and much more) in the same line count for the price of being clunkier. **D -- https://mail.python.org/mailman/listinfo/python-list

Re: Python3 - How do I import a class from another file

2019-12-10 Thread R.Wieser
Chris, > Well, that's exactly what happens. So, only the reference count gets lowered. Yep, thats daft. ... unless you explain why it can only be done that way. > Also, when you scorn something without knowing your facts, > you tend to make yourself look like a fool :) I tend to go with logic

Re: Python3 - How do I import a class from another file

2019-12-10 Thread Chris Angelico
On Tue, Dec 10, 2019 at 11:46 PM R.Wieser wrote: > > Chris, > > > Well, that's exactly what happens. > > So, only the reference count gets lowered. Yep, thats daft. > > ... unless you explain why it can only be done that way. Okay. What should happen when you do this? x = 5 del x Should the in

I downloaded the python application but my system is having issues with it. please, can you provide help?

2019-12-10 Thread Princess Oluchi
Sent from Mail for Windows 10 -- https://mail.python.org/mailman/listinfo/python-list

Re: More efficient/elegant branching

2019-12-10 Thread Python
Musbur wrote: I like it! I think it's a cute exercise but it doesn't really solve any problem. The if/elif chain can accomplish the same thing (and much more) in the same line count for the price of being clunkier. **D Yep! This is why I wrote half a dozen of switch implementation but never ac

Installation Error (0xc000007b)

2019-12-10 Thread Abhi Patel
i'm getting the error message while installing python in my dell laptop. ERROR: the application was unable to start (0xc07b). Close the application Please help -- https://mail.python.org/mailman/listinfo/python-list

Site Packages Folder Red on Clean Install

2019-12-10 Thread Timothy Coca
Hello, I have a new dell XPS, I freshly installed the latest version of Pythong (3.8.0) and pycharm. Pycharm shows the site packages folder as red, and I can not import and modules from inside of it. Pip install works to install some programs like numpy, scipy, but would not install matplotlib suc

Re: More efficient/elegant branching

2019-12-10 Thread Daniel Haude
Hello Neil, thanks for the detailed answer. Question: are there other people/factors who/which should be regarded as more important than the linter's opinion? Yes. Mine. I was just puzzled at the linter's output (took me a while to figure out what it actually meant), and that got me started

Re: Python3 - How do I import a class from another file

2019-12-10 Thread Python
R.Wieser wrote: Chris, ... But, as you mentioned, I do not know (all) the facts. Please do present them. Maybe there is a logic in there I do not yet see. We may, but then you wrote: Check out the 'with' statement. I'm sorry, but nope. Rule one: When debugging do *not* throw more stu

Re: More efficient/elegant branching

2019-12-10 Thread Chris Angelico
On Wed, Dec 11, 2019 at 12:26 AM Daniel Haude wrote: > The whole thing is rather academic. Also my efficiency argument doesn't > hold water because this routine is executed just a few times per hour. I > like the "condition table" approach for its lower line count but I'll > stick with if/elif bec

Re: Randomizing Strings In A Microservices World

2019-12-10 Thread Rhodri James
On 10/12/2019 03:35, Tim Daneliuk wrote: On 12/9/19 8:50 PM, Paul Rubin wrote: Tim Daneliuk writes: - Imagine an environment in which there may be multiple instances of a given microservice written in Python. Decide the maximum number of microservice instances, say 1000. Chop up the 10 d

Re: Randomizing Strings In A Microservices World

2019-12-10 Thread Peter Otten
Tim Daneliuk wrote: > I ran across a kind of fun problem today that I wanted to run past you > Gentle Geniuses (tm): > > - Imagine an environment in which there may be multiple instances of a > given > microservice written in Python. > > - Each of these services needs to produce a string of te

Re: Python3 - How do I import a class from another file

2019-12-10 Thread Antoon Pardon
On 10/12/19 13:44, R.Wieser wrote: > Chris, > >> Well, that's exactly what happens. > So, only the reference count gets lowered. Yep, thats daft. > > ... unless you explain why it can only be done that way. > >> Also, when you scorn something without knowing your facts, >> you tend to make yoursel

Re: More efficient/elegant branching

2019-12-10 Thread Musbur
Hello Neil, thanks for the detailed answer. Question: are there other people/factors who/which should be regarded as more important than the linter's opinion? Yes. Mine. I was just puzzled at the linter's output (took me a while to figure out what it actually meant), and that got me started

Re: python 2 to 3 converter

2019-12-10 Thread songbird
Chris Angelico wrote: > On Tue, Dec 10, 2019 at 12:15 PM songbird wrote: >> >> Chris Angelico wrote: >> ... >> > >> > Here's an example piece of code. >> > >> > sock = socket.socket(...) >> > name = input("Enter your username: ") >> > code = input("Enter the base64 code: ") >> > code = base64.b64d

Re: python 2 to 3 converter

2019-12-10 Thread songbird
Chris Angelico wrote: > On Tue, Dec 10, 2019 at 4:41 PM songbird wrote: >> >> Chris Angelico wrote: >> ... >> > What if neither works, because there are assumptions that don't work? >> >> then you get stuck doing it by hand, but you would have >> been stuck doing it before for sure by hand so if

Re: Python3 - How do I import a class from another file

2019-12-10 Thread Chris Angelico
On Wed, Dec 11, 2019 at 1:53 AM Antoon Pardon wrote: > What would you want to happen in the following case: > >foo1 = Bar() >foo2 = foo1 >del foo1 > > Should the object be cleaned up now or not? > TBH both are plausible, and to a Python programmer it's immediately obvious that "foo1.c

Re: python 2 to 3 converter

2019-12-10 Thread Chris Angelico
On Wed, Dec 11, 2019 at 1:57 AM songbird wrote: > > Chris Angelico wrote: > > On Tue, Dec 10, 2019 at 12:15 PM songbird wrote: > >> > >> Chris Angelico wrote: > >> ... > >> > > >> > Here's an example piece of code. > >> > > >> > sock = socket.socket(...) > >> > name = input("Enter your username:

Re: The file method read does not "see" CR

2019-12-10 Thread Stephen Tucker
Chris, Many thanks. The first part of your answer was spot on. I have modified the program, opening its input file in "rb" mode, and now the program is working as I intend it to. I am puzzled by the second part, where you say that the read call will return one character, if the file is in text mo

Re: Python3 - How do I import a class from another file

2019-12-10 Thread Antoon Pardon
On 10/12/19 16:10, Chris Angelico wrote: > On Wed, Dec 11, 2019 at 1:53 AM Antoon Pardon wrote: >> What would you want to happen in the following case: >> >>foo1 = Bar() >>foo2 = foo1 >>del foo1 >> >> Should the object be cleaned up now or not? >> > TBH both are plausible, I find that

Re: The file method read does not "see" CR

2019-12-10 Thread Chris Angelico
On Wed, Dec 11, 2019 at 2:18 AM Stephen Tucker wrote: > > Chris, > > Many thanks. The first part of your answer was spot on. I have modified the > program, opening its input file in "rb" mode, and now the program is working > as I intend it to. > Cool! > I am puzzled by the second part, where

Re: Python3 - How do I import a class from another file

2019-12-10 Thread Chris Angelico
On Wed, Dec 11, 2019 at 2:36 AM Antoon Pardon wrote: > > On 10/12/19 16:10, Chris Angelico wrote: > > On Wed, Dec 11, 2019 at 1:53 AM Antoon Pardon wrote: > >> What would you want to happen in the following case: > >> > >>foo1 = Bar() > >>foo2 = foo1 > >>del foo1 > >> > >> Should the

Re: Python3 - How do I import a class from another file

2019-12-10 Thread Antoon Pardon
On 10/12/19 16:56, Chris Angelico wrote: > On Wed, Dec 11, 2019 at 2:36 AM Antoon Pardon wrote: >> On 10/12/19 16:10, Chris Angelico wrote: >>> On Wed, Dec 11, 2019 at 1:53 AM Antoon Pardon wrote: What would you want to happen in the following case: foo1 = Bar() foo2 = f

Re: Randomizing Strings In A Microservices World

2019-12-10 Thread Peter Pearson
On Mon, 9 Dec 2019 21:38:43 -0600, Tim Daneliuk wrote: > On 12/9/19 8:54 PM, Dennis Lee Bieber wrote: >> On Mon, 9 Dec 2019 18:52:11 -0600, Tim Daneliuk >> declaimed the following: >> >>> - Each of these services needs to produce a string of ten digits >>> guaranteed to be unique on a per servic

Re: Python3 - How do I import a class from another file

2019-12-10 Thread Michael Torrie
On 12/10/19 5:44 AM, R.Wieser wrote: >> Well, that's exactly what happens. > > So, only the reference count gets lowered. Yep, thats daft. Why? Consider: a = someobject b = a How many references for someobject? After "del a" what should be be? It's still someobject (the same object). Or the

Re: Installation Error (0xc000007b)

2019-12-10 Thread poltone
i'm getting the error message while installing python in my dell laptop. ERROR: the application was unable to start (0xc07b). The error code 0xc07b means STATUS_INVALID_IMAGE_FORMAT, i.e. probably that the program you want to start is not made for the processor architecture of your com

Re: Python3 - How do I import a class from another file

2019-12-10 Thread R.Wieser
Python, > which contradicts your previous statement. I don't think so. > "with" is "more stuff" it is the right way to deal with disposable > ressource in the first place. Than you have missed the point altogether. It isn't about what you think is the perfect way to deal with something, but

Re: Python3 - How do I import a class from another file

2019-12-10 Thread R.Wieser
Chris, > Okay. What should happen when you do this? > > x = 5 > del x > > Should the integer 5 be deleted? Yep. What do you think happens instead ? I've not seen you explain or support anything in that regard, not even now. There is a bit of a problem with the above though: It has got zero t

Re: Python3 - How do I import a class from another file

2019-12-10 Thread R.Wieser
Antoon, > Well yes that is why it is stupid to rely on the garbage collector to do > those things for you. That is why Greg Ewing already stated: > >> If your object has a method for explicitly making it release its >> resources, it would be better to use that rather than rely on >> the garbage co

Re: Randomizing Strings In A Microservices World

2019-12-10 Thread Tim Daneliuk
On 12/10/19 10:36 AM, Peter Pearson wrote: > Just to be sure: you *are* aware that the "Birthday Paradox" says > that if you pick your 10-digit strings truly randomly, you'll probably > get a collision by the time of your 10**5th string . . . right? I did not consider this, but the point is taken.

Re: Python3 - How do I import a class from another file

2019-12-10 Thread MRAB
On 2019-12-10 17:18, R.Wieser wrote: Chris, Okay. What should happen when you do this? x = 5 del x Should the integer 5 be deleted? Yep. What do you think happens instead ? I've not seen you explain or support anything in that regard, not even now. There is a bit of a problem with the a

Re: Randomizing Strings In A Microservices World

2019-12-10 Thread Chris Angelico
On Wed, Dec 11, 2019 at 5:01 AM Tim Daneliuk wrote: > > On 12/10/19 10:36 AM, Peter Pearson wrote: > > Just to be sure: you *are* aware that the "Birthday Paradox" says > > that if you pick your 10-digit strings truly randomly, you'll probably > > get a collision by the time of your 10**5th string

Re: Python3 - How do I import a class from another file

2019-12-10 Thread Rhodri James
On 10/12/2019 17:18, R.Wieser wrote: Chris, Okay. What should happen when you do this? x = 5 del x Should the integer 5 be deleted? Yep. What do you think happens instead ? I've not seen you explain or support anything in that regard, not even now. As it happens, the object that is the

Re: Python3 - How do I import a class from another file

2019-12-10 Thread R.Wieser
Michael, >> So, only the reference count gets lowered. Yep, thats daft. > > Why? Consider: You missed the point. It was-and-is not about decrementing a reference but still having it above zero, but what happens when the reference becomes zero: is the __del__ method called directly (as I find

Re: Python3 - How do I import a class from another file

2019-12-10 Thread Chris Angelico
On Wed, Dec 11, 2019 at 5:51 AM R.Wieser wrote: > > Michael, > > >> So, only the reference count gets lowered. Yep, thats daft. > > > > Why? Consider: > > You missed the point. > > It was-and-is not about decrementing a reference but still having it above > zero, but what happens when the refere

Re: Python3 - How do I import a class from another file

2019-12-10 Thread R.Wieser
MRAB, > You merely disabled the mark-and-sweep collector. Nope. Go check the docs on "gc" Regards, Rudy Wieser -- https://mail.python.org/mailman/listinfo/python-list

Re: Python3 - How do I import a class from another file

2019-12-10 Thread Chris Angelico
On Wed, Dec 11, 2019 at 6:06 AM R.Wieser wrote: > > MRAB, > > > You merely disabled the mark-and-sweep collector. > > Nope. Go check the docs on "gc" > https://docs.python.org/3/library/gc.html """ This module provides an interface to the optional garbage collector. ... Since the collector sup

Re: Python3 - How do I import a class from another file

2019-12-10 Thread Rhodri James
On 10/12/2019 19:00, R.Wieser wrote: MRAB, You merely disabled the mark-and-sweep collector. Nope. Go check the docs on "gc" Yep. Go and check the docs on "gc" *carefully* *plonk* -- Rhodri James *-* Kynesim Ltd -- https://mail.python.org/mailman/listinfo/python-list

Re: Python3 - How do I import a class from another file

2019-12-10 Thread Roel Schroeven
R.Wieser schreef op 10/12/2019 om 13:44: Also, when you scorn something without knowing your facts, you tend to make yourself look like a fool :) I tend to go with logic. No logic => it most likely doesn't work that way. Choosing to go with a delayed action like you say will, as I already e

Re: Python3 - How do I import a class from another file

2019-12-10 Thread R.Wieser
Rhodri, > the object that is the integer 5 *isn't* deleted That was not the question. And you're now referring to the object as well as the integer, which makes it confusing. You also have not explained what happens instead. In short, your above statement has ZERO value to me. > On the cont

Re: Python3 - How do I import a class from another file

2019-12-10 Thread MRAB
On 2019-12-10 19:25, R.Wieser wrote: Rhodri, the object that is the integer 5 *isn't* deleted That was not the question. And you're now referring to the object as well as the integer, which makes it confusing. You also have not explained what happens instead. In short, your above statement

Re: Python3 - How do I import a class from another file

2019-12-10 Thread Rhodri James
On 10/12/2019 19:25, R.Wieser wrote: And to repeat, you have*no* guarantee*at all* in the language spec that this will happen. There is also absolutily no guarantee in those specs that my 'puter will not suddenly transform into a bonzai tree. Should I now expect it to happen ? That's an im

Re: Python3 - How do I import a class from another file

2019-12-10 Thread R.Wieser
Dennis, > In common Python, small integers are cached internally for reuse That is what I imagined could possibly be happening, reading the specific "the integer 5" formulation in the question ("reading between the lines" and all that). And thanks for that explanation, underbuild an all. :-)

Python3 - How do I import a class from another file

2019-12-10 Thread R.Wieser
Chris, > Once again, you make positive assertions about things you > don't understand. And you have refused to bring any kind of help (explanation!) forward that could have shown me the erring of my ways, as well as refusing to adress my (attempting to explain) examples. You might know a thing o

Re: Python3 - How do I import a class from another file

2019-12-10 Thread R.Wieser
Roel, > Rudy, unless/until you know the language inside out, you'd better listen > to Chris and other people here who spend a lot of time and effort in > helping people like you. I tried. But what he said made no sense to me, and no matter how hard I tried I could not get Chris (or others fo

Re: Python3 - How do I import a class from another file

2019-12-10 Thread Chris Angelico
On Wed, Dec 11, 2019 at 8:26 AM R.Wieser wrote: > > Roel, > > > Rudy, unless/until you know the language inside out, you'd better listen > > to Chris and other people here who spend a lot of time and effort in > > helping people like you. > > I tried. But what he said made no sense to me, and no

Re: Python3 - How do I import a class from another file

2019-12-10 Thread Paul Moore
On Tue, 10 Dec 2019 at 21:12, R.Wieser wrote: > And although you have been fighting me over when the __del__ method is > called, it /is/ called directly as a result of an "del instance" and the > refcount goes zero. There is /no/ delay.(with the only exception is > when a circular reference e

Re: Python3 - How do I import a class from another file

2019-12-10 Thread MRAB
On 2019-12-10 21:08, R.Wieser wrote: Chris, Once again, you make positive assertions about things you don't understand. And you have refused to bring any kind of help (explanation!) forward that could have shown me the erring of my ways, as well as refusing to adress my (attempting to explain

Re: Python3 - How do I import a class from another file

2019-12-10 Thread Michael Torrie
On 12/10/19 11:47 AM, R.Wieser wrote: > Who did I call stupid ?I mentioned that the language doing it as Chris > thinks it happens would be stupid, and I gave a reason for that (race > conditions everywhere). But odd: Neither him nor you nor anyone else who > complains about me thinking for

Re: Python3 - How do I import a class from another file

2019-12-10 Thread Michael Torrie
On 12/10/19 2:08 PM, R.Wieser wrote: > You might know a thing or two about Python, but you (and a number of others > here) positivily stink as teachers, incapable or even unwilling to place > themselves in the shoes of a newbie. As it happens, I've heard Chris speak about teaching Python to studen

Re: Python3 - How do I import a class from another file

2019-12-10 Thread Python
Michael Torrie wrote: On 12/10/19 2:08 PM, R.Wieser wrote: You might know a thing or two about Python, but you (and a number of others here) positivily stink as teachers, incapable or even unwilling to place themselves in the shoes of a newbie. As it happens, I've heard Chris speak about teach

datetime gotcha

2019-12-10 Thread Frank Millman
Hi all It took me a while to track down a bug that stemmed from this - >>> from datetime import date as dt, time as tm, datetime as dtm >>> x = dt.today() >>> isinstance(x, dt) True >>> isinstance(x, dtm) False >>> y = dtm.now() >>> isinstance(y, dt) True <--- ?? >>> isinstance