diff --git a/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/PyAnalysisExamples/MyCutClass.h b/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/PyAnalysisExamples/MyCutClass.h
index 2696a3eda9f283c1b185dc48910152f47a7ddb88..0c7098752d6f3e5e4152defe9dd6c68498f5c32c 100755
--- a/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/PyAnalysisExamples/MyCutClass.h
+++ b/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/PyAnalysisExamples/MyCutClass.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef PYANALYSISEXAMPLES_MYCUTCLASS_H
@@ -10,6 +10,8 @@
 
 #include "egammaEvent/Electron.h"
 
+namespace AthPyEx {
+
 class MyCutClass
 {
 public:
@@ -28,4 +30,6 @@ private:
   double m_Thr;
 };
 
+} // namespace AthPyEx
+
 #endif
diff --git a/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/PyAnalysisExamples/MyDetObj.h b/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/PyAnalysisExamples/MyDetObj.h
index d903201753df5652da65942528c243f21dc31836..e59386407822248f224ffc9b13eb49ca1b30df7b 100755
--- a/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/PyAnalysisExamples/MyDetObj.h
+++ b/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/PyAnalysisExamples/MyDetObj.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef PYANALYSISEXAMPLES_MYDETOBJ_H
@@ -9,6 +9,8 @@
 
 #include "AthenaKernel/CLASS_DEF.h"
 
+namespace AthPyEx {
+
 class MyDetObj
 {
 public:
@@ -21,7 +23,9 @@ private:
   std::string m_name;
 };
 
-CLASS_DEF(MyDetObj, 28914872, 1)
+} // namespace AthPyEx
+
+CLASS_DEF(AthPyEx::MyDetObj, 105730742, 1)
 
 #endif
 
diff --git a/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/PyAnalysisExamples/MyObj.h b/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/PyAnalysisExamples/MyObj.h
index b8e61ce860c80c3fb194a4e3b8bb4055b6c03f47..f1d19fe899076281abd6bdbbcb3407f023bb1c32 100755
--- a/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/PyAnalysisExamples/MyObj.h
+++ b/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/PyAnalysisExamples/MyObj.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef PYANALYSISEXAMPLES_MYOBJ_H
@@ -11,6 +11,8 @@
 
 #include "AthenaKernel/CLASS_DEF.h"
 
+namespace AthPyEx {
+
 class MyObj
 {
 public:
@@ -31,7 +33,9 @@ private:
   int m_a;
 };
 
-CLASS_DEF(MyObj, 86839352, 1)
+} // namespace AthPyEx
+
+CLASS_DEF(AthPyEx::MyObj, 28807578, 1)
 
 #endif
 
diff --git a/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/PyAnalysisExamples/MySelectionAlg.h b/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/PyAnalysisExamples/MySelectionAlg.h
index ed13a5aa3d37903a38fdb8f5f82b2ff46b6fe9b3..64e8924d6503d9a9d3e2d4b1b2ae3a2f6786715d 100755
--- a/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/PyAnalysisExamples/MySelectionAlg.h
+++ b/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/PyAnalysisExamples/MySelectionAlg.h
@@ -1,16 +1,16 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef PYANALYSISEXAMPLES_MYSELECTIONALG_H
 #define PYANALYSISEXAMPLES_MYSELECTIONALG_H
 
-class MyCutClass;
 
 #include "AthenaBaseComps/AthAlgorithm.h"
 
 namespace AthPyEx {
 class MyTool;
+class MyCutClass;
 
 class MySelectionAlg : public AthAlgorithm
 {
diff --git a/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/PyAnalysisExamples/MyTool.h b/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/PyAnalysisExamples/MyTool.h
index 59c554fbc6aa92bcd74ae1d875c4a7cb3a470b56..9f12f595f1f9369376705ab0b6cde64d913a8b0d 100755
--- a/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/PyAnalysisExamples/MyTool.h
+++ b/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/PyAnalysisExamples/MyTool.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef PYANALYSISEXAMPLES_MYTOOL_H
@@ -15,10 +15,10 @@
 #include "Python.h"
 #include "AthenaBaseComps/AthAlgTool.h"
 
-class MyObj;
-
 namespace AthPyEx {
 
+class MyObj;
+
 class MyTool : public AthAlgTool
 {
 public:
diff --git a/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/PyAnalysisExamples/PyAnalysisExamplesDict.h b/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/PyAnalysisExamples/PyAnalysisExamplesDict.h
index b6df71076445e8cc02da74a4b77235b84605f25d..1bcf511f95046af565e2fc54f07e6a4d070d7d99 100755
--- a/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/PyAnalysisExamples/PyAnalysisExamplesDict.h
+++ b/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/PyAnalysisExamples/PyAnalysisExamplesDict.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef PYANALYSISEXAMPLES_PYANALYSISEXAMPLESDICT_H
@@ -14,13 +14,12 @@ namespace  PyAnalysisExamplesDict
 {
   void tmp ()
   {
-    MyObj *obj = new MyObj("cccc");
+    auto obj = std::make_unique<AthPyEx::MyObj>("cccc");
     obj->setA<float>(0);    
     obj->setA<double>(0);    
     obj->setA<int>(0);
     obj->setA<long>(0);
     obj->setA<bool>(false);    
-    delete obj;
   }
 }
 
diff --git a/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/PyAnalysisExamples/selection.xml b/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/PyAnalysisExamples/selection.xml
index 7ab4576fe075fb052fb22411e7b347b6b6fe064c..5eeeb63080888b90a99f48d6d2c273f4c8ea585d 100755
--- a/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/PyAnalysisExamples/selection.xml
+++ b/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/PyAnalysisExamples/selection.xml
@@ -1,8 +1,8 @@
 <lcgdict>
 
-  <class name="MyCutClass" />
-  <class name="MyObj" />
-  <class name="MyDetObj" />
+  <class name="AthPyEx::MyCutClass" />
+  <class name="AthPyEx::MyObj" />
+  <class name="AthPyEx::MyDetObj" />
   <class name="AthPyEx::MyTool" />
   
 </lcgdict>
diff --git a/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/share/AlgorithmTest.py b/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/share/AlgorithmTest.py
index 1926f2d6d6fb228947143ea95b55cbe1c0a48512..93fd5e5a0e6062602a1fe4b36d222837afbd366f 100755
--- a/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/share/AlgorithmTest.py
+++ b/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/share/AlgorithmTest.py
@@ -30,11 +30,11 @@ theApp.nextEvent()
 # get transient Electrons which are recorded into SG by MySelectonAlg
 econ = PyParticleTools.getElectrons(myNewKey)
 for ie in range(len(econ)):
-    print "pt %f" % econ[ie].pt()
+    print ("pt %f" % econ[ie].pt())
 
 # load dict for MyDetObj
 pylcgdict.load_library("libPyAnalysisExamplesDict")
 
 # retrieve an object from DetectorStore
-obj = PyKernel.retrieveDet(g.MyDetObj,'myDetObj')
-print obj.name()
+obj = PyKernel.retrieveDet(g.AthPyEx.MyDetObj,'myDetObj')
+print (obj.name())
diff --git a/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/share/BindingsTest.py b/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/share/BindingsTest.py
index fa43689ab9cd5a1e294230ba9f26ee497c4452a4..d81b400d19ea1ec4c6685cd9034065ec7fd20b6f 100755
--- a/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/share/BindingsTest.py
+++ b/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/share/BindingsTest.py
@@ -10,7 +10,7 @@
 pylcgdict.load_library("libPyAnalysisExamplesDict")
 
 # instantiate a C++ class from python
-cut = g.MyCutClass(30*GeV)
+cut = g.AthPyEx.MyCutClass(30*GeV)
 
 # init application mgr
 theApp.initialize()
@@ -32,10 +32,10 @@ for ievent in range(5):
     for ie in range(len(econ)):
         eobj = econ[ie]
         if cut.isAccepted(eobj):
-            print "accept %f" % eobj.pt()
+            print ("accept %f" % eobj.pt())
             ha.Fill(eobj.pt())
         else:
-            print "reject %f" % eobj.pt()
+            print ("reject %f" % eobj.pt())
             hr.Fill(eobj.pt())            
 
 ha.Draw()
diff --git a/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/share/CallBackTest.py b/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/share/CallBackTest.py
index fde090ddec1f53f0258e80465291c66ae99ff8e0..f782e3f8f00053a7cb21240bb2f1aa0cacc14233 100755
--- a/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/share/CallBackTest.py
+++ b/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/share/CallBackTest.py
@@ -12,12 +12,12 @@ pylcgdict.load_library("libPyAnalysisExamplesDict")
 obj = g.CallBackTest()
 
 # setup reverse proxy
-g.PyReverseProxy(g.MyDetObj).setConv(g.PyReverseProxy(g.MyDetObj).getObj)
+g.PyReverseProxy(g.AthPyEx.MyDetObj).setConv(g.PyReverseProxy(g.AthPyEx.MyDetObj).getObj)
 
 # define a python function
 def aPyFunc(dobj):
-    print "   aPyFunc called"
-    print dobj.name()
+    print ("   aPyFunc called")
+    print (dobj.name())
     
 # set callback
 obj.setCallBack(aPyFunc)
diff --git a/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/share/ParticleTest.py b/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/share/ParticleTest.py
index d3e6b9f188404ecd5e3d322f75c944c0719ed468..bce919d95807326bb16d383330b5c6348a749ea7 100755
--- a/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/share/ParticleTest.py
+++ b/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/share/ParticleTest.py
@@ -15,16 +15,16 @@ theApp.nextEvent()
 
 # get ElectronContainer from AOD
 econ = PyParticleTools.getElectrons("ElectronCollection")
-print "Electron"
-print econ.size()
+print ("Electron")
+print (econ.size())
 
 for i in range(econ.size()):
     eobj = econ[i]
-    print "Electron pt:%f" % eobj.pt()
+    print ("Electron pt:%f" % eobj.pt())
     # get TrackParticle via ElementLink
     tp = eobj.track()
-    print "TrackParticle px:%f" % tp.px()
+    print ("TrackParticle px:%f" % tp.px())
     # get egamma via Navigation
     # this should be retrieved from ESD
     eg = eobj.eg()
-    print "egamma eta:%f" % eg.eta()
+    print ("egamma eta:%f" % eg.eta())
diff --git a/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/share/ToolTest.py b/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/share/ToolTest.py
index a7b22f3f9640c0ede8001a7233c24ba8a1c36f08..e6c4f99d1ae44bfbaaeffddc9a228d5f7f6df812 100755
--- a/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/share/ToolTest.py
+++ b/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/share/ToolTest.py
@@ -30,7 +30,7 @@ tool.setPython(tool)
 
 # set proxy
 def convFunc():
-    ptr = cppyy.libPyROOT.MakeNullPointer(g.MyObj)
+    ptr = cppyy.libPyROOT.MakeNullPointer(g.AthPyEx.MyObj)
     proxy = g.PyReverseProxy.getProxy("MyObj_Proxy")
     proxy.getObj(ptr)
     return ptr
@@ -40,16 +40,16 @@ proxy.setFunc(convFunc)
 counter=567
 # callback
 def py_execute(obj):
-    print "PyExecute begin"
-    print "   name : %s" % obj.name()
-    print "      A : %s" % obj.getA()
-    print "setA float in Python"
+    print ("PyExecute begin")
+    print ("   name : %s" % obj.name())
+    print ("      A : %s" % obj.getA())
+    print ("setA float in Python")
     obj.setA(1.22)
-    print "setA int in Python"    
+    print ("setA int in Python"    )
     global counter
     obj.setA(counter)
     counter += 1
-    print "PyExecute end"    
+    print ("PyExecute end"    )
     return True
 tool.py_execute = py_execute
 
diff --git a/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/share/TriggerTest.py b/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/share/TriggerTest.py
index f019821a977d86cb4e3bfd789feb80396a7c1b4e..4fc3cdd82ce346d86e13972116eebc507a475b0b 100755
--- a/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/share/TriggerTest.py
+++ b/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/share/TriggerTest.py
@@ -12,42 +12,42 @@ theApp.nextEvent()
 
 # CTP
 ctp = PyTriggerTools.getCTP_Decision ("CTP_Decision")
-print "CTP"
-print ctp.getTriggerTypeWord()
-print "-------------------------"
+print ("CTP")
+print (ctp.getTriggerTypeWord())
+print ("-------------------------")
 
 # L1 ROI
 L1rois = PyTriggerTools.getLVL1_ROI ("LVL1_ROI")
 
-print "Muon"
+print ("Muon")
 rois = L1rois.getMuonROIs()
 for roi in rois:
-    print "Eta:%s" % roi.getEta()
-    print "Phi:%s" % roi.getPhi()
-print "-------------------------"
+    print ("Eta:%s" % roi.getEta())
+    print ("Phi:%s" % roi.getPhi())
+print ("-------------------------")
 
-print "EmTau"
+print ("EmTau")
 rois = L1rois.getEmTauROIs()
 for roi in rois:    
-    print "Eta:%s" % roi.getEta()
-    print "Phi:%s" % roi.getPhi()
-print "-------------------------"
+    print ("Eta:%s" % roi.getEta())
+    print ("Phi:%s" % roi.getPhi())
+print ("-------------------------")
 
-print "Jet"
+print ("Jet")
 rois = L1rois.getJetROIs()
 for roi in rois:
-    print "Eta:%s" % roi.getEta()
-    print "Phi:%s" % roi.getPhi()
-print "-------------------------"
+    print ("Eta:%s" % roi.getEta())
+    print ("Phi:%s" % roi.getPhi())
+print ("-------------------------")
 
-print "JetET"
+print ("JetET")
 rois = L1rois.getJetEtROIs()
-print "-------------------------"
+print ("-------------------------")
 
-print "EnergySum"
+print ("EnergySum")
 rois = L1rois.getEnergySumROIs()
 for i in range(len(rois)):
-    print "EX:%s" % rois[i].getEnergyX()
-    print "EY:%s" % rois[i].getEnergyY()
-    print "ET:%s" % rois[i].getEnergyT()
-print "-------------------------"
+    print ("EX:%s" % rois[i].getEnergyX())
+    print ("EY:%s" % rois[i].getEnergyY())
+    print ("ET:%s" % rois[i].getEnergyT())
+print ("-------------------------")
diff --git a/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/share/TruthTest.py b/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/share/TruthTest.py
index bb4ea23570c53bfdacf2e9135ff656a7358a888b..5040960bc9164d626d885707b22ed78d3d76afac 100755
--- a/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/share/TruthTest.py
+++ b/PhysicsAnalysis/PyAnalysis/PyAnalysisExamples/share/TruthTest.py
@@ -17,7 +17,7 @@ mcc = PyTruthTools.getMcEvents('GEN_AOD')
 mc = mcc[0]
 
 # call a normal method
-print mc.alphaQCD()
+print (mc.alphaQCD())
 
 # get particle-iterators
 # GenEvent::particles_begin() and _end() give ietrators
@@ -32,7 +32,7 @@ while (it != itE):
     # dereference and increment the iterator
     # this corresponds to "p = *it++" 
     p = it.next()
-    print p.pdg_id()
+    print (p.pdg_id())
 
 # get vertex-iterator
 it = mc.vertices_begin()
@@ -49,5 +49,5 @@ itpE = v.particles_end(0)
 itp.end = v.particles_end
 
 while (itp != itpE):
-    print itp.next().pdg_id()
+    print (itp.next().pdg_id())