Dictionary usage with Python 3

Hi,

I’ve just run into something that I can’t make heads or tails of…

I’m experimenting with a “new compiler” at the moment. I’ve re-built all of my “externals” and all of my own code with this “new compiler”, and am trying to now use all of it.

The compiler’s setup came with a custom build of Python 3.7.4, so I built ROOT (and all of my own code) against that version of Python.

My problem is that I can’t make the ROOT python module recognise any of my own classes. :frowning: Even if I explicitly load the library holding a certain dictionary, I still get:

[bash][atspot01]:run > python
Python 3.7.4 (default, Sep 18 2019, 23:00:06) 
[GCC 7.3.0] :: Intel(R) Corporation on linux
Type "help", "copyright", "credits" or "license" for more information.
Intel(R) Distribution for Python is brought to you buy Intel Corporation.
Please check out: https://software.intel.com/en-us/python-distibution
>>> import ROOT
>>> ROOT.gSystem.Load( 'libAsyncEventLoop' )
0
>>> job = ROOT.async.Job()
  File "<stdin>", line 1
    job = ROOT.async.Job()
                   ^
SyntaxError: invalid syntax
>>>

Of course when I build the code against Python 2.7 I don’t see any issue like this. There ROOT correctly auto-loads all necessary dictionaries for me…

[bash][atspot01]:run > python
Python 2.7.15+ (default, Oct  7 2019, 17:39:04) 
[GCC 7.4.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ROOT
>>> job = ROOT.async.Job()
>>>

Since this is the first time that I’m actually trying to use (Py)ROOT with Python 3 I have no clue where the fault lies. Whether it’s something that this particular Python version is doing incorrectly, something that I messed up with my local ROOT build against that version of Python, or what.

Any ideas would be much appreciated!

Cheers,
Attila


Please read tips for efficient and successful posting and posting code

ROOT Version: 6.18/04
Platform: Ubuntu 18.04
Compiler: It’s a long story…


@etejedor will most probably be able to help you, as soon as he’s back

async is a keyword with Python 3.7.

(got to love non-bwd compatibility changes in Python with minor version bumps…)

>>> import keyword
>>> keyword.kwlist
['False',
 'None',
 'True',
 'and',
 'as',
 'assert',
 'async',
 'await',
[...]
 'try',
 'while',
 'with',
 'yield']
1 Like

Ahh. That would explain it of course. :stuck_out_tongue: Thanks Sebastien!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.