473,856 Members | 2,133 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

TypeError: 'module object is not callable'

Hi

I am new to Python and have recieved this error message when trying to
instantiate an object from a class from another file within the same
directory and wondered what I have done wrong.

I have a Step.py class:
class Step(object)
def __init__(self, sName):
"Initialise a new Step instance"
self.sName = sName
self.depSteps = []
self.remDepStep s = []
self.isComplete d = 0
Then I have created a new file within the same directory called
main.py:

import Step
a = Step("magn")

The following however generates the error
Traceback (most recent call last):
File "main.py", line 3, in ?
a = Step("magn")
TypeError: 'module' object is not callable

If anyone could help point me in the right direction, how to fix this
problem it would be much appreciated.
Chris

Sep 3 '07
33 56525
Thanks guys, I really appreciate it. I have never used google groups
before
and am so impressed with how helpful you all are. It is also lovely
that
none of you mock my little knowledge of Python but just want to
improve it.

I have another question in relation to the izip_longest function (I
persume
this should be within the same topic).
Using this funciton, is there a way to manipulate it so that the
columns can be formated
tabular i.e. perhaps using something such as str(list).rjust (15)
because currently the columns
overlap depending on the strings lengths within each column/list of
lists. i.e. my output is
currently like:

bo, daf, da
pres, ppar, xppc
magnjklep, *, dsa
*, *, nbi

But I want it justified, i.e:

bo , daf, da
pres , ppar, xppc
magnjklep, *, dsa
* , *, nbi

I am struggling to understand how the izip_longest function works
and thus don't really know how it could be manipulated to do the
above.
It would be much apprecited if somoene could also explain how
izip_function
works as I don't like adding code into my programs which I struggle to
understand.
Or perhaps I have to pad out the lists when storing the Strings?

Any help would be much appreciated.

Sep 5 '07 #31
On 9/5/07, cj***@bath.ac.u k <cj***@bath.ac. ukwrote:
Thanks guys, I really appreciate it. I have never used google groups
before and am so impressed with how helpful you all are. It is also lovely
that none of you mock my little knowledge of Python but just want to
improve it.
And we are proud of it !
I have another question in relation to the izip_longest function (I
persume
this should be within the same topic).
Using this funciton, is there a way to manipulate it so that the
columns can be formated
tabular i.e. perhaps using something such as str(list).rjust (15)
because currently the columns
overlap depending on the strings lengths within each column/list of
lists. i.e. my output is
currently like:

bo, daf, da
pres, ppar, xppc
magnjklep, *, dsa
*, *, nbi

But I want it justified, i.e:

bo , daf, da
pres , ppar, xppc
magnjklep, *, dsa
* , *, nbi
You can format the output while "print"ing the table. Have a look at:

http://www.python.org/doc/current/li...q-strings.html

example:
for tup in izip_longest(*d , **dict(fillvalu e='*')):
print "%15s, %15s, %15s" %tup # for a tuple of length 3, you can
generalize it

I am struggling to understand how the izip_longest function works
and thus don't really know how it could be manipulated to do the
above.
It would be much apprecited if somoene could also explain how
izip_function
works as I don't like adding code into my programs which I struggle to
understand.
Or perhaps I have to pad out the lists when storing the Strings?

Any help would be much appreciated.
This is an example of "generator" functions, to understand what they
are and how they work you can:
1. web-search for "python generators"
2. have a look at "itertools" module, for more generators

--
----
Amit Khemka
website: www.onyomo.com
wap-site: www.owap.in
Sep 5 '07 #32
On Behalf Of cj***@bath.ac.u k
bo, daf, da
pres, ppar, xppc
magnjklep, *, dsa
*, *, nbi

But I want it justified, i.e:

bo , daf, da
pres , ppar, xppc
magnjklep, *, dsa
* , *, nbi
Once you have a nice rectangular list of lists, you might want to take a
look at my padnums module.

# Usage:
import padnums
import sys

table = [row for row in izip_longest(*d , fillvalue='*')]
padnums.pprint_ table(sys.stdou t, table)

Code described here, with link to module:
http://ginstrom.com/scribbles/2007/0...ble-in-python/

Regards,
Ryan Ginstrom

Sep 5 '07 #33
cj***@bath.ac.u k a écrit :
Thanks guys, I really appreciate it. I have never used google groups
before
Actually, comp.lang.pytho n is a usenet newsgroup, not a google group.
Google only gives you a web fronted (and archives...) for that group. I
personnaly access it with my MUA.
and am so impressed with how helpful you all are. It is also lovely
that
none of you mock my little knowledge of Python but just want to
improve it.
Well... Why should we mock ? We've all been beginners, and we're still
all beginners in a domain or another.

But welcome to c.l.py and thanks for appreciating this group anyway !-)
I have another question in relation to the izip_longest function (I
persume
this should be within the same topic).
Using this funciton, is there a way to manipulate it so that the
columns can be formated
tabular i.e. perhaps using something such as str(list).rjust (15)
because currently the columns
overlap depending on the strings lengths within each column/list of
lists. i.e. my output is
currently like:

bo, daf, da
pres, ppar, xppc
magnjklep, *, dsa
*, *, nbi

But I want it justified, i.e:

bo , daf, da
pres , ppar, xppc
magnjklep, *, dsa
* , *, nbi

I am struggling to understand how the izip_longest function works
What's bothering you ?-)

Sorry, just joking. This code uses some 'advanced' stuffs like closures,
HOFs and generators/iterators, so it's obviously not that simple to grok
- FWIW, I myself had to read it at least thrice to understand it.
and thus don't really know how it could be manipulated to do the
above.
FWIW, you don't have - and IMHO should not try - to do this within
izip_longest, which is a generic function.
It would be much apprecited if somoene could also explain how
izip_function
works as I don't like adding code into my programs which I struggle to
understand.
Or perhaps I have to pad out the lists when storing the Strings?
I'd personnaly do the formatting just before printing.
Sep 5 '07 #34

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
13121
by: Atul Kshirsagar | last post by:
Hello, I am using Python 2.3.2 with a C++ extention DLL in muti-threaded environment. 1. For each new thread I create a separate sub-interpreter. 2. Each thread executes multiple python statements calling the class objects in my extention DLL. 3. Before each execution I import my extention module using;
7
3981
by: ‘5ÛHH575-UAZWKVVP-7H2H48V3 | last post by:
(see end of message for example code) When an instance has a dynamically assigned instance method, deepcopy throws a TypeError with the message "TypeError: instancemethod expected at least 2 arguments, got 0". Tested with Python 2.3.4 on OpenBSD and Python 2.4 on Win98; same results. Is this a bug in deepcopy, how I dynamically assign the instance method or something else? (See example code for how I did it.) If you're curious as...
5
22752
by: Randall Parker | last post by:
Using Python 2.4.2 on Windows 2000 in SPE. Getting: TypeError: 'str' object is not callable on this line: TmpErrMsg1 = "State machine %s " (StateMachineName) In Winpdb 1.0.6 the StateMachineName is of type str in the Namespace |
1
1706
by: Gary Wessle | last post by:
dear python users I am not sure why I am getting **************************************************************** Traceback (most recent call last): File "my.py", line 3, in ? urlparse('http://www.cwi.nl:80/%7Eguido/Python.html') TypeError: 'module' object is not callable ****************************************************************
10
11534
by: Charles Russell | last post by:
Why does this work from the python prompt, but fail from a script? How does one make it work from a script? #! /usr/bin/python import glob # following line works from python prompt; why not in script? files=glob.glob('*.py') print files Traceback (most recent call last):
2
6758
by: AWasilenko | last post by:
I'm trying to test a few different approaches to displaying pages via Cherrypy and I'm not having much luck. Here is my code so far: import sys, cherrypy, html class Root: @cherrypy.expose def index(self, pageid = None): selection = html.Page() return selection.input()
18
15784
by: Charlie of Bolton | last post by:
Hi, everybody, Did work hard on this one, as I`m a newbies... I did write the entire below script... This script is suppose to ping: a primary IP (only one), (entered manually w raw-input) and than secondaries IP ( less than 10), (entered manually w raw-input)
1
17248
by: Charles Fox | last post by:
Hi gys -- I am looking at Numpy but getting this error when I try to get array sizes. I'm using Ubuntu Edgy with standard repositories and scipy. Any ideas? Am I doing something wrong or is it my install of scipy? $ python Python 2.4.4c1 (#2, Oct 11 2006, 21:51:02) on linux2 Type "help", "copyright", "credits" or "license" for more information. array(,
0
9903
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9754
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11047
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10375
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9526
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5754
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5953
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4567
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3194
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.