Re: save files

2019-04-22 Thread Calvin Spealman
Can you give some more information about the problem and your setup, including: - What OS and OS version are you running? - What is the Python script you are trying to write? - Do you get the same behavior if you try to save an empty file? - Can you confirm you are talking about Idle, the editor t

Re: Function to determine list max without itertools

2019-04-22 Thread Grant Edwards
On 2019-04-20, Michael Torrie wrote: > On 04/19/2019 04:01 AM, Sayth Renshaw wrote: >> def max_try(listarg): >> myMax = listarg[0] >> try: >> for item in listarg: >> if item > myMax: >> myMax = item >> except TypeError: >> print(f'Only number

Re: Is this a "gotcha" in Python?

2019-04-22 Thread Grant Edwards
On 2019-04-20, Chris Angelico wrote: > In this specific case, I actually think that "l" is a bad choice, but > not because it's a single letter - more because there is a very strong > convention of using "i" for a loop iterator, and the lowercase "l" is > confusingly similar. Also, in some fonts

Re: Error while installing python for Windows 7 32bit

2019-04-22 Thread MRAB
On 2019-04-22 06:29, Bhargava Gurumanchi wrote: >  Hi Good morning > i am getting this type of error while installing python for windows 7 32bit > in my Laptop. please do needfull ASAP. > Please find the attachment below > Your PC is missing the Visual C++ Redistributable file api-ms-win-crt-ru

Re: Function to determine list max without itertools

2019-04-22 Thread Chris Angelico
On Tue, Apr 23, 2019 at 12:45 AM Grant Edwards wrote: > At the very top level _sometimes_ you want to have one single, global, > try/except to catch all exceptions and handle the nofication and exit > in a non-default way. For example: in a GUI application, it's > possible that nobody will see an

Re: Importing module from another subdirectory

2019-04-22 Thread Rich Shepard
On Thu, 18 Apr 2019, dieter wrote: I see two options for you: 1. put your scripts directly into "bustrac" (rather than a subdirectory) There are too many files; the directory is very cluttered. 2. extend "sys.path" in your scripts to contain the "bustrac" folder (before you try to import in

Re: save files

2019-04-22 Thread Terry Reedy
On 4/22/2019 7:51 AM, Calvin Spealman wrote: Can you give some more information about the problem and your setup, including: - What OS and OS version are you running? - What is the Python script you are trying to write? Specifically, what name are you trying to give to the file. If you use a

Re: Is this a "gotcha" in Python?

2019-04-22 Thread DL Neil
Isn't there an argument that in this context, using the single letter "l" as a variable name is 'lazy'? That the "l" could be used in different contexts (per OP). That it conveys no meaning as to the variable's purpose? In this specific case, I actually think that "l" is a bad choice, but not be

Re: Is this a "gotcha" in Python?

2019-04-22 Thread Chris Angelico
On Tue, Apr 23, 2019 at 6:18 AM DL Neil wrote: > Yet, because "i" (or "n", "a", or "x"...) does not convey usage-meaning > - other than, "I am a place-holder"! So, aren't we back to "_"? Not quite. The single-letter names mean "I am an iterator/index/etc", but "_" means "I am not used anywhere".

Re: Is this a "gotcha" in Python?

2019-04-22 Thread Skip Montanaro
> Not quite. The single-letter names mean "I am an iterator/index/etc", > but "_" means "I am not used anywhere". Small addendum to this. pyflakes (at least in my experience) doesn't interpret "_" as a variable name or prefix to a local variable as "unused". Skip -- https://mail.python.org/mailm

Re: Is this a "gotcha" in Python?

2019-04-22 Thread Chris Angelico
On Tue, Apr 23, 2019 at 7:28 AM Skip Montanaro wrote: > > > Not quite. The single-letter names mean "I am an iterator/index/etc", > > but "_" means "I am not used anywhere". > > Small addendum to this. pyflakes (at least in my experience) doesn't > interpret "_" as a variable name or prefix to a l

Re: Is this a "gotcha" in Python?

2019-04-22 Thread Skip Montanaro
> Interesting. So it would flag this code? > > for _ in range(5): next(f) # skip five lines As of at least recent versions (I have 2.1.1 in my Conda install at home) It seems to properly accept "_" as a variable name, even when not used. It also seems to accept any variable name as a loop index. H

Re: Is this a "gotcha" in Python?

2019-04-22 Thread Chris Angelico
On Tue, Apr 23, 2019 at 8:21 AM Skip Montanaro wrote: > > > Interesting. So it would flag this code? > > > > for _ in range(5): next(f) # skip five lines > > As of at least recent versions (I have 2.1.1 in my Conda install at > home) It seems to properly accept "_" as a variable name, even when >

Re: Is this a "gotcha" in Python?

2019-04-22 Thread Skip Montanaro
> > By "accepted" you mean that it isn't complaining? Accepted, as in it provokes no complaints. What kind of flagging? Unused. S -- https://mail.python.org/mailman/listinfo/python-list

Re: Is this a "gotcha" in Python?

2019-04-22 Thread Chris Angelico
On Tue, Apr 23, 2019 at 8:41 AM Skip Montanaro wrote: >> >> By "accepted" you mean that it isn't complaining? > > Accepted, as in it provokes no complaints. > >> What kind of flagging? > > Unused. > Cool, thanks. ChrisA -- https://mail.python.org/mailman/listinfo/python-list

need help understanding: converting text to binary

2019-04-22 Thread Eli the Bearded
Here's some code I wrote today: -- cut here 8< -- HEXCHARS = (b'0', b'1', b'2', b'3', b'4', b'5', b'6', b'7', b'8', b'9', b'A', b'B', b'C', b'D', b'E', b'F', b'a', b'b', b'c', b'd', b'e', b'f') # decode a single hex digit def hord(c): c = ord(c) if c >= or

Re: need help understanding: converting text to binary

2019-04-22 Thread Chris Angelico
On Tue, Apr 23, 2019 at 10:58 AM Eli the Bearded <*@eli.users.panix.com> wrote: > > Here's some code I wrote today: > > -- cut here 8< -- > HEXCHARS = (b'0', b'1', b'2', b'3', b'4', b'5', b'6', b'7', b'8', b'9', > b'A', b'B', b'C', b'D', b'E', b'F', > b'a', b'b', b'c

Re: need help understanding: converting text to binary

2019-04-22 Thread MRAB
On 2019-04-23 01:54, Eli the Bearded wrote: Here's some code I wrote today: [snip] # decode a single hex digit def hord(c): c = ord(c) if c >= ord(b'a'): return c - ord(b'a') + 10 elif c >= ord(b'A'): There's a bug here: return c - ord(b'a') + 10 It shou

Re: Questions on Instance methods

2019-04-22 Thread dieter
Arup Rakshit writes: > ... > As you saw from documentation link, those are just words kind of spec. > Which source you recommend to read which explains these concepts more with > example codes. I cannot help you much with this -- I am much turned towards spec[ification] like documentation and ha

Re: Importing module from another subdirectory

2019-04-22 Thread dieter
Rich Shepard writes: > On Thu, 18 Apr 2019, dieter wrote: > ... >> 2. extend "sys.path" in your scripts to contain the "bustrac" folder >> (before you try to import infrastructure modules/packages) > > I read the docs for sys and site and have insufficient experience with them > to know how best t