These are chat archives for ipython/ipython

21st
Dec 2015
Michael Parks
@Karunamon
Dec 21 2015 22:10
Greetings all - I'm having a hard time figuring out how to square what iPython is telling me with what I need to write. In short, an assertion that an object is an instance of a class.
Say I've got a t object that reports as <class jira.resources.Issue>
I've got the JIRA package imported, but I have no idea how to actually write a true assertion for isInstance(t, jira.resources.Issue) - which doesn't work as written.
Anton Akhmerov
@akhmerov
Dec 21 2015 22:12
isinstance shouldn't have a capital letter, I imagine
It's not so much an IPython question, as it is a general Python one.
Michael Parks
@Karunamon
Dec 21 2015 22:13
mm... no difference. The actual error I'm getting back is name 'jira' is not defined
Ahh, okay. I'm actuall wondering where then iPython is gathering this name from, seeing as how lowercase jira isn't in my namespace and can't be imported
(the actual name is allcaps JIRA)
Anton Akhmerov
@akhmerov
Dec 21 2015 22:15
In your assertion you call jira without caps.
Michael Parks
@Karunamon
Dec 21 2015 22:15
did. name 'jira' is not defined
but the allcaps version doesn't have a resources either.
aaand I just now noticed the existence of the /help channel.Should I be there instead?
Anton Akhmerov
@akhmerov
Dec 21 2015 22:17
Not really there neither, since it's not an IPython question...
Michael Parks
@Karunamon
Dec 21 2015 22:18
_< Okay: How is ipython resolving the name of this object since it's not in namespace?
err, resolving the type that is
something tells me the answer to that question will answer the larger one :P
peter216
@peter216
Dec 21 2015 22:19
try 'import jira'
Anton Akhmerov
@akhmerov
Dec 21 2015 22:19
The object was produced by something, right? I'm guessing that something had imported the correct jira.
Michael Parks
@Karunamon
Dec 21 2015 22:22
Gotcha, it can resolve the names of things that aren't necessarily available. That was more the question - if class(t) comes back with jira.resources.Issue, then why can't I immediately cook up an assert pointing at that. Answer: Because the package can bring in things that aren't necessarily in the context of your ipython session until you explicitly import them.
Neat, thanks ^^
Anton Akhmerov
@akhmerov
Dec 21 2015 22:25
Right :)
Michael Parks
@Karunamon
Dec 21 2015 22:26
The joys of being somewhat new to the language and being tasked to write a test suite. (Long story...)