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

2019-12-09 Thread R.Wieser
Terry, > Not really. The resulting global objects do not normally take enough > space to worry about on normal modern desktops. For some reason I still aim to keep my (running) programs as small as possible - even though the ammount of memory has grown more than a thousandfold since I started

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

2019-12-09 Thread R.Wieser
DL, > Some of this you will know. (Hopefully) some will be 'new': Some of it is known to me, and indeed I do hope that there will be new stuff in there too. Its why I took up Python. :-) Thanks for the explanation (including the aliassing I wasn't aware of) and the links. Regards, Rudy Wiese

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

2019-12-09 Thread R.Wieser
Greg, >>> Are you sure there's a difference between classes and functions here? >> >> Yes, quite sure. > > And we're even more sure that there isn't. :-) As it turned out "we're" are right, and I was thrown off by the error message. :-p The problem is that I had no idea why I got that (rather e

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

2019-12-09 Thread Greg Ewing
On 9/12/19 9:15 pm, R.Wieser wrote: To be honest, I was not aware/did not assume that I could delete a class definition that way (I even find it a bit weird, but as I'm a newbie in regard to Python that does not say much). Python is very dynamic. The class statement is actually an executable st

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

2019-12-09 Thread Terry Reedy
On 12/9/2019 2:36 AM, R.Wieser wrote: Terry, Standard for in-file test is [snip] Any reason to put the testcode in a procedure instead of just have it directly follow the "if __name__ == '__main__' " test ? One can, for instance, interactively do >>> import mod >>> mod.test() and explore t

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

2019-12-09 Thread R.Wieser
Python, > Child *depends* on Parent. I'm sorry, but without any kind of underbuilding statements like that are of no value to me I'm afraid. Also: if I can just copy-and-paste the class into the file which origionally included it and have the whole program run without a problem than that depe

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

2019-12-09 Thread R.Wieser
Greg, > There's nothing stopping you from subsequently rebinding that name to some > other object, or deleting it altogether. Which is something I did not expect. But running into is what makes doing something new interesting. :-) And I just realized something else: I just assumed that the "d

python 3 prefix to infix without too many parethesis

2019-12-09 Thread jezkator
Hi, I have got a problem. I wrote a code for prefix to infix. It works, but I need improve it so on input there will be only necessary parentheses. Can u help me? Here is the code: import re a = input() class Calculator: def __init__ (self): self.stack = [] def push (self, p):

More efficient/elegant branching

2019-12-09 Thread Musbur
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 two alternati

Re: More efficient/elegant branching

2019-12-09 Thread Chris Angelico
On Mon, Dec 9, 2019 at 10:36 PM 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 py

Re: More efficient/elegant branching

2019-12-09 Thread Peter Otten
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

Re: Regarding problem in python 3.8.0 installation

2019-12-09 Thread Rhodri James
On 08/12/2019 18:08, alok singh wrote: Sir, My system is windows 7 SP1 32-bit . after installing python in my system,when i try to launch it using command prompt then a message is shown. I am attaching a screenshot of the following. kindly look seriously into my problem and tell me the solution.

Re: More efficient/elegant branching

2019-12-09 Thread Tim Chase
On 2019-12-09 12:27, Musbur wrote: > def branch1(a, b, z): > """Inelegant, unwieldy, and pylint complains > about too many branches""" > if a > 4 and b == 0: > result = "first" > elif len(z) < 2: > result = "second" > elif b + a == 10: > result =

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

2019-12-09 Thread Python
Le 09/12/2019 à 09:15, R.Wieser a écrit : ... You'll find that *any* form of import executes all the top-level code. Thats certainly something I did not expect. How could it be otherwise? Consider a module defining two classes: Parent and Child, Child inheriting from Parent. if you do "from

Re: python 2 to 3 converter

2019-12-09 Thread songbird
Greg Ewing wrote: > On 8/12/19 9:30 pm, songbird wrote: >>wouldn't it make more sense to just go back and fix the >> converter program than to have to manually convert all this >> python2 code? > > Anything that isn't already fixed by 2to3 is probably > somewhere between very difficult and impo

Re: python 2 to 3 converter

2019-12-09 Thread songbird
jf...@ms4.hinet.net wrote: ... > Even string is hard to be handled by the AI:-) > > Quoted from https://portingguide.readthedocs.io/en/latest/strings.html > " ... This means that you need to go through the entire codebase, and decide > which value is what type. Unfortunately, this process generall

Re: python 2 to 3 converter

2019-12-09 Thread Chris Angelico
On Tue, Dec 10, 2019 at 5:05 AM songbird wrote: > > jf...@ms4.hinet.net wrote: > ... > > Even string is hard to be handled by the AI:-) > > > > Quoted from https://portingguide.readthedocs.io/en/latest/strings.html > > " ... This means that you need to go through the entire codebase, and > > deci

Re: python 2 to 3 converter

2019-12-09 Thread Rob Gaddi
On 12/9/19 9:55 AM, songbird wrote: jf...@ms4.hinet.net wrote: ... Even string is hard to be handled by the AI:-) Quoted from https://portingguide.readthedocs.io/en/latest/strings.html " ... This means that you need to go through the entire codebase, and decide which value is what type. Unfort

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

2019-12-09 Thread R.Wieser
Dennis, > "del instance" only deletes the NAME. [snip] Yep, I already assumed that that would happen. Just wanted to keep it simple. > "instance" xyz does not shadow "class" xyz... instead, the name "xyz" > only exists in the binding to the instance. That is what I tried to say: the name-bind

Re: python 3 prefix to infix without too many parethesis

2019-12-09 Thread Terry Reedy
On 12/9/2019 6:21 AM, jezka...@gmail.com wrote: Hi, I have got a problem. Is this homework? I wrote a code for prefix to infix. It works, but I need improve it so on input there will be only necessary parentheses. Define 'necessary'; give multiple input/output examples. Put them in a test f

Re: python 3 prefix to infix without too many parethesis

2019-12-09 Thread DL Neil via Python-list
On 10/12/19 8:40 AM, Terry Reedy wrote: On 12/9/2019 6:21 AM, jezka...@gmail.com wrote: Hi, I have got a problem. Is this homework? Same question - that way we know that our task is to help you learn to code in Python, cf a problem with Python itself... Similarly, you may like to know th

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

2019-12-09 Thread DL Neil via Python-list
It might be becoming 'long', but this discussion contains much of profit to many people! Us 'silver surfers' do need to periodically question those beliefs we hold as 'tenets' of ComSc. Amongst them is RAM (or "core"!) conservation. It remains a virtue somewhat, but at the same time, storage

Re: python 2 to 3 converter

2019-12-09 Thread songbird
Rob Gaddi wrote: ... > And how exactly do you propose to determine whether the constant I've > enclosed > in quotation marks in Python2 represents "text" or "binary data"? Not all > text > is words; think of SQL queries. And some words are binary data, think SCPI > commands being sent to a s

Randomizing Strings In A Microservices World

2019-12-09 Thread Tim Daneliuk
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 ten digits guaranteed to be unique

Re: python 2 to 3 converter

2019-12-09 Thread songbird
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.b64decode(code) > sock.write("""GET /foo HTTP/1.0 > Authentication: Demo %s/%s > > """ % (name, code)) > mat

Re: python 2 to 3 converter

2019-12-09 Thread Chris Angelico
On Tue, Dec 10, 2019 at 12:11 PM songbird wrote: > > Rob Gaddi wrote: > ... > > And how exactly do you propose to determine whether the constant I've > > enclosed > > in quotation marks in Python2 represents "text" or "binary data"? Not all > > text > > is words; think of SQL queries. And some

Re: python 2 to 3 converter

2019-12-09 Thread Chris Angelico
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.b64decode(code) > > sock.write("""GET

Re: More efficient/elegant branching

2019-12-09 Thread DL Neil via Python-list
I agree with you, so I'm going to ignore def branch2(a, b, z): and def branch3(a, b, z) because they appear too contrived - and I guess that's fair, in that you've contrived to satisfy pylint. Question: are there other people/factors who/which should be regarded as more important than the lint

Testing a TestPyPI package with dependencies

2019-12-09 Thread Akkana Peck
I'm a novice packager, trying to test a package I built and uploaded to TestPyPI. It has dependencies and I want to make sure my setup.py works before uploading to the real PyPI. https://packaging.python.org/guides/using-testpypi/ says that if a package has dependencies, to use this command to get

Re: Randomizing Strings In A Microservices World

2019-12-09 Thread Tim Delaney
On Tue, 10 Dec 2019 at 12:12, Tim Daneliuk wrote: > - Each of these services needs to produce a string of ten digits > guaranteed to be unique > on a per service instance basis AND to not collide for - oh, let's say - > forever :)s > > Can anyone suggest a randomization method that might achiev

Re: Randomizing Strings In A Microservices World

2019-12-09 Thread Tim Daneliuk
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 digit range into 1000 pieces, so 0

Re: Randomizing Strings In A Microservices World

2019-12-09 Thread Tim Daneliuk
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 service instance basis AND to not collide for - oh, let's say

Re: python 2 to 3 converter

2019-12-09 Thread songbird
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 you can write something which might get some of the easy cases done then at least you're sav

Re: python 2 to 3 converter

2019-12-09 Thread Chris Angelico
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 you can > write something whic