Skip to content
Snippets Groups Projects
Commit b3a3dc9b authored by jacques Grelet's avatar jacques Grelet
Browse files

replace __getattr__ by __getitem__

parent e03c00aa
No related branches found
No related tags found
No related merge requests found
...@@ -8,8 +8,12 @@ Successfully installed pip-19.0.3 ...@@ -8,8 +8,12 @@ Successfully installed pip-19.0.3
[ntird-us191-jg4:jgrelet]/c/git/python/pirata [ntird-us191-jg4:jgrelet]/c/git/python/pirata
Sous Linux Ubuntu 16.04, l'upgrade de pip failed ! Sous Linux Ubuntu 16.04, l'upgrade de pip failed !
---------------------------------------------------
voir: https://askubuntu.com/questions/1025793/running-pip3-importerror-cannot-import-name-main
Utiliser: Utiliser:
> python3 -m pip install --user <package> # instead > python3 -m pip install --user <package> # instead
A tester:
Then I recommend adding the following aliases to your .bashrc: Then I recommend adding the following aliases to your .bashrc:
pip() ( python -m pip "$@" ) pip() ( python -m pip "$@" )
pip3() ( python3 -m pip "$@" ) pip3() ( python3 -m pip "$@" )
...@@ -77,7 +81,7 @@ In setting.json: ...@@ -77,7 +81,7 @@ In setting.json:
"python.autoComplete.addBrackets": true, "python.autoComplete.addBrackets": true,
"editor.formatOnPaste": true "editor.formatOnPaste": true
Modules pYthon à intaller: Modules Python à intaller:
-------------------------- --------------------------
Autoformatting Autoformatting
---------------------- ----------------------
......
...@@ -20,9 +20,9 @@ class Roscop: ...@@ -20,9 +20,9 @@ class Roscop:
def __str__(self): def __str__(self):
return 'Class Roscop, file: %s, size = %d' % (self.file, len(self.hash)) return 'Class Roscop, file: %s, size = %d' % (self.file, len(self.hash))
def __getattr__(self, name): def __getitem__(self, name):
''' '''
overload r.key overload r[key]
''' '''
return self.hash[name] return self.hash[name]
...@@ -31,7 +31,7 @@ class Roscop: ...@@ -31,7 +31,7 @@ class Roscop:
def disp(self, theKey): def disp(self, theKey):
print("%s :" % theKey) print("%s :" % theKey)
print(self.hash[theKey]) print(self[theKey])
# read code roscop file # read code roscop file
def read(self): def read(self):
...@@ -87,6 +87,5 @@ if __name__ == "__main__": ...@@ -87,6 +87,5 @@ if __name__ == "__main__":
for k in key: for k in key:
r.disp(k) r.disp(k)
# print(r.TEMP)
# r.disp('TEMP') # r.disp('TEMP')
# print(r[key]) # print(r[key])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment