Re: [Tutor] From Numpy Import *

2007-11-09 Thread Evert Rol
> Thank-you! It is important for us to avoid potential code > conflicts and so we'll standardize on the import > syntax. > > On a related note: > We are using both NumPy and SciPy. Consider the example y = Ax > where A is a sparse matrix. If A is qualified as a scipy object > then do y

[Tutor] __doc__ strings for attributes?

2007-11-09 Thread Wesley Brooks
Dear Users, How can I add information to an object to explain what it expects as it's attributes? For instance I may have an object that creates a CAD file based on a set of default values which are set by the __init__ but can be altered before it runs. for example; class MakeBasicShape: def

Re: [Tutor] __doc__ strings for attributes?

2007-11-09 Thread Evert Rol
> How can I add information to an object to explain what it expects as > it's attributes? For instance I may have an object that creates a CAD > file based on a set of default values which are set by the __init__ > but can be altered before it runs. for example; Why don't you specify a doc-string

Re: [Tutor] __doc__ strings for attributes?

2007-11-09 Thread Wesley Brooks
Thanks for the comments. >shape0 = BasicShape() >shape1 = BasicShape('cylinder', [20.,10.,36.]) I like this way of doing things, I could inherit the 3D data object's class and get it to build on itself. I could for example use a function definition like the following: def __init__(*args, **param

Re: [Tutor] __doc__ strings for attributes?

2007-11-09 Thread Kent Johnson
Wesley Brooks wrote: > I do however get a real > problem when it comes to documenting the expected keywords and running > into huge doc strings, when I prefer concise documentation. > Is there an standard way of doing this? docstrings are the only standard way to document classes and functions.

Re: [Tutor] __doc__ strings for attributes?

2007-11-09 Thread Kent Johnson
Wesley Brooks wrote: > Dear Users, > > How can I add information to an object to explain what it expects as > it's attributes? For instance I may have an object that creates a CAD > file based on a set of default values which are set by the __init__ > but can be altered before it runs. for example

Re: [Tutor] __doc__ strings for attributes?

2007-11-09 Thread Evert Rol
> Thanks for the comments. > >> shape0 = BasicShape() >> shape1 = BasicShape('cylinder', [20.,10.,36.]) > > I like this way of doing things, I could inherit the 3D data object's > class and get it to build on itself. I could for example use a > function definition like the following: > > def __init

[Tutor] Type() Getting Type Error

2007-11-09 Thread Chernev Chernev
I'm debugging a script and want to check the type of an object. So in the script I write: print type([object] This bombs, and I get "TypeError: 'str' object is not callable' I've also tried x = type([object]) print x Same thing. In the interactive, 'type([object])' works fine. What am I missi

Re: [Tutor] Type() Getting Type Error

2007-11-09 Thread Kent Johnson
Chernev Chernev wrote: > I'm debugging a script and want to check the type of an object. > > So in the script I write: > print type([object] > > This bombs, and I get > "TypeError: 'str' object is not callable' > > What am I missing here? Probably you have a variable named 'type' in your script

Re: [Tutor] Type() Getting Type Error

2007-11-09 Thread Evert Rol
On 9 Nov 2007, at 14:48 , Chernev Chernev wrote: > I'm debugging a script and want to check the type of an object. > > So in the script I write: > print type([object] > > This bombs, and I get > "TypeError: 'str' object is not callable' > > I've also tried > x = type([object]) > print x > > Same

Re: [Tutor] Type() Getting Type Error

2007-11-09 Thread Chernev Chernev
On Nov 9, 2007 10:09 AM, Kent Johnson <[EMAIL PROTECTED]> wrote: > > So in the script I write: > > print type([object] > > > > This bombs, and I get > > "TypeError: 'str' object is not callable' > > > Probably you have a variable named 'type' in your script that is hiding > the builtin 'type' objec

Re: [Tutor] New Introductory Book

2007-11-09 Thread bhaaluu
Algorithm Education in Python http://www.ece.uci.edu/~chou/py02/python.html This article from Pai H. Chou at University of California, Irvine shows how well the Python programming language maps itself to the pseudocode used in _Introduction to Algorithms Second Editon_ [Corman, Leiserson, Rivest,

Re: [Tutor] Type() Getting Type Error

2007-11-09 Thread Alan Gauld
"Chernev Chernev" <[EMAIL PROTECTED]> wrote > So in the script I write: > print type([object] > > This bombs, and I get > "TypeError: 'str' object is not callable' > In the interactive, 'type([object])' works fine. Looks like you have defined type as a local variable somewhere in your script

Re: [Tutor] In-place expansion of list members... possible?

2007-11-09 Thread Ricardo Aráoz
Kent Johnson wrote: > Marc Tompkins wrote: >> I'm working with delimited files (ANSI X12 EDI nonsense, to be >> precise.) First I load the records to a list: >> tmpSegs = inString.split(self.SegTerm) >> >> Now, I want to replace each string in that list with a string: >> >> for se

Re: [Tutor] manipulating data

2007-11-09 Thread Ricardo Aráoz
Kent Johnson wrote: > Bryan Fodness wrote: >> I would like to have my data in a format so that I can create a contour plot. >> >> My data is in a file with a format, where there may be multiple fields >> >> field = 1 >> >> 1a 0 > > If your data is really this regular, it is pretty easy to parse.

[Tutor] parsing an array

2007-11-09 Thread sith .
newfile = open('y.txt') >>> for line in newfile: ... print line.rstrip() 3 5 7 11 8 10 Hi, I'm trying to parse an array. Now that I can open and read lines in my array, how can I access individual elements of my multidimensional array? I'd like to loop through the array and comp

[Tutor] Calling a function within a function within a class...

2007-11-09 Thread Trey Keown
Hey all... I'm creating a module for my program, and I need to call a function. Here's how it's set up: -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- class DoStuff: def Thing1(self): def ThingToCall(self): print "It worked!" def Thing2(self): #Call

Re: [Tutor] Calling a function within a function within a class...

2007-11-09 Thread Eric Brunson
Trey Keown wrote: > Hey all... > I'm creating a module for my program, and I need to call a function. > Here's how it's set up: > -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- > class DoStuff: > def Thing1(self): > def ThingToCall(self): > print "It worked!" >

Re: [Tutor] parsing an array

2007-11-09 Thread O.R.Senthil Kumaran
* sith . <[EMAIL PROTECTED]> [2007-11-09 17:53:53]: > newfile = open('y.txt') > >>> for line in newfile: > ... print line.rstrip() > > 3 5 7 > 11 8 10 This example is different from a array handling one. This is a file handle with with reading the contents of the file through a loop.

[Tutor] Swapping variables ...

2007-11-09 Thread Aditya Lal
After quizzing newbies in C on swapping without 3rd variable, I found this to be really *cool* construct to swap :) x = 10 y = 20 x,y = y,x -- Aditya ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] *args, **kargs as arguments

2007-11-09 Thread O.R.Senthil Kumaran
I know it can be a FAQ, but still I want ask to clarify my doubts and assumptions. I find usually in derived classes, a construct like this: class Derived(BaseClass): def __init__(self, *args, **kargs): BaseClass.__init__(self, *args, **kargs) - *args, **kargs passes a t

Re: [Tutor] In-place expansion of list members... possible?

2007-11-09 Thread Kent Johnson
Ricardo Aráoz wrote: > Kent Johnson wrote: >> or use slice assignment: >> tmpSegs[:] = [ seg.split(self.ElemSep) for seg in tmpSegs ] > > Won't the slice assignment create a new list and then assign it to the > old list (which the OP is trying to avoid)? Yes, it will, thanks! You can assign a gen

Re: [Tutor] *args, **kargs as arguments

2007-11-09 Thread wesley chun
hi, and welcome to Python!! > class Derived(BaseClass): > def __init__(self, *args, **kargs): > BaseClass.__init__(self, *args, **kargs) > > - *args, **kargs passes a tuple and a dictionary to the BaseClass constructor. > > My assumption is the BaseClass will always have a