Re: [Tutor] Print question in IDLE

2009-01-30 Thread Vern Ceder
I just tried it in Python 3 (both at the interactive prompt and in idle) and both places I get: >>> "food is very nice" #lets eat 'food is very nice' >>> So it looks like it *should* work. You might copy and paste exactly what you get into a post, including the full error traceso that we can s

Re: [Tutor] Print question in IDLE

2009-01-30 Thread Alan Gauld
"jims" wrote I apologize for asking such a dumb question The only dumb questions are the ones you don;t ask. Its how to learn! Simply put here is where I am stuck. (Python version 3.0) I type in the example using the comment command: (example) *>>> "food is very nice" #lets eat The >>

Re: [Tutor] Print question in IDLE

2009-01-30 Thread Eric Dorsey
At the >>> prompt (which is the interactive) interpreter, try: print('food is very nice') #lets eat On Fri, Jan 30, 2009 at 5:45 PM, jims wrote: > I apologize for asking such a dumb question but I have no prior programming > experience and am trying to learn by following examples from a book.

[Tutor] Print question in IDLE

2009-01-30 Thread jims
I apologize for asking such a dumb question but I have no prior programming experience and am trying to learn by following examples from a book. And also from the web. Simply put here is where I am stuck. (Python version 3.0) I type in the example using the comment command: (example) *>>> "f

Re: [Tutor] Writing a Configuration Facility for an Application

2009-01-30 Thread Wayne Watson
Title: Signature.html That's plenty of food for thought. Thanks to all. I'll see if I can absorb it in the next 36 hours. After that, I'll be out of town for 3 days. Kent Johnson wrote: On Fri, Jan 30, 2009 at 8:57 AM, A.T.Hofkamp wrote: Kent Johnson wrote: Anoth

Re: [Tutor] Properties of an object

2009-01-30 Thread Alan Gauld
"Eike Welk" wrote In a rather consistent approach, Python does not provide any standard way to simply define/describe/structure an object -- or a class. The added flexibility of Python gives great powers to the programmers of libraries. It goves a lot of flexibility, whether that really is

Re: [Tutor] Properties of an object

2009-01-30 Thread ALAN GAULD
> Python 2.x can add new methods to a user-defined class or instance or > redefine existing methods. > In [6]: def sayFoo(self): print 'foo' > > In [7]: Data.sayFoo = sayFoo > > In [8]: d1.sayFoo() > foo > Now for some reason I was sure that didn't work. So sure I never even tried! (despite

Re: [Tutor] Properties of an object

2009-01-30 Thread Eike Welk
Hello Spir! On Friday 30 January 2009, spir wrote: > In a rather consistent approach, Python does not provide any > standard way to simply define/describe/structure an object -- or a > class. The added flexibility of Python gives great powers to the programmers of libraries. There is for examp

Re: [Tutor] Properties of an object

2009-01-30 Thread Kent Johnson
On Fri, Jan 30, 2009 at 3:50 PM, Alan Gauld wrote: > "spir" wrote > >> I was not thinking at data hiding or protection, rather at object >> structure >> (or behaviour) specification. First, to the human -- and alse to the >> machine. > > Ah, OK, then in that case I am happier to agree that Python

Re: [Tutor] Properties of an object

2009-01-30 Thread Alan Gauld
"spir" wrote I was not thinking at data hiding or protection, rather at object structure (or behaviour) specification. First, to the human -- and alse to the machine. Ah, OK, then in that case I am happier to agree that Python is unusual (although not unique - Lisp can do the same) in its ab

Re: [Tutor] Properties of an object

2009-01-30 Thread spir
Le Fri, 30 Jan 2009 19:05:40 -, "Alan Gauld" a écrit : > "spir" wrote > > > There is no real native support for ordinary OOP in python, meaning > > as is done in most other languages, or according to the theory. > > I have to disagree. I think you are confusing OOP with C++ and Java. > The

Re: [Tutor] Properties of an object

2009-01-30 Thread Alan Gauld
"spir" wrote There is no real native support for ordinary OOP in python, meaning as is done in most other languages, or according to the theory. I have to disagree. I think you are confusing OOP with C++ and Java. The early OOP languages had a variety of approaches to this. Several took the s

Re: [Tutor] jumping from function to function

2009-01-30 Thread Alan Gauld
"David" wrote def main(): x = 3 f(x) def f(whatever): print whatever main() I am not quite sure what is going on here. Could you please correct my line of thought? As others have said you are pretty much correct apart from some terminology. However one of the insanely great

Re: [Tutor] jumping from function to function

2009-01-30 Thread bob gailer
David wrote: Dear List, the following comes from Harrington's "Hands-on Python" (section 1.11.8): http://www.cs.luc.edu/~anh/python/hands-on/ '''Avoiding any error by passing a parameter''' def main(): x = 3 f(x) def f(whatever): print whatever main() I am not quite sure

Re: [Tutor] Defining "bit" type -- why not '!' ?

2009-01-30 Thread bob gailer
Lie Ryan wrote: [snip] AFAIK no CPU implements hardware logical operation). I disagree. But perhaps logical operation means different things to you. Please expand. -- Bob Gailer Chapel Hill NC 919-636-4239 ___ Tutor maillist - Tutor@python.o

Re: [Tutor] jumping from function to function

2009-01-30 Thread spir
Le Sat, 31 Jan 2009 00:30:18 +0800, David a écrit : > Dear List, > > the following comes from Harrington's "Hands-on Python" (section > 1.11.8): http://www.cs.luc.edu/~anh/python/hands-on/ > > > > > '''Avoiding any error by passing a parameter''' > > def main(): > x = 3 > f(x) >

[Tutor] jumping from function to function

2009-01-30 Thread David
Dear List, the following comes from Harrington's "Hands-on Python" (section 1.11.8): http://www.cs.luc.edu/~anh/python/hands-on/ '''Avoiding any error by passing a parameter''' def main(): x = 3 f(x) def f(whatever): print whatever main() I am not quite sure what is going

Re: [Tutor] Writing a Configuration Facility for an Application

2009-01-30 Thread Kent Johnson
On Fri, Jan 30, 2009 at 8:57 AM, A.T.Hofkamp wrote: > Kent Johnson wrote: >> >> Another way is to use a .ini file. The ConfigParser module can read >> ini files but not write them. >> http://docs.python.org/library/configparser.html > > What do you mean 'not write them'? > > > from the Python docs

Re: [Tutor] Writing a Configuration Facility for an Application

2009-01-30 Thread spir
Le Fri, 30 Jan 2009 14:17:34 +0100, Willi Richert a écrit : > Hi, > > I have often found that just initializing all the necessary stuff in one > Configuration.py module. You just import it and it works. I support this as it's far the most straightforward way! Now, depending on the actual use,

Re: [Tutor] Writing a Configuration Facility for an Application

2009-01-30 Thread A.T.Hofkamp
Kent Johnson wrote: Another way is to use a .ini file. The ConfigParser module can read ini files but not write them. http://docs.python.org/library/configparser.html What do you mean 'not write them'? from the Python docs: RawConfigParser.write(fileobject) Write a representation of the

Re: [Tutor] Writing a Configuration Facility for an Application

2009-01-30 Thread Willi Richert
Hi, I have often found that just initializing all the necessary stuff in one Configuration.py module. You just import it and it works. If you like the Windows .ini format, ConfigParser is your friend (http://docs.python.org/library/configparser.html). Regards, wr On Freitag, 30. Januar 2009 1

Re: [Tutor] non-greedy matching

2009-01-30 Thread Willi Richert
Hi, you make it non-greedy with "?": import re text="axa axa" greedy_x, greedy_y = re.match("a.*a", text).span() print text[greedy_x:greedy_y] non_greedy_x, non_greedy_y = re.match("a.*?a", text).span() print text[non_greedy_x:non_greedy_y] Will print out: axa axa axa Regards, wr On Freitag,

Re: [Tutor] Writing a Configuration Facility for an Application

2009-01-30 Thread Kent Johnson
On Fri, Jan 30, 2009 at 7:40 AM, Wayne Watson wrote: > I'm about to provide a config file for an application I've been working > with. > I suspect there may be a standard way of doing this in Python that relies on > more complex operations that simplify matters than just reading the file one > li

Re: [Tutor] Writing a Configuration Facility for an Application

2009-01-30 Thread A.T.Hofkamp
Wayne Watson wrote: mask file: c:\operation/horizon.jpg latitutde: -140.22 longitude 38.22 start time: 18:25:00 stop time: 06:30:00 event directory: d:\events_2009 grey scale: yes autoexpose format: gif I suspect there may be a standard way of doing this in Python that relies on more complex o

Re: [Tutor] non-greedy matching

2009-01-30 Thread A.T.Hofkamp
spir wrote: Hello, imagine you need to match such a pattern: pat : (@@ [charset]* @@) | [charset]* ... where [charset] has to include '@' My questions are: * Is there any other way than using a non-greedy form of [charset]* ? Something like this? (in pseudo-RE syntax) "(@@" ( [...@]* "@" [.

[Tutor] Writing a Configuration Facility for an Application

2009-01-30 Thread Wayne Watson
Title: Signature.html I'm about to provide a config file for an application I've been working with. One can set a number of values via the GUI during the use of the program only to see the settings disappear when restarted. Fortunately, most of the time the program runs for days.  Nevertheless,

Re: [Tutor] Properties of an object

2009-01-30 Thread Vicent
On Fri, Jan 30, 2009 at 12:43, Kent Johnson wrote: > > A note on terminology: In Python, what you are describing is called an > attribute. 'property' has a very specific meaning, it is a way to > associate a value with an instance that uses attribute notation for > access, i.e. a.b, but actually

Re: [Tutor] Properties of an object

2009-01-30 Thread spir
Le Fri, 30 Jan 2009 12:22:10 +0100, Vicent a écrit : > Thanks to all for your clear answers. I learned a lot about the way Python > manages properties or attributes. > > In my particular case, I think, as Spir said, that the best implementation > depends on wether I am going to update the "base"

[Tutor] non-greedy matching

2009-01-30 Thread spir
Hello, imagine you need to match such a pattern: pat : (@@ [charset]* @@) | [charset]* ... where [charset] has to include '@' My questions are: * Is there any other way than using a non-greedy form of [charset]* ? * How, actually, is non-greedy character string matching performed? Thank you, de

Re: [Tutor] Properties of an object

2009-01-30 Thread Kent Johnson
On Thu, Jan 29, 2009 at 1:59 PM, Vicent wrote: > This is an easy question, I guess, but I am not able to find out the answer. > > In fact, it is both a Python question and a general programming "style" > question. > > I want to define a class that contains a list (or a NumPy array) of elements > o

Re: [Tutor] Properties of an object

2009-01-30 Thread Vicent
Thanks to all for your clear answers. I learned a lot about the way Python manages properties or attributes. In my particular case, I think, as Spir said, that the best implementation depends on wether I am going to update the "base" properties very often or not, and wether I am going to access "t