Syntax question

2020-08-16 Thread Klaus Jantzen

Hi,

the other day I came across the book "Classic Computer Science Problems 
in Python" by David Kopec.


The function definitions in the examples  like

=
def fib2(n: int) -> int:
    if n < 2:  # base case
    return n
    return fib2(n - 2) + fib2(n - 1)  # recursive case


if __name__ == "__main__":
    print(fib2(5))
    print(fib2(10))

=

use a syntax that I have never seen on this list or in other publications.

My questions:

Is that new?

Is is 'recommended' to use this is the future?

I can only see a certain advantage of using this type of function 
definition in resp. to the documentation, as it does not provide an 
automatic check of the type of the argument(s) or of the result as in Java.


--

K.D.J.

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


[SOLVED] Re: Installing Python 3.8.3 with tkinter

2020-07-24 Thread Klaus Jantzen

On 7/22/20 12:20 PM, Klaus Jantzen wrote:

Hi,

Trying to install Python 3.8.3 with tkinter I run configure with the 
following options


./configure --enable-optimizations --with-ssl-default-suites=openssl 
--with-openssl=/usr/local --enable-loadable-sqlite-extensions 
--with-pydebug --with-tcltk-libs='-L/opt/ActiveTcl-8.6/lib/tcl8.6' 
--with-tcltk-includes='-I/opt/ActiveTcl-8.6/include'


Running Python gives the following information

Python 3.8.3 (default, Jul 22 2020, 11:52:15)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
>>> import tkinter
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/local/lib/python3.8/tkinter/__init__.py", line 36, in 

    import _tkinter # If this fails your Python may not be configured 
for Tk

ModuleNotFoundError: No module named '_tkinter'
>>>

Obviously there is something wrong with my configure options.

How do that correctly?

Thanks for any help.

K.D.J.



In my post I forgot to mention that I am running PY under Debian Buster.

As suggested by Ned Deily I switched to PY 3.8.5

After some more research in the internet I found that the tcl/tk 
libraries have automaticalle been installed during the Buster installation.


For automatically including tkinter during the PY installation one needs 
also the 'tk-dev toolkit'.


With that I did not need the options 
'--with-tcltk-libs'/'--with-tcltk-includes'


After the installation of PY 3.8.5 I can import tkinter.

Thank you very much for your replies.

K.D.J.



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


Re: Installing Python 3.8.3 with tkinter

2020-07-22 Thread Klaus Jantzen

On 7/22/20 11:05 PM, Ned Deily wrote:

On 2020-07-22 06:20, Klaus Jantzen wrote:

Trying to install Python 3.8.3 with tkinter I run configure with the
following options

./configure --enable-optimizations --with-ssl-default-suites=openssl
--with-openssl=/usr/local --enable-loadable-sqlite-extensions
--with-pydebug --with-tcltk-libs='-L/opt/ActiveTcl-8.6/lib/tcl8.6'
--with-tcltk-includes='-I/opt/ActiveTcl-8.6/include'

Running Python gives the following information

[...]

How do that correctly?

Try --with-tcltk-libs='-L/opt/ActiveTcl-8.6/lib -ltcl8.6 -ltk8.6'



Thank you for your suggestion; unfortunately it did not help.

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


Installing Python 3.8.3 with tkinter

2020-07-22 Thread Klaus Jantzen

Hi,

Trying to install Python 3.8.3 with tkinter I run configure with the 
following options


./configure --enable-optimizations --with-ssl-default-suites=openssl 
--with-openssl=/usr/local --enable-loadable-sqlite-extensions 
--with-pydebug --with-tcltk-libs='-L/opt/ActiveTcl-8.6/lib/tcl8.6' 
--with-tcltk-includes='-I/opt/ActiveTcl-8.6/include'


Running Python gives the following information

Python 3.8.3 (default, Jul 22 2020, 11:52:15)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
>>> import tkinter
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/local/lib/python3.8/tkinter/__init__.py", line 36, in 
    import _tkinter # If this fails your Python may not be configured 
for Tk

ModuleNotFoundError: No module named '_tkinter'
>>>

Obviously there is something wrong with my configure options.

How do that correctly?

Thanks for any help.

K.D.J.


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


Py 3.6 tarfile

2017-09-23 Thread Klaus Jantzen
   Hi,

   if I understand the documentation of the tarfile module correctly writing

   TarfileObject.add(".../path/to/filename", recursive=False)

   means that the directory structure of the file object will not be included
   in the archive.

   In the following script only "testtext1.pdf" is stored outside a directory
   structure. The other files are always stored in a directory structure;
   using recursive=False does not have any effect.

   

   #!/usr/bin/env python3
   #
   import argparse
   import sys
   import tarfile
   import os

   arch = "Archive.tgz"
   os.unlink(arch)
   try:
   TO = tarfile.open(name=arch, mode='x:gz')  # Tarfile object
   TO.add("testtext1.pdf")
   TO.add("./testtext2.pdf")
   TO.add("./testtext3.pdf", recursive=False)
   TO.add("./files/testtext4.pdf")
   TO.add("./files/testtext5.pdf", recursive=False)
   TO.close()
   except FileExistsError as err:
   pass

   =

   Is my understanding correct or what do have to do so that the files are
   stored without any directory information?

   Thanks for any hints.

   --

   K.D.J.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Recompilation of Python3.6.x

2017-03-23 Thread Klaus Jantzen

On 03/23/2017 12:23 AM, Jon Ribbens wrote:

On 2017-03-22, Grant Edwards  wrote:

On 2017-03-22, Thomas Nyberg  wrote:

On 03/22/2017 03:22 PM, Jon Ribbens wrote:

A simple table with a list of the library names, the debian package
names, and the rpm names would provide the information in a way that
would be useful to everyone.

A _simple_ table would be useful.  However, a _simple_ table is not
possible.


I definitely agree, but it would be kind of difficult to maintain. I
mean if you supported debian and redhat (should others be
considered?),

And you would need table for each _version_ of each distribution
(libraries sometimes get combined/renamed/split).

Not really, that's why I suggested one of the fields in the table
would be the standard library name - people should always be able
to use that to find the appropriate package for their distribution
(if there is one, otherwise they'll need to compile from source).


And you would need tables showing which libraires are required for
which Python features: tkinter is optional, crypto is optional (or at
least used to be), etc.

That's a good idea - that would make the simple table have 4 columns:
name, deb, rpm, python module (or "essential").


The information must be somewhere because Python must have been compiled 
frequently and correctly for the various (important) OSs before making 
it available to the public. And I do not think that it is left up to 
"your luck" that the required packages and libraries are present.


--

K.D.J.

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


Re: Recompilation of Python3.6.x

2017-03-22 Thread Klaus Jantzen
   On 03/22/2017 06:34 PM, Thomas Nyberg wrote:

 On 03/22/2017 12:42 PM, Klaus Jantzen wrote:

   Hello,

   in order to have the Python-SQLite support available one has to
   recompile Python. For the recompiliation to succeed a number of
   'modules/libs' have to be present.

   In the internet I found the following list

   build-essential
   libz-dev
   libreadline-dev
   libncursesw5-dev
   libssl-dev
   libgdbm-dev
   libsqlite3-dev
   libbz2-dev
   liblzma-dev
   tk-dev
   libdb-dev
   libc6-dev

   zlib

   After having installed these 'modules/libs' I recompiled Python3.6.1
   and
   although the steps

   'make', 'make test', and 'make install' produced some errors the
   sqlite3-support is available.

   My question: Is this list complete or are there superfluous items?

   My suggestion: Couldn't such a list be provided in the README file?

 If you're using Ubuntu/debian, you could use `sudo apt-get build-dep
 python3.5` (might need another version depending upon what you have in
 your package manager). What that does is install the packages required
 to build the debian packages. Unless any new libraries are needed for
 3.6, you should be good.

   I did not know somenthing like this exists.

 I can't speak for the maintainers, but I don't think that providing such
 a list is super reasonable considering that there are many different OSs
 which have sometimes have slightly different library package names
 (though of course one could argue that Ubuntu/debian helps a lot of
 people).

 Cheers,
 Thomas

   With the above my suggestion is superfluous.

   Thanks a lot for the information.

   --

   K.D.J.
-- 
https://mail.python.org/mailman/listinfo/python-list


Recompilation of Python3.6.x

2017-03-22 Thread Klaus Jantzen

Hello,

in order to have the Python-SQLite support available one has to 
recompile Python. For the recompiliation to succeed a number of 
'modules/libs' have to be present.


In the internet I found the following list

build-essential
libz-dev
libreadline-dev
libncursesw5-dev
libssl-dev
libgdbm-dev
libsqlite3-dev
libbz2-dev
liblzma-dev
tk-dev
libdb-dev
libc6-dev

zlib

After having installed these 'modules/libs' I recompiled Python3.6.1 and 
although the steps


'make', 'make test', and 'make install' produced some errors the 
sqlite3-support is available.


My question: Is this list complete or are there superfluous items?

My suggestion: Couldn't such a list be provided in the README file?
--

K.D.J.

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


Re: SQLite

2016-03-06 Thread Klaus Jantzen
   On 02/22/2016 09:32 AM, Klaus Jantzen wrote:

On 02/21/2016 10:37 PM, Albert-Jan Roskam wrote:

  (Sorry for top posting)

  IIRC, you have to do
  sudo apt-get install build-essential python-dev
  ... then re-compile python

  > To: [[1]1]python-list@python.org
  > From: [[2]2]k.d.jant...@mailbox.org
  > Subject: SQLite
  > Date: Sun, 21 Feb 2016 18:11:18 +0100
  >
  > Hello,
  >
  > I have downloaded Python3.5.1 as .targz, compiled it(configure,
  make,...)
  > and it works
  > (under Debian Wheezy AMD64) up to the moment I wanted to use SQLite.
  >
  > I get the following message:
  > ===
  > jantzen@PC4:~$ python
  > Python 3.5.0 (default, Dec  2 2015, 14:16:16)
  > [GCC 4.7.2] on linux
  > Type "help", "copyright", "credits" or "license" for more information.
  > >>> import sqlite3
  > Traceback (most recent call last):
  >   File "", line 1, in 
  >   File "/usr/local/lib/python3.5/sqlite3/__init__.py", line 23, in
  > 
  >     from sqlite3.dbapi2 import *
  >   File "/usr/local/lib/python3.5/sqlite3/dbapi2.py", line 27, in
  
  >     from _sqlite3 import *
  > ImportError: No module named '_sqlite3'
  > ===
  >
  > Obviously something is missing.
  > How do I solve the problem? Where do I find this module?
  >
  > Thanks for a hint.
  > --
  >
  > K.D.J.
  > --
  > [3][3]https://mail.python.org/mailman/listinfo/python-list

Hello,

thanks for your hint.
That did it!!!

   At least on one machine!!!

--

K.D.J.

 References

Visible links
1. [4]mailto:python-list@python.org
2. [5]mailto:k.d.jant...@mailbox.org
3. [6]https://mail.python.org/mailman/listinfo/python-list

   On the second machine  (DELL E6530) I have everything in the installation
   directory (the expansion of the tarball): sqlite directory with all the
   modules.
   I ran the apt-get install as suggested above.
   I ran './configure --enable-loadable-sqlite-extensions' and find the
   appropriate entry in the
   configure.log.
   I ran 'make' and find the configure option in the Makefile.
   But when running 'make test' the sqlite test fails  with 'no _sqlite3
   module' 

   Any helpful ideas?
   Thanks.
   --

   K.D.J.

References

   Visible links
   1. mailto:1]python-list@python.org
   2. mailto:2]k.d.jant...@mailbox.org
   3. https://mail.python.org/mailman/listinfo/python-list
   4. mailto:python-list@python.org
   5. mailto:k.d.jant...@mailbox.org
   6. https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: SQLite

2016-02-22 Thread Klaus Jantzen
   On 02/22/2016 02:44 AM, Chris Angelico wrote:

 On Mon, Feb 22, 2016 at 8:37 AM, Albert-Jan Roskam
 [1] wrote:

 IIRC, you have to do
 sudo apt-get install build-essential python-dev
 ... then re-compile python

 That may well work, but it's probably easier to work this way:

 sudo apt-get build-dep python3

 That should grab all the compilation dependencies of the python3
 package, which on Wheezy is a 3.2 IIRC. The deps haven't changed since
 then AFAIK.

 When you build, you should get a summary at the end that tells you
 about any modules that couldn't be built. The most common reason for
 that is missing deps. If you still have any after running the above,
 post here and we may be able to more directly advise.

 ChrisA

   That did not work because I did not install Python 3.5. with apt-get
   but downloaded the source and compiled myself.
   Thus apt-get does not have any information about the Python 3.5
   installation.
   I got it to work following the hint by Albert-Jan Roskam.
   --

   K.D.J.

References

   Visible links
   1. mailto:sjeik_ap...@hotmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: SQLite

2016-02-22 Thread Klaus Jantzen
   On 02/21/2016 10:37 PM, Albert-Jan Roskam wrote:

 (Sorry for top posting)

 IIRC, you have to do
 sudo apt-get install build-essential python-dev
 ... then re-compile python

 > To: [1]python-list@python.org
 > From: [2]k.d.jant...@mailbox.org
 > Subject: SQLite
 > Date: Sun, 21 Feb 2016 18:11:18 +0100
 >
 > Hello,
 >
 > I have downloaded Python3.5.1 as .targz, compiled it(configure,
 make,...)
 > and it works
 > (under Debian Wheezy AMD64) up to the moment I wanted to use SQLite.
 >
 > I get the following message:
 > ===
 > jantzen@PC4:~$ python
 > Python 3.5.0 (default, Dec  2 2015, 14:16:16)
 > [GCC 4.7.2] on linux
 > Type "help", "copyright", "credits" or "license" for more information.
 > >>> import sqlite3
 > Traceback (most recent call last):
 >   File "", line 1, in 
 >   File "/usr/local/lib/python3.5/sqlite3/__init__.py", line 23, in
 > 
 >     from sqlite3.dbapi2 import *
 >   File "/usr/local/lib/python3.5/sqlite3/dbapi2.py", line 27, in
 
 >     from _sqlite3 import *
 > ImportError: No module named '_sqlite3'
 > ===
 >
 > Obviously something is missing.
 > How do I solve the problem? Where do I find this module?
 >
 > Thanks for a hint.
 > --
 >
 > K.D.J.
 > --
 > [3]https://mail.python.org/mailman/listinfo/python-list

   Hello,

   thanks for your hint.
   That did it!!!
   --

   K.D.J.

References

   Visible links
   1. mailto:python-list@python.org
   2. mailto:k.d.jant...@mailbox.org
   3. https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


SQLite

2016-02-21 Thread Klaus Jantzen
   Hello,

   I have downloaded Python3.5.1 as .targz, compiled it(configure, make,...)
   and it works
   (under Debian Wheezy AMD64) up to the moment I wanted to use SQLite.

   I get the following message:
   ===
   jantzen@PC4:~$ python
   Python 3.5.0 (default, Dec  2 2015, 14:16:16)
   [GCC 4.7.2] on linux
   Type "help", "copyright", "credits" or "license" for more information.
   >>> import sqlite3
   Traceback (most recent call last):
     File "", line 1, in 
     File "/usr/local/lib/python3.5/sqlite3/__init__.py", line 23, in
   
       from sqlite3.dbapi2 import *
     File "/usr/local/lib/python3.5/sqlite3/dbapi2.py", line 27, in 
       from _sqlite3 import *
   ImportError: No module named '_sqlite3'
   ===

   Obviously something is missing.
   How do I solve the problem? Where do I find this module?

   Thanks for a hint.
   --

   K.D.J.
-- 
https://mail.python.org/mailman/listinfo/python-list