Re: [Tutor] Import package module problem

2009-05-12 Thread spir
Le Mon, 11 May 2009 21:44:09 +0100 (BST), man...@themacaque.com s'exprima ainsi: > Hello there, > > I have just started working with python and I have some issues > understanding how I should be importing modules from packages. Curretly I > have the following tree structure: > > general/ > _

Re: [Tutor] Import package module problem

2009-05-12 Thread A.T.Hofkamp
man...@themacaque.com wrote: Hello there, I have just started working with python and I have some issues understanding how I should be importing modules from packages. Curretly I have the following tree structure: general/ __init__.py address_book.py groups/ __init__.py contact_

Re: [Tutor] Import package module problem

2009-05-12 Thread mandel
> Le Mon, 11 May 2009 21:44:09 +0100 (BST), > man...@themacaque.com s'exprima ainsi: > >> Hello there, >> >> I have just started working with python and I have some issues >> understanding how I should be importing modules from packages. Curretly >> I >> have the following tree structure: >> >> gen

Re: [Tutor] Import package module problem

2009-05-12 Thread mandel
> man...@themacaque.com wrote: >> Hello there, >> >> I have just started working with python and I have some issues >> understanding how I should be importing modules from packages. Curretly >> I >> have the following tree structure: >> >> general/ >> __init__.py >> address_book.py >> group

Re: [Tutor] Alternative for Shelve

2009-05-12 Thread Timo
Alan Gauld schreef: "Timo" wrote I have an issue with the Shelve module. It works great for my needs, the only problem is that a file made with Shelve isn't interchangable between different computers. I thought it would be. What kind of computers are you having issues with? And what kind of

Re: [Tutor] How to set up an Array?

2009-05-12 Thread spir
Le Mon, 11 May 2009 19:09:30 -0700 (PDT), nickel flipper s'exprima ainsi: > > Hello, > Just getting started with Python, and have had some early, although trivial > success. It looks like just the ticket to parse a data file. Total noob at > this, but really kind of overwhelmed by all the optio

Re: [Tutor] Alternative for Shelve

2009-05-12 Thread Timo
Kent Johnson schreef: On Mon, May 11, 2009 at 1:39 PM, Timo wrote: Hello all, I have an issue with the Shelve module. It works great for my needs, the only problem is that a file made with Shelve isn't interchangable between different computers. I want my data to be exchanged between users.

[Tutor] Calling method in parent class

2009-05-12 Thread The Green Tea Leaf
Hi, I've started to learn Python and I'm a bit confused over how to call a method in a parent class. Assume I have: class Parent(object): def somemethod( self, bla ): print 'Parent',bla I then create a child class that want to call somemethod. As I understand it I can either do it lik

Re: [Tutor] How to set up an Array?

2009-05-12 Thread nickel
John Fouhy fouhy.net> writes: > Hmm, hairy! > Thank you John for your quick reply. It looks like its going to take a bit to digest what you have written. Back to the Python 2.6 docs and the net. Had actually read the expressions section earlier in the day, but did not see how to apply to sai

[Tutor] Considering translating bash script to Python to learn

2009-05-12 Thread Dotan Cohen
I am considering translating a homegrown bash script to Python to learn the language. The script grabs different specific pages of either a ODF or PDF file (I can use either as the input file, based on Python's abilities), combines it with an HTML file, rotates, rearranges, then sends the whole thi

Re: [Tutor] Import package module problem

2009-05-12 Thread mandel
> Le Tue, 12 May 2009 08:37:27 +0100 (BST), > man...@themacaque.com s'exprima ainsi: > >> Lets see if I understand what you mean, in my example I should add an >> import inside __init__.py to be able to use relative imports: >> >> /general >>__init__.py >> from address_book import AddressBook >

Re: [Tutor] Calling method in parent class

2009-05-12 Thread Jeremiah Dodds
On Tue, May 12, 2009 at 9:05 AM, The Green Tea Leaf < thegreenteal...@gmail.com> wrote: > Hi, > I've started to learn Python and I'm a bit confused over how to call a > method in a parent class. Assume I have: > > class Parent(object): >def somemethod( self, bla ): >print 'Parent',bla

Re: [Tutor] Calling method in parent class

2009-05-12 Thread The Green Tea Leaf
OK, bad example. But assume I have the same method in both classes and want to call the method in the parent. On Tue, May 12, 2009 at 10:26, Jeremiah Dodds wrote: > > > On Tue, May 12, 2009 at 9:05 AM, The Green Tea Leaf > wrote: >> >> Hi, >> I've started to learn Python and I'm a bit confused o

Re: [Tutor] Calling method in parent class

2009-05-12 Thread Jeremiah Dodds
On Tue, May 12, 2009 at 9:55 AM, The Green Tea Leaf < thegreenteal...@gmail.com> wrote: > OK, bad example. But assume I have the same method in both classes and > want to call the method in the parent. > > Can you give a concrete example of _why_ you would want to do this? You can use super, if yo

Re: [Tutor] Considering translating bash script to Python to learn

2009-05-12 Thread spir
Le Tue, 12 May 2009 11:26:00 +0300, Dotan Cohen s'exprima ainsi: > I am considering translating a homegrown bash script to Python to > learn the language. The script grabs different specific pages of > either a ODF or PDF file (I can use either as the input file, based on > Python's abilities), c

Re: [Tutor] Calling method in parent class

2009-05-12 Thread The Green Tea Leaf
I just want to know what is the best way to do this. As for an example, I would say the __init__ method where the parent class do some initialization, to be sure that everything is set up correctly I would call the parents class __init__ method before doing something else.

Re: [Tutor] Calling method in parent class

2009-05-12 Thread spir
Le Tue, 12 May 2009 10:55:18 +0200, The Green Tea Leaf s'exprima ainsi: > OK, bad example. But assume I have the same method in both classes and > want to call the method in the parent. That should not happen! Basic contract is: same name = same meaning. Either you implement a method in a paren

Re: [Tutor] Calling method in parent class

2009-05-12 Thread The Green Tea Leaf
> That should not happen! Basic contract is: same name = same meaning. Same meaning yes, but that doesn't mean that I can't/shouldn't reuse code that address a part of the problem. > Having two methods with the name that both need two be used on the same > object is clearly a design flaw. What d

Re: [Tutor] Calling method in parent class

2009-05-12 Thread Jeremiah Dodds
On Tue, May 12, 2009 at 11:02 AM, The Green Tea Leaf < thegreenteal...@gmail.com> wrote: > > That should not happen! Basic contract is: same name = same meaning. > > Same meaning yes, but that doesn't mean that I can't/shouldn't reuse > code that address a part of the problem. > > > If your superc

[Tutor] Retrieving Data from Pmw.EntryFeild

2009-05-12 Thread Sampath Girish
Hi friendThis is Sam, a python learner. I have got some problem in retrieving data from a grid of Pmw.EntryFields. Now i have developed a grid of size 3X3 using two for loops. One for row and other for column. Now i Have 9 entry fields in the form of a matrix. I need to get all

Re: [Tutor] Calling method in parent class

2009-05-12 Thread The Green Tea Leaf
> If your superclass has a method with the same name (other than __init__ > here), that contains some logic that a subclass that overrides the method > needs, it's written wrong in python. In this case, use different method > names, or factor out the parent class methods functionality into (probabl

Re: [Tutor] Alternative for Shelve

2009-05-12 Thread Kent Johnson
On Tue, May 12, 2009 at 3:59 AM, Timo wrote: > Alan Gauld schreef: >> >> "Timo" wrote >> >>> I have an issue with the Shelve module. It works great for my needs, the >>> only problem is that a file made with Shelve isn't interchangable between >>> different computers. >> >> I thought it would be.

Re: [Tutor] Alternative for Shelve

2009-05-12 Thread Kent Johnson
On Tue, May 12, 2009 at 4:00 AM, Timo wrote: > Kent Johnson schreef: >> Try the pickle module. > > I went from Pickle to Shelve because I couldn't store my wanted list of > dictionaries in Pickle. What was the problem? You should be able to create a dict whose values are lists of dicts. This woul

Re: [Tutor] Calling method in parent class

2009-05-12 Thread Kent Johnson
On Tue, May 12, 2009 at 6:32 AM, Jeremiah Dodds wrote: > If your superclass has a method with the same name (other than __init__ > here), that contains some logic that a subclass that overrides the method > needs, it's written wrong in python. In this case, use different method > names, or factor

Re: [Tutor] Retrieving Data from Pmw.EntryFeild

2009-05-12 Thread Kent Johnson
On Tue, May 12, 2009 at 3:28 AM, Sampath Girish wrote: > Hi friend >                 This is Sam, a python learner. I have got some problem in > retrieving data from a grid of Pmw.EntryFields. Now i have developed a grid > of size 3X3 using two for loops. One for row and other for column. Now

Re: [Tutor] How to set up an Array?

2009-05-12 Thread Kent Johnson
On Tue, May 12, 2009 at 3:59 AM, spir wrote: > Le Mon, 11 May 2009 19:09:30 -0700 (PDT), > nickel flipper s'exprima ainsi: >> So from the data set below, will be looking to print out: >> RA7,OSC1,CLKI >> RA6,OSC2 >> RA5,AN4,nSS1,LVDIN,RCV,RP2 >> ETC. >> >> Any tips greatly appreciated.  Thanks.

Re: [Tutor] Calling method in parent class

2009-05-12 Thread Jeremiah Dodds
On Tue, May 12, 2009 at 12:27 PM, Kent Johnson wrote: > On Tue, May 12, 2009 at 6:32 AM, Jeremiah Dodds > wrote: > > > If your superclass has a method with the same name (other than __init__ > > here), that contains some logic that a subclass that overrides the method > > needs, it's written wro

[Tutor] The use of leading underscore in names

2009-05-12 Thread The Green Tea Leaf
The Python style guide says "Use one leading underscore only for non-public methods and instance variables." Have I understood correctly if I say that this is purely a convention and there is nothing in the language that says that it should be this way and that nothing special happens (except tha

Re: [Tutor] Calling method in parent class

2009-05-12 Thread Kent Johnson
On Tue, May 12, 2009 at 8:44 AM, Jeremiah Dodds wrote: > On Tue, May 12, 2009 at 12:27 PM, Kent Johnson wrote: >> I don't agree with this at all. It's not at all unusual for a derived >> class to override a base class method in order to add additional >> functionality to it, then to call the bas

Re: [Tutor] The use of leading underscore in names

2009-05-12 Thread Kent Johnson
On Tue, May 12, 2009 at 9:24 AM, The Green Tea Leaf wrote: > The Python style guide says > > "Use one leading underscore only for non-public methods and instance > variables." > > Have I understood correctly if I say that this is purely a convention > and there is nothing in the language that say

Re: [Tutor] The use of leading underscore in names

2009-05-12 Thread The Green Tea Leaf
Thank you ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Calling method in parent class

2009-05-12 Thread Jeremiah Dodds
On Tue, May 12, 2009 at 2:27 PM, Kent Johnson wrote: > On Tue, May 12, 2009 at 8:44 AM, Jeremiah Dodds > wrote: > > On Tue, May 12, 2009 at 12:27 PM, Kent Johnson wrote: > > >> I don't agree with this at all. It's not at all unusual for a derived > >> class to override a base class method in or

Re: [Tutor] Retrieving Data from Pmw.EntryFeild

2009-05-12 Thread Kent Johnson
On Tue, May 12, 2009 at 9:48 AM, Sampath Girish wrote: > Thank you Mr Kent for giving me reply. I've done with that this afternoon. > Now i got one more hurdle to cross. I need to take that data row wise and > add it to a grid of same size. >          For example i retrieved the entire data into a

Re: [Tutor] Import package module problem

2009-05-12 Thread Eike Welk
Hello Manuel! On Tuesday 12 May 2009, man...@themacaque.com wrote: > I have actually rearranged my code to have such hierarchy which > obviously works. The problem is that I want ot be able to perform > unit tests withinn the package of the code. I keep having the > problem Use a test discovery

Re: [Tutor] Considering translating bash script to Python to learn

2009-05-12 Thread Dotan Cohen
> I think you should first keep these very pdf-specific tasks the way > they are. Use the subprocess module to launch os commands. So > that you can concentrate on translating the overall logic into python, > which should not be too hard, probably. This is what I thought, thanks. -- Dotan Cohen

Re: [Tutor] Alternative for Shelve

2009-05-12 Thread Timo
Kent Johnson schreef: On Tue, May 12, 2009 at 3:59 AM, Timo wrote: Alan Gauld schreef: "Timo" wrote I have an issue with the Shelve module. It works great for my needs, the only problem is that a file made with Shelve isn't interchangable between different computers.

Re: [Tutor] Alternative for Shelve

2009-05-12 Thread Timo
Kent Johnson schreef: On Tue, May 12, 2009 at 4:00 AM, Timo wrote: Kent Johnson schreef: Try the pickle module. I went from Pickle to Shelve because I couldn't store my wanted list of dictionaries in Pickle. What was the problem? You should be able to create a dict whose

Re: [Tutor] Calling method in parent class

2009-05-12 Thread Alan Gauld
"The Green Tea Leaf" wrote class Child(Parent): def somemethod( self, bla ): Parent.somemethod(self,bla) or like this class Child(Parent): def somemethod( self, bla ): super(Child,self).somemethod(bla) The first version seem to have the obvious disadvantage that I need t

Re: [Tutor] Calling method in parent class

2009-05-12 Thread Alan Gauld
"Jeremiah Dodds" wrote Can you give a concrete example of _why_ you would want to do this? You can use super, if you really want to, but it can get ugly (I do not fully understand all of supers caveats). I can't think of a case off the top of my head where you would want to call a parent cla

Re: [Tutor] Calling method in parent class

2009-05-12 Thread spir
Le Tue, 12 May 2009 07:27:52 -0400, Kent Johnson s'exprima ainsi: > I don't agree with this at all. It's not at all unusual for a derived > class to override a base class method in order to add additional > functionality to it, then to call the base class method to complete > the implementation.

Re: [Tutor] Calling method in parent class

2009-05-12 Thread Alan Gauld
"spir" wrote OK, bad example. But assume I have the same method in both classes and want to call the method in the parent. That should not happen! Basic contract is: same name = same meaning. Nope, its called polymorphism. The semantics may be the same but the implementation detail may d

Re: [Tutor] Calling method in parent class

2009-05-12 Thread Alan Gauld
"Jeremiah Dodds" wrote > That should not happen! Basic contract is: same name = same meaning. Same meaning yes, but that doesn't mean that I can't/shouldn't reuse code that address a part of the problem. If your superclass has a method with the same name (other than __init__ here), that con

Re: [Tutor] Calling method in parent class

2009-05-12 Thread Alan Gauld
"Jeremiah Dodds" wrote Ahh, I stand corrected. Perhaps because the shop I work in is primarily python, and because we strongly favor composition over inheritance, I never see (python) classes being used this way. Composition over inheritance has now become so overused it is losing one of t

Re: [Tutor] Considering translating bash script to Python to learn

2009-05-12 Thread Alan Gauld
"Dotan Cohen" wrote I am considering translating a homegrown bash script to Python to learn the language. Thats rarely a good approach. While you can replace bash with Python you will just wind up calling a bunch of external programs and thats what shell scripts are best at. The only tim

Re: [Tutor] Calling method in parent class

2009-05-12 Thread spir
Le Tue, 12 May 2009 17:43:24 +0100, "Alan Gauld" s'exprima ainsi: > > Having two methods with the name that both need two be used > > on the same object is clearly a design flaw. What do you think? > > Two methods only one message. It is what polymorphism is all about. Well, I do not want to

[Tutor] simply moving files

2009-05-12 Thread Matt Herzog
On monday I posted the below code: def schmove(src,dst): ... src = '/home/datasvcs/PIG/cjomeda_exp/' ... dst = '/home/datasvcs/PIG/cjomeda_exp_archive/' ... listOfFiles = os.listdir(src) ... for filez in listOfFiles: ... os.system("mv"+ " " + src + " " +

[Tutor] Toronto PyCamp 2009

2009-05-12 Thread Chris Calloway
For beginners, this ultra-low-cost Python Boot Camp developed by the Triangle Zope and Python Users Group makes you productive so you can get your work done quickly. PyCamp emphasizes the features which make Python a simpler and more efficient language. Following along by example speeds your le

Re: [Tutor] simply moving files]

2009-05-12 Thread David
David wrote: Subject: [Tutor] simply moving files From: Matt Herzog Date: Tue, 12 May 2009 13:51:36 -0400 To: Python List To: Python List On monday I posted the below code: def schmove(src,dst): ... src = '/

Re: [Tutor] Considering translating bash script to Python to learn

2009-05-12 Thread Dotan Cohen
> Thats rarely a good approach. While you can replace bash with Python you > will just wind up calling a bunch of external programs and thats what shell > scripts are best at. That is why is has been a bash script until now. > The only time its worthwhile is where the bash code is > structurally

Re: [Tutor] simply moving files

2009-05-12 Thread Kent Johnson
On Tue, May 12, 2009 at 1:51 PM, Matt Herzog wrote: > On monday I posted the below code: > > def schmove(src,dst): > ...         src = '/home/datasvcs/PIG/cjomeda_exp/' > ...         dst = '/home/datasvcs/PIG/cjomeda_exp_archive/' > ...         listOfFiles = os.listdir(src) > ...         for filez

Re: [Tutor] How to set up an Array?

2009-05-12 Thread nickel
Kent Johnson tds.net> writes: > In [39]: rr = [ ','.join(t for t in i if t!='-') for i in zip(*( > i.split() for i in p.findall(s) )) ] > > In [40]: rr > Out[40]: > ['RA7,OSC1,CLKI', > 'RA6,OSC2,CLKO', > 'RA5,AN4,nSS1,LVDIN,RCV,RP2', > '', > 'RA3,AN3,VREF_PLUS,C1INB', > 'RA2,AN2,VREF_MINUS,

Re: [Tutor] Calling method in parent class

2009-05-12 Thread Alan Gauld
"spir" wrote Two methods only one message. It is what polymorphism is all about. Well, I do not want to argue. But this is not what I call polymorphism. Not "on the same object". Polymorphism as I know it rather dispatches depending on the object (usually it's actual type). Yes, the two m

Re: [Tutor] simply moving files

2009-05-12 Thread Alan Gauld
"Matt Herzog" wrote os.renames happily renames the source directory, but that's not what I want. Any other suggestions? You still haven't said why you can't use shutil.move() move() uses rename if appropriate or copies/deletes if not. It makes moving much more reliable and saves you a lot

[Tutor] [Fwd: Re: simply moving files]]

2009-05-12 Thread David
Forwarded to the list, I would also like to understand the forward slash; os.system("mv %s/%s %s" % (src, fnames, dst)) -- Powered by Gentoo GNU/Linux http://linuxcrazy.com --- Begin Message --- On Tue, May 12, 2009 at 03:50:00PM -0400, David wrote: > David wrote: > > > >--

Re: [Tutor] [Fwd: Re: simply moving files]]

2009-05-12 Thread sli1que
Dave Slashes in linux indicate a directory path. You use them when trying to specify paths. You can also use them to specify a path to a file. Sent from my Verizon Wireless BlackBerry -Original Message- From: David Date: Tue, 12 May 2009 20:07:10 To: Subject: [Tutor] [Fwd: Re: simply