Re: [Tutor] getopt matching incorrect options

2005-07-11 Thread David Rock
* Jay Loden <[EMAIL PROTECTED]> [2005-07-11 22:30]: > I have an app that takes a command line argument of -l or --list. It uses > the > getopt module to parse the arguments, and I just noticed that for some > reason, getopt is matching "--lis" or "--li" etc to "--list". (Code pasted in > below

[Tutor] getopt matching incorrect options

2005-07-11 Thread Jay Loden
I have an app that takes a command line argument of -l or --list. It uses the getopt module to parse the arguments, and I just noticed that for some reason, getopt is matching "--lis" or "--li" etc to "--list". (Code pasted in below) Is this normal behavior, and if so, is there any way to avoi

[Tutor] getopt matching incorrect options

2005-07-11 Thread Jay Loden
I have an app that takes a command line argument of -l or --list. It uses the getopt module to parse the arguments, and I just noticed that for some reason, getopt is matching "--lis" or "--li" etc to "--list". (Code pasted in below) Is this normal behavior, and if so, is there any way to avoid

Re: [Tutor] Abnormal \r character in csv text files: csv module error

2005-07-11 Thread Kent Johnson
Alessandro Brollo wrote: > Abnormal \r characters inside a .csv text file raise > an error when the file is read by csv.reader() (Python > 2.3). > > This is a warning to newbies like me and a question > for experts: is it a bug into csv module? This has been reported as a bug. http://sourceforge.

[Tutor] domain logic and avoiding setters and setters.

2005-07-11 Thread David Driver
So I have been trying to figure out how to get around doing getters and setters and still have an oo way to inherit and apply business rules. This is what I have some up with so far. Is there any better way? class RuleViolationError(Exception): def __init__(self, msg): self.msg = msg

[Tutor] Abnormal \r character in csv text files: csv module error

2005-07-11 Thread Alessandro Brollo
Abnormal \r characters inside a .csv text file raise an error when the file is read by csv.reader() (Python 2.3). I'm sending the following files: test.txt : a "csv"-like text file with a \r character; test1.txt : same file, with an x replacing \r; example.txt: the hard copy of my Python shell

Re: [Tutor] Confused "from module import Name" better than "importmodule"?

2005-07-11 Thread Alan G
> module import name': is there a performance hit to consider when > importing the entire module rather than just getting the specific > niceFunction()? Not significant. Basically import module puts the module name into the local names dictionary. "from m import f" puts f into the dictionar

Re: [Tutor] Confused "from module import Name" better than "importmodule"?

2005-07-11 Thread Alan G
> I guess it could be easier to replace the implementation, > for example if you split a module you could change > from module import Name1, Name1 > to > from module1 import Name1 > from module2 import Name2 > and the rest of the client code wouldn't have to change. Thats true, but OTOH it's nmuc

Re: [Tutor] Confused "from module import Name" better than "importmodule"?

2005-07-11 Thread Alan G
> I'm confused. I was just reading the URL below.. > > http://jaynes.colorado.edu/PythonGuidelines.html Me too. :-) > and this statement confused me: "Always use from module import Name, > Name2, Name3.. syntax instead of import module or from module import > *. This is more efficient, reduces

Re: [Tutor] Confused "from module import Name" better than "import module"?

2005-07-11 Thread Mike Hansen
> Subject: > Re: [Tutor] Confused "from module import Name" better than "import module"? > From: > Kent Johnson <[EMAIL PROTECTED]> > Date: > Mon, 11 Jul 2005 12:30:16 -0400 > > CC: > tutor@python.org > > > Mike Hansen wrote: > >> I'm confused. I was just reading the URL below.. >> >> http://ja

Re: [Tutor] Confused "from module import Name" better than "import module"?

2005-07-11 Thread Matt Richardson
Kent Johnson wrote: > > This is good stuff to understand, but really, it isn't going to make an > appreciable difference in most applications. Where it does matter, for > example if func() is called many times in a loop, the best solution will > probably be to bind func to a local variable whi

Re: [Tutor] ImportError: No module named numarray

2005-07-11 Thread Kent Johnson
Danny Yoo wrote: >>nltk is looking for a module called numarray that is not part of the >>standard Python distribution. Do you have numarray installed? Look for >>C:\Python24\Lib\site-packages\numarray. If you don't have it then >>download numarray from C:\Python24\Lib\site-packages\numarray and >>

Re: [Tutor] Confused "from module import Name" better than "import module"?

2005-07-11 Thread Kent Johnson
Matt Richardson wrote: > I have a question about 'import module' versus 'from > module import name': is there a performance hit to consider when > importing the entire module rather than just getting the specific > niceFunction()? I can't imagine that there is a performance difference that wou

Re: [Tutor] ImportError: No module named numarray

2005-07-11 Thread Danny Yoo
> nltk is looking for a module called numarray that is not part of the > standard Python distribution. Do you have numarray installed? Look for > C:\Python24\Lib\site-packages\numarray. If you don't have it then > download numarray from C:\Python24\Lib\site-packages\numarray and > install it accord

Re: [Tutor] Confused "from module import Name" better than "import module"?

2005-07-11 Thread Matt Richardson
Kent Johnson wrote: > from module import * is problematic and discouraged. It causes namespace > pollution and makes it harder to find out where a name is defined. > > Other than that I think it is personal preference. > I have avoided the 'from module import *' style for the reasons you ment

Re: [Tutor] Confused "from module import Name" better than "import module"?

2005-07-11 Thread Kent Johnson
Mike Hansen wrote: > I'm confused. I was just reading the URL below.. > > http://jaynes.colorado.edu/PythonGuidelines.html > > and this statement confused me: "Always use from module import Name, Name2, > Name3.. syntax instead of import module or from module import *. This is more > efficient,

[Tutor] Confused "from module import Name" better than "import module"?

2005-07-11 Thread Mike Hansen
I'm confused. I was just reading the URL below.. http://jaynes.colorado.edu/PythonGuidelines.html and this statement confused me: "Always use from module import Name, Name2, Name3.. syntax instead of import module or from module import *. This is more efficient, reduces typing in the rest of th

Re: [Tutor] py2exe

2005-07-11 Thread Alberto Troiano
Hey all I had some problems with this module too but I aas able with your help to make a script that works Here it is: from distutils.core import setup import py2exe, sys, os sys.argv.append('py2exe') ##setup( ##windows = [{'script': "NovusExtension.pyw"}], ##) setup( console = [{'scrip

Re: [Tutor] ImportError: No module named numarray

2005-07-11 Thread Kent Johnson
enas khalil wrote: > when i write a code to import some module like the following : > > > from nltk.probability import ConditionalFreqDist > > I got the error : > > Traceback (most recent call last): > File "C:\Python24\toky.py", line 1, in -toplevel- > from nltk.probability import Co

[Tutor] ImportError: No module named numarray

2005-07-11 Thread enas khalil
when i write a code to import some module like the following :     from nltk.probability import ConditionalFreqDist   I got the error :   Traceback (most recent call last):  File "C:\Python24\toky.py", line 1, in -toplevel-    from nltk.probability import ConditionalFreqDist  File "C:\Python24\Lib

Re: [Tutor] What's going on with this code? Error message supplied.

2005-07-11 Thread Roel Schroeven
Alan G wrote: >> Here's an error message: >> >> File "D:\GC.py", line 78 >> cal_opt = cal_menu() >> ^ >> SyntaxError: invalid syntax >> >> The relevant code: >> >> option = main_menu() >> if option == 1: >> cal_menu() >> cal_opt = cal_menu() > > > Consistent indentation is