python unistallation

2020-10-17 Thread Aniruddha Ghosh
I by chance deleted the python 3.9 files from my file explorer and now while 
unistalling it is showing fatal error . I cant uninstall it . please anyone 
help.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python unistallation

2020-10-17 Thread MRAB

On 2020-10-17 18:39, Aniruddha Ghosh wrote:

I by chance deleted the python 3.9 files from my file explorer and now while 
unistalling it is showing fatal error . I cant uninstall it . please anyone 
help.


Have you tried using the installer to repair it first?
--
https://mail.python.org/mailman/listinfo/python-list


Subprocess Connection Error

2020-10-17 Thread Dave Dungan via Python-list
Hello,

I bought a book called Coding for Beginners to learn how to code using Python. 
The first few exercises went fine. When I got to the page called Recognizing 
types and did the exercise and saved it and tried to run the module it comes up 
with a Subprocess Connection Error. It says, "IDLE's subprocess didn't make 
connection. See the Start up failure section of the IDLE doc, online at 
https://docs.python.org/3/library/idle.html#startup-failure."; I went there and 
it said to try uninstalling python and then reinstalling it. I did this and it 
did the same thing again. It also said something about it is because of the 
antivirus software. I tried installing python on a different computer and it 
happened at the exact same place in the exercises in the book. I am far from 
being a computer whiz, just thought it would be fun to learn some simple 
coding. Any help would be appreciated. One more thing, the book says to save it 
as "types.py". 

Thank you,
Dave Dungan
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Subprocess Connection Error

2020-10-17 Thread Dan Stromberg
Does this help?

https://stackoverflow.com/questions/29567051/python-error-idles-subprocess-didnt-make-connection-either-idle-cant-start


On Sat, Oct 17, 2020 at 12:44 PM Dave Dungan via Python-list <
python-list@python.org> wrote:

> Hello,
>
> I bought a book called Coding for Beginners to learn how to code using
> Python. The first few exercises went fine. When I got to the page called
> Recognizing types and did the exercise and saved it and tried to run the
> module it comes up with a Subprocess Connection Error. It says, "IDLE's
> subprocess didn't make connection. See the Start up failure section of the
> IDLE doc, online at
> https://docs.python.org/3/library/idle.html#startup-failure."; I went
> there and it said to try uninstalling python and then reinstalling it. I
> did this and it did the same thing again. It also said something about it
> is because of the antivirus software. I tried installing python on a
> different computer and it happened at the exact same place in the exercises
> in the book. I am far from being a computer whiz, just thought it would be
> fun to learn some simple coding. Any help would be appreciated. One more
> thing, the book says to save it as "types.py".
>
> Thank you,
> Dave Dungan
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Simple question - end a raw string with a single backslash ?

2020-10-17 Thread Mladen Gogala via Python-list
On Thu, 15 Oct 2020 21:30:15 +, Stefan Ram wrote:

> Tony Flury  writes:
>> >>> a = r'end' + chr(92)
> 
>   Or maybe,
> 
> a = r'''
> end\
> '''[ 1: -1 ]
> 
>   ? The first and the last line are messy, but in the middle,
>   the intended string is clearly visible.


You can use perl module for python. It is installable by pip.
Perl has no problems with handling backslashes.

https://pypi.org/project/perl/

What you need is something like this:

mgogala@umajor:~$ perl -e '$a="abcd";$a=~s/$/\\/; print "$a\n";'
abcd\

Python has a problem with backslashes:

Python 3.8.5 (default, Jul 28 2020, 12:59:40) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> a="abcd"
>>> b=re.sub('$',chr(28),a)
>>> b
'abcd\x1c'

>>> b=re.sub('$',chr(0x41),a)
>>> b
'abcdA'
>>> b=re.sub('$','Z',a)
>>> b
'abcdZ'
>>> b=re.sub('$',chr(0x1C),a)
>>> b
'abcd\x1c'
>>> 

Any other character is shown as it should be, except backslash.





-- 
Mladen Gogala
Database Consultant
http://mgogala.byethost5.com
-- 
https://mail.python.org/mailman/listinfo/python-list


File Name issue

2020-10-17 Thread Steve
The line:
with open("HOURLYLOG.txt", 'r') as infile:
works but, when I rename the file, the line:
with open("HOURLY-LOG.txt", 'r') as infile:
does not.  The complaint is: Cannot Assign to operator

However, I have:
BPM_O2s=open("BPM-O2-Readings.txt","a")
And it works.

At first, I thought the issue was due to having the - in the filename.

Is there a fix or explanation for this?
Steve




FootNote:
Would it be ironic if Popeye's chicken was fried in Olive Oil?


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Subprocess Connection Error

2020-10-17 Thread Terry Reedy

On 10/17/2020 5:00 PM, Dan Stromberg wrote:

Does this help?

https://stackoverflow.com/questions/29567051/python-error-idles-subprocess-didnt-make-connection-either-idle-cant-start


I believe I included every legitimate answer on stackoverflow, including 
that post, in the doc section linked below.



On Sat, Oct 17, 2020 at 12:44 PM Dave Dungan via Python-list <
python-list@python.org> wrote:


Hello,

I bought a book called Coding for Beginners to learn how to code using
Python. The first few exercises went fine. When I got to the page called
Recognizing types and did the exercise and saved it and tried to run the
module it comes up with a Subprocess Connection Error. It says, "IDLE's
subprocess didn't make connection. See the Start up failure section of the
IDLE doc, online at
https://docs.python.org/3/library/idle.html#startup-failure."; I went
there and it said to try uninstalling python and then reinstalling it.


It actually says, for 3.8+,

[some things to try]

Python installation issues occasionally stop IDLE: multiple versions can 
clash, or a single installation might need admin access. If one [cannot] 
undo the clash, or cannot or does not want to run as admin, it might be 
easiest to completely remove Python and start over.


[more things to try].

I should fix the type and move this down to the bottom as a last resort.



I did this and it did the same thing again. It also said something about it
is because of the antivirus software. I tried installing python on a
different computer and it happened at the exact same place in the exercises
in the book. I am far from being a computer whiz, just thought it would be
fun to learn some simple coding. Any help would be appreciated. One more
thing, the book says to save it as "types.py".


I'm glad you added that.  Naming files after stdlib modules is a bad 
idea and is covered by the the first item in the doc.


"A common cause of failure is a user-written file with the same name as 
a standard library module, such as random.py and tkinter.py. When such a 
file is located in the same directory as a file that is about to be run, 
IDLE cannot import the stdlib file. The current fix is to rename the 
user file."


types.py is a standard library file, so try a different name and see if 
this is the problem.


--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list


Re: File Name issue

2020-10-17 Thread Mladen Gogala via Python-list
On Sat, 17 Oct 2020 18:12:16 -0400, Steve wrote:

> with open("HOURLYLOG.txt", 'r') as infile:
> works but, when I rename the file, the line:
> with open("HOURLY-LOG.txt", 'r') as infile:
> does not.  The complaint is: Cannot Assign to operator

Try this:

with open("HOURLY\-LOG.txt", 'r') as infile:


-- 
Mladen Gogala
Database Consultant
http://mgogala.byethost5.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: File Name issue

2020-10-17 Thread MRAB

On 2020-10-17 23:12, Steve wrote:

The line:
with open("HOURLYLOG.txt", 'r') as infile:
works but, when I rename the file, the line:
with open("HOURLY-LOG.txt", 'r') as infile:
does not.  The complaint is: Cannot Assign to operator

However, I have:
BPM_O2s=open("BPM-O2-Readings.txt","a")
And it works.

At first, I thought the issue was due to having the - in the filename.

Is there a fix or explanation for this?
Steve


I see nothing wrong in those lines as written.

Try reducing it to the smallest complete example that shows the problem.
--
https://mail.python.org/mailman/listinfo/python-list


Re: File Name issue

2020-10-17 Thread Mladen Gogala via Python-list
On Sat, 17 Oct 2020 22:51:11 +, Mladen Gogala wrote:

> On Sat, 17 Oct 2020 18:12:16 -0400, Steve wrote:
> 
>> with open("HOURLYLOG.txt", 'r') as infile:
>> works but, when I rename the file, the line:
>> with open("HOURLY-LOG.txt", 'r') as infile:
>> does not.  The complaint is: Cannot Assign to operator
> 
> Try this:
> 
> with open("HOURLY\-LOG.txt", 'r') as infile:

BTW, I used this
cp /var/log/syslog ./in-file.log

#!/usr/bin/env python3
import io
with open("in-file.log","r") as infile:
for line in infile:
print(line)

I got a different error:



Traceback (most recent call last):
  File "./test.py", line 4, in 
for line in infile:
  File "/usr/lib/python3.8/codecs.py", line 322, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd8 in position 897: 
invalid continuation byte

However, that doesn't have anything to do with your problem. 

-- 
Mladen Gogala
Database Consultant
http://mgogala.byethost5.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Subprocess Connection Error

2020-10-17 Thread Greg Ewing

On 17/10/20 4:04 pm, Dave Dungan wrote:

One more thing, the book says to save it as "types.py".


Which is probably a bad thing to do, because there is a built-in
module called "types" that this will shadow. If IDLE happens to
use that module, bad things could happen.

Have you tried using a different name, such as "my_types.py"?

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list


Re: File Name issue

2020-10-17 Thread shrimp_banana

On 10/17/20 4:12 PM, Steve wrote:
> The line:
> with open("HOURLYLOG.txt", 'r') as infile:
> works but, when I rename the file, the line:
> with open("HOURLY-LOG.txt", 'r') as infile:
> does not.  The complaint is: Cannot Assign to operator
>
> However, I have:
> BPM_O2s=open("BPM-O2-Readings.txt","a")
> And it works.
>
> At first, I thought the issue was due to having the - in the filename.
>
> Is there a fix or explanation for this?
> Steve

I am unsure if this will help but you could try putting an r in front of 
the quotes to make it take raw data only.

ie.

with open(r"HOURLY-LOG.txt", 'r') as infile
--
https://mail.python.org/mailman/listinfo/python-list


Re: Embedding version in command-line program

2020-10-17 Thread Tony Flury via Python-list



On 07/10/2020 12:06, Loris Bennett wrote:

Hi,

I have written a program, which I can run on the command-line thus

   mypyprog --version

and the get the version, which is currently derived from a variable in
the main module file.

However, I also have the version in an __init__.py file and in a
pyproject.toml (as I'm using poetry, otherwise this would be in
setup.py).

What's the best way of reducing these three places where the version is
defined to a single one?

Cheers,

Loris
My top level package always has a version.py file which defines 
__version__, __author__ etc. I am not sure if that helps in your .toml 
file though - is it executed or does it have the ability to read files 
when it creates the distributable ?

--
https://mail.python.org/mailman/listinfo/python-list


Re: MERGE SQL in cx_Oracle executemany

2020-10-17 Thread Jason Friedman
>
> I'm looking to insert values into an oracle table (my_table) using the
> query below. The insert query works when the PROJECT is not NULL/empty
> (""). However when PROJECT is an empty string(''), the query creates a new
> duplicate row every time the code is executed (with project value
> populating as null). I would like to modify my query so a new row is not
> inserted when all column values are matched (including when project code is
> null).
> I'm guessing I would need to include a "when matched" statement, but not
> too sure on how to get this going. Would appreciate help with this, thanks.
>
> ```
> con = cx_Oracle.connect(connstr)
> cur = con.cursor()
> rows = [tuple(x) for x in df.values]
> cur3.executemany('''merge into my_table
> using dual
> on (YEAR = :1 and QUARTER = :2 and CODE = :3 and AMOUNT = :4 and DATE = :5
> and COMMENTS = :6 and PROJECT = :7)
> when not matched then insert values (:1, :2, :3, :4, :5, :6, :7)
> ''',rows)
> con.commit()
> cur.close()
> con.close()
>

Perhaps the issue is that NULL is not equal to anything. Oracle provides
the IS NULL function to determine if a value is NULL.

Note also you define "cur" but executemany with "cur3".

And is "rows = [tuple(x) for x in df.values]" what you want? Print it.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: MERGE SQL in cx_Oracle executemany

2020-10-17 Thread Mladen Gogala via Python-list
On Sat, 17 Oct 2020 21:23:40 -0600, Jason Friedman wrote:


>> I'm looking to insert values into an oracle table (my_table) using the
>> query below. The insert query works when the PROJECT is not NULL/empty
>> (""). However when PROJECT is an empty string(''), the query creates a
>> new duplicate row every time the code is executed (with project value
>> populating as null). I would like to modify my query so a new row is
>> not inserted when all column values are matched (including when project
>> code is null).
>> I'm guessing I would need to include a "when matched" statement, but
>> not too sure on how to get this going. Would appreciate help with this,
>> thanks.
>>
>> ```
>> con = cx_Oracle.connect(connstr)
>> cur = con.cursor()
>> rows = [tuple(x) for x in df.values]
>> cur3.executemany('''merge into my_table using dual on (YEAR = :1 and
>> QUARTER = :2 and CODE = :3 and AMOUNT = :4 and DATE = :5 and COMMENTS =
>> :6 and PROJECT = :7)
>> when not matched then insert values (:1, :2, :3, :4, :5, :6, :7)
>> ''',rows)
>> con.commit()
>> cur.close()
>> con.close()
>>
>>
> Perhaps the issue is that NULL is not equal to anything. Oracle provides
> the IS NULL function to determine if a value is NULL.
> 
> Note also you define "cur" but executemany with "cur3".
> 
> And is "rows = [tuple(x) for x in df.values]" what you want? Print it.

Obviously, the "PROJECT" column is causing the issue. NULL in Oracle 
database is never equal to anything. If :7 is NULL, your "not matched" 
condition is satisfied and your MERGE statement will insert a new and 
exciting row. That has nothing to do with Python. The only solution is
"ALTER TABLE my_table modify(project not null)" or 
"ALTER TABLE my_table add constraint project_nn check(project is not null)"  I

If you already have NULL values in the PROJECT column than use "add constraint" 
with NOVALIDATE option. Other than that, allowing NULL values in key columns is
a sign of bad design. Namely, Oracle cannot index NULL columns, so PROJECT IS 
NULL
predicate cannot be resolved by an index.

-- 
Mladen Gogala
Database Consultant
http://mgogala.byethost5.com
-- 
https://mail.python.org/mailman/listinfo/python-list