Re: python read line by line and keep indent

2020-04-17 Thread Souvik Dutta
You can actually read and write in a file simultaneously. Just replace "r" with "w+" if the file has not been previously made or use "r+" is the file has already been made. Souvik flutter dev On Sat, Apr 18, 2020, 4:45 AM wrote: > Hi; > > I am reading a Python file and find an specific line, re

Re: python read line by line and keep indent

2020-04-17 Thread DL Neil via Python-list
On 18/04/20 11:10 AM, hnasr9...@gmail.com wrote: I am reading a Python file and find an specific line, replace a text and then write back to the file. When I check back the file, I am getting indent error. How to fix this issue. Please make it easier for us (volunteers giving-up our free ti

Re: python read line by line and keep indent

2020-04-17 Thread Greg Ewing
On 18/04/20 11:10 am, hnasr9...@gmail.com wrote: Hi; I am reading a Python file and find an specific line, replace a text and then write back to the file. When I check back the file, I am getting indent error. It looks like your script is stripping out all the indentation when it writes the

Re: What variable type is returned from Open()?

2020-04-17 Thread DL Neil via Python-list
On 18/04/20 4:18 AM, dcwhat...@gmail.com wrote: Yes,personal preference is definitely a factor and a bias, in these matters. But aside from trying to make it easier for future A.I. to figure out what the heck we humans were doing, it also makes a difference in how the IDE interpets the code.

python read line by line and keep indent

2020-04-17 Thread hnasr9999
Hi; I am reading a Python file and find an specific line, replace a text and then write back to the file. When I check back the file, I am getting indent error. How to fix this issue. reading_file = open("myfile.py", "r") new_file_content = "" for line in reading_file:

Re: What variable type is returned from Open()?

2020-04-17 Thread Rhodri James
On 17/04/2020 22:27, dcwhat...@gmail.com wrote: On Friday, April 17, 2020 at 2:11:17 PM UTC-4, Rhodri James wrote: And people wonder why I stick to gdb when at all possible :-) Never worked with it. Is it a debugger for compiled code, i.e. it steps through the executable while displaying the

Re: What variable type is returned from Open()?

2020-04-17 Thread dcwhatthe
On Friday, April 17, 2020 at 2:11:17 PM UTC-4, Rhodri James wrote: > On 17/04/2020 17:18, dc wrote: > > Maybe it isn't true for all IDE's or all languages. (I know SOMEONE > > will interject here, to argue for the sake of arguing). But when I > > worked with Groovy in Intellij about 5 years ago, th

Re: Why generate POP_TOP after an "import from?"

2020-04-17 Thread Alexandre Brault
On 2020-04-17 2:22 p.m., Adam Preble wrote: Given this in Python 3.6.8: from dis import dis def import_from_test(): from sys import path dis(import_from_test) 2 0 LOAD_CONST 1 (0) 2 LOAD_CONST 2 (('path',)) 4 IMPORT_N

Re: Why generate POP_TOP after an "import from?"

2020-04-17 Thread Chris Angelico
On Sat, Apr 18, 2020 at 4:26 AM Adam Preble wrote: > > Given this in Python 3.6.8: > > from dis import dis > > def import_from_test(): >from sys import path > > >>> dis(import_from_test) > 2 0 LOAD_CONST 1 (0) > 2 LOAD_CONST 2 (('path',)) >

Re: Why generate POP_TOP after an "import from?"

2020-04-17 Thread Adam Preble
On Friday, April 17, 2020 at 1:22:18 PM UTC-5, Adam Preble wrote: > At this point, my conceptual stack is empty. If I POP_TOP then I have nothing > to pop and the world would end. Yet, it doesn't. What am I missing? Check out this guy replying to himself 10 minutes later. I guess IMPORT_FROM pu

Why generate POP_TOP after an "import from?"

2020-04-17 Thread Adam Preble
Given this in Python 3.6.8: from dis import dis def import_from_test(): from sys import path >>> dis(import_from_test) 2 0 LOAD_CONST 1 (0) 2 LOAD_CONST 2 (('path',)) 4 IMPORT_NAME 0 (sys) 6 IMPORT_

Re: What variable type is returned from Open()?

2020-04-17 Thread Rhodri James
On 17/04/2020 17:18, dcwhat...@gmail.com wrote: Maybe it isn't true for all IDE's or all languages. (I know SOMEONE will interject here, to argue for the sake of arguing). But when I worked with Groovy in Intellij about 5 years ago, there were times when the IDE was confused, during a debugging s

Re: Floating point issue

2020-04-17 Thread Cousin Stanley
Aakash Jana wrote: > I am calculating couple of ratios and according to the problem > there must be a 6 decimal precision. > > But when I print the result I only get one 0. > > E.g:- 2 / 5 = 0.40 but I am only getting 0.4 You might try using a ' '.format string ratios = { '1/8'

Re: What variable type is returned from Open()?

2020-04-17 Thread dcwhatthe
Yes,personal preference is definitely a factor and a bias, in these matters. But aside from trying to make it easier for future A.I. to figure out what the heck we humans were doing, it also makes a difference in how the IDE interpets the code. Maybe it isn't true for all IDE's or all languages

Re: Tkinter date entry with boxes

2020-04-17 Thread Souvik Dutta
You can use 12 if statements to check for the correctness of dates. For the year you would only be needed to check the type. To insert "/" you should return your own data type. That is make a class that returns a string of the format "dd/mm/yy" using parameters of date, month and year. As for not g

Tkinter date entry with boxes

2020-04-17 Thread annunci . pervendite
Hi, I'm creating a registration form and I found this script that I'd like to use to have my participants to input their birth date: import tkinter as tk class DateEntry(tk.Frame): def __init__(self, parent, **kwargs): years = kwargs.pop('years', (1900, )) super().__init

Re: Floating point problem

2020-04-17 Thread ast
Le 17/04/2020 à 13:40, Aakash Jana a écrit : I am running python 3.8 only but my issue is I need more zeroes after my result. I want 2/5 = 0.40 But I am only getting 0.4 f"{2/5:.6f}" '0.40' -- https://mail.python.org/mailman/listinfo/python-list

Scientific Software Developers | Job positions at CMCC Foundation, Italy

2020-04-17 Thread CMCC Info
/Please, feel free to circulate //to anyone you think may be interested./// -- Open positions at CMCC Foundation: Scientific Software Developer (Job Opening Code: 10712) Deadline: 30/04/2020 The location is CMCC Headquarters in Lec

Re: Floating point problem

2020-04-17 Thread Peter Otten
Aakash Jana wrote: > I am running python 3.8 only but my issue is I need more zeroes after my > result. > I want 2/5 = 0.40 > But I am only getting 0.4 This is either a formatting problem >>> value = 0.4 >>> print(f"{value:10.6f}") 0.40 or -- if you want to *calculate* with a fixed pr

Re: Floating point problem

2020-04-17 Thread Rhodri James
On 17/04/2020 12:40, Aakash Jana wrote: I am running python 3.8 only but my issue is I need more zeroes after my result. I want 2/5 = 0.40 But I am only getting 0.4 When you just print or display a floating point number, Python only uses as many digits as needed if the answer happens to be

Re: Floating point problem

2020-04-17 Thread Aakash Jana
I am running python 3.8 only but my issue is I need more zeroes after my result. I want 2/5 = 0.40 But I am only getting 0.4 On Fri, 17 Apr 2020, 5:08 pm Peter Otten <__pete...@web.de wrote: > Aakash Jana wrote: > > > I am calculating couple of ratios and according to the problem there must >

Re: Floating point problem

2020-04-17 Thread Peter Otten
Aakash Jana wrote: > I am calculating couple of ratios and according to the problem there must > be a 6 decimal precision. But when I print the result I only get one 0. > E.g:- 2 / 5 = 0.40 but I am only getting 0.4 Make sure that you are using Python 3, not Python 2 or use at least one floa

Floating point problem

2020-04-17 Thread Aakash Jana
I am calculating couple of ratios and according to the problem there must be a 6 decimal precision. But when I print the result I only get one 0. E.g:- 2 / 5 = 0.40 but I am only getting 0.4 -- https://mail.python.org/mailman/listinfo/python-list

Floating point issue

2020-04-17 Thread Aakash Jana
I am calculating couple of ratios and according to the problem there must be a 6 decimal precision. But when I print the result I only get one 0. E.g:- 2 / 5 = 0.40 but I am only getting 0.4 On Fri, 17 Apr 2020, 4:08 am Muneer Malla Dear All > hope you all are fine and doing good in these cri

Re: Regarding Python

2020-04-17 Thread Bev In TX
Bev > On Apr 16, 2020, at 5:36 PM, Muneer Malla wrote: > ... potion snipped ... > I need to install python 3.7 or above version, however the previously > installed version is python2.7 > I tried many commands > sudo apt-get install python3.8 > after running the command it fails What failed?