Pickling issue.

2020-12-21 Thread Vincent Vande Vyvre

Hi,

I've an object that I want to serialise with pickle.
When I reload the object the attributes of this object are correctly 
fixed except one of these.


This attribute (value) define a simple string.

Example:
-
tag =  XmpTag('Xmp.dc.format', 'image/jpeg')
tag.key
'Xmp.dc.format'
tag.type
'MIMEType'
tag.value
'image/jpeg'

s = pickle.dumps(tag)
t = pickle.loads(s)
t.key
'Xmp.dc.format' # Correct
t.type
'MIMEType'  # Correct
t.value
('image', 'jpeg')   # Not correct
-

Tested with Python-3.8

An idea ?
--
https://mail.python.org/mailman/listinfo/python-list


Re: Finding it very difficult to move pyexiv2 code from Python 2 to Python 3

2020-08-20 Thread Vincent Vande Vyvre
Le 20/08/20 à 09:07, Robin Becker a écrit :
> .
>>> so obviously I need to install some version of boost libs or
>>> Boost.Python etc etc. Gave up :(
>>> -luddite-ly yrs-
>>> Robin Becker
>>>
>> The aur repository, no ?
>>
>> https://aur.archlinux.org/packages/python-exiv2/
>>
>> Vincent
>>
>
> that would work (if I had thought hard about it), but not for a pip
> install which is where the fun started :), I was only trying to see
> what was going wrong.
> -- 
> Robin Becker

See the README for the compilation instructions:
https://bazaar.launchpad.net/~vincent-vandevyvre/py3exiv2/trunk/view/head:/py3exiv2/README

Vincent

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


Re: Finding it very difficult to move pyexiv2 code from Python 2 to Python 3

2020-08-19 Thread Vincent Vande Vyvre
Le 19/08/20 à 10:15, Robin Becker a écrit :
> On 18/08/2020 20:05, Vincent Vande Vyvre wrote:
> .
>>>
>> Hi,
>>
>> Two solutions:
>> 1. Install exiv2-dev and py3exiv2 with pip
>>  $ sudo apt-get install libexiv2-dev
>>  $ sudo pip3 install py3exiv2
>>
>> 2. Install my ppa
>>  $ sudo add-apt-repository ppa:vincent-vandevyvre/vvv
>>  $ sudo apt-get update
>>  $ sudo apt-get install python3-exiv2
>>
>> Don't change your old code for pyexiv2, the names of the modules are
>> unchanged, your old code should work as it.
>>
>> Off course old strings are now unicode.
>>
>> Vincent (AKA VinsS)
>>
> I haven't tried #2 (I use Arch), but I did try 1) in a python 3.8
> virtual env. I ended up getting into a problem with boost
>
>>    src/exiv2wrapper.hpp:34:10: fatal error: boost/python.hpp: No such
>> file or directory
>>    34 | #include "boost/python.hpp"
>>   |  ^~
>>     compilation terminated.
>>     error: command 'gcc' failed with exit status 1
>
> so obviously I need to install some version of boost libs or 
> Boost.Python etc etc. Gave up :(
> -luddite-ly yrs-
> Robin Becker
>
The aur repository, no ?

https://aur.archlinux.org/packages/python-exiv2/

Vincent

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


Re: Finding it very difficult to move pyexiv2 code from Python 2 to Python 3

2020-08-18 Thread Vincent Vande Vyvre
Le 18/08/20 à 19:22, Chris Green a écrit :
> I have a fairly simple Python program that I wrote a while ago in
> Python 2 that transfers images from my camera to a date ordered
> directory hierarchy on my computer.
>
> I am trying to get it to work on Python 3 as I have just upgraded to
> Ubuntu 20.04 and on that Python 3 is now the default version of Python.
>
> I seem to be descending into a horrible morass of dependencies (or
> failed dependencies) when I try to install pyexiv2 (pr py3exiv2) using
> pip3.
>
> Can anyone point me at anywhere that might have some documentation
> that will help? 
>
> The first problem (it might be the whole problem, I'm not sure) is
> which 'pyexiv2' I should be installing, there seem to be several
> apparently competing versions and it's not at all clear which is the
> most likely to work.  On pypi there's py3exiv2 and pyexiv2 both of
> which claim to be for Python 3.  On the http://py3exiv2.tuxfamily.org/
> page it states: "py3exiv2 is the Python 3 version of pyexiv2 written
> for Python 2, ...", really! no wonder I'm confused.
>
> Essentially I need the python-pyexiv2 package for Ubuntu 20.04 and
> it's only available up to 19.10.
>
Hi,

Two solutions:
1. Install exiv2-dev and py3exiv2 with pip
    $ sudo apt-get install libexiv2-dev
    $ sudo pip3 install py3exiv2

2. Install my ppa
    $ sudo add-apt-repository ppa:vincent-vandevyvre/vvv
    $ sudo apt-get update
    $ sudo apt-get install python3-exiv2

Don't change your old code for pyexiv2, the names of the modules are
unchanged, your old code should work as it.

Off course old strings are now unicode.

Vincent (AKA VinsS)

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


Re: RFC: For Loop Invariants

2020-04-20 Thread Vincent Vande Vyvre
Le 20/04/20 à 13:08, Tony Flury via Python-list a écrit :
>
> On 10/04/2020 21:44, Elliott Dehnbostel wrote:
>> *We could do this:*
>>
>> chars = "abcaaabkjzhbjacvb"
>> seek = {'a','b','c'}
>> count = sum([1 for a in chars if a in seek])
>>
>> However, this changes important semantics by creating an entire new
>> list before summing.
>
> Creating the list is pointless in this case - sum will take any
> iterable, including a generator expression:
>
> chars = "abcaaabkjzhbjacvb"
> seek = {'a','b','c'}
> count = sum(1 for a in chars if a in seek)
>
> So you haven't really changed any semantics - and it seems that this
> is far better than fiddling with the for loop syntax.

You can use boolean as integer.

>>> chars = "abcaaabkjzhbjacvb"
>>> seek = {'a', 'b', 'c'}
>>> count = 0
>>> for i in chars:
... count += i in seek
...
>>> count
11


Vincent.

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


Re: Python 3.73 cannot install py3exiv2

2019-05-02 Thread Vincent Vande Vyvre

Le 1/05/19 à 15:12, Ken Martell a écrit :

I’m a retired aerospace engineer. I’m a Windows 10 user & have zero experience with 
Python. My goal is to learn, get this working & run lens distortion correction 
routines using Python. I’ve tried or many hours and read as much as I can but cannot 
get the py3exiv2 module to install. Other needed modules installed fine. It appears the 
Python version 2 of evix2 is needed as a dependent for the version 3 but neither pip or 
pip3 will install old or new. Sorry for taking your time but I’m a newbie just trying 
to help my fellow photographers correct  lens distortion problems in post-processing as 
well as my own.

Any help much appreciated!

Thank you
Ken Martell



Sent from Mail for Windows 10




The package available on PyPI is for *nix machines.

I don't have access to a Windows machine nor the knowledge to build an 
executable for Windows.


But, recently an user send me how it has successfully compiled py3exiv2 
for Windows.




Hello Vincent,

 I’ve run through the trouble of building py3exiv2 on Windows and was 
successful in doing so,


therefore I’d like to present you the steps I’ve taken to get there, so 
that you can alter setup.py and give some instructions on how to install 
it on Windows.


This is a copy of his mail:
---
 The key part in making this work is 
https://github.com/Microsoft/vcpkg, it has both exiv2 and boost-python.


Here’s what I did:

 [INSTALLING PYEXIV3 ON WINDOWS]
- install GIT-2.21.0-64-bit.exe
- install VSCodeUserSetup-x64-1.33.1.exe
- clone vcpkg, note the folder name
    $ git clone https://github.com/Microsoft/vcpkg.git
- install vcpkg by running .\bootstrap-vcpkg.bat
- run vcpkg.exe install boost-python:x64-windows
- run vcpkg.exe install exiv2:x64-windows
- make sure to add /installed/x64-windows/bin to the PATH (for dll import)
- get the pyexiv2 sources from here: http://py3exiv2.tuxfamily.org/downloads
- replace setup.py with my version
- set the environment variable VCPKG to the folder where you installed it
- run pip install -e 

I’ve attached my modified version of setup.py. It’s very rough since I 
don’t know much about setuptools at all, but it essentially involves 
bypassing `get_libboost_name` which fails completely on windows and 
using the environment variable VCPGK that has to be set by the user to 
point at the vcpkg directory. There’s probably a cleaner way of doing 
this, like accepting a command line argument. But again, I have no idea 
how setuptools handles this so hopefully you can clean it up a bit. 
`boost_python37-vc140-mt` is also completely hardcoded, you’d probably 
have to modify `get_libboost_name` to work on Windows.


 While I’m at this, I’ve noticed the lack of support for custom xmp 
tags. For now I’ve resorted to abusing various IPTC Tags for my purpose, 
but that’s a rather terrible solution. I’d appreciate it if you could 
prioritize adding that feature in the future.


 with best regards,

Vic

setup.py

#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys
import os
import glob
import subprocess

from setuptools import setup, find_packages, Extension

from codecs import open
from os import path

here = path.abspath(path.dirname(__file__))

# Get the long description from the relevant file
with open(path.join(here, 'DESCRIPTION.rst'), encoding='utf-8') as f:
    long_description = f.read()

def get_libboost_name():
    """Returns the name of the lib libboost_python 3

    """
    # libboost libs are provided without .pc files, so we can't use 
pkg-config

    places = ('/usr/lib/', '/usr/local/lib/', '/usr/')
    for place in places:
    cmd = ['find', place, '-name', 'libboost_python*']
    rep = subprocess.Popen(cmd, 
stdout=subprocess.PIPE).communicate()[0]

    if not rep:
    continue

    # rep is type bytes
    libs = rep.decode(sys.getfilesystemencoding()).split('\n')
    for l in libs:
    _, l = os.path.split(l)
    if '.so' in l:
    l = l.split('.so')[0]
    # Assume there's no longer python2.3 in the wild
    if '3' in l[-2:]:
    return l.replace('libboost', 'boost')

if os.name == 'nt':
    basep = os.environ["VCPKG"] + r"\installed\x64-windows"
    os.environ["INCLUDE"] = basep + r"\include"
    libboost = basep + r"\lib\boost_python37-vc140-mt"
    libexiv = basep + r"\lib\exiv2"
    extra_compile_args = []
else:
    libboost = get_libboost_name()
    extra_compile_args = []
    libexiv = 'exiv2'

setup(
    name='py3exiv2',
    version='0.7.0',
    description='A Python3 binding to the library exiv2',
    long_description=long_description,
    url='https://launchpad.net/py3exiv2',
    author='Vincent Vande Vyvre',
    author_email='vincent.vandevy...@oqapy.eu',
    license='GPL-3',

    # 

Re: How to catch a usefull error message ?

2019-04-25 Thread Vincent Vande Vyvre

Le 25/04/19 à 08:25, Chris Angelico a écrit :

On Thu, Apr 25, 2019 at 2:32 PM Vincent Vande Vyvre
 wrote:

Le 24/04/19 à 19:57, MRAB a écrit :

On 2019-04-23 20:21, Vincent Vande Vyvre wrote:

Le 23/04/19 à 20:54, Chris Angelico a écrit :


Why a SystemError ?
The SystemError means that you're using the Python C API in a way that
doesn't make sense to the interpreter. You're leaving a marker saying
"hey, I need you to throw an exception" but then you're also returning
a value. You'll need to figure out where that's happening and exactly
what is being called. How are you setting up your class?

ChrisA
The syntaxe

   if (!PyArg_ParseTuple(args, "s", ))
return NULL;

Is the usage described in the doc [*]

And without block try-except I get the good one error.


[*]
https://docs.python.org/3.5//extending/extending.html#back-to-the-example



If you look at the previous example, the function's return type is
"PyObject *".

On success it returns a reference (pointer) to an object; on error it
returns NULL.

Your function's return type is int.

In this case yes, beause it need to return the result of the command system.

But the "return 0" is a common case for an "Foo_init()"

see:
https://docs.python.org/3.5//extending/newtypes.html#adding-data-and-methods-to-the-basic-example

... And that's nothing to do with my initial question

Actually, it is a lot to do with your initial question. Notice how
there are two distinct signatures being demonstrated in the example
you linked to: those declared as returning PyObject* and those
declared as returning int. If something is meant to return an object,
then returning NULL says "hey, I set an error state, unwind the stack
and raise the exception". If it's meant to return an integer, though,
it returns -1 to give that message. See details here (second
paragraph):

https://docs.python.org/3/c-api/intro.html#exceptions

The __init__ function is defined as returning an integer:

https://docs.python.org/3/c-api/typeobj.html#c.PyTypeObject.tp_init

You're right that "return 0" is a common case; that isn't the problem.
The problem is the "return NULL", which is correct for a function that
normally returns a PyObject*, but not for one that returns an int.
That's why you're getting a SystemError - you're setting the exception
state, but then saying "hey, everything's fine, it's okay to return
None".

ChrisA


Does not change anything with PyObject *, same behaviour.

But with "static int" and "return -1;" instead of "NULL",  now I have 
the correct error.



So, thanks to all and sorry for the delays of my mails but it seems I'm 
always moderated ...



Vincent

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


Re: How to catch a usefull error message ?

2019-04-24 Thread Vincent Vande Vyvre

Le 24/04/19 à 19:57, MRAB a écrit :

On 2019-04-23 20:21, Vincent Vande Vyvre wrote:

Le 23/04/19 à 20:54, Chris Angelico a écrit :

On Wed, Apr 24, 2019 at 4:47 AM Vincent Vande Vyvre
 wrote:

Into the lib:

static int
ImgProc_init(ImgProc *self, PyObject *args, PyObject *kwds)
{
  PyObject *tmp;
  char *fname;

  if (!PyArg_ParseTuple(args, "s", ))
  return NULL;

  tmp = self->src;
  self->src = PyUnicode_FromString(fname);
  Py_XDECREF(tmp);
  return 0;
}

If i do:
  try:
  tif = ImgProc(123)
  except Exception as why:
  print(sys.exc_info())
  raise
I get:
(, SystemError("
returned a result with an error set",), )
TypeError: argument 1 must be str, not int

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
    File "/home/vincent/oqapy-3/trunk/filters/ui_lenscorrection.py", 
line

104, in on_main_cursor_changed
  self.prepare_preview_process()
    File "/home/vincent/oqapy-3/trunk/filters/ui_lenscorrection.py", 
line

137, in prepare_preview_process
  self.main.process_on_preview(params)
    File "/home/vincent/oqapy-3/trunk/filters/lenscorrection.py", line
56, in process_on_preview
  tif = ImgProc(123)
SystemError:  returned a result with an 
error set
 


Why a SystemError ?
The SystemError means that you're using the Python C API in a way that
doesn't make sense to the interpreter. You're leaving a marker saying
"hey, I need you to throw an exception" but then you're also returning
a value. You'll need to figure out where that's happening and exactly
what is being called. How are you setting up your class?

ChrisA


The syntaxe

  if (!PyArg_ParseTuple(args, "s", ))
   return NULL;

Is the usage described in the doc [*]

And without block try-except I get the good one error.


[*]
https://docs.python.org/3.5//extending/extending.html#back-to-the-example 



If you look at the previous example, the function's return type is 
"PyObject *".


On success it returns a reference (pointer) to an object; on error it 
returns NULL.


Your function's return type is int.


In this case yes, beause it need to return the result of the command system.

But the "return 0" is a common case for an "Foo_init()"

see: 
https://docs.python.org/3.5//extending/newtypes.html#adding-data-and-methods-to-the-basic-example


... And that's nothing to do with my initial question

Vincent

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


Re: How to catch a usefull error message ?

2019-04-24 Thread Vincent Vande Vyvre

Le 23/04/19 à 21:48, MRAB a écrit :

On 2019-04-23 19:21, Vincent Vande Vyvre wrote:

Le 23/04/19 à 19:23, Chris Angelico a écrit :

On Wed, Apr 24, 2019 at 3:18 AM Vincent Vande Vyvre
 wrote:

Hi,

In a CPython lib I have an _init() method wich take one argument, a 
file

name.

  char *fname;

  if (!PyArg_ParseTuple(args, "s", ))
  return NULL;

So, if I instanciate my object with a bad argument I've a good error
message:

tif = ImgProc(123)
TypeError: argument 1 must be str, not int
(followed by the traceback)

But if I do:
try:
  tif = ImgProc(123)
except Exception as why:
  print("Error:", why)

I get just:

Error:  returned a result with an error set


It looks like there's an internal problem in the C function. Are you
sure it's hitting the PyArg_ParseTuple and then immediately returning
NULL? Post a bit more of your code; this error looks like something is
leaving an error state but then carrying on with the code.

ChrisA


Into the lib:

static int
ImgProc_init(ImgProc *self, PyObject *args, PyObject *kwds)
{
      PyObject *tmp;
      char *fname;

      if (!PyArg_ParseTuple(args, "s", ))
      return NULL;

      tmp = self->src;
      self->src = PyUnicode_FromString(fname);
      Py_XDECREF(tmp);
      return 0;
}


[snip]

That function returns an int.

If PyArg_ParseTuple fails, your function returns NULL, which is cast 
to an int, 0.


If PyArg_ParseTuple succeeds, your function returns 0.

Either way, it returns 0.

So how does the caller know whether the function was successful? Does 
it check PyErr_Occurred?


No, the caller is in a block try-except for that.

The exact question here is why without a try-except I've the good one 
error and not in a try-except.


The /return 0;/ is usual in a /Foo_init()/ function.


Vincent

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


Re: How to catch a usefull error message ?

2019-04-24 Thread Vincent Vande Vyvre

Le 23/04/19 à 20:54, Chris Angelico a écrit :

On Wed, Apr 24, 2019 at 4:47 AM Vincent Vande Vyvre
 wrote:

Into the lib:

static int
ImgProc_init(ImgProc *self, PyObject *args, PyObject *kwds)
{
  PyObject *tmp;
  char *fname;

  if (!PyArg_ParseTuple(args, "s", ))
  return NULL;

  tmp = self->src;
  self->src = PyUnicode_FromString(fname);
  Py_XDECREF(tmp);
  return 0;
}

If i do:
  try:
  tif = ImgProc(123)
  except Exception as why:
  print(sys.exc_info())
  raise
I get:
(, SystemError("
returned a result with an error set",), )
TypeError: argument 1 must be str, not int

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/vincent/oqapy-3/trunk/filters/ui_lenscorrection.py", line
104, in on_main_cursor_changed
  self.prepare_preview_process()
File "/home/vincent/oqapy-3/trunk/filters/ui_lenscorrection.py", line
137, in prepare_preview_process
  self.main.process_on_preview(params)
File "/home/vincent/oqapy-3/trunk/filters/lenscorrection.py", line
56, in process_on_preview
  tif = ImgProc(123)
SystemError:  returned a result with an error set

Why a SystemError ?
The SystemError means that you're using the Python C API in a way that
doesn't make sense to the interpreter. You're leaving a marker saying
"hey, I need you to throw an exception" but then you're also returning
a value. You'll need to figure out where that's happening and exactly
what is being called. How are you setting up your class?

ChrisA


The syntaxe

if (!PyArg_ParseTuple(args, "s", ))
 return NULL;

Is the usage described in the doc [*]

And without block try-except I get the good one error.


[*] 
https://docs.python.org/3.5//extending/extending.html#back-to-the-example



Vincent

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


Re: How to catch a usefull error message ?

2019-04-23 Thread Vincent Vande Vyvre

Le 23/04/19 à 19:27, MRAB a écrit :

On 2019-04-23 10:56, Vincent Vande Vyvre wrote:

Hi,

In a CPython lib I have an _init() method wich take one argument, a file
name.

      char *fname;

      if (!PyArg_ParseTuple(args, "s", ))
      return NULL;

So, if I instanciate my object with a bad argument I've a good error
message:

tif = ImgProc(123)
TypeError: argument 1 must be str, not int
(followed by the traceback)

But if I do:
try:
      tif = ImgProc(123)
except Exception as why:
      print("Error:", why)

I get just:

Error:  returned a result with an error set

Without traceback. That's not very usefull.

I prefer to keep the instanciation of this object into a try-except bloc
but how to read the error message ?


Have a look ta the 'traceback' module.
Example:

import traceback

try:
    1/0
except Exception as ex:
    print('Error:', ex)
    traceback.print_exc()


    try:
    tif = ImgProc(123)
    except Exception as why:
    traceback.print_exc()
    print("always alive !")

TypeError: argument 1 must be str, not int

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/vincent/oqapy-3/trunk/filters/lenscorrection.py", line 
56, in process_on_preview

    tif = ImgProc(123)
SystemError:  returned a result with an error set
always alive !
-

This is better of nothing and the try-except works.

Vincent

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


Re: How to catch a usefull error message ?

2019-04-23 Thread Vincent Vande Vyvre

Le 23/04/19 à 19:23, Chris Angelico a écrit :

On Wed, Apr 24, 2019 at 3:18 AM Vincent Vande Vyvre
 wrote:

Hi,

In a CPython lib I have an _init() method wich take one argument, a file
name.

  char *fname;

  if (!PyArg_ParseTuple(args, "s", ))
  return NULL;

So, if I instanciate my object with a bad argument I've a good error
message:

tif = ImgProc(123)
TypeError: argument 1 must be str, not int
(followed by the traceback)

But if I do:
try:
  tif = ImgProc(123)
except Exception as why:
  print("Error:", why)

I get just:

Error:  returned a result with an error set


It looks like there's an internal problem in the C function. Are you
sure it's hitting the PyArg_ParseTuple and then immediately returning
NULL? Post a bit more of your code; this error looks like something is
leaving an error state but then carrying on with the code.

ChrisA


Into the lib:

static int
ImgProc_init(ImgProc *self, PyObject *args, PyObject *kwds)
{
    PyObject *tmp;
    char *fname;

    if (!PyArg_ParseTuple(args, "s", ))
    return NULL;

    tmp = self->src;
    self->src = PyUnicode_FromString(fname);
    Py_XDECREF(tmp);
    return 0;
}

If i do:
    try:
    tif = ImgProc(123)
    except Exception as why:
    print(sys.exc_info())
    raise
I get:
(, SystemError(" 
returned a result with an error set",), 0x7f3bcac748c8>)

TypeError: argument 1 must be str, not int

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/vincent/oqapy-3/trunk/filters/ui_lenscorrection.py", line 
104, in on_main_cursor_changed

    self.prepare_preview_process()
  File "/home/vincent/oqapy-3/trunk/filters/ui_lenscorrection.py", line 
137, in prepare_preview_process

    self.main.process_on_preview(params)
  File "/home/vincent/oqapy-3/trunk/filters/lenscorrection.py", line 
56, in process_on_preview

    tif = ImgProc(123)
SystemError:  returned a result with an error set

Why a SystemError ?

I'm using Python 3.6.7 and 3.7.3

Vincent

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


How to catch a usefull error message ?

2019-04-23 Thread Vincent Vande Vyvre

Hi,

In a CPython lib I have an _init() method wich take one argument, a file 
name.


    char *fname;

    if (!PyArg_ParseTuple(args, "s", ))
    return NULL;

So, if I instanciate my object with a bad argument I've a good error 
message:


tif = ImgProc(123)
TypeError: argument 1 must be str, not int
(followed by the traceback)

But if I do:
try:
    tif = ImgProc(123)
except Exception as why:
    print("Error:", why)

I get just:

Error:  returned a result with an error set

Without traceback. That's not very usefull.

I prefer to keep the instanciation of this object into a try-except bloc 
but how to read the error message ?



Vincent

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


Re: pip unable to find an extension of a lib.

2019-04-12 Thread Vincent Vande Vyvre

Le 12/04/19 à 09:48, Paul Moore a écrit :

>From https://pypi.org/project/PyQt5-sip/#files, it looks like the
project only distributes wheels (no source archive). You don't say
what platform you're using, but if it's Linux, the fact that you have
a debug Python probably means you need a different ABI, so the
standard wheels that they provide aren't compatible. So if there's no
compatible wheel and no source, there's nothing that can be installed.

pip install -v pyqt5 might give you some more information about why
the files available are not being considered as suitable, but I think
the above is likely.

Paul


Exact, in mode verbose it enumerate all versions of pyqt-sip and all are declared 
"not compatible with this Python"

So I'll create a 3.7.3 venv without the "--with-pydebug"

Thanks,
Vincent.

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


Re: pip unable to find an extension of a lib.

2019-04-12 Thread Vincent Vande Vyvre

Le 12/04/19 à 07:40, dieter a écrit :

Vincent Vande Vyvre  writes:

...
Using Python-3.7.2 (compiled with --with-pydebug) in a venv, I've
encountered this problem:

$ pip install --upgrade pip setuptools wheel

Successfully installed setuptools-41.0.0 wheel-0.33.1
---
...
$ pip install pyqt5
...
Collecting PyQt5_sip<4.20,>=4.19.14 (from pyqt5)
   Could not find a version that satisfies the requirement
PyQt5_sip<4.20,>=4.19.14 (from pyqt5) (from versions: )
No matching distribution found for PyQt5_sip<4.20,>=4.19.14 (from pyqt5)
...
$ pip search pyqt5
...
PyQt5-sip (4.19.15)   - Python extension module support

There is a spelling difference: "PyQt5_sip" versus "PyQt5-sip" --
not sure, however, whether this is important.

Yes, I see that but the names returned by pip search are different than 
the names used with pip install


ie: PyQt5 versus pyqt5.


Vincent.

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


pip unable to find an extension of a lib.

2019-04-11 Thread Vincent Vande Vyvre

Hi,

Using Python-3.7.2 (compiled with --with-pydebug) in a venv, I've 
encountered this problem:


$ pip install --upgrade pip setuptools wheel

Successfully installed setuptools-41.0.0 wheel-0.33.1
---

$ pip install pyqt5
  /pip/_vendor/html5lib/_trie/_base.py:3: DeprecationWarning: (skip)
  from collections import Mapping
Collecting pyqt5
  /pip/_vendor/msgpack/fallback.py:222: PendingDeprecationWarning: (skip)
  Using cached 
https://files.pythonhosted.org/packages/98/61/fcd53201a23dd94a1264c29095821fdd55c58b4cd388dc7115e5288866db/PyQt5-5.12.1-5.12.2-cp35.cp36.cp37.cp38-abi3-manylinux1_x86_64.whl

Collecting PyQt5_sip<4.20,>=4.19.14 (from pyqt5)
  Could not find a version that satisfies the requirement 
PyQt5_sip<4.20,>=4.19.14 (from pyqt5) (from versions: )

No matching distribution found for PyQt5_sip<4.20,>=4.19.14 (from pyqt5)


$ pip search pyqt5
  /pip/_vendor/html5lib/_trie/_base.py:3: DeprecationWarning: (skip)
  from collections import Mapping
pyqt5-tools (5.11.3.1.4)  - Tools to supplement the official 
PyQt5 wheels
PyQt5-stubs (5.12.1.0)    - PEP561 stub files for the PyQt5 
framework
PyQt5-sip (4.19.15)   - Python extension module support for 
PyQt5

PyQt5 (5.12.1)    - Python bindings for the Qt cross ...
.

The version of PyQt5-sip (4.19.15) seems OK, no ?

I've already posted on the PyQt ML, but I am the only one with this problem.

Thanks for all advices

Vincent.

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


Re: How to force the path of a lib ?

2019-01-24 Thread Vincent Vande Vyvre

Le 23/01/19 à 13:11, Neal Becker a écrit :

dieter wrote:


Vincent Vande Vyvre  writes:
.




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.


To follow up on that last point, look up --rpath and related.

Trying the first solution with "export 
LD_LIBRARY_PATH=/home/vincent/CPython/py370_venv/lib" has no effect.


The second solution is better, after looking de doc of 
distutils.core.Extension I've added this line into my setup.py

    Extension('libexiv2python',
    ...,
runtime_library_dirs=['/home/vincent/CPython/py370_venv/lib/'],
    ...

rebuild, install and test
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyexiv2
>>>

Great!

Many 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

(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


Re: How to display video files (mkv, wav, mp4 etc) within a TKinter widget?

2019-01-02 Thread Vincent Vande Vyvre

Le 2/01/19 à 15:17, Arie van Wingerden a écrit :

I found (mostly fairly old stuff) some questions and a lot of (apparently often 
not working) Python code.

1. does TKinter offer such thing out of the box?
2. or is there another way using TKinter?
3. or do I need another GUI tool (e.g. QT) for this?

TIA


With Qt it's very easy to implement a video player.

See this example:

https://bazaar.launchpad.net/~vincent-vandevyvre/qarte/qarte-4/view/head:/gui/videoplayer.py

It is implemented into this window:

https://bazaar.launchpad.net/~vincent-vandevyvre/qarte/qarte-4/view/head:/gui/uiconcerts.py


Vincent

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


Fishing from PyPI ?

2018-08-06 Thread Vincent Vande Vyvre

I've received a mail askink me to confirm my identity on PyPI.

The begining of the message:

-

Your account VinsS on PyPI 
 
does not have a verified primary email address.


Please take 2 minutes to verify your email:

 * To ensure that every email we send is going to its intended recipient
 * To ensure email sent from PyPI isn’t marked as spam by email clients
   and service
 * *If you do not verify, you will not be able to upload to PyPI, or be
   added as a maintainer to projects. You will no longer receive
   notifications from PyPI.*

   To verify, visit your Account Settings
   

   page.

-

The Account Settings 
 
is : 
https://pypi.us18.list-manage.com/track/click?u=b96f861be540deb98fd700265=1763135c31=8824682d0f


Phishing ? yes, no ?


Vincent

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


Re: I'm getting a spamassassin party here

2018-06-26 Thread Vincent Vande Vyvre

Le 26/06/18 à 15:50, Gene Heskett a écrit :

On Tuesday 26 June 2018 02:50:01 Cameron Simpson wrote:


On 24Jun2018 17:03, Gene Heskett  wrote:

Greetings list;

Generally spamassassin only gets picky about this occasionally, but
for the past several hours its working overtime on python list
messages, with the major problem being the servers time stamp, a day
or more in the past. Anyboy ever hear of ntpd?
-- Cheers, Gene Heskett

Could you eyeball some of these problematic messages please?

I've been noticing a swathe of messages in the past few days with
From: headers like this:

   From: "Steven D'Aprano" 

where the From: has been badly mangled, I think by a usenet->list
gateway. The Path: on these messages looks like this (give or take):

   Path:
uni-berlin.de!fu-berlin.de!news.linkpendium.com!news.linkpendium.com!n
ews.snarked.org!news.bbs.nz!.POSTED.184-155-113-241.cpe.cableone.net!no
t-for-mail

I'd be interested to know if there is significant overlap between my
problematic messages and yours.

Cheers,
Cameron Simpson 

Stevens messages are among the most frequent spamassassin triggers. The
scoring diff that tips the scales is the time error:
  1.0 DATE_IN_PAST_12_24 Date: is 12 to 24 hours before Received: date

There is also this:
0.5 APOSTROPHE_FROMFrom address contains an apostrophe

This list commits a whole menu of errors that spamassassin doesn't like.

The whole list from a different message:

Content analysis details:   (5.6 points, 5.1 required)

  pts rule name  description
 -- --
  3.5 BAYES_99   BODY: Bayes spam probability is 99 to 100%
 [score: 1.]
  0.0 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail
 domains are different
  1.0 DATE_IN_PAST_12_24 Date: is 12 to 24 hours before Received: date
  0.2 BAYES_999  BODY: Bayes spam probability is 99.9 to 100%
 [score: 1.]
  0.8 RDNS_NONE  Delivered to internal network by a host with
no rDNS
  0.0 T_DKIM_INVALID DKIM-Signature header exists but is not valid

Some of these should be fixable by proper configuration of the
listserver, but don't confuse me with an expert. I am subscribed to the
list.


Same for me since yesterday.

Two examples:

The 2018-05-18 17:20
---
From: "Peter J. Holzer" 


--prnws536gtytpj5v
[ following the message ]

Same day, same hour but arrived today

From: "Peter J. Holzer" 

From: "Peter J. Holzer" 


--prnws536gtytpj5v
[ following the same message ]



Or again:
The 2018-06-23 18:46

From: Steven D'Aprano 

On Sat, 23 Jun 2018 06:26:22 -0400, Richard Damon wrote:
[ following the message ]

Same day, same hour but arrived today

From: "Steven D'Aprano" 

From: Steven D'Aprano 

On Sat, 23 Jun 2018 06:26:22 -0400, Richard Damon wrote:
[ following the same message ]


I've re-received 22 old duplicated messages like this today.

Vincent
Send Tue, 26 Jun 2018 19:53:46 +0200

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


Re: Is it possible to call a class but without a new instance created?

2018-06-18 Thread Vincent Vande Vyvre

Le 18/06/18 à 06:48, Jach Fong a écrit :

After looking into the \tkiniter\font.py source file, triggered by Jim's
hint on my previous subject "Why an object changes its "address" between
adjacent calls?", I get more confused.

Below was quoted from the font.py:

def nametofont(name):
    """Given the name of a tk named font, returns a Font representation.
    """
    return Font(name=name, exists=True)

class Font:
    """Represents a named font.
    Constructor options are:
    ...
    exists -- does a named font by this name already exist?
   Creates a new named font if False, points to the existing font 
if True.

    ...
    """

    def __init__(self, root=None, font=None, name=None, exists=False,
 **options):
    ...
--
From my understanding, the __init__ method was called after the instance
was created, that's why the __init__ has a self parameter, right? Then,
how is it possible "...points to the existing font if True"? I didn't
see any clue in __init__ doing this.

I also make a test of my own and it fails too.

>>> class A:
... objs = []
... def __init__(self, exists=False):
... if exists:  self = self.objs[0]
... else:  self.objs.append(self)
...
>>> a0 = A()
>>> id(a0)
35569968
>>> a1 = A(exists=True)
>>> id(a1)
35572336

What I expect is that id(a0) and id(a1) has the same value. They 
should points to the same object.



Best Regards,
Jach Fong




---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus


Hi,


What you try to do is called a /singleton./

A classic example :

class Foo:
    _instance = None
    def __new__(cls, *args, **kwargs):
    if cls._instance is None:
    cls._instance = super(Foo, cls).__new__(cls, *args, **kwargs)
    return cls._instance

    def __init__(self, ...):

        ...


Vincent

Send at Mon, 18 Jun 2018 09:17:21 +0200

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


Obsolete method in the html module

2018-06-09 Thread Vincent Vande Vyvre

Not really important, just a comment.

In Python-3.7.0b5 we can find at the end of html/parser.py:

    def unescape(self, s):
    warnings.warn('The unescape method is deprecated and will be 
removed '

  'in 3.5, use html.unescape() instead.',
  DeprecationWarning, stacklevel=2)
    return unescape(s)

Vincent

(send at 08:07 GMT)

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


Re: Uploading on PyPI fail (solved)

2018-05-15 Thread Vincent Vande Vyvre

Le 15/05/18 à 12:05, Vincent Vande Vyvre a écrit :

Hi,

Trying to upgrade a package on PyPI, I get this error:

$ python3 setup.py register sdist upload
...
Submitting dist/py3exiv2-0.3.0.tar.gz to https://pypi.python.org/pypi
Upload failed (308): Redirect to Primary Domain
error: Upload failed (308): Redirect to Primary Domain

I know the site has changed but what is changed for me ?

This is the content of my .pypirc:
-
[distutils]
index-servers=
    pypi
    pypitest

[pypitest]
repository = https://test.pypi.org/legacy/
username = VinsS
password = ***

[pypi]
repository = https://upload.pypi.org/legacy/
username = VinsS
password = **
-

Note: I've tested on test.pypi.org without problems.

Thanks for all advices,

Vincent

(send at Tue, 15 May 2018 12:04:10 +0200)


Solved with $ twine upload  dist/*


...

Vincent

(send at Tue, 15 May 2018 14:34:10 +0200)


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


Uploading on PyPI fail

2018-05-15 Thread Vincent Vande Vyvre

Hi,

Trying to upgrade a package on PyPI, I get this error:

$ python3 setup.py register sdist upload
...
Submitting dist/py3exiv2-0.3.0.tar.gz to https://pypi.python.org/pypi
Upload failed (308): Redirect to Primary Domain
error: Upload failed (308): Redirect to Primary Domain

I know the site has changed but what is changed for me ?

This is the content of my .pypirc:
-
[distutils]
index-servers=
    pypi
    pypitest

[pypitest]
repository = https://test.pypi.org/legacy/
username = VinsS
password = ***

[pypi]
repository = https://upload.pypi.org/legacy/
username = VinsS
password = **
-

Note: I've tested on test.pypi.org without problems.

Thanks for all advices,

Vincent

(send at Tue, 15 May 2018 12:04:10 +0200)

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


Re: lire du son en format natif avec python

2018-03-21 Thread Vincent Vande Vyvre

Le 21/03/18 à 11:25, asphjt--- via Python-list a écrit :

Bonjour à tous,
En utilisant le module pyaudio pour enregistrer du son, j'ai une chaine de 
caractères de la forme 
b'\x01\x00\n\x00\x04\x00\xfe\xff\x04\x00\x0b\x00\n\x00\x07\x00'b'\x01\x00\xff\xff\x00\x00\xff\xff\x01\x00\n\x00\n\x00\n\x00
 qui correspond aux valeurs hexadécimales (je pense) du son brut, et j'aimerai 
pouvoir le lire sans passer par un encodage ou format de compression comme mp3, 
wav,...
J'ai lu que l'on pouvait le faire avec ossaudiodev, mais je n'arrive pas à le 
trouver, ni à l'installer depuis pyzo.
Si quelqu'un peut m'aider, merci à lui d'avance.


Hi,


This is an English mailing list.


If you prefer talk in French, I recommend you this forum:

https://www.developpez.net/forums/f96/autres-langages/python-zope/


Best


Vincent

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


Re: Is there are good DRY fix for this painful design pattern?

2018-02-26 Thread Vincent Vande Vyvre

Le 26/02/18 à 15:41, Steven D'Aprano a écrit :

I have a class with a large number of parameters (about ten) assigned in
`__init__`. The class then has a number of methods which accept
*optional* arguments with the same names as the constructor/initialiser
parameters. If those arguments are None, the defaults are taken from the
instance attributes.

An example might be something like this:


class Foo:
 def __init__(self, bashful, doc, dopey, grumpy,
happy, sleepy, sneezy):
 self.bashful = bashful  # etc

 def spam(self, bashful=None, doc=None, dopey=None,
grumpy=None, happy=None, sleepy=None,
sneezy=None):
 if bashful is None:
 bashful = self.bashful
 if doc is None:
 doc = self.doc
 if dopey is None:
 dopey = self.dopey
 if grumpy is None:
 grumpy = self.grumpy
 if happy is None:
 happy = self.happy
 if sleepy is None:
 sleepy = self.sleepy
 if sneezy is None:
 sneezy = self.sneezy
 # now do the real work...

 def eggs(self, bashful=None, # etc...
):
 if bashful is None:
 bashful = self.bashful
 # and so on
  


There's a lot of tedious boilerplate repetition in this, and to add
insult to injury the class is still under active development with an
unstable API, so every time I change one of the parameters, or add a new
one, I have to change it in over a dozen places.

Is there a good fix for this to reduce the amount of boilerplate?


Thanks,




Maybe something like this:

    def config(self, **kwargs):
    for key, value in kwargs.items():
    if value is not None:
    setattr(self, key, value)

    def spam(self, **kwargs):
    self.config(kwargs)


Vincent

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


Re: Package containing C sources (Posting On Python-List Prohibited)

2018-01-31 Thread Vincent Vande Vyvre

Le 31/01/18 à 07:52, Victor Porton a écrit :

Lawrence D’Oliveiro wrote:


On Wednesday, January 31, 2018 at 6:13:00 PM UTC+13, Victor Porton wrote:

I am going to create a Python wrapper around a generally useful C
library. So the wrapper needs to contain some C code to glue them
together.

Not necessarily. It’s often possible to implement such a wrapper entirely
in Python, using ctypes .

But if I will find that I need C code, do I need to package it separately?

So I would get three packages: the C library, the C wrapper for Python, and
the Python code.

Can this be done with just two packages: the C library and C wrapper and
Python in one package?


Hi,

You can made an all-in-one package without problems.


Vincent

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


Re: Argh!! Can't wrap my head around this Python stuff!

2017-11-26 Thread nospam . Vincent Vande Vyvre
Le 26/11/17 Ä  10:09, Greg Tibbet a ÄCcritâ :
> I'm an old timer, have programmed in Fortran, C, C++, Perl, and a bit
> of Java and trying to learn this new-fangled Python language!
>
> I've got a small program that uses PIL to create an image, draw some
> primitives (rectanges, ellipses, etc...) and save it.  Works fine...
> no issues.
>
> I've found in the past, the best way to "really learn" the language
> was to "dig into the guts" and understand it,.. I thought I was making
> progress, but when looking into the PIL library to see what's going on
> behind the scenes, I find the following code in ImageDraw.py
>
> def ellipse(self, xy, fill=None, outline=None):
>  """Draw an ellipse."""
>  ink, fill = self._getink(outline, fill)
>  if fill is not None:
>  self.draw.draw_ellipse(xy, fill, 1)
> <...snipped...>
>
> ellipse() uses the method  self.draw.draw_ellipse()   Okay, fine...
> but WHERE is draw_ellipse defined??  What magic is happening there?
> I've searched the entire PIL directory tree, and the ONLY two places
> draw_ellipse is mentioned are right there in the ellipse() function...
> WHAT am I missing??
>
> Thanks!
> -Stumpy (aka Greg)

Hi,

It's not defined in Python module but in
Pillow-3.5/Pillow-master/libImaging/Draw.c

... line 748


Vincent

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


Re: Argh!! Can't wrap my head around this Python stuff!

2017-11-26 Thread Vincent Vande Vyvre

Le 26/11/17 à 10:09, Greg Tibbet a écrit :

I'm an old timer, have programmed in Fortran, C, C++, Perl, and a bit
of Java and trying to learn this new-fangled Python language!

I've got a small program that uses PIL to create an image, draw some
primitives (rectanges, ellipses, etc...) and save it.  Works fine...
no issues.

I've found in the past, the best way to "really learn" the language
was to "dig into the guts" and understand it,.. I thought I was making
progress, but when looking into the PIL library to see what's going on
behind the scenes, I find the following code in ImageDraw.py

def ellipse(self, xy, fill=None, outline=None):
 """Draw an ellipse."""
 ink, fill = self._getink(outline, fill)
 if fill is not None:
 self.draw.draw_ellipse(xy, fill, 1)
<...snipped...>

ellipse() uses the method  self.draw.draw_ellipse()   Okay, fine...
but WHERE is draw_ellipse defined??  What magic is happening there?
I've searched the entire PIL directory tree, and the ONLY two places
draw_ellipse is mentioned are right there in the ellipse() function...
WHAT am I missing??

Thanks!
-Stumpy (aka Greg)


Hi,

It's not defined in Python module but in 
Pillow-3.5/Pillow-master/libImaging/Draw.c


... line 748


Vincent

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


Re: for/ if against dict - one liner

2017-11-14 Thread Vincent Vande Vyvre

Le 14/11/17 à 06:44, Andrew Z a écrit :

Hello,
  i wonder how do i get the "for" and "if" to work against a dictionary in
one line?

basically i want to "squeeze":
  dct= [ 1 : "one", 2:"two", 3:"three"]
  for k, val in dct:
if k >= 2:
   # do magnificent things

Thank you
AZ


Maybe something like that:

lst = [do_magnificent_thing(dct[k]) for k in dct if k >= 2]

lst contains the returns of do_magnificent_thing(k) in unpredictable order.


Vincent

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


Re: Return str to a callback raise a segfault if used in string formating

2017-10-14 Thread Vincent Vande Vyvre

Le 14/10/17 à 15:59, Stefan Behnel a écrit :

Vincent Vande Vyvre schrieb am 13.10.2017 um 13:18:

Le 13/10/17 à 12:39, Paul Moore a écrit :

As a specific suggestion, I assume the name of the created file is a
string object constructed in the C extension code, somehow. The fact
that you're getting the segfault with some uses of that string
(specifically, passing it to %-formatting) suggests that there's a bug
in the C code that constructs that string. That's where I'd start by
looking.

Absolutely.



That was my first idea, because I can verify the instance of PyUnraw is not
destroyed when I use the file name, but I was in trouble by the usage of
the file name in string formatting.

For example I can use the file name into the slot i.e. shutil.copy(fname,
"path/renamed.tiff")
The file is correctly copied.

In fact, I can do anything with the file name except use it in string
formatting, then your approach is probably a good way.

Into the CPython part I have a c-string pythonized by:
     temp = self->outfname;
     self->outfname = PyUnicode_FromString(ofname);
     Py_XDECREF(temp);

and exposed to Python with:
static PyMemberDef PyUnraw_members[] = {
     {"out_file", T_OBJECT_EX, offsetof(PyUnraw, outfname), 0,
  "Path of the decoded file"},

One more suggestion, in case this is actually your own C code: it's much
easier to write extension modules in Cython than in plain C and C-API code.
Much easier. There is a learning curve, sure, but it unburdens you from so
many pitfalls and boilerplate code that it's always worth switching. And
you also get faster code as a side-effect. How's that for a tradeoff. :)

Stefan
(Cython core developer)


Thanks, I know Cython but the code is already in C.

This is a lib released as a frontend.  Then usable only in command line.

It's not my own code, my job is to reimplement the main() function of 
the lib in CPython.


The work is nearly complete, I'm in the tests part.

I think I've found the problem, the string (a file path) is modified in 
c with "sprintf, snprintf, ..." And I plan to change that with some 
CPython equivalent function.



Vincent

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


Re: Return str to a callback raise a segfault if used in string formating

2017-10-13 Thread Vincent Vande Vyvre

Le 13/10/17 à 12:39, Paul Moore a écrit :

As a specific suggestion, I assume the name of the created file is a
string object constructed in the C extension code, somehow. The fact
that you're getting the segfault with some uses of that string
(specifically, passing it to %-formatting) suggests that there's a bug
in the C code that constructs that string. That's where I'd start by
looking. Maybe something isn't zero-terminated that should be? Maybe
your code doesn't set up the character encoding information correctly?

Paul
That was my first idea, because I can verify the instance of PyUnraw is 
not destroyed when I use the file name, but I was in trouble by the 
usage of the file name in string formatting.


For example I can use the file name into the slot i.e. 
shutil.copy(fname, "path/renamed.tiff")

The file is correctly copied.

In fact, I can do anything with the file name except use it in string 
formatting, then your approach is probably a good way.


Into the CPython part I have a c-string pythonized by:
    temp = self->outfname;
    self->outfname = PyUnicode_FromString(ofname);
    Py_XDECREF(temp);

and exposed to Python with:
static PyMemberDef PyUnraw_members[] = {
    {"out_file", T_OBJECT_EX, offsetof(PyUnraw, outfname), 0,
 "Path of the decoded file"},
    ...

Vincent



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


Re: Return str to a callback raise a segfault if used in string formating

2017-10-13 Thread Vincent Vande Vyvre

Le 13/10/17 à 09:23, Chris Angelico a écrit :

On Fri, Oct 13, 2017 at 4:46 PM, Vincent Vande Vyvre
<vincent.vande.vy...@telenet.be> wrote:

Simplified code:

---%<--
...
---%<--

If I place self.callback() at the end of the func process that doesn't
change anything.

First off, exactly what version of Python are you running this under?
With a segfault, you need to be pretty specific - platform, version,
word size, as much as you can gather.

Secondly: Can you create a version of this that doesn't comment out
part of the work? If you can make a script where, any time you run it,
Python segfaults, that would be extremely helpful.

Your code currently looks a bit weird. You create a thread, start it,
and then immediately wait for it (join()). When you add a task, if
it's the first task you've added, you process tasks, thus removing
that task. So the class isn't actually doing anything, and logically,
you could simply process the files directly in the loop. I'm guessing
that something in there (probably the threading) is causing the crash,
but without a complete and testable demo, it's hard to be sure.

ChrisA


I'm using 3.6.1 in venv

It's not easy to write a runnable code because in this example the 
method process() is too simplified and the code don't reproduce the 
segfault.


The code is an image processing in two parts: the processing himself in 
CPython and an api in Python.


I have written the two parts.

In the real code this is the equivalent of the method process():
--
    def unraw(self, index=0, dest=""):
    """Run the demosaication process.

    Args:
    index -- the index of the image or "all" if there's more than 
one image

 into the file
    dest -- the absolute file name for the image decoded.  If a 
file with

    the same name already exists, it will be overwritten.

    Raise IndexError if index >= self.image_count
    """
    if not self.is_raw:
    fname = os.path.basename(self.filename)
    raise TypeError("RAW file %s not supported!" % fname)

    if index >= self.data["image_count"]:
    raise IndexError("Index of image %s out of range(%s)"
 %(index, self.data["image_count"]))

    multi = 0
    if index == "all":
    multi = 1
    index = 0

    if not dest:
    dest = self.filename

    target = os.path.splitext(dest)[0]
    res = self.raw.demosaicate(index, multi, target)    # This call 
the CPython code

    self.out_filename = self.raw.out_file

    def run_multitasks(self):
    def process(*args):
    fname, idx, oname = args
    self.identify()
    self.unraw(idx, oname)

    while self.tasks:
    t = Thread(target=process, args=self.tasks.pop(0))
    t.start()
    t.join()
    if self.callback:
    self.callback(self.out_filename)


I use a list of 20 files and all files are converted, one by one, 
because the CPython part is not thread safe.


But the real interesting thing is the behaviour in the slot() function.

Examples:
 1 ---
def slot(name):
    if os.path.isfile(name):
    print("Created:", name, type(name))
    print("%s created" % name)

result:
add: /home/vincent/Images/RAW_orig/RAW_CANON_1DSM2.CR2
Scaling with darkness 127, saturation 3712, and
multipliers 2.310656 1.00 1.257116 1.00
AHD interpolation...
Converting to sRGB colorspace...
Created: 
/home/vincent/CPython/py361_venv/pyunraw/unraws/RAW_CANON_1DSM2.tiff 


Erreur de segmentation (core dumped)
--

 2 
def slot(name):
    new = name[:]
    if os.path.isfile(name):
    print("Created:", name, type(name))
    print("New:", new)
    print("%s created" % new)

result:
add /home/vincent/Images/RAW_orig/RAW_CANON_1DSM2.CR2
Scaling with darkness 127, saturation 3712, and
multipliers 2.310656 1.00 1.257116 1.00
AHD interpolation...
Converting to sRGB colorspace...
Created: 
/home/vincent/CPython/py361_venv/pyunraw/unraws/RAW_CANON_1DSM2.tiff 


New: /home/vincent/CPython/py361_venv/pyunraw/unraws/RAW_CANON_1DSM2.tiff
Erreur de segmentation (core dumped)
--

The most important, of course is the name of the new file created and I 
can be satisfied with that, I just need the file name, but it's not a 
reason to ignore the problem.


Vincent

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


Return str to a callback raise a segfault if used in string formating

2017-10-13 Thread Vincent Vande Vyvre

Simplified code:

---%<--
class Foo:
    tasks = []
    def process(self, *args):
    # process with the file
    # save result on disk with a new name
    self.out_filename.write(.)

    def run_multitasks(self):
    while self.tasks:
    t = Thread(target=process, args=self.tasks.pop(0))
    t.start()
    t.join()
    self.callback(self.out_filename)

    def add_task(self, fname, callback):
    self.tasks.append(fname)
    self.callback = callback
    if len(self.tasks) == 1:
    self.run_multitasks()

def slot(filename):
    print(filename) # Works
    print("%s created" % filename)  # Segfault !

Files = [list of files]
foo = Foo()
for f in Files:
    foo.add_task(f, slot)
---%<--

If I place self.callback() at the end of the func process that doesn't 
change anything.



Regards,

Vincent.

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


The mysterious ways of Python mailing list

2017-09-29 Thread Vincent Vande Vyvre
Is it a reason why my messages appears always a long time (today 9 
hours) on the list after I send it ?


Send at 19:14 UTC+2


Vincent

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


Re: Textwrap doesn't honour NO-BREAK SPACE

2017-09-29 Thread Vincent Vande Vyvre

Le 29/09/17 à 08:58, Frank Millman a écrit :
"Steve D'Aprano"  wrote in message 
news:59cde998$0$14935$b1db1813$d948b...@news.astraweb.com...


On Fri, 29 Sep 2017 03:55 pm, Terry Reedy wrote:


Expected result:


Lorum ipsum dolor sit amet, consectetur adipiscing elit
ZZZ ZZZ sed do euismod tempor incididunt ut labore et
dolore magna aliqua.


On Windows 10, I get this on 2.7, 3.5, 3.6, 3.7.


Actual result in Python 3.5 and older:

Lorum ipsum dolor sit amet, consectetur adipiscing elit ZZZ
ZZZ sed do euismod tempor incididunt ut labore et dolore
magna aliqua.


Sorry Terry, it isn't clear to me which result (expected, or actual) 
is "this"

in your comment.


I was also unsure, so to double-check myself I ran this from the 
prompt (Windows 10), not from the interpreter -


C:\Users\User>type aib\aib\test_db100.py

import textwrap
text = ('Lorum ipsum dolor sit amet, consectetur adipiscing'
   ' elit ZZZ\xa0ZZZ sed do euismod tempor incididunt'
   ' ut labore et dolore magna aliqua.')
print()
print(textwrap.fill(text, 59))

C:\Users\User>py -3.5 aib\aib\test_db100.py

Lorum ipsum dolor sit amet, consectetur adipiscing elit ZZZ
ZZZ sed do euismod tempor incididunt ut labore et dolore
magna aliqua.

C:\Users\User>py -3.6 aib\aib\test_db100.py

Lorum ipsum dolor sit amet, consectetur adipiscing elit
ZZZ ZZZ sed do euismod tempor incididunt ut labore et
dolore magna aliqua.

It confirms that the problem was there in 3.5, but is fixed in 3.6.

Frank Millman



Python 3.6.1 in venv

Python 3.6.1 (default, Apr 16 2017, 16:15:46)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import textwrap
>>> text = ('Lorum ipsum dolor sit amet, consectetur adipiscing'
... ' elit ZZZ\xa0ZZZ sed do euismod tempor incididunt'
... ' ut labore et dolore magna aliqua.')
>>> print(textwrap.fill(text, 59))
Lorum ipsum dolor sit amet, consectetur adipiscing elit
ZZZ ZZZ sed do euismod tempor incididunt ut labore et
dolore magna aliqua.


Vincent

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


Re: The Incredible Growth of Python (stackoverflow.blog)(kdnuggets)

2017-09-15 Thread Vincent Vande Vyvre

Again an other review:

http://www.kdnuggets.com/2017/08/python-overtakes-r-leader-analytics-data-science.html

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


Re: Signals and Slots - Summerfield - what exactly is a signal?

2017-08-05 Thread Vincent Vande Vyvre

Le 05/08/17 à 16:28, veek a écrit :

1. What exactly is a signal. In hardware, an interrupt can be viewed as a
signal and the voltage on a pin will suddenly jump to +5V as an indicator
that an interrupt has occurred. With Qt signals - if a widget-c++ code has
to 'signal' an event - what does it do?

As a consequence of not understanding the above..

2. How do you connect a single signal to multiple slots? Do the
slots/methods get called one by one? or are they treated as independent
threads and run on different cores?

You have to connect yours slots each by each.
self.my_button.clicked.connect(self.foo)
self.my_button.clicked.connect(self.baz)
...
Be care you can't know the order of the execution of foo and baz.
Any thread will be created for that, the binding will be executed into 
the main loop of your app.
But, if your signal is emitted from a thread, the slot will be executed 
into the main thread, this is a great advantage, your slot can interact 
safely with the graphics part of your app.


3. pg 130 of Summerfield

class ZeroSpinBox(QObject):
def __init__(self, parent=None):
   super(...blah initialize QObject with parent
   self.connect(self, SIGNAL("valuedChanged(int)"), self.checkzero)

def checkzero(self):
   if self.value() == 0:
  self.emit(SIGNAL("atzero"), self.zeros)

basically when SpinBox gets set to zero we emit 'atzero' and return a zeros
counter.

What i don't get is the valueChanged(int) bit.. he clearly defines an (int)
being passed to checkzero so shouldn't the definition reflect the same?
Mistake?
This is the old signal-slot methods, I encourage you to use the new (new 
but not recent) method

Like this:
from QtCore import pyqtSignal

class ZeroSpinBox(QObject):
   atZero = pyqtSignal(int)
   def __init__(self, parent=None):
  super(...blah initialize QObject with parent
  self.valuedChanged.connect(self.checkzero)

   def checkzero(self, value):
  if not value:
 # maybe increment self.zeros ?
 self.atzero.emit(self.zeros)


A. additionally I did not understand short circuit signals where you can
drop the (type1, type2) in the signature and just do
SIGNAL("atzero")

Is this doable ONLY in emit() or also in connect()??

I don't know, never used this construction of code.



4. pg 131 'any data can be passed as arguments to the emit method and they
can be passed as Python objects'

self.emit(SIGNAL("atzero"), 10, 20, 30) or
self.emit(SIGNAL("atzero"), [10, 20, 30])
does he mean i can pass a SINGLE OBJECT of any python type or does he mean
multiple independent containers?
(assuming the definition matches)

When you define your signal you can use any Python type
sig = pyqtSignal(int, float, str, str, ...)


5. He says 'a signal with one argument is a Qt signal or a non-short-circuit
Python signal'

So if I have a Qt widget in C++ and it emits a valueChanged(int) signal..
okay he's going to have to convert our asm/x86 int to python-integer and
then call the python-method that was mapped to 'valueChanged' with the
python-integer argument OR the signal is being generated from Python code
itself AND WILL be converted to C++ datatype - huh why??

The wrapper use simply the CPython "PyLong_AsLong" or "PyUnicode_FromString"
or "Py_BuildValue" or other and you get always a Python object.


I'm guessing there's some dispatch code that maintains a mapping table?? SO
why can't it differentiate between inhouse python widget and Qt-c++ widget??


6. "If we use the SIGNAL() function with a signalSignature (a possibly empty
parenthesized list of comma-separated PyQt types)..."??

how can it be an empty () list..?? If there's a list it's no longer empty..

7. What exactly is a Python signal vs a Qt signal originating from a C++-
asm-widget?? PyQt is a wrapper around C++Qt so.. where are the python
widgets??

8.
class TaxRate(QObject):
   def __init__(self):
 super(TaxRate, self).__init__()
 self.__rate = 17.5

   def rate(self):
 return self.__rate

   def setRate(self, rate):
 if rate != self.__rate:
self.__rate = rate
self.emit(SIGNAL("rateChanged"), self.__rate)

def rateChanged(value):
print "TaxRate changed to %.2f%%" % value

vat = TaxRate()
vat.connect(vat, SIGNAL("rateChanged"), rateChanged)
vat.setRate(17.5) # No change will occur (new rate is the same)
vat.setRate(8.5) # A change will occur (new rate is different)

Isn't this a mistake? self.connect( should be:
vat.connect(vat, SIGNAL("rateChanged"), rate)


Again, use the new syntaxe (new but not recent) it's more clear.

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


Re: PYhton Mercator projection

2017-04-18 Thread Vincent Vande Vyvre

Le 18/04/17 à 16:04, jorge.conr...@cptec.inpe.br a écrit :



 Hi,

 I copy the script merc.py from:

 https://matplotlib.org/basemap/users/merc.html


 then I did: python merc.py and I had:


 Segmentation fault


 Please can someone help me.


 Conrado




Add some print() to see where the code fail.


Vincent

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


Re: Python 3.5+ Arrow keys and others in the console

2017-04-16 Thread Vincent Vande Vyvre

Le 16/04/17 à 15:19, Wolfgang Maier a écrit :

On 16.04.2017 10:56, Vincent Vande Vyvre wrote:

Hi,

I'm using Python 3.5 and 3.6 in venv and I see a strange behaviour in
the interactive interpreter.

The arrow keys can't be used to move the cursor into the current line of
code or to rewrite the last lines.

With the 3.5 I can use the backspace and erase the code but not in 3.6

Python 3.5.2 (default, Dec 19 2016, 11:46:33)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.

f = "kjhfgt"^[[D# Left Arrow Key
^[[A# Up Arrow Key



Python 3.6.1 (default, Apr 12 2017, 11:39:17)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.

f = "lkjgh"
^[[A^[[B# Up Arrow Key and Backspace Key

  File "", line 1

^
SyntaxError: invalid syntax






Make sure you build Python (I guess you did this for 3.6, but are 
probably using your OS Python3.5) with readline. This needs the dev 
version of the readline library installed at build time.
So, step 1 would be to get the library, then rebuild Python3.6 by 
running:


1) make clean
2) ./configure
3) make

It could be worthwhile checking for other missing optional C libraries 
first though. If you want to make sure you have all of them, follow 
the steps described here:


https://docs.python.org/devguide/setup.html#build-dependencies

Best,
Wolfgang




No, both are in venv, my system version is the 3.4.

Anyway, after "apt-get build-dep python3.4" and following your advice 
all works as expected.


Thanks Wolfgang.


Incidentally, with the 3.6 I've added the argument 
"--enable-optimizations" to the configure.


The unitest were executed and fail with hashlib, then it rerun some 
compilation, rerun the unittest, refail with hashlib, recompile some 
modules and finish without error. (see a little part of the log below)


I don't know if this is relevant ...


Vincent




0:06:47 [161/405] test_hash
0:06:49 [162/405] test_hashlib
Fatal Python error: Segmentation fault

Current thread 0x2af5c0cfa380 (most recent call first):
  File 
"/home/vincent/CPython/Python-3.6.1/Lib/test/support/__init__.py", line 
1508 in gc_collect
  File 
"/home/vincent/CPython/Python-3.6.1/Lib/test/libregrtest/save_env.py", 
line 271 in __exit__
  File 
"/home/vincent/CPython/Python-3.6.1/Lib/test/libregrtest/runtest.py", 
line 168 in runtest_inner
  File 
"/home/vincent/CPython/Python-3.6.1/Lib/test/libregrtest/runtest.py", 
line 129 in runtest
  File 
"/home/vincent/CPython/Python-3.6.1/Lib/test/libregrtest/main.py", line 
343 in run_tests_sequential
  File 
"/home/vincent/CPython/Python-3.6.1/Lib/test/libregrtest/main.py", line 
418 in run_tests
  File 
"/home/vincent/CPython/Python-3.6.1/Lib/test/libregrtest/main.py", line 
490 in _main
  File 
"/home/vincent/CPython/Python-3.6.1/Lib/test/libregrtest/main.py", line 
468 in main
  File 
"/home/vincent/CPython/Python-3.6.1/Lib/test/libregrtest/main.py", line 
532 in main
  File "/home/vincent/CPython/Python-3.6.1/Lib/test/regrtest.py", line 
46 in _main
  File "/home/vincent/CPython/Python-3.6.1/Lib/test/regrtest.py", line 
50 in 
  File "/home/vincent/CPython/Python-3.6.1/Lib/runpy.py", line 85 in 
_run_code
  File "/home/vincent/CPython/Python-3.6.1/Lib/runpy.py", line 193 in 
_run_module_as_main

Segmentation fault (core dumped)
make[1]: quittant le répertoire « /home/vincent/CPython/Python-3.6.1 »
make build_all_merge_profile
make[1]: entrant dans le répertoire « /home/vincent/CPython/Python-3.6.1 »
true
make[1]: quittant le répertoire « /home/vincent/CPython/Python-3.6.1 »
Rebuilding with profile guided optimizations:
make clean
make[1]: entrant dans le répertoire « /home/vincent/CPython/Python-3.6.1 »
find . -depth -name '__pycache__' -exec rm -rf {} ';'
find . -name '*.py[co]' -exec rm -f {} ';'
find . -name '*.[oa]' -exec rm -f {} ';'
find . -name '*.s[ol]' -exec rm -f {} ';'
find . -name '*.so.[0-9]*.[0-9]*' -exec rm -f {} ';'
find build -name 'fficonfig.h' -exec rm -f {} ';' || true
find build -name '*.py' -exec rm -f {} ';' || true
find build -name '*.py[co]' -exec rm -f {} ';' || true
rm -f pybuilddir.txt
rm -f Lib/lib2to3/*Grammar*.pickle
rm -f Programs/_testembed Programs/_freeze_importlib
find build -type f -a ! -name '*.gc??' -exec rm -f {} ';'
rm -f Include/pydtrace_probes.h
make[1]: quittant le répertoire « /home/vincent/CPython/Python-3.6.1 »
make build_all_use_profile
make[1]: entrant dans le répertoire « /home/vincent/CPython/Python-3.6.1 »
make build_all CFLAGS_NODIST=" -fprofile-use -fprofile-correction " 
LDFLAGS=" "

make[2]: entrant dans le répertoire « /home

Python 3.5+ Arrow keys and others in the console

2017-04-16 Thread Vincent Vande Vyvre

Hi,

I'm using Python 3.5 and 3.6 in venv and I see a strange behaviour in 
the interactive interpreter.


The arrow keys can't be used to move the cursor into the current line of 
code or to rewrite the last lines.


With the 3.5 I can use the backspace and erase the code but not in 3.6

Python 3.5.2 (default, Dec 19 2016, 11:46:33)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> f = "kjhfgt"^[[D# Left Arrow Key
>>> ^[[A# Up Arrow Key


Python 3.6.1 (default, Apr 12 2017, 11:39:17)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> f = "lkjgh"
>>> ^[[A^[[B# Up Arrow Key and Backspace Key
  File "", line 1

^
SyntaxError: invalid syntax
>>>


Am I the only one with this ?

Vincent

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


Re: CPython Class variable exposed to Python is altered.

2017-04-12 Thread Vincent Vande Vyvre

Le 12/04/17 à 11:47, Peter Otten a écrit :

Vincent Vande Vyvre wrote:



No, no warning.


For the truth, this code is copy-pasted from the doc.

https://docs.python.org/3.5//extending/newtypes.html#adding-data-and-methods-to-the-basic-example

But the example expects objects (the big O), not strings. Following the
example you need

  if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|", kwlist, ))
  return -1;

and also

static PyMemberDef Test_members[] = {
  {"name", T_OBJECT_EX, offsetof(Test, name), 0,
   "The object name"},
  {NULL}  /* Sentinel */
};

If you want a string instead of an object you must not apply Py_INCREF(),
you probably have to manage its lifetime yourself.



I've just installed a new venv with the 3.6.1 and tested your changes.

And now, that's all right.

I see the devil is into the details ...


Many thanks Peter


Vincent

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


Re: CPython Class variable exposed to Python is altered.

2017-04-12 Thread Vincent Vande Vyvre

Le 12/04/17 à 10:51, Peter Otten a écrit :

Vincent Vande Vyvre wrote:


Le 12/04/17 à 08:57, Vincent Vande Vyvre a écrit :

Hi,

Learning CPython, I've made this simple exercice, a module test which
contains an object Test.

The object Test has an attribute name, fixed at instanciation.

So, I try my code with a script:

---
from test import Test

for n in ("The name", "Foo", "Spam"):
 t = Test(n)
 print("%s --> %s" %(n, t.name))
---

And the return:

Uhe name --> Uhe name
Goo --> Goo
Tpam --> Tpam

As we can see, the first letter is changed with the next letter in
alphabetical order, but not only for the attribute name, also for the
reference n.

  if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|", kwlist, ))
  return -1;

  if (name) {
  tmp = self->name;
  Py_INCREF(name);

While I don't know how to do this properly you seem to be applying
Py_INCREF() to a C string rather than a Python string object. C being C you
can cast anything to anything else...

Aren't there any warnings at compile time?



No, no warning.


For the truth, this code is copy-pasted from the doc.

https://docs.python.org/3.5//extending/newtypes.html#adding-data-and-methods-to-the-basic-example


Vincent

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


Re: CPython Class variable exposed to Python is altered.

2017-04-12 Thread Vincent Vande Vyvre

Le 12/04/17 à 08:57, Vincent Vande Vyvre a écrit :

Hi,

Learning CPython, I've made this simple exercice, a module test which 
contains an object Test.


The object Test has an attribute name, fixed at instanciation.

So, I try my code with a script:

---
from test import Test

for n in ("The name", "Foo", "Spam"):
t = Test(n)
print("%s --> %s" %(n, t.name))
---

And the return:

Uhe name --> Uhe name
Goo --> Goo
Tpam --> Tpam

As we can see, the first letter is changed with the next letter in 
alphabetical order, but not only for the attribute name, also for the 
reference n.


Same into a console:

(py352_venv) vincent@djoliba:~/CPython/py352_venv/pydcraw$ python
Python 3.5.2 (default, Dec 19 2016, 11:46:33)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from test import Test
>>> for n in ("The name", "Foo", "Spam"):
... t = Test(n)
... print("%s --> %s" %(n, t.name))
...
Uhe name --> Uhe name
Goo --> Goo
Tpam --> Tpam


I'm working in a venv.

The testmodule.c is attached.


The setup.py

from distutils.core import setup, Extension
setup(name="test", version="1.0",
  ext_modules=[
 Extension("test", ["testmodule.c"],
   libraries=[])
 ])



Best,


Vincent


I see the attachement is rejected.


This is the testmodule.c

---

#include 
#include "structmember.h"


typedef struct {
PyObject_HEAD
PyObject *name;
} Test;

static void
Test_dealloc(Test* self)
{
Py_XDECREF(self->name);
}

static PyObject *
Test_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
Test *self;

self = (Test *)type->tp_alloc(type, 0);
if (self != NULL){
self->name = PyUnicode_FromString("");
if (self->name == NULL){
Py_DECREF(self);
return NULL;
}
}

return (PyObject *)self;
}

static int
Test_init(Test *self, PyObject *args, PyObject *kwds)
{
PyObject *name, *tmp;
static char *kwlist[] = {"name", NULL};

if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|", kwlist, ))
return -1;

if (name) {
tmp = self->name;
Py_INCREF(name);
self->name = name;
Py_XDECREF(tmp);
}

return 0;
}

static PyMemberDef Test_members[] = {
{"name", T_STRING, offsetof(Test, name), 0,
 "The object name"},
{NULL}  /* Sentinel */
};

static PyMethodDef Test_methods[] = {
{NULL} /* sentinel */
};

static PyTypeObject TestType = {
PyVarObject_HEAD_INIT(NULL, 0)
"test.Test",  /* tp_name */
sizeof(Test), /* tp_basicsize */
0,/* tp_itemsize */
(destructor)Test_dealloc, /* tp_dealloc */
0,/* tp_print */
0,/* tp_getattr */
0,/* tp_setattr */
0,/* tp_reserved */
0,/* tp_repr */
0,/* tp_as_number */
0,/* tp_as_sequence */
0,/* tp_as_mapping */
0,/* tp_hash  */
0,/* tp_call */
0,/* tp_str */
0,/* tp_getattro */
0,/* tp_setattro */
0,/* tp_as_buffer */
Py_TPFLAGS_DEFAULT |
Py_TPFLAGS_BASETYPE,  /* tp_flags */
"Test object",/* tp_doc */
0,/* tp_traverse */
0,/* tp_clear */
0,/* tp_richcompare */
0,/* tp_weaklistoffset */
0,/* tp_iter */
0,/* tp_iternext */
Test_methods, /* tp_methods */
Test_members, /* tp_members */
0,/* tp_getset */
0,/* tp_base */
0,/* tp_dict */
0,/* tp_descr_get */
0,/* tp_descr_set */
0,/* tp_dictoffset */
(initproc)Test_init,  /* tp_init */
0,/* tp_alloc */
Test_new, /* tp_new */
};

static PyModuleDef testmo

CPython Class variable exposed to Python is altered.

2017-04-12 Thread Vincent Vande Vyvre

Hi,

Learning CPython, I've made this simple exercice, a module test which 
contains an object Test.


The object Test has an attribute name, fixed at instanciation.

So, I try my code with a script:

---
from test import Test

for n in ("The name", "Foo", "Spam"):
t = Test(n)
print("%s --> %s" %(n, t.name))
---

And the return:

Uhe name --> Uhe name
Goo --> Goo
Tpam --> Tpam

As we can see, the first letter is changed with the next letter in 
alphabetical order, but not only for the attribute name, also for the 
reference n.


Same into a console:

(py352_venv) vincent@djoliba:~/CPython/py352_venv/pydcraw$ python
Python 3.5.2 (default, Dec 19 2016, 11:46:33)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from test import Test
>>> for n in ("The name", "Foo", "Spam"):
... t = Test(n)
... print("%s --> %s" %(n, t.name))
...
Uhe name --> Uhe name
Goo --> Goo
Tpam --> Tpam


I'm working in a venv.

The testmodule.c is attached.


The setup.py

from distutils.core import setup, Extension
setup(name="test", version="1.0",
  ext_modules=[
 Extension("test", ["testmodule.c"],
   libraries=[])
 ])



Best,


Vincent

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


Re: Temporary variables in list comprehensions

2017-04-06 Thread Vincent Vande Vyvre

Le 06/04/17 à 14:25, Piet van Oostrum a écrit :

Steven D'Aprano  writes:


Suppose you have an expensive calculation that gets used two or more times in a
loop. The obvious way to avoid calculating it twice in an ordinary loop is with
a temporary variable:

result = []
for x in data:
 tmp = expensive_calculation(x)
 result.append((tmp, tmp+1))


But what if you are using a list comprehension? Alas, list comps don't let you
have temporary variables, so you have to write this:


[(expensive_calculation(x), expensive_calculation(x) + 1) for x in data]


Or do you? ... no, you don't!


[(tmp, tmp + 1) for x in data for tmp in [expensive_calculation(x)]]


I can't decide whether that's an awesome trick or a horrible hack...

It is a poor man's 'let'. It would be nice if python had a real 'let'
construction. Or for example:

[(tmp, tmp + 1) for x in data with tmp = expensive_calculation(x)]

Alas!


With two passes

e = [expensive_calculation(x) for x in data]
final = [(x, y+1) for x, y in zip(e, e)]

Vincent


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


Re: python and pyqt4

2017-03-14 Thread Vincent Vande Vyvre

Le 14/03/17 à 20:56, Xristos Xristoou a écrit :

i will want to create a simple python script with pyqt4 and Q designer where 
the user put a number (line_edit) and if that number is something the user take 
back three new codes(lineEdit_2,lineEdit_3,lineEdit_4) and if user press 
ok(buttonBox) then plugin do something else in the some GUI.
for that i create a new additional pushButton in Qdesigner and i create 
additional def function(run1) for execute code for pushButton.


first i add new pushbutton in __init__ :
def __init__(self, iface):
 self.dlg = pluginDialog()
 self.dlg.pushButton.clicked.connect(self.run1)

plugin work without error but dont show me the codes 
(lineEdit_2,lineEdit_3,lineEdit_4) in the plugin window if i press
pushbutton
any idea ? my python code :

def run1(self):
 distance = str(self.dlg.lineEdit.text())
 if distance==0:
 area1='some'
 area2='hello'
 area3='world'
 self.dlg.lineEdit_2.setText(str(area1))
 self.dlg.lineEdit_3.setText(str(area2))
 self.dlg.lineEdit_4.setText(str(area3))



def run(self):
 self.dlg.show()
 result = self.dlg.exec_()

 if result:
 pass

and i try to replace run1 with :

def run1(self):
 self.dlg.show()
 result = self.dlg.exec_()
 if result:
 distance = str(self.dlg.lineEdit.text())
 if distance==0:
 area1='some'
 area2='hello'
 area3='world'
 self.dlg.lineEdit_2.setText(str(area1))
 self.dlg.lineEdit_3.setText(str(area2))
 self.dlg.lineEdit_4.setText(str(area3))
 pass

but no change.


distance is a string, then you have to compare it with the string "0" 
not the integer



Vincent

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


Re: Usage of ast.

2017-02-27 Thread Vincent Vande Vyvre

Le 27/02/17 à 14:09, Chris Angelico a écrit :

On Mon, Feb 27, 2017 at 11:57 PM, Vincent Vande Vyvre
<vincent.vande.vy...@telenet.be> wrote:

I've this strange error:

Python 3.4.3 (default, Nov 17 2016, 01:08:31)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.

import ast
l = "print('hello world')"
ast.literal_eval(l)

Traceback (most recent call last):
   File "", line 1, in 
   File "/usr/lib/python3.4/ast.py", line 84, in literal_eval
 return _convert(node_or_string)
   File "/usr/lib/python3.4/ast.py", line 83, in _convert
 raise ValueError('malformed node or string: ' + repr(node))
ValueError: malformed node or string: <_ast.Call object at 0x7fcf955871d0>


Is it an import question ?

The message is a little confusing, but the error comes from the fact
that literal_eval permits a very few legal operations, and calling a
function isn't one of them. So when you try to evaluate the "literal"
that you've given it, you get back an error saying that a Call is
'malformed'. More accurate would be to say that it's not permitted.

ChrisA


OK, it's coherent with the secure execution.


Thanks


Vincent

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


Usage of ast.

2017-02-27 Thread Vincent Vande Vyvre

I've this strange error:

Python 3.4.3 (default, Nov 17 2016, 01:08:31)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ast
>>> l = "print('hello world')"
>>> ast.literal_eval(l)
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python3.4/ast.py", line 84, in literal_eval
return _convert(node_or_string)
  File "/usr/lib/python3.4/ast.py", line 83, in _convert
raise ValueError('malformed node or string: ' + repr(node))
ValueError: malformed node or string: <_ast.Call object at 0x7fcf955871d0>


Is it an import question ?


Vincent

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


Re: os.path.isfile

2017-02-10 Thread Vincent Vande Vyvre

Le 10/02/17 à 22:03, Vincent Vande Vyvre a écrit :

Le 10/02/17 à 21:36, Peter Otten a écrit :

Vincent Vande Vyvre wrote:


Le 10/02/17 à 19:11, epro...@gmail.com a écrit :

Hello NG

Python 3.5.2

Windows 10

os.path.isfile() no recognise file with double dot?

eg. match.cpython-35.pyc

Please somebody know something about that?

Thank You in advance


Interesting, you're right.

Python 3.4.3 (default, Nov 17 2016, 01:08:31)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
  >>> import os
  >>>

os.path.isfile('/home/vincent/oqapy-3/trunk/__pycache__/grid.cpython-34.pyc 


')
False


Why ?
No idea in the case of the OP -- on Windows a string literal 
containing a

sequence like "...\t..." is always a good candidate.

But you probably sneaked in a trailing newline or space -- i. e. 'twas a
pasting mishap ;)



No, it's a copy-paste.

No trailing newline.


OooPs, no newline but just a space.


I'm using frequently the copy-paste of file name into a terminal and I 
don't never see that.


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


Re: os.path.isfile

2017-02-10 Thread Vincent Vande Vyvre

Le 10/02/17 à 21:36, Peter Otten a écrit :

Vincent Vande Vyvre wrote:


Le 10/02/17 à 19:11, epro...@gmail.com a écrit :

Hello NG

Python 3.5.2

Windows 10

os.path.isfile() no recognise file with double dot?

eg. match.cpython-35.pyc

Please somebody know something about that?

Thank You in advance


Interesting, you're right.

Python 3.4.3 (default, Nov 17 2016, 01:08:31)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
  >>> import os
  >>>


os.path.isfile('/home/vincent/oqapy-3/trunk/__pycache__/grid.cpython-34.pyc

')
False


Why ?

No idea in the case of the OP -- on Windows a string literal containing a
sequence like "...\t..." is always a good candidate.

But you probably sneaked in a trailing newline or space -- i. e. 'twas a
pasting mishap ;)



No, it's a copy-paste.

No trailing newline.

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


Re: os.path.isfile

2017-02-10 Thread Vincent Vande Vyvre

Le 10/02/17 à 19:11, epro...@gmail.com a écrit :

Hello NG

Python 3.5.2

Windows 10

os.path.isfile() no recognise file with double dot?

eg. match.cpython-35.pyc

Please somebody know something about that?

Thank You in advance


Interesting, you're right.

Python 3.4.3 (default, Nov 17 2016, 01:08:31)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> 
os.path.isfile('/home/vincent/oqapy-3/trunk/__pycache__/grid.cpython-34.pyc 
')

False


Why ?

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


Re: Unable to Debug

2017-01-02 Thread Vincent Vande Vyvre

Le 02/01/17 à 10:04, Aritra Bhattacharjee a écrit :

I am new to python programming. I wrote a code to search for the product names 
on a page of snapdeal.com .

Code:
import urllib.request
from bs4 import BeautifulSoup as BS

url = 'https://www.snapdeal.com/products/electronics-headphones?sort=plrty'

response = urllib.request.urlopen(url).read()
soup = BS(response, 'html.parser')

#for dataprice in soup.find_all('span', class_="lfloat product-price"):
#print(dataprice)
product_name={}
i=0
for title in soup.find_all('p', class_="product-title"):
 product_name[i]=title.string
 i += 1
for i in range(1,21):
 print(product_name[i])


Output:
Traceback (most recent call last):
Motorola Pulse 2 Over Ear Wired Headphones With Mic (Black)
Bose SoundLink On-Ear Bluetooth Headphones - Black & Blue
Sony MDR-ZX110A Headphones Without Mic (White)
Philips SBCHL140/98 Over Ear Headphone Without Mic
   File "C:/Users/Aritra Bhattacharjee/PycharmProjects/PythonWebModules/Web 
Scraper.py", line 17, in 
Intex Desire BT Over Ear Wired With Mic Headphone Black
 print(product_name[i])
JBL T450 On Ear Wired Headphones With Mic Black
KeyError: 20
Motorola Pulse Max Over Ear Wired Headphones With Mic (Black)
Philips SHB7250WT/00 Over Ear Wireless Headphones With Mic White
Sony MDR-XB650BT On-Ear Extra Bass(XB) Headphones with Bluetooth & NFC (Black)
Intex JAZZ Over Ear Wired With Mic Headphone Black
Skullcandy S5GBW-J539 On Ear Wireless Headphones With Mic Black
JBL C300SI Over Ear Wired Without Mic Headphone Black
Zoook Rocker iFit Bluetooth Wireless Headphones With Mic Black
Signature VM-46 Over Ear Wired Headphone Without Mic White
Sony MDR-G45 Over Ear Wired Without Mic Headphone- Black
Motorola Pulse Max Over Ear Wired Headphones With Mic (White)
Bose SoundTrue Around-Ear Headphones with Mic (Navy Blue) for Samsung and 
Android Devices
JBL T450 On Ear Wired Headphones With Mic Blue
Motorola Pulse 2 Over Ear Wired Headphones With Mic (White)


The Output shows some error that I could not understand why...Thanks in Advance


Try with:


for i in product_name:

print(i)


Vincent

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


Re: Can't see numpy etc after upgrading Python on Ubuntu

2016-12-20 Thread Vincent Vande Vyvre

Le 20/12/16 à 10:13, Chris Angelico a écrit :

On Tue, Dec 20, 2016 at 7:36 PM, Vincent Vande Vyvre
<vincent.vande.vy...@telenet.be> wrote:

It seems you have shadowed your default python2 with the new one. A very bad
idea.

Only because /usr/local/bin is ahead of /usr/bin in PATH.

That's the problem.



The link /usr/bin/python *MUST* point to the 2.7.3 version, if not, restore
it.

It does. When he installs pip via apt, it manages his original 2.7.3.
Anything that explicitly shebangs to /usr/bin/python will be
unaffected by this.

ChrisA


Not sure, when the OP enter python into a terminal he have:

peter@sirboris:~$ python
Python 2.7.12 (default, Dec 11 2016, 22:16:38)

So, python point now to the new one. No? VVV

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


Re: Can't see numpy etc after upgrading Python on Ubuntu

2016-12-20 Thread Vincent Vande Vyvre

Le 20/12/16 à 08:45, Chris Angelico a écrit :

On Tue, Dec 20, 2016 at 5:19 PM,   wrote:

Thanks Chris for replying, but it didn't work. The upgrade happened, but still 
python can't see numpy! So it seems to be a path problem. The numpy (and scipy 
and matplotlib) files are there, so surely in principle it's a simple matter of 
pointing my python path at them?

Any ideas how?

You just installed pip into your /usr/bin/python, not
/usr/local/bin/python. You'll need to get pip in that Python and use
that. I'm not sure the best way to install pip into a 2.7 - someone
else on this list can advise.

ChrisA


It seems you have shadowed your default python2 with the new one. A very 
bad idea.


You can have two python2 but you can't replace the default version.

The default is in /usr/lib and the new is in /usr/locale/lib

The third party libs are into the default version. For this reason 
there's probably some applications that are broken. (apport, bzr, 
synaptic?, ...)


The link /usr/bin/python *MUST* point to the 2.7.3 version, if not, 
restore it.


One solution for use the new version is to create the necessary symbolic 
links into /usr/locale/lib/python2.7/dist-packages which point to 
/usr/lib/python2.7/dist-packages numpy, scipy and others.


In fact, this is the same think when you create a virtual environment, 
the libs are not copied but linked.



VVV

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


Re: TemplateError

2016-11-20 Thread Vincent Vande Vyvre

Le 21/11/2016 à 07:22, iivri.an...@gmail.com a écrit :

THIS error is constantly showing up when I run my python script
  eloiim:build iivri.andre$ python run.py
  * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
[2016-11-21 01:15:26,561] ERROR in app: Exception on / [GET]
Traceback (most recent call last):
   File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1988, in 
wsgi_app
 response = self.full_dispatch_request()
   File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1641, in 
full_dispatch_request
 rv = self.handle_user_exception(e)
   File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1544, in 
handle_user_exception
 reraise(exc_type, exc_value, tb)
   File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1639, in 
full_dispatch_request
 rv = self.dispatch_request()
   File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1625, in 
dispatch_request
 return self.view_functions[rule.endpoint](**req.view_args)
   File "run.py", line 10, in IsSelf
 return render_template('index.html', author=author, name=name)
   File "/usr/local/lib/python2.7/site-packages/flask/templating.py", line 133, 
in render_template
 return 
_render(ctx.app.jinja_env.get_or_select_template(template_name_or_list),
   File "/usr/local/lib/python2.7/site-packages/jinja2/environment.py", line 
851, in get_or_select_template
 return self.get_template(template_name_or_list, parent, globals)
   File "/usr/local/lib/python2.7/site-packages/jinja2/environment.py", line 
812, in get_template
 return self._load_template(name, self.make_globals(globals))
   File "/usr/local/lib/python2.7/site-packages/jinja2/environment.py", line 
774, in _load_template
 cache_key = self.loader.get_source(self, name)[1]
   File "/usr/local/lib/python2.7/site-packages/flask/templating.py", line 57, 
in get_source
 return self._get_source_fast(environment, template)
   File "/usr/local/lib/python2.7/site-packages/flask/templating.py", line 85, 
in _get_source_fast
 raise TemplateNotFound(template)
TemplateNotFound: index.html

THIS is the code

from flask import Flask, render_template
app = Flask(__name__)

@app.route('/')
# THE @ is a decorator that is used to 'augment' function definitions
# Flask uses 'route()' to indicate that if the browser requests the address '/' 
(the default | home address), then our app shoud 'route' that request to this 
'IsSelf' function
def IsSelf() :
 author = "raphael James "
 name = "Jaden iivii"
 return render_template('index.html', author=author, name=name)

if __name__ == "__main__" :
 app.run()


How do I fix this?


Flask don't know where are your templates.

I use this:

WEBDIR = os.path.dirname(os.path.abspath('__files__'))
PAGESDIR = os.path.join(os.path.dirname(WEBDIR), 'somewhere/templates')
STATICDIR = os.path.join(os.path.dirname(WEBDIR), 'somewhere/static')
...

app = Flask(__name__, template_folder=PAGESDIR, static_folder=STATICDIR)
...

--
Vincent V.V.
Oqapy  . python3-exiv2 
 . Qarte 
 . PaQager 

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


Re: Python GUI application embedding a web browser - Options?

2016-10-19 Thread Vincent Vande Vyvre

Le 19/10/2016 à 12:07, Paul Moore a écrit :

I'm looking to write a GUI application in Python (to run on Windows, using 
Python 3.5). The application is just a relatively thin wrapper around a browser 
- it's presenting an existing web application, just in its own window rather 
than in a standard browser window. I'm looking for advice on a good GUI toolkit 
to use.

I've not done much GUI programming in Python, so I don't have a "preferred toolkit" as 
such. A bit of Google searching found an embedded browser widget in PyQt, but the examples I tried 
didn't work - it looks like the QWebView class is deprecated and has been removed in the current 
version of PyQt. I haven't really found any other examples (there's a "embedding a web page in 
Tkinter" example I found, but it looks like it's just doing rendering, not embedding a full 
browser - which I need as the site I want to access uses CSS/JavaScript).

Is there any good option for this, or would I be better looking elsewhere for a 
solution? I could probably work out how to knock something up using .NET, or a 
HTA file, for example, I'm just more comfortable coding in Python.

Thanks,
Paul


Hi,

PyQt is a good choice to embed a web viewer in a GUI application.

There's no great differences between Qt4 and Qt5.

An example with PyQt4:
http://bazaar.launchpad.net/~vincent-vandevyvre/oqapy/2.0/files/head:/oqapy-2.0/g9n/

The same with PyQt5:
http://bazaar.launchpad.net/~vincent-vandevyvre/oqapy/3.0/files/head:/g9n/

--
Vincent V.V.
Oqapy  . python3-exiv2 
 . Qarte 
 . PaQager 

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


Re: PEP suggestion: Uniform way to indicate Python language version

2016-08-21 Thread Vincent Vande Vyvre

Le 21/08/2016 à 20:28, rocky a écrit :

The problem:

1. there are various code inspection tools that parse Python programs looking 
for style issues or whatnot. The deeper ones have to do a full parse of the 
python program. It would be helpful if there were a uniform way to indicate the 
Python language level used in Python source code.

2. I get a standalone python program that is not part of a package. vcprompt 
https://bitbucket.org/gward/vcprompt might be an example
It would be helpful if there were an easy way to know what language version of 
Python it assumes

Perl has something like called "use perl".  "use" is roughly equivalent to 
"import".

Possible solutions:

Do it the similar to "use perl". Here "perl" is a package that just tests the 
parameter given it. In Python such the code would look something like

File/module python30.py

import sys
assert sys.version >= (sys.version_info >= (3, 0))

The above works, but to reduce proliferation of packages it might be preferable 
to come up with some way to pass a version specification string similar to the 
specification strings allowed in setup.py

A metadata tag as a comment in a docstring or in a comment.
Preferably this would be given towards the top of the file to make it easier 
for tools to extract this information.

Thoughts?


I don't understand your assertion

Python 3.2.3 (default, Jun 18 2015, 21:46:42)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> assert sys.version >= (sys.version_info >= (3, 0))
Traceback (most recent call last):
  File "", line 1, in 
TypeError: unorderable types: str() >= bool()


What you means ?

--
Vincent V.V.
Oqapy  . python3-exiv2 
 . Qarte 
 . PaQager 

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


Re: PyQt5: is the wrapper incomplete?

2016-06-16 Thread Vincent Vande Vyvre

Le 16/06/2016 04:54, jlada...@itu.edu a écrit :

I am developing a data acquisition system for a custom device that communicates 
over USB.  On the host computer side, I am using PyQt5.4.  My Linux box has 
both Qt4 and Qt5 installed on it.  I assume that PyQt5.4 compiled on top of Qt5 
automatically.  I'm not sure how to check that.

In any case, I used PySerial to handle the USB communication.  I just noticed 
that Qt also has serial features.  I need to give the completed program to 
other users, on Windows no less.  If I can forego PySerial and use Qt's serial 
interface instead, it would simplify the installation.

Now, the PyQt5 documentation implies that a module called QtSerial exists.  But 
while I can write...

from PyQt5.QtWidgets import (...), or
from PyQt5.QtGui import (...), or
from PyQt5.QtCore import (...),

...attempting to import from PyQt5.QtSerial raises an ImportError.

I've tried many variations on the spelling, and I've tried various import 
statements to inspect the (very large and complex) PyQt5 namespace.  I haven't 
found the QtSerial classes.  Are they even there?  Maybe the wrapping of the 
library is incomplete?

Any guidance is appreciated, thanks!


On Debian, this is a separate package python3-pyqt5.qtserialport, I 
don't know for other Linux


After install you can use:

from PyQt5.QtSeriaPort import QSerialPort

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


Re: AttributeError into a bloc try-except AttributeError

2016-06-12 Thread Vincent Vande Vyvre

Le 12/06/16 09:20, Vincent Vande Vyvre a écrit :

Hi,

I have a strange behaviour in my code.

In an interactive session, the result is as expected:

Python 3.4.3 (default, Oct 14 2015, 20:28:29)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> a = None
>>> try:
... _ = a.value
... except AttributeError:
... print('OK')
...
OK
>>>

But not in my code:

def call_settings_dialog(self):
try:
_ = self.video.category
self.core.artelive.configure_downloading(self.video)
except AttributeError:
self.core.artetv.configure_downloading(self.video)

and ...

Traceback (most recent call last):
  File "/home/vincent/qarte-3/trunk/loadingscheduler.py", line 240, in 
call_settings_dialog

_  = self.video.category
AttributeError: 'TVItem' object has no attribute 'category'

I have two types of video, one with an attribute category handled by a 
module 'artelive' and an other without this attribute handled by an 
other module, that's the reason of this code.



... I have just rewrite the line "_ = self.video.category" and the 
problem disappears.


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


AttributeError into a bloc try-except AttributeError

2016-06-12 Thread Vincent Vande Vyvre

Hi,

I have a strange behaviour in my code.

In an interactive session, the result is as expected:

Python 3.4.3 (default, Oct 14 2015, 20:28:29)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> a = None
>>> try:
... _ = a.value
... except AttributeError:
... print('OK')
...
OK
>>>

But not in my code:

def call_settings_dialog(self):
try:
_ = self.video.category
self.core.artelive.configure_downloading(self.video)
except AttributeError:
self.core.artetv.configure_downloading(self.video)

and ...

Traceback (most recent call last):
  File "/home/vincent/qarte-3/trunk/loadingscheduler.py", line 240, in 
call_settings_dialog

_  = self.video.category
AttributeError: 'TVItem' object has no attribute 'category'

I have two types of video, one with an attribute category handled by a 
module 'artelive' and an other without this attribute handled by an 
other module, that's the reason of this code.

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


Re: Setting Return-Path in email

2016-05-23 Thread Vincent Vande Vyvre

Le 23/05/2016 10:39, ragav s a écrit :

Hi all,

How can i add different Return-path and fromid in python.i have pasted the 
below code for preview


def sendMail(sub,fromid,to,cc,html):
 msg = MIMEMultipart('alternative')
 msg['Subject'] = sub
 msg['From'] = fromid
 msg['To'] = to
 toaddress = [to]
 if cc:
 msg['Cc'] = cc
 toaddress = to+","+ cc
 toaddress = toaddress.split(",")

 type = 'plain'
 part = MIMEText(html, type,'utf-8')
 msg.attach(part)

 s = smtplib.SMTP('localhost')
 s.sendmail(fromid,toaddress, msg.as_string())
 s.quit()



Try with
msg['Reply-To'] = the adress

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


Re: Developers using Python QT framework ??

2016-05-15 Thread Vincent Vande Vyvre

Le 15/05/2016 13:19, tommy yama a écrit :

Hi folks,

Are there people using QT cross-platform framework on the list?
I appreciate for your advices and references regarding this.

I am a novice python programmer who started using this framework.


Thanks a lot in advance!

Tomo

Yes.

Note, it is also a mailing list PyQt:
https://www.riverbankcomputing.com/mailman/listinfo/pyqt

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


Re: How to get a directory list sorted by date?

2016-05-15 Thread Vincent Vande Vyvre

Le 15/05/2016 10:47, c...@isbd.net a écrit :

I have a little Python program I wrote myself which copies images from
a camera (well, any mounted directory) to my picture archive.  The
picture archive is simply a directory hierarchy of dates with years at
the top, then months, then days.

My Python program simply extracts the date from the image (put there
by the camera) and copies the image to the appropriate place in the
picture archive.

There is one small bit of speeding up done by my program, it checks if
the file is already in the archive and doesn't copy if it's already
there.  I don't generally clear pictures off the camera memory cards
so it's often the case that most of the pcitures are already in the
archive and all I actually want to do is copy the last couple of weeks
of new pictures.

As camera memory card sizes get bigger (and images get more detailed)
this is beginning to take rather a long time.

So, to the question, how can I get a list of the files on the memory
card (i.e. files in a directory) in date/time order, latest first.  I
can then copy them until the first one I find which is already in the
archive.  The file date may not *exactly* match the date/time in the
image file but it will produce the right order which is what I need.

What I want is a list in the order produced by:-
 ls --sort=time

I suppose I could use a system call but that seems a little inelegant.


Hi,

Seeing all the answers, I think there's a misunderstood here.

The date used to sort the picture is not the file date provided by 
os.stat but the shooting date written into the metadata of each picture.


Can the OP confirm that ?

So, if the name of the picture are unchanged why not just compare the 
file name ?


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


Re: PyQt4

2016-04-03 Thread Vincent Vande Vyvre

Le 03/04/2016 21:36, Muhammad Ali a écrit :

On Sunday, April 3, 2016 at 12:15:06 PM UTC-7, Michael Torrie wrote:

On 04/03/2016 12:57 PM, Muhammad Ali wrote:

Hi,

How can we confirm that either  PyQt4 is already installed on LInux machine or 
not?

Please suggest commands to confirm the already existence of  PyQt4 in the 
machine.

Ideally you make a distribution-specific package of the binary in a .deb
on Debian or an RPM on other distros, and specify that it depends on the
package that provides PyQt4.  That way when it's installed, modern
package managers will automatically install the dependencies.

Alternatively you can use try and except in your python code to attempt
to import something from PyQt4 and see if it fails or not.  This
technique is also used to make your code work either PyQt4 or PySide,
depending on which the user has installed.

try:
 from PySide import QtGui
except ImportError:
 from PyQt4 import QtGui

If neither are installed, this little example will end with an ImportError.

Thank you for your suggestions. I tried both but it shows the following error:
IndentationError: expected an indented block

Actually, I have to plot some graphs by using matplotlib and PyQt4 at 
supercomputer.

Any other suggestion???


There's no IndentationError in the exemple provided by Michael.

Copy the code AS IT in a file and retry.

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


Re: Grab metadata from images and save to file, batch mode

2016-04-02 Thread Vincent Vande Vyvre

Le 01/04/2016 23:20, accessnew...@gmail.com a écrit :

I have a directory (and sub-directories) full of images that I want to cycle 
through and grab certain metadata values and save those values to a single row 
in a cvs file. I would like to tack on the full path name to the row as a 
separate value.

Folder
C:\Images\Family
Brother.jpg
Sister.jpg
Mom.jpg

Keys/Values
Original Date/Time
User Name
File Name

Thus, data might look like this in a Family.csv file
2014:11:10 13:52:12; BillyBob111; Brother.jpg; C:\Images\Family\Brother.jpg
2015:10:54 11:45:34; BillyBob111; Sister.jpg; C:\Images\Family\Sister.jpg
2010:10:31 19:22:11; SallySue232; Mom.jpg; C:\Images\Family\Mom.jpg

Big time noob. Much of what I have read cites command line examples dealing 
with single files and no info as to how to extract specific keys and their 
values.
What module would some of you users recommend I use (I want it to be python as 
that is what I am trying to learn)

Can you give me some coding suggestions to get me goings? I haven't found any 
substantive scripts to use as guides.

Many thanks in advance



Have a look at py3exiv2:

http://python3-exiv2.readthedocs.org/en/latest/

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


Re: Exclude every nth element from list?

2016-03-26 Thread Vincent Vande Vyvre

Le 26/03/2016 18:06, Vincent Vande Vyvre a écrit :

Le 26/03/2016 17:49, beliavsky--- via Python-list a écrit :
I can use x[::n] to select every nth element of a list. Is there a 
one-liner to get a list that excludes every nth element?

Something like that:

>>> l = list("lkodjuyhrtgfedcvfg")
>>> l
['l', 'k', 'o', 'd', 'j', 'u', 'y', 'h', 'r', 't', 'g', 'f', 'e', 'd', 
'c', 'v', 'f', 'g']

>>> ll = [c for i, c in enumerate(l) if i % 3]
>>> ll.insert(0, l[0])
>>> ll
['l', 'k', 'o', 'j', 'u', 'h', 'r', 'g', 'f', 'd', 'c', 'f', 'g']



Vincent

Correction, it's more correct with the insert before the list comprehension

>>> l.insert(0, "_")
>>> ll = [c for i, c in enumerate(l) if i % 3]
>>> ll
['l', 'k', 'd', 'j', 'y', 'h', 't', 'g', 'e', 'd', 'v', 'f']
--
https://mail.python.org/mailman/listinfo/python-list


Re: Exclude every nth element from list?

2016-03-26 Thread Vincent Vande Vyvre

Le 26/03/2016 17:49, beliavsky--- via Python-list a écrit :

I can use x[::n] to select every nth element of a list. Is there a one-liner to 
get a list that excludes every nth element?

Something like that:

>>> l = list("lkodjuyhrtgfedcvfg")
>>> l
['l', 'k', 'o', 'd', 'j', 'u', 'y', 'h', 'r', 't', 'g', 'f', 'e', 'd', 
'c', 'v', 'f', 'g']

>>> ll = [c for i, c in enumerate(l) if i % 3]
>>> ll.insert(0, l[0])
>>> ll
['l', 'k', 'o', 'j', 'u', 'h', 'r', 'g', 'f', 'd', 'c', 'f', 'g']



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


Re: Experimenting with PyPyJS

2016-03-19 Thread Vincent Vande Vyvre

Le 19/03/2016 16:32, Salvatore DI DIO a écrit :

Le samedi 19 mars 2016 16:28:36 UTC+1, Salvatore DI DIO a écrit :

Hy all,

I am experimenting PyPyJS and found it not so bad at all.
The virtual machine loads on a few seconds (using firefox).

It s really nice for  learning Python, you have all the standard libraries,
and traceback on errors. I don't have to choose anymore with all transpilers 
around

You can try it here, but please don't tell it s too long to load the VM.
After all, don't you wait when you start a desktop application, or an heavy 
game online ?

Just try it and tell your feeling

Regards

http://salvatore.diodev.fr/pypybox/

Use Firefox...


That's look fine but:

  PID USER  PR  NI  VIRT  RES  SHR S %CPU %MEMTIME+  COMMAND
 4917 vincent   20   0 1081m 305m  52m R *50.3* 15.4   5:23.75 firefox
 1094 root  20   0 48152  15m 7180 S *35.0*  0.8   4:43.28 Xorg
 5421 vincent   20   0  162m  14m  10m R  2.0  0.7   0:02.49 mate-terminal
1 root  20   0  3660 1984  ...

85.3 % (50.3 + 35) CPU usage just for a rotating square it's too much cost.

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


Re: Struggeling with collections

2016-03-07 Thread Vincent Vande Vyvre

Le 07/03/2016 09:24, Faling Dutchman a écrit :

Hey folks,

I am just starting off in python, but have good knowledge of both Java and C#. 
Now is the problem that I need to have multiple instances of one dictionary, 
that is not a problem if you know how many, but now, it is an unknown amount.

Some background info:

I am making a library for an API. This library must be easy to use for the 
people who are going to use it. So I am making the models for the data, the 
connections and so on, so they just have to fill in the gaps. In C# and Java I 
did it with objects, but they do not work alike in python, or at least that is 
what I have found.

If I do this:

class Item:
 def __init__(self, id, productId, quantity, pageCount, files, option, 
metadata):
 self.id = id
 self.productId = productId
 self.quantity = quantity
 self.pageCount = pageCount
 self.files = files
 self.option = option
 self.metadata = metadata

itm = Item(1,None,1,1,'asdf',{'asdf': 3, 'ads': 55},None)
print(itm)

it prints: <__main__.Item object at 0x02EBF3B0>

So that is not usefull to me. There can be an infinite amount of objects of 
Item, and it needs to be easy accessable, just like
for i in items
 print(i)

and it has to show all the parameters of the class Item and not say "ive got an 
object  at this memory address, have a nice day"

I hope my question is clear.


The classes have a dict

Python 3.2.3 (default, Jun 18 2015, 21:46:42)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> class Item:
... def __init__(self, id, productId, quantity, pageCount, files, 
option, metadata):

... self.id = id
... self.productId = productId
... self.quantity = quantity
... self.pageCount = pageCount
... self.files = files
... self.option = option
... self.metadata = metadata
...
>>> i = Item(1,None,1,1,'asdf',{'asdf': 3, 'ads': 55},None)
>>> i.__dict__
{'files': 'asdf', 'option': {'ads': 55, 'asdf': 3}, 'pageCount': 1, 
'metadata': None, 'productId': None, 'id': 1, 'quantity': 1}

>>>

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


Re: Attribute path not in PurePosixPath ?

2016-01-24 Thread Vincent Vande Vyvre

Le 24/01/2016 08:58, Vincent Vande Vyvre a écrit :

Hi,

Refering to the doc 
https://docs.python.org/3/library/pathlib.html?highlight=pathlib#pathlib.PurePath.path


 


Python 3.4.3 (default, Oct 14 2015, 20:28:29)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from pathlib import PurePath
>>> p = PurePath('/home/vincent/Images')
>>> p.name
'Images'
>>> p.suffix
''
>>> p.parent
PurePosixPath('/home/vincent')
>>> [parent for parent in p.parents]
[PurePosixPath('/home/vincent'), PurePosixPath('/home'), 
PurePosixPath('/')]

>>> p.path
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'PurePosixPath' object has no attribute 'path'
 



Am I misunderstood the doc ?



OOps, is new in 3.4.5

Sorry for the noise.

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


Attribute path not in PurePosixPath ?

2016-01-24 Thread Vincent Vande Vyvre

Hi,

Refering to the doc 
https://docs.python.org/3/library/pathlib.html?highlight=pathlib#pathlib.PurePath.path



Python 3.4.3 (default, Oct 14 2015, 20:28:29)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from pathlib import PurePath
>>> p = PurePath('/home/vincent/Images')
>>> p.name
'Images'
>>> p.suffix
''
>>> p.parent
PurePosixPath('/home/vincent')
>>> [parent for parent in p.parents]
[PurePosixPath('/home/vincent'), PurePosixPath('/home'), PurePosixPath('/')]
>>> p.path
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'PurePosixPath' object has no attribute 'path'


Am I misunderstood the doc ?
--
https://mail.python.org/mailman/listinfo/python-list


Re: ouvrir python

2016-01-06 Thread Vincent Vande Vyvre

Le 04/01/2016 10:10, Jacques Rosier a écrit :

J’ai téléchargé Python 351. Il est dans la liste des applications de mon ordi 
(Lenovo; Windows 10). Mais impossible de l’ouvrir. Que faire?
Cette liste de diffusion est anglophone, je te recommande de poster sur 
ce forum:


http://www.developpez.net/forums/f96/autres-langages/python-zope/

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


Re: Accessing container's methods

2015-12-08 Thread Vincent Vande Vyvre

Le 08/12/2015 20:02, Thomas 'PointedEars' Lahn a écrit :

Erik wrote:

Please fix, Erik #75656.


On 07/12/15 18:10, Tony van der Hoff wrote:

A highly contrived example, where I'm setting up an outer class in a
Has-a relationship, containing a number of Actors. The inner class needs
to access a method of the outer class; here the method get_name.

Generally, an object should not need to know which container it's in

NAK.  All kinds of objects already "know" which container they are in.


(let alone its "index" or "key" in that container).

That is a different issue.


Amongst other things, you can't put the object into multiple containers

You can.  Quickhack:

class Child:
 self._parents = []

 def add_to_parent (self, parent):
 self._parents.append(parent)
 self._parents = list(set(self._parents))

 def get_parents (self)
 return self._parents

class Parent:
 self._children = []
.

I thing you should test your code before post it.

>>> class Child:
... self.parents = []
...
Traceback (most recent call last):
  File "", line 1, in 
  File "", line 2, in Child
NameError: name 'self' is not defined

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


Re: Persist objects in a LIST

2015-11-14 Thread Vincent Vande Vyvre

Le 14/11/2015 16:39, Dennis Lee Bieber a écrit :

On Sat, 14 Nov 2015 07:02:41 -0800 (PST), John Zhao 
declaimed the following:


I found a solution.  replace  bDict.clear() with  bDict = {}


Which is creating a second, empty, dictionary and binding the name
"bDict" to that new one.

If all you want is to get rid of the name

del bDict

should suffice.

Not exactly.

>>> l = []
>>> d = {'key': 'val'}
>>> l.append(d)
>>> l
[{'key': 'val'}]
>>> del d
>>> l
[{'key': 'val'}]
>>> del l[0]
>>> l
[]
>>>

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


Re: [Ubuntu] PyQt5

2015-11-07 Thread Vincent Vande Vyvre

Le 08/11/2015 04:13, Andrew Diamond a écrit :

Hi!

I'm fairly new to Python, and installed pyqt5 and began working through the 
examples at http://zetcode.com/gui/pyqt5/menustoolbars/  However, whenever I 
click one of the buttons or menus in the example apps I run that is supposed to 
quit the application, it locks up.  This happens with all the examples I 
installed that handle code to quit the app.

Running Ubuntu 15.10, and installed pyqt5 via:

sudo apt-get install python3-pyqt5
sudo apt-get install qtcreator

Thank you in advance for any assistance!

Works fine for me on 15.04.

I've tested the first example with the menuBar.

Have you a message into the terminal? Maybe an error?

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


Re: Problem with Python 3.5.0

2015-10-11 Thread Vincent Vande Vyvre

Le 11/10/2015 19:12, eetix letix a écrit :

Hi,

I'm sorry but the last version of Python (3.5.0) had a problem. I 
start and I meet this problem :


>>>a=5
>>>if a>0:
. . . print("a is a positive.")
. . . if a<0:
 ^
SyntaxError: invalid syntax
>>>

Normally this should work but problem comes to the fact that Python 
considers "a" is a positive number and refuses to do the command >>>if 
a<0:


And the command |\n is doesn't working :

|
|>>> a="test||\nto||\nsee||\nif||\nit||\nis||\nworking"
|
|>>> a
|
|'||test||\nto||\nsee||\nif||\nit||\nis||\nworking'
>>>


|
Normally, \n should make that the text returns to the line but doesn't 
make it. And if y do :


>>> a="""test
. . .  to
. . .  see
. . .  if
. . .  it
. . .  is
. . .  working"""
>>>a
|'||test||\nto||\nsee||\nif||\nit||\nis||\nworking'
>>>


|
|Thanks to fix this problems and good luck ;)


|
|PS : I'm sorry for this really bad english but I'm french and I'm 14
|



Hi,

see:

>>> a = 5
>>> if a > 0:
... print('a is a positive')
...  # here, type a Enter
a is a positive
>>> elif a 

>>> a = "test\nto\nsee\nif\nit\nis\nworking"
>>> a
'test\nto\nsee\nif\nit\nis\nworking'
>>> print(a)
test
to
see
if
it
is
working
>>>

Clear ?

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


Re: No request in module urllib ?

2015-09-03 Thread Vincent Vande Vyvre

Le 04/09/2015 04:30, Chris Angelico a écrit :

On Fri, Sep 4, 2015 at 12:17 PM, Vincent Vande Vyvre
<vincent.vande.vy...@telenet.be> wrote:

import urllib.request
urllib.request.urlopen('http://example.org')


Thanks, that works with 3.4.0. No with 3.2.3

Hmm, not sure why it wouldn't. According to the docs [1] it should be
available. But I don't have a 3.2 anywhere around me now, so I can't
check. (Steven D'Aprano no doubt can!) What happens when you try?
ImportError? AttributeError?

ChrisA

[1] https://docs.python.org/3.2/library/urllib.request.html

Sorry, my fault, a typo in the import line.

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


No request in module urllib ?

2015-09-03 Thread Vincent Vande Vyvre

Hi,

Python 3.2.3 (default, Jun 18 2015, 21:46:42)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import urllib
>>> urllib.request.urlopen('http://example.org')
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'module' object has no attribute 'request'

Same error with Python 3.4.0
--
https://mail.python.org/mailman/listinfo/python-list


Re: No request in module urllib ?

2015-09-03 Thread Vincent Vande Vyvre

Le 04/09/2015 04:08, Chris Angelico a écrit :

On Fri, Sep 4, 2015 at 11:56 AM, Vincent Vande Vyvre
<vincent.vande.vy...@telenet.be> wrote:

Python 3.2.3 (default, Jun 18 2015, 21:46:42)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.

import urllib
urllib.request.urlopen('http://example.org')

Traceback (most recent call last):
   File "", line 1, in 
AttributeError: 'module' object has no attribute 'request'

Same error with Python 3.4.0

With packages, like this, you sometimes need to explicitly import the
piece you want. That way, the urllib module doesn't have to load
everything up just because you wanted one small part. Try this
instead:

import urllib.request
urllib.request.urlopen('http://example.org')

Hope that helps!

ChrisA

Thanks, that works with 3.4.0. No with 3.2.3


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


Re: Fwd: Python Error: ImportError: No module named ''folder_name’ at Command Prompt

2015-07-12 Thread Vincent Vande Vyvre

Le 12/07/2015 06:02, Ernest Bonat, Ph.D. a écrit :

Thanks for your help. I had follow the link: How to add a Python module
to syspath?

http://askubuntu.com/questions/470982/how-to-add-a-python-module-to-syspath
and I could not make it work. I did use sys.path.insert() and
sys.path.append() as:

Examples: sys.path.append('/python_mvc_calculator/calculator/') or
sys.path.insert(0, /python_mvc_calculator/calculator)

I did try it to:
sys.path.append('/python_mvc_calculator/calculator/controller') or
sys.path.insert(0, /python_mvc_calculator/calculator/controller) too!

The main.py file is in python_mvc_calculator/calculator folder and I
need to import a module calculatorcontroller.py in
python_mvc_calculator/calculator/controller

I hope this explanation helps a bit!

http://askubuntu.com/questions/470982/how-to-add-a-python-module-to-syspath

Thanks



If /python_mvc_calculator/calculator/controller is a folder and if you 
have a file __init__.py into this folder, you have to use:


sys.path.insert(0, /python_mvc_calculator/calculator/controller)
from calculatorcontroller import foo # or import calculatorcontroller

But the init file must be named __init__.py NOT init.py as sayed in 
askubuntu.


Vincent

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


Re: Bug in floating point multiplication

2015-07-02 Thread Vincent Vande Vyvre

Le 02/07/2015 16:52, Steven D'Aprano a écrit :

Despite the title, this is not one of the usual Why can't Python do
maths? bug reports.

Can anyone reproduce this behaviour? If so, please reply with the version of
Python and your operating system. Printing sys.version will probably do.


x = 1 - 1/2**53
assert x == 0.
for i in range(1, 100):
 if int(i*x) == i:
 print(i); break


Using Jython and IronPython, the loop runs to completion. That is the
correct behaviour, or so I am lead to believe. Using Python 2.6, 2.7 and
3.3 on Centos and Debian, it prints 2049 and breaks. That should not
happen. If you can reproduce that (for any value of i, not necessarily
2049), please reply.

See also http://bugs.python.org/issue24546 for more details.





Hi,

vincent@tiemoko:~$ python3
Python 3.2.3 (default, Jun 18 2015, 21:46:42)
[GCC 4.6.3] on linux2
Type help, copyright, credits or license for more information.
 x = 1 - 1/2**53
 assert x == 0.
 for i in range(1, 100):
... if int(i*x) == i:
... print(i)
... break
...
2049


---
vincent@djoliba:~$ python3
Python 3.4.0 (default, Jun 19 2015, 14:20:21)
[GCC 4.8.2] on linux
Type help, copyright, credits or license for more information.
 x = 1 - 1/2**53
 assert x == 0.
 for i in range(1, 100):
... if int(i*x) == i:
... print(i)
... break
...


Both on Ubuntu.

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


Re: Regex Python Help

2015-03-24 Thread Vincent Vande Vyvre

Le 24/03/2015 20:22, Gregg Dotoli a écrit :

Thank you! But

The print error is gone, but now the script quickly finishes and doesnt walk
the OS tree or search.

Gregg



On Tuesday, March 24, 2015 at 2:14:32 PM UTC-4, Gregg Dotoli wrote:

I am creating a tool to search a filesystem for one simple string.
I cannot get the syntax correct.
Thank you in advance for your help.

import sys
import re
import os
path='/'
viewfiles=os.listdir(path)
for allfiles in viewfiles:
 file= os.path.join(path, allfiles)
text=open(file, r)
for line in text:
 if re.match(DECRYPT_I, line):
 print line,

--
This should search every file for the simple regex DECRYPT_I
This is from the root down.

The error is:

SyntaxError: Missing parentheses in call to 'print'

Please help.
Gregg Dotoli

Your indentation is wrong.

for allfiles in viewfiles:
file= os.path.join(path, allfiles)
text=open(file, r)
for line in text:
if re.match(DECRYPT_I, line):
print line,


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


Re: Regex Python Help

2015-03-24 Thread Vincent Vande Vyvre

Le 24/03/2015 20:38, Vincent Vande Vyvre a écrit :

Le 24/03/2015 20:22, Gregg Dotoli a écrit :

Thank you! But

The print error is gone, but now the script quickly finishes and 
doesnt walk

the OS tree or search.

Gregg



On Tuesday, March 24, 2015 at 2:14:32 PM UTC-4, Gregg Dotoli wrote:

I am creating a tool to search a filesystem for one simple string.
I cannot get the syntax correct.
Thank you in advance for your help.

import sys
import re
import os
path='/'
viewfiles=os.listdir(path)
for allfiles in viewfiles:
 file= os.path.join(path, allfiles)
text=open(file, r)
for line in text:
 if re.match(DECRYPT_I, line):
 print line,

--
This should search every file for the simple regex DECRYPT_I
This is from the root down.

The error is:

SyntaxError: Missing parentheses in call to 'print'

Please help.
Gregg Dotoli

Your indentation is wrong.

for allfiles in viewfiles:
file= os.path.join(path, allfiles)
text=open(file, r)
for line in text:
if re.match(DECRYPT_I, line):
print line,


Vincent

... and me too

for allfiles in viewfiles:
file= os.path.join(path, allfiles)
text=open(file, r)
for line in text:
if re.match(DECRYPT_I, line):
print line,
--
https://mail.python.org/mailman/listinfo/python-list


Re: Use à Python 2 module with Python 3

2015-03-11 Thread Vincent Vande Vyvre

Le 11/03/2015 18:06, Ian Kelly a écrit :

On Wed, Mar 11, 2015 at 4:54 AM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:

Michael Parchet wrote:


Hello,

The pyside project is ded.

What makes you think that Pyside is dead? It seems to be active to me. The
latest update was just 29 days ago:

https://github.com/PySide

4 days ago, even. Seems that most of the development is still on gitorious:

https://qt.gitorious.org/pyside


In fact, the devel team of PySide has announced the official abandon of 
the project at the begin of this year.


The announce was made in this page:

http://qt-project.org/wiki/PySide

... but, now, I see this page was reversed to his old content.

So, have a look at the bug tracker and you'll see some comment as this one:

PySide is abandoned by the initial development team due to a lack of 
funding, so right now the destiny of the bugs such as this is in hands 
of those who understand how to debug them.


(Quoted from https://bugreports.qt.io/browse/PYSIDE-164)

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


Re: tabs and the Python3 console

2015-02-10 Thread Vincent Vande Vyvre

Le 10/02/2015 15:36, Laura Creighton a écrit :

I have the debian version of python3 installed here.

Python 3.4.2 (default, Nov 13 2014, 07:01:52)
[GCC 4.9.2] on linux
Type help, copyright, credits or license for more information.
But I cannot seem to type a tab here:


def fn(**kw):

...

(I type a tab here, and get a beep.  If I type a tab again I get:

Display all 178 possibilities? (y or n)
ArithmeticError(chr(
AssertionError( class
AttributeError( classmethod(
BaseException(  compile(
BlockingIOError(complex(
BrokenPipeError(continue
lots more skipped, because you get the idea
...

Do I need a python3 enabled with readline support, or something?

Thanks very much,
Laura Creighton




It's a recent change (3.4), use the argument -S if you want the old 
behaviour


https://docs.python.org/3/library/site.html#rlcompleter-config

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


Re: smtplib not working as expected

2014-12-26 Thread Vincent Vande Vyvre

Le 27/12/2014 03:52, Juan Christian a écrit :
On Fri Dec 26 2014 at 11:07:30 PM MRAB pyt...@mrabarnett.plus.com 
mailto:pyt...@mrabarnett.plus.com wrote:

According to the docs, if you let the port parameter default to 0,
it'll use port 465.

I tested with my ISP.

Using port 465, it failed.

Using the default, it succeeded.

So, I changed the code how you said, but still not working.


Code:

import smtplib

fromaddr = 'mksfjnsfji4433j4...@bk.ru mailto:mksfjnsfji4433j4...@bk.ru'
toaddrs = ['mksfjnsfji4433j4...@bk.ru mailto:mksfjnsfji4433j4...@bk.ru']

msg = (From: %s\r\nTo: %s\r\n\r\n
% (fromaddr, , .join(toaddrs)))

msg = msg + 'test'

server = smtplib.SMTP('smtp.mail.ru http://smtp.mail.ru')
server.set_debuglevel(1)
server.sendmail(fromaddr, toaddrs, msg)
server.quit()


Traceback:

send: 'ehlo [192.168.0.107]\r\n'
reply: b'250-smtp15.mail.ru http://250-smtp15.mail.ru\r\n'
reply: b'250-SIZE 73400320\r\n'
reply: b'250-8BITMIME\r\n'
reply: b'250-PIPELINING\r\n'
reply: b'250-AUTH PLAIN LOGIN XOAUTH2\r\n'
reply: b'250 STARTTLS\r\n'
reply: retcode (250); Msg: b'smtp15.mail.ru 
http://smtp15.mail.ru\nSIZE 73400320\n8BITMIME\nPIPELINING\nAUTH 
PLAIN LOGIN XOAUTH2\nSTARTTLS'
send: 'mail FROM:mksfjnsfji4433j4...@bk.ru 
mailto:mksfjnsfji4433j4...@bk.ru size=70\r\n'

reply: b'250 2.0.0 OK\r\n'
reply: retcode (250); Msg: b'2.0.0 OK'
send: 'rcpt TO:mksfjnsfji4433j4...@bk.ru 
mailto:mksfjnsfji4433j4...@bk.ru\r\n'
reply: b'550 SMTP is available only with SSL or TLS connection 
enabled.\r\n'
reply: retcode (550); Msg: b'SMTP is available only with SSL or TLS 
connection enabled.'

send: 'rset\r\n'
Traceback (most recent call last):
File .\test.py, line 13, in module
server.sendmail(fromaddr, toaddrs, msg)
File C:\Python34\lib\smtplib.py, line 793, in sendmail
raise SMTPRecipientsRefused(senderrs)
smtplib.SMTPRecipientsRefused: {'mksfjnsfji4433j4...@bk.ru 
mailto:mksfjnsfji4433j4...@bk.ru': (550, b'SMTP is available only 
with SSL or TLS connection e

nabled.')}



Try with the TLS:


...
server.set_debuglevel(1)
server.ehlo()
server.starttls()
server.ehlo()
server.sendmail(
--
https://mail.python.org/mailman/listinfo/python-list


Re: How to access Qt components loaded from file?

2014-11-18 Thread Vincent Vande Vyvre

Le 18/11/2014 13:18, Juan Christian a écrit :

I have this simple code that load any Qt Designer .UI file:

from PySide.QtCore import QFile
from PySide.QtGui import QApplication
from PySide.QtUiTools import QUiLoader


def loadui(file_name):
loader = QUiLoader()
uifile = QFile(file_name)
uifile.open(QFile.ReadOnly)
ui = loader.load(uifile)
uifile.close()
return ui


if __name__ == __main__:
import sys

app = QApplication(sys.argv)
MainWindow = loadui(main.ui)
MainWindow.show()
app.exec_()

Let's say I have a QTextEdit called txtbox. How can I access this 
txtbox inside my Python code?




How about MainWindow.txtbox  ?
--
https://mail.python.org/mailman/listinfo/python-list


Re: How to access Qt components loaded from file?

2014-11-18 Thread Vincent Vande Vyvre

Le 18/11/2014 15:49, Juan Christian a écrit :

I was doing some tests, then I tried this:

app = QApplication(sys.argv)
MainWindow = loadui(main.ui)
MainWindow.btn.clicked.connect(MainWindow.txtbox.setText(test()))

MainWindow.show()
app.exec_()

But I get RuntimeError: Failed to connect signal clicked()., why?

The syntax is correct, I don't know why it failed, the btn is in the 
Form too, it's a QPushButton.


The test func is just a simple func that returns a random text.

On Tue Nov 18 2014 at 11:08:48 AM Juan Christian 
juan0christ...@gmail.com mailto:juan0christ...@gmail.com wrote:


Many thanks, worked. The only problem now is that I don't have
auto-complete for anything, because of this approach... I'll have
to check the doc more regularly. ^^



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




You can't have a slot like this:

MainWindow.btn.clicked.connect(MainWindow.txtbox.setText(test()))

because that's mean: connect to the return of 
MainWindow.txtbox.setText(test()) and it's not possible at this stage 
of your program.


Use instead a function:

MainWindow.btn.clicked.connect(my_slot) # No parenthesis !

def my_slot():
MainWindow.txtbox.setText(test())
--
https://mail.python.org/mailman/listinfo/python-list


Re: PySide 1.2.2 setMaxWidth and AeroSnap

2014-11-16 Thread Vincent Vande Vyvre

Le 16/11/2014 16:51, Juan Christian a écrit :

PySide 1.2.2
Python 3.4.2

Code:

from PySide.QtGui import *

class MainWindow(QWidget):
def __init__(self):
QWidget.__init__(self)
self.setMinimumSize(600, 700)
self.setMaximumWidth(600)
self.setLayout(QVBoxLayout())

* Call to this module in another module *
app = QApplication(sys.argv)
window = MainWindow()
window.show()
app.exec_()

When I set the setMaxWidth I can't use the Windows AeroSnap anymore, 
why?


I didn't set a setMaxHeight, so this shouldn't lock me from doing 
the snap. Without the setMaxWidth the AeroSnap works as usual, but I 
need to limit my width to 600, because I need my tool to have this 
kind of short-width, long-height look.



No probleme with PyQt but I think this is a window manager question. 
Window, gnome, KDE, Mate, ...



If your widget is a QMainWindow or a QDialog add a size grip:

self.setSizeGripEnabled(True)

The QWidget don't have this method, so, in this case, you must 
reimplement his resizeEvent()


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


Re: PySide 1.2.2 setMaxWidth and AeroSnap

2014-11-16 Thread Vincent Vande Vyvre

Le 16/11/2014 19:09, Juan Christian a écrit :
On Sun Nov 16 2014 at 3:46:40 PM Vincent Vande Vyvre 
vincent.vande.vy...@telenet.be 
mailto:vincent.vande.vy...@telenet.be wrote:


No probleme with PyQt but I think this is a window manager question.
Window, gnome, KDE, Mate, ...


If your widget is a QMainWindow or a QDialog add a size grip:

 self.setSizeGripEnabled(True)

The QWidget don't have this method, so, in this case, you must
reimplement his resizeEvent()


I changed to QMainWindow, but I don't have a function called 
setSizeGripEnabled here.




... missed in PySide ?

Reimplement the resizeEvent().

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


Re: Creating a counter

2014-10-15 Thread Vincent Vande Vyvre

Le 15/10/2014 20:39, Shiva a écrit :

Hi,

I am trying to search a string through files in a directory - however while
Python script works on it and writes a log - I want to present the user with
count of number of strings found. So it should increment for each string found.

How do I implement it?

If I use a print() within a if condition statement - and execute the script
in terminal - for each find, the print() prints in new line instead of a
constantly incrementing counter.

Thanks,
Shiva


Try this:

 def counter(x):
... for i in range(x):
... print \rProgress .. %s % i,
... sys.stdout.flush()
... time.sleep(1)
...
 counter(5)


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


Re: Python Imaging Library 1.x - 64bit setup file for Python 2.7.2.

2014-09-25 Thread Vincent Vande Vyvre

Le 25/09/2014 10:07, Pinter, Karina /C a écrit :


Dear Team,

I am working as a software analyst at ExxonMobil. I received a 
software request for Python Imaging Library 1.x and the user needs a 
64bit setup file for Python 2.7.2. Can I download it somewhere?


Thanks in advance.

*/Best Regards,/*

*/
Karina Pinter/**
**/ExxonMobil BSC Hungary Kft./*
/Software Analyst/
/EMIT / IT Operations / Customer Infrastructure / IT Asset Management/*//*

/H-1139 Budapest, Váci út 81-85. Phone/: +36 1 298 5361

cid:image001.png@01CEF5B8.F78ACF20




for Windows I presume, have a look here:
http://www.lfd.uci.edu/~gohlke/pythonlibs/#pillow
--
https://mail.python.org/mailman/listinfo/python-list


Re: PyQt4 - Issue with deleting a QWidget from a QGridLayout

2014-08-20 Thread Vincent Vande Vyvre

Le 20/08/2014 16:22, Alex Murray a écrit :

Please do not post in HTML it makes everything an unreadable mess
(I have left you original post above so you can see what I mean.)

Sorry, here's the original e-mail in plain text:

Hi,

I've discovered some very strange behaviour when trying to
delete a QWidget from a QGridLayout. The following code demonstrates
this behaviour:


from PyQt4 import QtGui
import sys
app = QtGui.QApplication(sys.argv)
grid_layout = QtGui.QGridLayout()
grid_layout.addWidget(QtGui.QWidget())
item = grid_layout.takeAt(0)
item.deleteLater()

Traceback (most recent call last):
   File stdin, line 1, in module
AttributeError: 'QWidgetItem' object has no attribute 'deleteLater'

This makes no sense to me whatsoever. Firstly, why is it returning
a QWidgetItem when I inserted a QWidget to begin with? Secondly, every
Qt object derives from QObject, and deleteLater() is a method of
QObject, so that method should exist. Additional info:

Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2

Not exactly, QLayoutItem or QSpacerItem doesn't inherits of QObject.
As I've sayed in my precedent post, you must use 
item.widget().deleteLater().

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


Re: PyQt4 - Issue with deleting a QWidget from a QGridLayout

2014-08-19 Thread Vincent Vande Vyvre

Le 20/08/2014 00:11, Alex Murray a écrit :

Hi,
I've discovered some very strange behaviour when trying to delete a 
QWidget from a QGridLayout. The following code demonstrates this 
behaviour:

 from PyQt4 import QtGui
 import sys
 app = QtGui.QApplication(sys.argv)
 grid_layout = QtGui.QGridLayout()
 grid_layout.addWidget(QtGui.QWidget())
 item = self.grid_layout.takeAt(0)
 item.deleteLater()
Traceback (most recent call last):
  File stdin, line 1, in module
AttributeError: 'QWidgetItem' object has no attribute 'deleteLater'
This makes no sense to me whatsoever. Firstly, why is it returning a 
QWidgetItem when I inserted a QWidget to begin with? Secondly, every 
Qt object derives from QObject, and deleteLater() is a method of 
QObject, so that method should exist. Additional info:

Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
using PyQt4


QLayout.takeAt() returns a QWidgetItem not the instance of the widget 
himself.


See: http://pyqt.sourceforge.net/Docs/PyQt4/qlayout.html#takeAt

You must use item.widget() to retrieve your widget instance.
--
https://mail.python.org/mailman/listinfo/python-list


Re: Unable to run print('Réussi') on windows and on linux

2014-08-14 Thread Vincent Vande Vyvre

Le 14/08/2014 14:35, marc.vanhoomis...@gmail.com a écrit :

Hello,

This very simple program runs well on windows 7

# -*- utf8 -*-
print('Réussi')

But, when I start the vrey same file on Linux (ubuntu 14), I got:

Traceback (most recent call last):
   File /partages/bureau/PB/Dev/Python3/test.py, line 2, in module
 print('R\xe9ussi')
UnicodeEncodeError: 'ascii' codec can't encode character '\xe9' in position 1: 
ordinal not in range(128)

What should i do to let the same program run on both OS, without changes?

Thank you for your answer

Marc Vanhoomissen

No problem on Ubuntu

Python 3.2.3 (default, Feb 27 2014, 21:33:50)
[GCC 4.6.3] on linux2
Type help, copyright, credits or license for more information.
 print(Réussi)
Réussi

Are you really using Python 3 ?

$ python3 test.py
--
https://mail.python.org/mailman/listinfo/python-list


Re: Unable to run print('Réussi') on windows and on linux

2014-08-14 Thread Vincent Vande Vyvre

Le 14/08/2014 15:31, YBM a écrit :

Le 14/08/2014 14:35, marc.vanhoomis...@gmail.com a écrit :

Hello,

This very simple program runs well on windows 7

# -*- utf8 -*-
print('Réussi')

But, when I start the vrey same file on Linux (ubuntu 14), I got:

Traceback (most recent call last):
   File /partages/bureau/PB/Dev/Python3/test.py, line 2, in module
 print('R\xe9ussi')
UnicodeEncodeError: 'ascii' codec can't encode character '\xe9' in 
position 1: ordinal not in range(128)


What should i do to let the same program run on both OS, without 
changes?


the correct comment line should be : # -*- encoding: utf-8 -*-
and it could be usefull to begin with #!/usr/bin/env python
or #!/usr/bin/env python3 :

$ cat  réussi.py
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
print('Réussi');
^D
$ chmod +x réussi.py
$ ./réussi.py
Réussi
$ python réussi.py
Réussi



Nothing to do with the file encoding.

... if the OP use really Python 3
--
https://mail.python.org/mailman/listinfo/python-list


Re: About python while statement and pop()

2014-06-11 Thread Vincent Vande Vyvre

Le 12/06/2014 05:12, hito koto a écrit :

Hello,all
I'm first time,

I want to make a while statement which can function the same x.pop () and 
without the use of pop、how can i to do?

i want to change this is code:

def foo(x):
 y = []
 while x !=[]:
 y.append(x.pop())
 return y

Something like that :

def foo(x):
return reversed(x)

--
Vincent V.V.
Oqapy https://launchpad.net/oqapy . Qarte 
https://launchpad.net/qarte . PaQager https://launchpad.net/paqager

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


  1   2   >