Basic Confusion

This is the place for queries that don't fit in any of the other categories.

Basic Confusion

Postby AlanD » Mon Jun 17, 2013 4:02 am

I am a newbie to Python, tho' an experienced coder.

In IDLE (Python 3.3) I type
Code: Select all

dir(a) shows me that I have three built-in functions available, conjugate, real and imag.

Trial and error informs me that, whereas I need to use
Code: Select all
to avoid getting an error message, with the other two I need simply
Code: Select all
Code: Select all
, and adding brackets results in an error message for each.

What logic am I missing here, and how do I learn which option to use for any built-in function simply by typing dir(a)?
Posts: 1
Joined: Mon Jun 17, 2013 3:43 am
Location: Weybridge, England

Re: Basic Confusion

Postby micseydel » Mon Jun 17, 2013 4:20 am

You can use help() instead of dir() to get that information you wanted.

As for why it is that way, it's because the latter two are properties of the object that do not require any computation, whereas the first is something that has to be generated from the imaginary number rather than being part of what's stored for it. It's a subtle difference.
Join the #python-forum IRC channel on!
User avatar
Posts: 929
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA

Re: Basic Confusion

Postby ochichinyezaboombwa » Mon Jun 17, 2013 5:01 am

In other tongue, there are "data members" and "member functions (methods)". The former you use, the latter you call().
Posts: 200
Joined: Tue Jun 04, 2013 7:53 pm

Return to General Coding Help

Who is online

Users browsing this forum: No registered users and 1 guest