Re: [Tutor] general import VS importing inside a function

2009-08-29 Thread Alan Gauld
"Fidel Sanchez-Bueno" wrote What is the best aproach when it comes to import??, is allways better to make all the import calls in the global scope, making the overall runtime of the program better because the program is not going to import something everytime a function is called, or is bett

Re: [Tutor] general import VS importing inside a function

2009-08-29 Thread Kent Johnson
On Fri, Aug 28, 2009 at 10:34 PM, Fidel Sanchez-Bueno wrote: > What is the best aproach when it comes to import??, is allways better to > make all the import calls in the global scope, making the overall runtime of > the program better because the program is not going to import something > everytim

Re: [Tutor] Declaration order of classes... why it is important?

2009-08-29 Thread Mac Ryan
On Fri, 2009-08-28 at 12:24 -0400, Dave Angel wrote: > > Thank you Dave, very helpful as ever. I made a few tests and experiments > > to understand better, and I feel I am understanding how it works. > > Although the mechanic of this is increasingly clear, the logic behind is > > still a bit obscur

Re: [Tutor] Declaration order of classes... why it is important?

2009-08-29 Thread Mac Ryan
On Fri, 2009-08-28 at 18:03 +0100, Alan Gauld wrote: > "Mac Ryan" wrote > > > I am not sure I understood the difference between staticmethod end > > classmethod, though, even if I can guess it has to do with subclassing, > > I think it is mainly historical. staticmethod came first (I think) and

Re: [Tutor] NLTK

2009-08-29 Thread Kent Johnson
On Fri, Aug 28, 2009 at 10:16 PM, Ishan Puri wrote: emma = nltk.corpus.gutenberg.words('austen-emma.txt') len(emma) > 192427 > > So this is the number of words in a particular 'austen-emma.txt'. How would > I do this > with my IM50re.txt? It > seems the code "nltk.corpus.gutenberg.words

Re: [Tutor] Declaration order of classes... why it is important?

2009-08-29 Thread ALAN GAULD
> What is still unclear to me, is what the staticmethods are for, though: > since the reference to the object instance or to the class object are > stripped away from the call, I wonder why not to use a module function > instead. First recall that xsstatic methods were historically the first att

Re: [Tutor] Store Class in Tuple Before Defining it ...

2009-08-29 Thread Lie Ryan
Damon Timm wrote: Sorry for the double post! Went off by mistake before I was done ... Anyhow, I would like to have a tuple defined at the beginning of my code that includes classes *before* they are defined ... as such (this is on-the-fly-hack-code just for demonstrating my question): What

Re: [Tutor] general import VS importing inside a function

2009-08-29 Thread Fidel Sanchez-Bueno
thanks both (Alan and Kent)! now am clear about the right way of making import.. salu2.. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Declaration order of classes... why it is important?

2009-08-29 Thread Mac Ryan
On Sat, 2009-08-29 at 11:44 +, ALAN GAULD wrote: > First recall that xsstatic methods were historically the first attempt at > giving Python class methods. (They were called staticmethods because > C++ and Java define their class methods using the label 'static' ) > ... > > The only differenc

[Tutor] How to convert binary files back to text files?

2009-08-29 Thread prasad rao
Hello! I want to convert compiled files to text files. I believe compiled files are binary files. I am able to convert a given string to binary and back to text. But when it comes to a file it is proving to be impossible. def p(a): s=open(a,'rb') for x in s: d=map(lambda y

Re: [Tutor] How to convert binary files back to text files?

2009-08-29 Thread prasad rao
>On 8/29/09, Geneviève DIAGORN wrote: > > >Bonjour, > >Je suis absente jusqu'au 02/09 inclus. > >En cas d'urgence Soprane, contacter notre adresse générique > >projet.sopr...@teamlog.com. > >Cordialement. > > >Geneviève I dont know your language.Please communicate in English. I am using the cod

Re: [Tutor] Store Class in Tuple Before Defining it ...

2009-08-29 Thread Damon Timm
Hi Everyone - thanks for your responses. Answered my direct questions: [1] can't be done at the top and [2] would have to move the tuple somewhere else as well as gave me some new ideas about completely rethinking the design ... I love keeping the RE definitions with the child classes ... makes

Re: [Tutor] How to convert binary files back to text files?

2009-08-29 Thread Mac Ryan
On Sat, 2009-08-29 at 18:42 +0530, prasad rao wrote: > >On 8/29/09, Geneviève DIAGORN wrote: > >Bonjour, > >Je suis absente jusqu'au 02/09 inclus. > >En cas d'urgence Soprane, contacter notre adresse générique > >projet.sopr...@teamlog.com. > >Cordialement

Re: [Tutor] NLTK

2009-08-29 Thread Ishan Puri
Hi, Yes! It works! I guess I am asking how did you know to use wordlists.words('IM50re.txt')? Is this a specific command, as I believe it was not in the book? Thanks. From: Kent Johnson To: Ishan Puri Cc: *tutor python Sent: Saturday, August 29,

Re: [Tutor] Store Class in Tuple Before Defining it ...

2009-08-29 Thread Lie Ryan
Damon Timm wrote: Hi Everyone - thanks for your responses. Answered my direct questions: [1] can't be done at the top and actually you can, but it's opening a can of worms that I wouldn't dare to go near: VIDEO_RE = { re.compile(r'regex here'): 'Youtube', re.compile(r'regex there')

[Tutor] Initialize Class Variables by Dictionary ...

2009-08-29 Thread Damon Timm
Hi again - thanks for your help with my question early today (and last night). Tried searching google for this next question but can't get an answer ... here is what I would like to do (but it is not working) ... >>>dict = {'test1': 'value1', 'test2': 'value2', 'test3': 'value3'} >>> class Test()

Re: [Tutor] Initialize Class Variables by Dictionary ...

2009-08-29 Thread Mac Ryan
On Sat, 2009-08-29 at 16:31 -0400, Damon Timm wrote: > Hi again - thanks for your help with my question early today (and last > night). Tried searching google for this next question but can't get > an answer ... here is what I would like to do (but it is not working) > ... > > >>>dict = {'test1':

[Tutor] update html pages using python

2009-08-29 Thread pedro
Hi, I was wondering if anyone could point me in the right direction as far as the best way to use python to update html. Specifically, I have a python script which coordinates the rendering of image sequences to disk (rendered from Nuke, the compositing program) and also automates the creation

Re: [Tutor] NLTK

2009-08-29 Thread Kent Johnson
On Sat, Aug 29, 2009 at 2:08 PM, Ishan Puri wrote: > Hi, >     Yes! It works! I guess I am asking how did you know to use > wordlists.words('IM50re.txt')? Is this a specific command, as I believe it > was not in the book? It is taken directly from the example in the book: >>> wordlists.fileids() [

Re: [Tutor] How to convert binary files back to text files?

2009-08-29 Thread Kent Johnson
On Sat, Aug 29, 2009 at 9:02 AM, prasad rao wrote: > Hello! >  I want to convert compiled files to text files. > > I believe compiled files are binary files. I don't understand what you are trying to do. Do you mean compiled Python files, e.g. .pyc files? Kent

Re: [Tutor] Initialize Class Variables by Dictionary ...

2009-08-29 Thread Damon Timm
Hey! I am a newbie too but it works for me: >>> class Test(object): ... def __init__(self,dict): ... for key in dict: ... self.__setattr__(key,dict[key]) ... >>> t = Test() >>> t.test1 'hi there' >>> t.test2 'not so much' >>> t.test3 'etc' Thanks! On Sat, Aug 29, 2009 at 4:59 PM, M

Re: [Tutor] How to convert binary files back to text files?

2009-08-29 Thread Alan Gauld
"prasad rao" wrote I want to convert compiled files to text files. I believe compiled files are binary files. If you are talking about compiled executables made from C++ for example yes. But... I am able to convert a given string to binary and back to text. They are not just binary rep

Re: [Tutor] update html pages using python

2009-08-29 Thread Alan Gauld
"pedro" wrote Hi, I was wondering if anyone could point me in the right direction as far as the best way to use python to update html. There are a number of modules in the standard library that can help but the best known module for this is BeautifulSoup which you have to download - try G

Re: [Tutor] Initialize Class Variables by Dictionary ...

2009-08-29 Thread Kent Johnson
On Sat, Aug 29, 2009 at 6:30 PM, Damon Timm wrote: > Hey!  I am a newbie too but it works for me: > class Test(object): > ...   def __init__(self,dict): > ...     for key in dict: > ...       self.__setattr__(key,dict[key]) Use the setattr() builtin: setattr(self, key, dict[key]} or just d

Re: [Tutor] update html pages using python

2009-08-29 Thread pedro
On 2009-08-29 19:34:15 -0400, "Alan Gauld" said: "pedro" wrote Hi, I was wondering if anyone could point me in the right direction as far as the best way to use python to update html. There are a number of modules in the standard library that can help but the best known module for this is