Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'Tuple' object has no attribute 'id' #31

Closed
AEDWIP opened this issue Apr 14, 2017 · 1 comment
Closed

AttributeError: 'Tuple' object has no attribute 'id' #31

AEDWIP opened this issue Apr 14, 2017 · 1 comment

Comments

@AEDWIP
Copy link

AEDWIP commented Apr 14, 2017

week1.ipynb.txt

Note sure how to debug the following error. Attached is the notebook I tried to import. They are in the same directory

Any ideas?

Thanks

Andy

#from ipynb.fs.defs.week1 import patternToNumber
import ipynb.fs.defs.week1 as wk1

#import ipynb.fs.defs.week1 as week1

import ipynb.fs from .defs.week2 \

import foo from .defs.week1 \

import patternToNumber

import ipynb.fs

from ../week2/week2 import patternToNumber from .defs.week1

# base 4 to base 10

# TODO copied from week1 notebook

def patternToNumber(pattern) :

exponent = 0

ret = 0

for nucleotide in reversed(pattern):

digit = 0

if nucleotide == "C" :

digit = 1

elif nucleotide == "G" :

digit = 2

elif nucleotide == "T" :

digit = 3

ret = ret + digit * 4**exponent

#print("ret:{0}, digit:{1}, exponent:{2} nucleotide:{3}"

# .format(ret, digit, exponent, nucleotide))

exponent = exponent + 1

return ret


AttributeError Traceback (most recent call last)
in ()
----> 1 from ipynb.fs.defs.week1 import patternToNumber
2 #import ipynb.fs.defs.week1 as wk1
3
4 #import ipynb.fs.defs.week1 as week1
5 # import ipynb.fs from .defs.week2 \

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/importlib/_bootstrap.py in find_and_load(name, import)

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/importlib/_bootstrap.py in find_and_load_unlocked(name, import)

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/importlib/_bootstrap.py in _load_unlocked(spec)

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/importlib/_bootstrap_external.py in exec_module(self, module)

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/ipynb/fs/defs/init.py in get_code(self, fullname)
60 ))
61 return self.source_to_code(
---> 62 self._get_filtered_ast(code_from_ipynb(nb)),
63 self.path
64 )

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/ipynb/fs/defs/init.py in _get_filtered_ast(self, source)
47 """
48 tree = ast.parse(source)
---> 49 tree.body = [n for n in tree.body if self._filter_ast_node(n)]
50 return tree
51

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/ipynb/fs/defs/init.py in (.0)
47 """
48 tree = ast.parse(source)
---> 49 tree.body = [n for n in tree.body if self._filter_ast_node(n)]
50 return tree
51

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/ipynb/fs/defs/init.py in _filter_ast_node(self, node)
38
39 if isinstance(node, ast.Assign):
---> 40 return all([t.id.isupper() for t in node.targets])
41
42 return False

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/ipynb/fs/defs/init.py in (.0)
38
39 if isinstance(node, ast.Assign):
---> 40 return all([t.id.isupper() for t in node.targets])
41
42 return False

AttributeError: 'Tuple' object has no attribute 'id'

@blairhudson
Copy link
Contributor

I ran into the same error. This is caused by a bug in handling tuple-based assignment. See #34 for details. Suggesting merge and close.

yuvipanda added a commit that referenced this issue Sep 18, 2017
tonyfast added a commit to deathbeds/ipynb that referenced this issue Jan 2, 2020
* Moves tests into the source.
* Add lazy loading to address ipython#31
* Add a lazy import test
* Remove the dataclasses dependency and test on 3.4 and 3.5
* Remove the black dependency
* You hasty son of a gun
* Dump the docs deploy to pass 3.6
* Escape lazy loading in python 3.4
* Filefinder compat
* mkdir compat
* pathlib compat in the tests
* Add pypi version to deployments to travis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants