0

I am new to Python and a bit confused about parameters transfer: I have 2 methods:

def convert(self, ipnb, indices = []):
    with self.fopen(ipnb, u'r') as f:
        emptyIndicesList = not indices
        #some code

def test_read(self):
    s = self.convert(self, u'test.ipynb')
    #some code

I encounter 2 issues:

  1. If I run the code as is self.fopen(ipnb, u'r') as f throws... But if I change with self.fopen(ipnb, u'r') as f to self.fopen(u'test.ipynb', u'r') as f it works properly

  2. emptyIndicesList is false, I expect it to be true, since I think that I am using default parameter - empty list What am I missing in parameter transfer? How the above issues should be solved?

Thanks :)

1 Answer 1

1

You are passing the context as a first argument to the function convert.

Change s = self.convert(self, u'test.ipynb') to s = self.convert(u'test.ipynb') which shall resolve both of your issues.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.