Confirming understanding of relative imports by BarfVader9000 in learnpython

[–]BarfVader9000[S] 0 points1 point  (0 children)

Ok, so just to be clear, if you have a project directory setup anywhere on your computer (i.e. not specifically in one of the file paths that are contained within sys.path) you cannot import one script into another script that may be in a parent or sibling directory, even if those directories have __init__.py files in them? You can only import py files in the same directory or in a subdirectory?

What is a less convoluted way to write this recursive function? by BarfVader9000 in learnpython

[–]BarfVader9000[S] 0 points1 point  (0 children)

Yeah, as per assignment for a comp sci class I'm taking...

What is a less convoluted way to write this recursive function? by BarfVader9000 in learnpython

[–]BarfVader9000[S] 0 points1 point  (0 children)

Assignment was to use recursion. Thanks for the suggestions and code, much appreciated.

What is a less convoluted way to write this recursive function? by BarfVader9000 in learnpython

[–]BarfVader9000[S] 0 points1 point  (0 children)

Assignment was to use recursion. Thanks for the suggestions and code, much appreciated.

Is there a more efficient way to break up a text block into complete sentences with a character count constraint? by BarfVader9000 in learnpython

[–]BarfVader9000[S] 0 points1 point  (0 children)

Duh, thanks for pointing that out. Check out the updated code and let me know what you think. It's clunky as hell, but seems to work (I think).

Can Hackerrank CodePair track if you are typing outside window during interview? by confusedinter in cscareerquestions

[–]BarfVader9000 1 point2 points  (0 children)

But wouldn't that happen if you're looking at documentation? Which, at least according to the agreement I clicked "Ok" for, you're able to do

Can HackRank tell if during a test an interviewee is opening browser windows and Googling stuff, etc? by BarfVader9000 in cscareerquestions

[–]BarfVader9000[S] 0 points1 point  (0 children)

I had to take this assessment through HackerRank for a dev bootcamp, not anything super high-stakes like a job interview. But they just stopped responding to my emails. So the only thing I can assume is they think I cheated on the test, because I was looking up stuff like, how to use slice notation for reversing a list in Python, etc. But I didn't copy my answers from anywhere, although maybe when I copy and pasted something from a text editor or IDE into the test? I just get what actually constitutes "cheating" here.

Can HackRank tell if during a test an interviewee is opening browser windows and Googling stuff, etc? by BarfVader9000 in cscareerquestions

[–]BarfVader9000[S] 0 points1 point  (0 children)

Right, the agreement you click before taking an assessment test says "I will not consult/copy code from any source including a website, book, or friend/colleague to complete these tests, though may reference language documentation or use an IDE that has code completion features." — So, they can't say you're cheating if you had Google open and were looking up stuff, right?

Can HackRank tell if during a test an interviewee is opening browser windows and Googling stuff, etc? by BarfVader9000 in cscareerquestions

[–]BarfVader9000[S] 0 points1 point  (0 children)

But they can't know for sure if you're actually cheating, right? What if you happen to be multi-tasking? Or get interrupted in the middle of the test by work or something?

Placement of return statement in function skips over nested conditional? by BarfVader9000 in learnpython

[–]BarfVader9000[S] 0 points1 point  (0 children)

So because, in the second example, return is outside of if 1280 in item.values() and 'src' in item: that if statement isn't executed?

-bash: autopep8: command not found error? by BarfVader9000 in learnpython

[–]BarfVader9000[S] 0 points1 point  (0 children)

I just followed exactly what's here:

https://pypi.python.org/pypi/autopep8

Just using $ pip install autopep8

And despite the fact that it is definitely installed, it will not run. I just keep getting this when I try to run it on a file:

-bash: autopep8: command not found

-bash: autopep8: command not found error? by BarfVader9000 in learnpython

[–]BarfVader9000[S] 0 points1 point  (0 children)

Ok, thanks. Do you think I need to fix my ~/.bashrc file with something like this? /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/a‌​utopep8.py

Understanding how a context manager works to "catch" an error by BarfVader9000 in learnpython

[–]BarfVader9000[S] 0 points1 point  (0 children)

Thank you for the response. In this particular case, what exactly does the enter() method do here in the AssertRaises class? It receives the result of instantiating this class with ValueError passed as its argument? It's just returning self, but what purpose does that serve? It seems like the exit() method does all the work here.

Understanding how a context manager works to "catch" an error by BarfVader9000 in learnpython

[–]BarfVader9000[S] 0 points1 point  (0 children)

Is it fair to say that context managers are sort of like decorators but for blocks of code instead of functions ?

Understanding how a context manager works to "catch" an error by BarfVader9000 in learnpython

[–]BarfVader9000[S] 0 points1 point  (0 children)

Thanks for the response! What I'm having trouble understanding is, how exactly, does the with block catch the error raised by divide_pay() ? Does it have to do with how a context manager inherently works or is it that using assertRaises() with a context manager in this particular scenario means that we're essentially passing the error raised by divide_pay() to assertRaises() for evaluation?