Re: Find and display gif file/s in web browser, according to the passed string, compared to files names in the folder.

2019-01-22 Thread Grant Edwards
On 2019-01-22, Dennis Lee Bieber  wrote:
> On Mon, 21 Jan 2019 22:49:19 +0100, "pe...@o2.pl"  declaimed
> the following:
>
>>Character/s starting from 8 to "*" are called "InitialText".
>
> Illegal requirement in Windows, and likely also in Linux. "*" is
> considered a wild-card character by command line utilities.

In Linux, it quite legal to have a '*' character anywhere in a in a
filename.  In Linux, there are only two characters that are not allowed to
appear in filenames: '/' and '\x00'.

Using '*' as part of a filename does requires that you escape it if
writing in a language that regards it as a special character
(e.g. Bash or the 're' pattern language).  However, Linux doesn't
care, and neither does Python.

> Define reasonable... Charging as a contractor I'd likely be asking
> for $75-100 US$ PER HOUR SPENT.

That seems a bit low to me.  And don't forget the 4 hour minimum...

-- 
Grant Edwards   grant.b.edwardsYow! I'm rated PG-34!!
  at   
  gmail.com

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


How to force the path of a lib ?

2019-01-22 Thread Vincent Vande Vyvre

(Resend because the previous message was incomplete)


Hi,

I am working on a python3 binding of a C++ lib. This lib is installed in 
my system but the latest version of this lib introduce several 
incompatibilities. So I need to update my python binding.


I'm working into a virtual environment (py370_venv) python-3.7.0 is 
installed into ./localpythons/lib/python3.7


So, the paths are:
# python-3.7.0
~/./localpythons/lib/python3.7/
# my binding python -> libexiv2
~/./localpythons/lib/python3.7/site-packages/pyexiv2/*.py
~/./localpythons/lib/python3.7/site-packages/pyexiv2/libexiv2python.cpython-37m-x86_64-linux-gnu.so

# and the latest version of libexiv2
~/CPython/py370_venv/lib/libexiv2.so.0.27.0

All theses path are in the sys.path

Now I test my binding:
>>> import pyexiv2
Traceback (most recent call last):
  File "", line 1, in 
  File 
"/home/vincent/CPython/py370_venv/lib/python3.7/site-packages/py3exiv2-0.1.0-py3.7-linux-x86_64.egg/pyexiv2/__init__.py", 
line 60, in 

    import libexiv2python
ImportError: 
/home/vincent/CPython/py370_venv/lib/python3.7/site-packages/py3exiv2-0.1.0-py3.7-linux-x86_64.egg/libexiv2python.cpython-37m-x86_64-linux-gnu.so: 
undefined symbol: _ZN5Exiv27DataBufC1ERKNS_10DataBufRefE

>>>

Checking the libexiv2.so the symbol exists
~/CPython/py370_venv/lib$ objdump -T libexiv2.so.0.27.0

0012c8d0 g    DF .text    000f  Base 
_ZN5Exiv27DataBufC1ERKNS_10DataBufRefE



But it is not present into my old libexiv2 system, so I presume python use
/usr/lib/x86_64-linux-gnu/libexiv2.so.14.0.0  (The old 0.25) instead of
 ~/CPython/py370_venv/lib/libexiv2.so.0.27.0 (The latest 0.27)

How can I solve that ?

My sys.path:
['', '/home/vincent/.localpythons/lib/python37.zip', 
'/home/vincent/.localpythons/lib/python3.7', 
'/home/vincent/.localpythons/lib/python3.7/lib-dynload', 
'/home/vincent/CPython/py370_venv/lib/python3.7/site-packages', 
'/home/vincent/CPython/py370_venv/lib/python3.7/site-packages/py3exiv2-0.1.0-py3.7-linux-x86_64.egg', 
'/home/vincent/CPython/py370_venv/lib/']


Thanks, Vincent

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


How to force the path of a lib ?

2019-01-22 Thread Vincent Vande Vyvre
I'm working into a virtual environment (py370_venv) python-3.7.0 is 
installed into .localpythons/lib/python3.7


So, the paths are:
# python-3.7.0
~/.localpythons/lib/python3.7/
# my binding python -> libexiv2
~/.localpythons/lib/python3.7/site-packages/pyexiv2/*.py
~/.localpythons/lib/python3.7/site-packages/pyexiv2/libexiv2python.cpython-37m-x86_64-linux-gnu.so

# and the latest version of libexiv2
~/CPython/py370_venv/lib/libexiv2.so.0.27.0

All theses path are in the sys.path

Now I test my binding:
>>> import pyexiv2
Traceback (most recent call last):
  File "", line 1, in 
  File 
"/home/vincent/CPython/py370_venv/lib/python3.7/site-packages/py3exiv2-0.1.0-py3.7-linux-x86_64.egg/pyexiv2/__init__.py", 
line 60, in 

    import libexiv2python
ImportError: 
/home/vincent/CPython/py370_venv/lib/python3.7/site-packages/py3exiv2-0.1.0-py3.7-linux-x86_64.egg/libexiv2python.cpython-37m-x86_64-linux-gnu.so: 
undefined symbol: _ZN5Exiv27DataBufC1ERKNS_10DataBufRefE

>>>

Checking the libexiv2.so the symbol exists

~/CPython/py370_venv/lib$ objdump -T libexiv2.so.0.27.0

0012c8d0 g    DF .text    000f  Base 
_ZN5Exiv27DataBufC1ERKNS_10DataBufRefE



But it is not present into my old libexiv2 system, so I presume python use
/usr/lib/x86_64-linux-gnu/libexiv2.so.14.0.0  (The old 0.25) instead of
 ~/CPython/py370_venv/lib/libexiv2.so.0.27.0 (The latest 0.27)

How can I solve that ?

My sys.path:
['', '/home/vincent/.localpythons/lib/python37.zip', 
'/home/vincent/.localpythons/lib/python3.7', 
'/home/vincent/.localpythons/lib/python3.7/lib-dynload', 
'/home/vincent/CPython/py370_venv/lib/python3.7/site-packages', 
'/home/vincent/CPython/py370_venv/lib/python3.7/site-packages/py3exiv2-0.1.0-py3.7-linux-x86_64.egg', 
'/home/vincent/CPython/py370_venv/lib/']


Thanks, Vincent

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


What is your experience porting Python 2.7.x scripts to Python 3.x?

2019-01-22 Thread Schachner, Joseph
In the company I work for we have a program (free) that runs scripts (that we 
sell) to test according to particular standards.  The program embeds a Python 
interpreter, and the scripts are Python (which uses functions revealed to 
Python from within the program).

Well, this year must be time ... I've told my manager that we need to change 
from Python 2.7.13 (the last version to which I updated it) to Python 3.x, 
whatever the latest is, sometime this year and to get that on our roadmap. I 
should mention that updating from earlier 2.x versions through 2.7.13 has not 
caused any errors or problems in our scripts.  I guess that is as expected.

I've read about the 2to3 utility, and I think our Python code is pretty simple 
... I don't expect much beyond changing print to print( ) wherever it occurs 
(we capture stdout and stderr and emit what we get to a file, that can be very 
helpful). There are Python function calls to C functions that are callable from 
Python in our program but that should not be a problem, they are known to be 
functions.  Still, I am concerned; I have never tried using 2to3 so I can't 
give a justifiable estimate of how long this migration might take.

For anyone who has moved a substantial bunch of Python 2 to Python 3,   can you 
please reply with your experience?  Did you run into any issues?   Did 2to3 do 
its job well, or did you have to review its output to eliminate some working 
but silly thing?

Thank you, anyone who replies, for replying.

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


Re: ttk present but not found for import

2019-01-22 Thread cem . isik
On Sunday, 20 January 2019 02:01:45 UTC+3, Rich Shepard  wrote:
> I've started to learn tkinter as the GUI widget set I'll use from now on.
> While ttk-8.6 is installed here (/usr/lib/tk8.6/ttk), I cannot import it:
> 
> $ python3
> Python 3.6.7 (default, Dec  8 2018, 06:22:57) 
> [GCC 5.5.0] on linux
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import tkinter
> >>> import ttk
> Traceback (most recent call last):
>File "", line 1, in 
> ModuleNotFoundError: No module named 'ttk'
> >>>
> 
> What have I done incorrectly?
> 
> TIA,
> 
> Rich

try as below;

import tkinter.ttk as ttk
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: ttk present but not found for import

2019-01-22 Thread cem . isik
On Sunday, 20 January 2019 02:01:45 UTC+3, Rich Shepard  wrote:
> I've started to learn tkinter as the GUI widget set I'll use from now on.
> While ttk-8.6 is installed here (/usr/lib/tk8.6/ttk), I cannot import it:
> 
> $ python3
> Python 3.6.7 (default, Dec  8 2018, 06:22:57) 
> [GCC 5.5.0] on linux
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import tkinter
> >>> import ttk
> Traceback (most recent call last):
>File "", line 1, in 
> ModuleNotFoundError: No module named 'ttk'
> >>>
> 
> What have I done incorrectly?
> 
> TIA,
> 
> Rich
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What is your experience porting Python 2.7.x scripts to Python 3.x?

2019-01-22 Thread Grant Edwards
On 2019-01-22, Schachner, Joseph  wrote:

> For anyone who has moved a substantial bunch of Python 2 to Python
> 3, can you please reply with your experience?

If you used bytes (or raw binary strings) at all (e.g. for doing
things like network or serial protocols) you're in for a lot of pain.

Everything else is pretty minor.

-- 
Grant Edwards   grant.b.edwardsYow! Are we live or on
  at   tape?
  gmail.com

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


Re: ttk present but not found for import

2019-01-22 Thread Rich Shepard

On Tue, 22 Jan 2019, cem.i...@compello.com.tr wrote:


try as below;
import tkinter.ttk as ttk


  I posted this solution shortly after the first message.

Thanks,

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


Re: What is your experience porting Python 2.7.x scripts to Python 3.x?

2019-01-22 Thread Akkana Peck
Grant Edwards writes:
> On 2019-01-22, Schachner, Joseph  wrote:
> 
> > For anyone who has moved a substantial bunch of Python 2 to Python
> > 3, can you please reply with your experience?
> 
> If you used bytes (or raw binary strings) at all (e.g. for doing
> things like network or serial protocols) you're in for a lot of pain.
> 
> Everything else is pretty minor.

2to3 handles most porting issues nicely. The three pain points I've
hit are the bytes vs strings vs unicode problem Grant mentions;
GUIs in either Qt or (especially) GTK; and networking, anything that
uses urllib, urllib2 or related libraries. For those three issues I
usually have to do a lot of porting and debugging by hand, and a lot
of testing afterward because there are always problems that crop up
later upon discovering that the Python3 version of some library is
returning bytes when Python3 wants chars, or some such.

If you don't have automated tests set up, consider writing some now,
before you start porting, with particular emphasis on anything that
gets data from a network or writes it to a file.

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


Re: What is your experience porting Python 2.7.x scripts to Python 3.x?

2019-01-22 Thread Chris Angelico
On Wed, Jan 23, 2019 at 9:43 AM Akkana Peck  wrote:
>
> Grant Edwards writes:
> > On 2019-01-22, Schachner, Joseph  wrote:
> >
> > > For anyone who has moved a substantial bunch of Python 2 to Python
> > > 3, can you please reply with your experience?
> >
> > If you used bytes (or raw binary strings) at all (e.g. for doing
> > things like network or serial protocols) you're in for a lot of pain.
> >
> > Everything else is pretty minor.
>
> 2to3 handles most porting issues nicely. The three pain points I've
> hit are .. networking, anything that
> uses urllib, urllib2 or related libraries.

For this last one, I would recommend first porting your code to using
'requests' as much as possible, if you aren't already. The requests
API is consistent across Py2 and Py3, and then all you need urllib
itself for is a handful of utility functions like urllib.parse, which
I believe 2to3 can handle.

Yes, requests is third-party. But it's such a good library that I
recommend it fully any time you aren't utterly unable to use non-core
libraries.

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


Re: What is your experience porting Python 2.7.x scripts to Python 3.x?

2019-01-22 Thread Cameron Simpson

On 22Jan2019 19:20, Grant Edwards  wrote:

On 2019-01-22, Schachner, Joseph  wrote:

For anyone who has moved a substantial bunch of Python 2 to Python
3, can you please reply with your experience?


If you used bytes (or raw binary strings) at all (e.g. for doing
things like network or serial protocols) you're in for a lot of pain.


Yes, but you will be the better for it afterwards. I've had a few 
programs which worked with binary data, and often also "text". In Python 
2 there was _constant_ uncertanty when these were mixed (writing text 
into binary fields and related). In Python 3 I am never confused. It is 
a huge win.


The pain here is completely offset by the relief which comes later.


Everything else is pretty minor.


Largely. It is also possible to write a _lot_ of code compatible with 
both 2 and 3.


 from __future__ import absolute_imports, print_function

gets you a long way. It will force these 2 things on your Python 2, 
making it Python 3 ready in that regard before you cut over.


I gather the 2to3 tool is useful, but it generates _separate_ Python 3 
code from your python 2 codebase as I understand it. I don't like that 
maintenance burden. I went with portability myself for most things, and 
a small personal library of python 3 flavoured routines with python 2 
ports for some differing behaviour (because that gets me native Python 3 
performance in Python 3, post cutover - the library is basicly "import 
the Python 3 names" in Python 3, and "implement the same names in Python 
2" where needed for the Python 2).  The "six" library is apparently the 
go to one for this kind of thing, I gather.


The pain level is really pretty low. The bytes vs strings stuff is the 
most difficult, but the outcome is vastly better afterwards.


Cheers,
Cameron Simpson 
--
https://mail.python.org/mailman/listinfo/python-list


Re: How to force the path of a lib ?

2019-01-22 Thread dieter
Vincent Vande Vyvre  writes:
> I am working on a python3 binding of a C++ lib. This lib is installed
> in my system but the latest version of this lib introduce several
> incompatibilities. So I need to update my python binding.
>
> I'm working into a virtual environment (py370_venv) python-3.7.0 is
> installed into ./localpythons/lib/python3.7
>
> So, the paths are:
> # python-3.7.0
> ~/./localpythons/lib/python3.7/
> # my binding python -> libexiv2
> ~/./localpythons/lib/python3.7/site-packages/pyexiv2/*.py
> ~/./localpythons/lib/python3.7/site-packages/pyexiv2/libexiv2python.cpython-37m-x86_64-linux-gnu.so
>
> # and the latest version of libexiv2
> ~/CPython/py370_venv/lib/libexiv2.so.0.27.0
>
> All theses path are in the sys.path
>
> Now I test my binding:
 import pyexiv2
> Traceback (most recent call last):
>   File "", line 1, in 
>   File
> "/home/vincent/CPython/py370_venv/lib/python3.7/site-packages/py3exiv2-0.1.0-py3.7-linux-x86_64.egg/pyexiv2/__init__.py",
> line 60, in 
>     import libexiv2python
> ImportError:
> /home/vincent/CPython/py370_venv/lib/python3.7/site-packages/py3exiv2-0.1.0-py3.7-linux-x86_64.egg/libexiv2python.cpython-37m-x86_64-linux-gnu.so:
> undefined symbol: _ZN5Exiv27DataBufC1ERKNS_10DataBufRefE

>
> Checking the libexiv2.so the symbol exists
> ~/CPython/py370_venv/lib$ objdump -T libexiv2.so.0.27.0
> 
> 0012c8d0 g    DF .text    000f  Base
> _ZN5Exiv27DataBufC1ERKNS_10DataBufRefE
> 
>
> But it is not present into my old libexiv2 system, so I presume python use
> /usr/lib/x86_64-linux-gnu/libexiv2.so.14.0.0  (The old 0.25) instead of
>  ~/CPython/py370_venv/lib/libexiv2.so.0.27.0 (The latest 0.27)
>
> How can I solve that ?

To load external C/C++ shared objects, the dynamic lickage loader
(ldd) is used. "ldd" does not look at Pthon's "sys.path".
Unless configured differently, it looks at standard places
(such as "/usr/lib/x86_64-linux-gnu").

You have several options to tell "ldd" where to look for
shared objects:

 * use the envvar "LD_LIBRARY_PATH"
   This is a "path variable" similar to the shell's "PATH",
   telling the dynamic loader in which directories (before
   the standard ones) to look for shared objects

 * use special linker options (when you link your Python
   extension shared object) to tell where dependent shared
   object can be found.

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


Re: What is your experience porting Python 2.7.x scripts to Python 3.x?

2019-01-22 Thread dieter
"Schachner, Joseph"  writes:
> ...
> For anyone who has moved a substantial bunch of Python 2 to Python 3,   can 
> you please reply with your experience?

It can be simple and it can be difficult.

I have found "http://python-future.org/compatible_idioms.html";
especially useful.

> Did you run into any issues?

Besides the already mentioned "urllib*" and "bytes/str" problems,
I have had significant issues with "dict" (missing "iter*" methods, missing
"has_key").
Another important problem domain are doctests with unicode results.

>  Did 2to3 do its job well

I have not used "2to3" -- because I doubt, that it can handle
important cases, i.e. when a Python 2 "str" must become a Python 3 bytes
or when a "dict.{keys, values, items}" must be listified.

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


Re: What is your experience porting Python 2.7.x scripts to Python 3.x?

2019-01-22 Thread Chris Angelico
On Wed, Jan 23, 2019 at 6:10 PM dieter  wrote:
> >  Did 2to3 do its job well
>
> I have not used "2to3" -- because I doubt, that it can handle
> important cases, i.e. when a Python 2 "str" must become a Python 3 bytes
> or when a "dict.{keys, values, items}" must be listified.

Have you tried? It errs on the side of safety. Your code should be
functional, and then if you decide that they _don't_ need to be
listified, you can remove the list() call.

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