[Tutor] help

vnsampath vns@coconutmail.com
Sun, 20 May 2001 19:01:15 +0800





---------- Original Message ----------------------------------
From: tutor-request@python.org
Reply-to: tutor@python.org
Date: Sun, 20 May 2001 06:56:02 -0400

>Send Tutor mailing list submissions to
>	tutor@python.org
>
>To subscribe or unsubscribe via the World Wide Web, visit
>	http://mail.python.org/mailman/listinfo/tutor
>or, via email, send a message with subject or body 'help' to
>	tutor-request@python.org
>
>You can reach the person managing the list at
>	tutor-admin@python.org
>
>When replying, please edit your Subject line so it is more specific
>than "Re: Contents of Tutor digest..."
>
>
>Today's Topics:
>
>   1. Re: Possible Useless Python Challenge. (Rob Andrews)
>   2. Re: Setting Path From Python Shell (IDLE 0.8) (Bruce Sass)
>   3. complete newbie tuple question (Colin Day)
>   4. Re: complete newbie tuple question (Colin Day)
>   5. Re: complete newbie tuple question (Benoit Dupire)
>   6. Re: complete newbie tuple question (Kojo Idrissa)
>   7. inspect (Andrew Wilkins)
>   8. RE: inspect (Andrew Wilkins)
>   9. help (vnsampath)
>
>--__--__--
>
>Message: 1
>Date: Sat, 19 May 2001 12:42:36 -0500
>From: Rob Andrews <robnospam@jam.rr.com>
>Organization: Useless Python
>To: Tesla Coil <tescoil@irtc.net>
>CC: tescoil@irtc.net, tutor@python.org
>Subject: [Tutor] Re: Possible Useless Python Challenge.
>
>I finally added the KISS viewer idea to the Useless Python Challenge
>page, with a link to the Tutor archive of the first suggestion of it.
>Andrew Wilkins has also sent in the first Challenge solution in the form
>of a chat application featuring a GUI and modest encryption.
>
>Rob
>
>Tesla Coil wrote:
>> 
>> Wondering about this as a possible Useless Python
>> Challenge.  I'd feel a little guilty suggesting it,
>> as I'm uncertain how difficult a task it is, but
>> really, Gilbert Roulot is moreso to blame. ;)
>> 
>> Roulot is the author of the Foks Linux KiSS viewer.
>> On the homepage, http://perso.wanadoo.fr/issarlk/Foks/
>> Roulot lists among "Features and technical stuff" that
>> Foks is "written in the GNU Sather language. The best
>> language there is to write KiSS viewers (IMNSHO)!"
>> 
>> It doesn't appear this has ever been demonstrated
>> incorrect by a better KiSS viewer being written
>> in Python--for that matter, any KiSS viewer being
>> written in Python.
>> 
>> A KiSS viewer could prove a somewhat larger app than
>> would be considered "Useless Python," but it probably
>> qualifies in that one would be writing it perhaps more
>> to have it done in Python than need for the utility of
>> Yet Another program with which to play paperdolls...
>> 
>> KiSS data sets are bundled using LZH compression,
>> if there's a module for that, I haven't located it.
>> I suppose that a cel file decoder could be cooked up
>> using Python Imaging Library, but I've no experience
>> in that department at all.  Other than that, I guess
>> one is up against reading .cnf files generated by a
>> variety of editors and sometimes written by hand.
>> 
>> More introduction & file specs can be found at
>> http://www2s.biglobe.ne.jp/~yav/kiss/indexe.html
>
>-- 
>
>You should have listened when your mother warned you about
>Useless Python!
>http://www.lowerstandard.com/python/pythonsource.html
>
>
>--__--__--
>
>Message: 2
>Date: Sat, 19 May 2001 12:16:11 -0600 (MDT)
>From: Bruce Sass <bsass@freenet.edmonton.ab.ca>
>To: "Mr. Razak" <arazak@kansai.com.my>
>cc: <tutor@python.org>
>Subject: Re: [Tutor] Setting Path From Python Shell (IDLE 0.8)
>
>On Sat, 19 May 2001, Mr. Razak wrote:
>
>> I want to know, how can i change directory while working inside python shell.
>> Let say i want to save my python program in C:\PY_PRG directory and
>i want to set default to this directory. How to do that.
>
>The following sequence should help...
>
>Python 2.1 (#4, Apr 25 2001, 03:51:07)
>[GCC 2.95.4 20010319 (Debian prerelease)] on linux2
>Type "copyright", "credits" or "license" for more information.
>IDLE 0.8 -- press F1 for help
>>>> import os
>>>> import sys
>>>> sys.executable
>'/usr/local/bin/python2.1'
>>>> os.path.dirname(sys.executable)
>'/usr/local/bin'
>>>> os.getcwd()
>'/home/bsass'
>>>> os.chdir(os.path.dirname(sys.executable))
>>>> os.getcwd()
>'/home/usr/local/bin'
>
>NOTE: /usr/local is a symlink to /home/usr/local on this box
>(just one of the things to keep in mind when playing with paths).
>
>So, you can use ``os.chdir("C:\some\path")'' manually from the "Python
>Shell" prompt; or you can have PY_PRG set its own current working
>directory based on sys.argv[0] (I used sys.executable because sys.argv
>only makes sense while a program is running).
>
>
>- Bruce
>
>
>
>--__--__--
>
>Message: 3
>From: "Colin Day" <spotfreerinse@home.com>
>To: <tutor@python.org>
>Date: Sat, 19 May 2001 17:30:38 -0500
>Subject: [Tutor] complete newbie tuple question
>
>Hello all, I just starting trying to learn to Program and I was reading
>Alan's very helpful website when I came across the section on indexing and
>tuples:
>
>aTuple = (1,3,5)
>>>> print aTuple[1]    # use indexing like a list
>3
>
>now this confuses me (like a lot of things so far :) ) because the way it
>seems to me is that
>
>    print aTuple[1] would refer to the first charachter in the tuple, in
>this case "1", but it doesn't.
>
>could someone help clear this up for me?
>
>thanks
>
>Colin
>
>
>
>--__--__--
>
>Message: 4
>From: "Colin Day" <spotfreerinse@home.com>
>To: <tutor@python.org>
>Subject: Re: [Tutor] complete newbie tuple question
>Date: Sat, 19 May 2001 17:36:04 -0500
>
>hmm upon reflection is it perhaps because the numbering in a list or tuple
>begins with "0"?
>
>
>
>--__--__--
>
>Message: 5
>Date: Sat, 19 May 2001 18:18:23 -0400
>From: Benoit Dupire <bdupire@seatech.fau.edu>
>Organization: Florida Atlantic University
>To: Colin Day <spotfreerinse@home.com>
>CC: tutor@python.org
>Subject: Re: [Tutor] complete newbie tuple question
>
>
>
>Colin Day wrote:
>
>> hmm upon reflection is it perhaps because the numbering in a list or tuple
>> begins with "0"?
>>
>
>you are right.
>
>>
>> _______________________________________________
>> Tutor maillist  -  Tutor@python.org
>> http://mail.python.org/mailman/listinfo/tutor
>
>--
>Benoit Dupire
>Graduate Student
>
>
>
>
>--__--__--
>
>Message: 6
>Date: Sat, 19 May 2001 20:02:19 -0500
>To: tutor@python.org
>From: Kojo Idrissa <kojo@hal-pc.org>
>Subject: Re: [Tutor] complete newbie tuple question
>
>Darn!  A question I could have actually answered, and I'm beaten to 
>it.  I'll have to do one of two things:  Learn more Python, or spend more 
>time monitoring the list...
>
><...goes to learn more Python...>
>
>At 06:18 PM 5/19/2001 -0400, Benoit wrote:
>
>
>>Colin Day wrote:
>>
>> > hmm upon reflection is it perhaps because the numbering in a list or tuple
>> > begins with "0"?
>> >
>>
>>you are right.
>>
>> >
>> > _______________________________________________
>> > Tutor maillist  -  Tutor@python.org
>> > http://mail.python.org/mailman/listinfo/tutor
>>
>>--
>>Benoit Dupire
>>Graduate Student
>>
>>
>>
>>_______________________________________________
>>Tutor maillist  -  Tutor@python.org
>>http://mail.python.org/mailman/listinfo/tutor
>
>****************************
>Kojo Idrissa
>
>kojo@hal-pc.org
>http://www.hal-pc.org/~kojo/
>****************************
>
>
>
>--__--__--
>
>Message: 7
>From: "Andrew Wilkins" <toodles@yifan.net>
>To: <tutor@python.org>
>Date: Sun, 20 May 2001 14:09:37 +0800
>Subject: [Tutor] inspect
>
>Hi,
>
>I'm making a module to take a class and convert it to an XML representation.
>I've been fiddling with the inspect module from Python 2.1, and more
>specifically, at the getargspec function, which returns the arguments to be
>used with a given function. What I want to know, is whether there is some
>way of doing this with a method object.
>
>TIA,
>Andrew Wilkins
>
>
>
>
>--__--__--
>
>Message: 8
>From: "Andrew Wilkins" <toodles@yifan.net>
>To: <tutor@python.org>
>Subject: RE: [Tutor] inspect
>Date: Sun, 20 May 2001 14:17:44 +0800
>
>Shortly after I posted, I had the idea of looking at inspect.py =)
>Sorry folks, I have the answer now...
>
>Andrew
>
>> -----Original Message-----
>> From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
>> Andrew Wilkins
>> Sent: Sunday, 20 May 2001 2:10 PM
>> To: tutor@python.org
>> Subject: [Tutor] inspect
>>
>>
>> Hi,
>>
>> I'm making a module to take a class and convert it to an XML
>> representation.
>> I've been fiddling with the inspect module from Python 2.1, and more
>> specifically, at the getargspec function, which returns the
>> arguments to be
>> used with a given function. What I want to know, is whether there is some
>> way of doing this with a method object.
>>
>> TIA,
>> Andrew Wilkins
>>
>>
>>
>> _______________________________________________
>> Tutor maillist  -  Tutor@python.org
>> http://mail.python.org/mailman/listinfo/tutor
>>
>
>
>
>
>--__--__--
>
>Message: 9
>Date: Sun, 20 May 2001 18:53:08 +0800
>From: "vnsampath" <vns@coconutmail.com>
>Reply-To: <vns@coconutmail.com>
>To: <tutor@python.org>
>Subject: [Tutor] help
>
>
>
>
>
>
>
>---------- Original Message ----------------------------------
>From: tutor-request@python.org
>Reply-to: tutor@python.org
>Date: Sat, 19 May 2001 12:01:09 -0400
>
>>Send Tutor mailing list submissions to
>>	tutor@python.org
>>
>>To subscribe or unsubscribe via the World Wide Web, visit
>>	http://mail.python.org/mailman/listinfo/tutor
>>or, via email, send a message with subject or body 'help' to
>>	tutor-request@python.org
>>
>>You can reach the person managing the list at
>>	tutor-admin@python.org
>>
>>When replying, please edit your Subject line so it is more specific
>>than "Re: Contents of Tutor digest..."
>>
>>
>>Today's Topics:
>>
>>   1. Re: singleton pattern (Michael P. Reilly)
>>   2. RE: singleton pattern (alan.gauld@bt.com)
>>   3. Large scope CGI & DB problem... where to start? (Ryan Booz)
>>   4. Re: singleton pattern (Roeland Rengelink)
>>   5. Re: singleton pattern (Roeland Rengelink)
>>   6. Re: singleton pattern (D-Man)
>>   7. Re: removing digits from a file (Daniel Yoo)
>>   8. RE: removing digits from a file (Tim Peters)
>>   9. wxPython & distribution (Andrew Wilkins)
>>  10. RE: wxPython & distribution (Andrew Wilkins)
>>  11. Setting Path From Python Shell (IDLE 0.8) (Mr. Razak)
>>  12. C=EC=EE=F2=F0=E8=F2=E5 =ED=E0 =E2=E8=E4=E5=EE "=D7=C5=D0=CD=DB=C9 =
>=D4=D0=C0=C5=D0" (=D7=C5=D0=CD=DB=C9 =D4=D0=C0=C5=D0)
>>  13. Re: Setting Path From Python Shell (IDLE 0.8) (Kalle Svensson)
>>
>>-- __--__-- 
>>
>>Message: 1
>>From: "Michael P. Reilly" <arcege@dsl092-074-184.bos1.dsl.speakeasy.net>
>>Subject: Re: [Tutor] singleton pattern
>>To: alan.gauld@bt.com
>>Date: Fri, 18 May 2001 12:14:11 -0400 (EDT)
>>Cc: tutor@python.org
>>Reply-To: arcege@speakeasy.net
>>
>>alan.gauld@bt.com wrote
>>> 
>>> Acerge wrote:
>>> > class SingletonInstance:
>>> >   instance =3D None  # class member for the singleton instance
>>> >   def __init__(self, klass):
>>> >     if self.__class__.instance is None:
>>> 
>>> OK, I've now read the docs and had a play.
>>> 
>>> This is solving a slightly different problem, I think.
>>> The self.__class__.instance is only a convoluted way of writing
>>> SingletonInstance.instance - I think the latter is clearer.
>>
>>Except that self.__class__.instance works with subclasses of
>>SingletonInstance but SingletonInstance.instance does not.  The class I
>>gave was geared more to subclasses for the individual singleton classes
>>(which addressed your different class issue below).  But since I had
>>already specified that there had been lengthy discussions in more
>>appropriate forums, I wasn't going to go further.
>>
>>> >       self.__class__.instance =3D klass() # make the instance
>>> 
>>> This is setting the instance attribute of the SingletonInstance
>>> class to an instance of the manufactured class. I'm not sure how 
>>> this gives us a singleton structure? It will ensure that 
>>> calls to SingletonInstance produce a new instance of klass
>>> and assign it to the class variable, but for a singleton we 
>>> want to ensure that calls to the constructor return a pointer 
>>> to *the same* instance.
>>
>>Pointing to the same instance is not a necessary condition for the
>>the problem of a singleton class.  It might be how you think it should
>>work, but nothing in the functionality defined even hints to "Class()
>>is Class()" as a tautology.
>>
>>The above does not "ensure that calls to SingletonInstance produce a new
>>instance of klass".  It ensures that SingletonInstance instances will
>>always reference ONE instance (created by SingletonInstance) of klass.
>>
>>With:
>>>>> aspam =3D SingletonInstance(Spam)
>>>>> bspam =3D SingletonInstance(Spam)
>>>>> aspam.__class__.instance is bspam.__class__.instance
>>1
>>>>> 
>>
>>I assert that for any two instances of a call to the SingletonInstance
>>class, the 'instance' class member will always be the first instance
>>of the klass given in the first call and that the two instances behave
>>identically.
>>
>>The goal, and requirement, of a singleton class is that an instance
>>from a class _behaves identically_ to any other instance of that class,
>>not that only one instance can be created.  In Python, there is no
>>way for a Python class constructor to return anything other than a new
>>instance.  For that you might want to create the factory and use __call__.=
>
>>This solution allows for any instance to always access the data in the
>>first instance created.  Other more involved solutions would be to always
>>use the class members, never instance members.  The point is that object
>>identity is not a condition of singleton classes.
>>
>>> Thus:
>>> foo =3D SingletonInstance(MyFileClass)
>>> 
>>> and
>>> 
>>> bar =3D SingletonInstance(MySocketClass)
>>> 
>>> should make foo and bar reference the same instance (but, 
>>> in this case,  set the internal instance variable 
>>> to a new class reference)
>>[Here, functionally, I would hope that MyFileClass would want a
>>different singleton instance than MySocketClass since they are different
>>classes, but it was also mentioned above that here there should be two
>>subclasses of SingletonInstance to solve that.]
>>
>>Commonly idioms to this have already been put out, and ppl just need
>>to look at the multitude of modules in the standard library that
>>implement them.  Mine was not the answer to the original question and
>>I didn't attempt to make it such, but more of a method of dealing with
>>overly-complicated, abortive method at instance creation.
>>
>>  -Arcege
>>
>>-- 
>>+----------------------------------+-----------------------------------+
>>| Michael P. Reilly                | arcege@speakeasy.net              |
>>
>>
>>-- __--__-- 
>>
>>Message: 2
>>From: alan.gauld@bt.com
>>To: arcege@speakeasy.net, alan.gauld@bt.com
>>Cc: tutor@python.org
>>Subject: RE: [Tutor] singleton pattern
>>Date: Fri, 18 May 2001 17:32:37 +0100
>>
>>> > Acerge wrote:
>>> Except that self.__class__.instance works with subclasses of
>>> SingletonInstance but SingletonInstance.instance does not.  
>>
>>OK, fair point.
>>I was making a single factory class that could generate 
>>singletons of any type but you are making a class which 
>>can be subclassed, fair enough.
>>
>>> > >       self.__class__.instance =3D klass() # make the instance
>>> ... 
>>> Pointing to the same instance is not a necessary condition for the
>>> the problem of a singleton class.  It might be how you think 
>>> it should work, but nothing in the functionality defined 
>>> even hints to "Class() is Class()" as a tautology.
>>
>>Indeed, but surely "instance is instance" is?
>>
>>> The above does not "ensure that calls to SingletonInstance 
>>> produce a new instance of klass".  
>>
>>Yes, looking again I see that in fact if you try to pass 
>>a different class in subsequent calls it will be ignored. 
>>(In fact its ignored regardless of what you pass in!)
>>
>>> >>> aspam =3D SingletonInstance(Spam)
>>> >>> bspam =3D SingletonInstance(Spam)
>>> >>> aspam.__class__.instance is bspam.__class__.instance
>>> 1
>>
>>> the 'instance' class member will always be the first instance
>>> of the klass given in the first call 
>>
>>Exactly so, that was the bit I missed first time around.
>>
>>> and that the two instances behave identically.
>>
>>Since they delegate everything to the underlying 
>>singleton instance, correct. This is the tie in 
>>to Roelands post about the two techniques for 
>>generating singleton behaviour. I was trying 
>>to build a generic singleton factory, you are 
>>building a singleton wrapper. Because the ctors 
>>looked similar I tried to apply a factory metaphor 
>>to your wrapper class....
>> 
>>> The goal, and requirement, of a singleton class 
>>> is that an instance from a class _behaves identically_ 
>>> to any other instance of that class,
>>
>>Agreed.
>>
>>> not that only one instance can be created.  
>>
>>Agreed, one instance is only one way of implementing that 
>>behaviour.
>>
>>> Mine was not the answer to the original question and
>>> I didn't attempt to make it such, 
>>
>>I think thats what confused me. I assumed it was an attempt 
>>to answer the original question.
>>
>>> overly-complicated, abortive method at instance creation.
>>
>>That'd be my original pseudo-code then :-)
>>
>>Alan g
>>
>>
>>-- __--__-- 
>>
>>Message: 3
>>Date: Fri, 18 May 2001 12:55:53 -0400
>>From: Ryan Booz <ryanbooz@alumni.psu.edu>
>>To: tutor@python.org
>>Subject: [Tutor] Large scope CGI & DB problem... where to start?
>>
>>Hello all...
>>
>>I'd like to ask some questions about a CGI program I'm trying to write
>>(well, just trying to do the planning right now) and see if I can get
>>some starting points.  I'm still on the low end of the learning curve
>>with Python (learning and teaching at the same time), but I'm getting
>>ready to leave this school at the end of the year, and want to leave
>>some useful web-based management programs here for the guy that is going
>>to take over.  Of course, it's also giving me a chance to get more
>>programming experience.  I know that I'm asking a question that probably
>>has many other better solutions (PHP for instance, maybe ZOPE) but I
>>figure I'll get a start here and explore the other options as I have
>>time to learn those tools.
>>
>>The first program I'm working on is a weekly computer lab schedule that
>>can be updated to show (ala calendar type table) the periods for the
>>desired week, what classes are in the lab, and how many computers are
>>open during each period.  If there is an "open" period (or open
>>computers) a teacher can schedule that period for their class.
>>
>>So, getting the table drawn is simple enough with a CGI script.  But,
>>I really don't have a good sense how to start thinking about storing the
>>data.  Separate file for each week of school (this seems terribly
>>inefficient)? One large file with dictionaries or shelving? Would it be
>>easier to set up a MySQL DB and interface with that (yeah, I'm just
>>trying to start the DB learning curve also.... ahhhh!).
>>
>>I know this is a pretty large scope question.  And, depending on how I
>>store the data, would determine how I retrieve the data for each given
>>week.  So... I'm new and inexperienced.  Any suggestions, even "you're
>>going about this all wrong - use _______ instead", would be greatly
>>appreciated.
>>
>>Thanks for the advice and help,
>>Ryan Booz
>>Tech Coordinator
>>Belleville Mennonite School
>>
>>
>>
>>-- __--__-- 
>>
>>Message: 4
>>Date: Fri, 18 May 2001 19:43:09 +0200
>>From: Roeland Rengelink <r.b.rigilink@chello.nl>
>>To: tutor@python.org
>>Subject: Re: [Tutor] singleton pattern
>>
>>alan.gauld@bt.com wrote:
>>> 
>>
>>[snip]
>>
>>> > * the SingletonFactory
>>> >
>>> > class SingletonFactory:
>>> >     singleton =3D None
>>> >     def __call__(self):
>>> >         if SingletonFactory.singleton is None:
>>> >             SingletonFactory.singleton =3D Singleton()
>>> >         return SingletonFactory.singleton
>>> 
>>> And this is what I was doing in my second post except
>>> that I was allowing multiple Factories to be created
>>> each one managing a singleton instance of the class
>>> specified in the ctor. But I then moved the actual
>>> construction of the singleton into the makeInstance
>>> method and used an exception to pass back the actual
>>> singleton instance rather than fake access thru'
>>> the Factory class.
>>> 
>>> > >>> SF =3D SingletonFactory()
>>> > >>> x =3D SF()
>>> > >>> y =3D SF()
>>> > >>> id(x) =3D=3D id(y)
>>> > 1
>>> 
>>> I guess my question is whether it wouyld be easier to
>>> assign the instance attribute directly to x,y:
>>> 
>>> >>> x =3D SF().instance
>>> >>> y =3D SF().instance
>>> 
>>
>>that's what 
>>
>>>>> x =3D SF()
>>>>> y =3D SF()
>>
>>allready do
>>
>>Remember SF is an instance of SingletonFactory, SF().instance makes no
>>sense
>>
>>x =3D SF()
>>
>>is equivalent to
>>
>>x =3D SF.__call__()
>>
>>which is equivalent to
>>
>>x =3D SF.singleton    # if SF.singleton !=3D None)
>>
>>or
>>
>>SF.singleton =3D Singleton() # if SF.singleton =3D=3D None
>>x =3D SF.singleton
>>
>>> And also what happens using this model if we create more than one
>>> SignletonFactory instance:
>>> 
>>> SF =3D SingletonFactorty()
>>> MF =3D SingletonFactorty()
>>> x =3D MF()
>>> y =3D SF()
>>> 
>>
>>SF.singleton =3D=3D MF.singleton
>>
>>That's why I assigned to SingletonFactory.singleton, rather than
>>self.singleton
>>
>>SingletonFactory in this sense behaves like a singleton itself (i.e.
>>different ids, but identical state)
>>
>>> are x and y now pointing at the same object?
>>> 
>>
>>yes
>>
>>
>>Have fun,
>>
>>Roeland
>>
>>-- 
>>r.b.rigilink@chello.nl
>>
>>"Half of what I say is nonsense. Unfortunately I don't know which half"
>>
>>
>>-- __--__-- 
>>
>>Message: 5
>>Date: Fri, 18 May 2001 19:59:14 +0200
>>From: Roeland Rengelink <r.b.rigilink@chello.nl>
>>To: tutor@python.org
>>Subject: Re: [Tutor] singleton pattern
>>
>>D-Man wrote:
>>> 
>>> For those interested in seriously pursuing software development I
>>> highly recommend the book "Design Patterns: Elements of Reusable
>>> Object Oriented Software" by the so-called Gang of Four (Gamma, Helm,
>>> Johnson, Vlissides).  The ISBN number is 0-201-63361-2.  It is a
>>> hard-cover book and costs ~$50.  This book is not for beginners,
>>> however, and all the example code is in C++ or Smalltalk.  The
>>> patterns are really good to know and are not language specific.
>>> 
>>
>>I'd like to second that.
>>
>>One of the purposes of the book --which makes it interesting even for
>>those who cannot yet fully grasp the implementation issues addressed--
>>is to provide a design vocabulary by naming common design idioms.
>>
>>For example, this thread would have long ago degenerated into complete
>>gibberish, if this book hadn't defined the term 'singleton', giving us a
>>single word for 'a class of which there is, at any time, only one
>>instance.'
>>
>>Well, maybe it did degenerate into complete gibberish long ago. Just
>>imagine, it could have even worse.
>>
>>Roeland
>>-- 
>>r.b.rigilink@chello.nl
>>
>>"Half of what I say is nonsense. Unfortunately I don't know which half"
>>
>>
>>-- __--__-- 
>>
>>Message: 6
>>Date: Fri, 18 May 2001 13:53:10 -0400
>>From: D-Man <dsh8290@rit.edu>
>>To: tutor@python.org
>>Subject: Re: [Tutor] singleton pattern
>>
>>On Fri, May 18, 2001 at 07:43:09PM +0200, Roeland Rengelink wrote:
>>| SingletonFactory in this sense behaves like a singleton itself (i.e.
>>| different ids, but identical state)
>>
>>Flyweight, not Singleton.  :-).  (There is more than one instance, but
>>they share state)
>>
>>-D
>>
>>
>>
>>-- __--__-- 
>>
>>Message: 7
>>Date: Fri, 18 May 2001 15:43:42 -0700 (PDT)
>>From: Daniel Yoo <dyoo@hkn.eecs.berkeley.edu>
>>To: sheri <din22@home.com>
>>cc: tutor@python.org
>>Subject: Re: [Tutor] removing digits from a file
>>
>>On Fri, 18 May 2001, sheri wrote:
>>
>>> i want to do something like this 
>>>   
>>> if char (is a digit)
>>>    delete char
>>
>>To do this, we can write a small "isDigit()" function that tells us if a
>>character is a digit.
>>
>>###
>>def isDigit(mychar):
>>    return mychar =3D=3D '0' or mychar =3D=3D '1' or mychar =3D=3D '2' or =
>...
>>###
>>
>>But we can see that this is a really dull way of writing this.  An easier
>>way to do this is to take advantage of a list structure: doing this will
>>allow us to say: "Go though each one of these digits, and see if it
>>matches with mychar."
>>
>>###
>>def isDigit(mychar):
>>    numbers =3D ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
>>    for n in numbers:
>>        if n =3D=3D mychar: return 1
>>    return 0
>>###
>>
>>We're being careful to put those numbers in quotes, because we want to
>>make sure we're making comparisons between two characters.  Python's a
>>little strict about this:
>>
>>###
>>>>> 1 =3D=3D '1'
>>0
>>###
>>
>>so we need to be aware of the trap of comparing between apples and
>>oranges.
>>
>>
>>
>>This version of isDigit() works, but there are small idioms we can use to
>>make this even nicer.
>>
>>One idiom is to use the 'in' operation on our list of numbers.  We can say=
>
>>that if our mychar is 'in' the numbers, we're ok:
>>
>>###
>>def isDigit(mychar):
>>    numbers =3D ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
>>    return mychar in numbers
>>###
>>
>>
>>One other cute trick we can use is to express the characters from '0' to
>>'9' like this:
>>
>>
>>###
>>def isDigit(mychar):
>>    numbers =3D map(str, range(10))
>>    return mychar in numbers
>>###
>>
>>which means: "Let's allows numbers to stand for the list that contains the=
>
>>range from 0 through 9.  By the way, we're making all those digits into
>>strings first."
>>
>>
>>
>>-- __--__-- 
>>
>>Message: 8
>>Reply-To: <tutor@python.org>
>>From: "Tim Peters" <tim.one@home.com>
>>To: "sheri" <din22@home.com>
>>Cc: <tutor@python.org>
>>Subject: RE: [Tutor] removing digits from a file
>>Date: Fri, 18 May 2001 19:00:00 -0400
>>
>>[sheri]
>>> hello, i am trying to write a script to remove digits from a list of
>>> spelling words.
>>> i have a file like this:
>>> 1. that 2. cat 3. rat 4. etc...
>>>
>>> i want to do something like this
>>>
>>> if char (is a digit)
>>>   delete char
>>>
>>> so that the output file is like this:
>>> that cat rat etc...
>>
>>Hmm.  Since I see you got 4 replies that didn't mention the obvious soluti=
>on
>>yet, maybe it's not really that obvious <wink>.
>>
>>The string module has a translate() function that can both substitute
>>characters and delete them.  You don't want any substitutions here, so the=
>
>>code needed to turn substituting off gets in the way a bit:
>>
>>import string
>>dont_substitute_anything =3D string.maketrans("", "")
>>
>>def sheri(a_string):
>>    return string.translate(a_string,
>>                            dont_substitute_anything,
>>                            "0123456789.") # characters to delete
>>
>>Then, for example,
>>
>>>>> sheri("1. that 2. cat 3. rat 4. etc...")
>>' that  cat  rat  etc'
>>>>>
>>
>>
>>
>>-- __--__-- 
>>
>>Message: 9
>>From: "Andrew Wilkins" <toodles@yifan.net>
>>To: <tutor@python.org>
>>Date: Sat, 19 May 2001 10:37:46 +0800
>>Subject: [Tutor] wxPython & distribution
>>
>>Howdy folks,
>>
>>I'm trying to make an .exe distribution of a script that uses wxPython. I'=
>ve
>>tried using Gordon McMillan's installer scripts. They build everything oka=
>y,
>>but when i execute the file, it does absolutely nothing: it simply exits.
>>Has anyone had similar troubles, or are you all using Tkinter? :o)
>>
>>TIA,
>>Andrew
>>
>>
>>
>>
>>-- __--__-- 
>>
>>Message: 10
>>From: "Andrew Wilkins" <toodles@yifan.net>
>>To: <tutor@python.org>
>>Subject: RE: [Tutor] wxPython & distribution
>>Date: Sat, 19 May 2001 11:53:17 +0800
>>
>>Actually it's nothing to do with wxPython...
>>
>>I made a new file, a.py with one line "print 1", and that did nothing
>>either. It might be because I'm using python 2.1, I'll check it out later!=
>
>>
>>Andrew
>>
>>> -----Original Message-----
>>> From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of=
>
>>> Andrew Wilkins
>>> Sent: Saturday, 19 May 2001 10:38 AM
>>> To: tutor@python.org
>>> Subject: [Tutor] wxPython & distribution
>>>
>>>
>>> Howdy folks,
>>>
>>> I'm trying to make an .exe distribution of a script that uses
>>> wxPython. I've
>>> tried using Gordon McMillan's installer scripts. They build
>>> everything okay,
>>> but when i execute the file, it does absolutely nothing: it simply exits=
>.
>>> Has anyone had similar troubles, or are you all using Tkinter? :o)
>>>
>>> TIA,
>>> Andrew
>>>
>>>
>>>
>>> _______________________________________________
>>> Tutor maillist  -  Tutor@python.org
>>> http://mail.python.org/mailman/listinfo/tutor
>>>
>>
>>
>>
>>
>>-- __--__-- 
>>
>>Message: 11
>>From: "Mr. Razak" <arazak@kansai.com.my>
>>To: <tutor@python.org>
>>Date: Sat, 19 May 2001 09:50:50 +0800
>>Subject: [Tutor] Setting Path From Python Shell (IDLE 0.8)
>>
>>This is a multi-part message in MIME format.
>>
>>------=3D_NextPart_000_000F_01C0E049.2FF69EE0
>>Content-Type: text/plain;
>>	charset=3D"iso-8859-1"
>>Content-Transfer-Encoding: quoted-printable
>>
>>I want to know, how can i change directory while working inside python =
>=3D
>>shell.
>>Let say i want to save my python program in C:\PY_PRG directory and i =3D
>>want to set default to this directory. How to do that.
>>
>>FYI I'm using window98 flat form.
>>
>>Thank.
>>
>>------=3D_NextPart_000_000F_01C0E049.2FF69EE0
>>Content-Type: text/html;
>>	charset=3D"iso-8859-1"
>>Content-Transfer-Encoding: quoted-printable
>>
>><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
>><HTML><HEAD>
>><META content=3D3D"text/html; charset=3D3Diso-8859-1" =3D
>>http-equiv=3D3DContent-Type>
>><META content=3D3D"MSHTML 5.00.2614.3500" name=3D3DGENERATOR>
>><STYLE></STYLE>
>></HEAD>
>><BODY bgColor=3D3D#ffffff>
>><DIV><FONT face=3D3DArial size=3D3D3>I want to know, how can i change =3D
>>directory while=3D20
>>working inside python shell.</FONT></DIV>
>><DIV><FONT face=3D3DArial size=3D3D3>Let say i want to save my python =3D
>>program in=3D20
>>C:\PY_PRG directory=A0and=A0i want to set default to this =3D
>>directory. How=3D20
>>to do that.</FONT></DIV>
>><DIV>=A0</DIV>
>><DIV><FONT face=3D3DArial size=3D3D3>FYI I'm using window98 flat =3D
>>form.</FONT></DIV>
>><DIV>=A0</DIV>
>><DIV><FONT face=3D3DArial size=3D3D3><FONT=3D20
>>size=3D3D3>Thank</FONT>.</FONT></DIV></BODY></HTML>
>>
>>------=3D_NextPart_000_000F_01C0E049.2FF69EE0--
>>
>>
>>
>>-- __--__-- 
>>
>>Message: 12
>>From: =D7=C5=D0=CD=DB=C9 =D4=D0=C0=C5=D0<russianvideo@yahoo.com>
>>To: tutor@python.org
>>Reply-To: russianvideo@yahoo.com
>>Date: Sat, 19 May 2001 14:53:40 +0300
>>Subject: [Tutor] C=EC=EE=F2=F0=E8=F2=E5 =ED=E0 =E2=E8=E4=E5=EE "=D7=C5=D0=
>=CD=DB=C9 =D4=D0=C0=C5=D0"
>>
>>
>>                                                         =D1=EC=EE=F2=F0=
>=E8=F2=E5 =ED=E0 =E2=E8=E4=E5=EE
>>                                           =F1=EA=E0=ED=E4=E0=EB=FC=ED=FB=
>=E9  =F0=EE=F1=F1=E8=E9=F1=EA=E8=E9 =F4=E8=EB=FC=EC:
>>
>>                                                         =D7=C5=D0=CD=DB=
>=C9 =D4=D0=C0=C5=D0
>>
>>=DD=F2=EE =F4=E8=EB=FC=EC =F1=ED=FF=F2=FB=E9   =E2 =F1=EE=E2=E5=F0=F8=E5=
>=ED=ED=EE =ED=EE=E2=EE=EC =F1=F2=E8=EB=E5. =C6=E5=F1=F2=EE=EA=E8=E9 =E1=EE=
>=E5=E2=E8=EA =F1=EE=E5=E4=E8=ED=FF=E5=F2=F1=FF =F1 =F3=EC=EE=F0=E8=F2=E5=
>=EB=FC=ED=EE=E9 =EA=EE=EC=E5=E4=E8=E5=E9,
>>=E1=E0=ED=E4=E8=F2=F1=EA=E8=E5 =F0=E0=E7=E1=EE=F0=EA=E8 =F1=EC=E5=ED=FF=
>=FE=F2=F1=FF =EF=E0=F0=EE=E4=E8=E5=E9 =ED=E0 =EA=F3=EB=FC=F2=EE=E2=FB=E5 =
>=EA=E0=F0=F2=E8=ED=FB: =C1=F0=E0=F2, =C8=E3=EB=E0,  =C0=F1=F1=E0.
>>=C8 =E3=EB=E0=E2=ED=EE=E5, =E7=E4=E5=F1=FC =E5=F1=F2=FC =CD=EE=E2=FB=E9 =
>=C3=E5=F0=EE=E9, =E6=E5=F1=F2=EE=EA=E8=E9  =E8 =F0=EE=EC=E0=ED=F2=E8=F7=E5=
>=F1=EA=E8=E9.
>>
>>
>>-- __--__-- 
>>
>>Message: 13
>>Date: Sat, 19 May 2001 15:47:59 +0200
>>From: Kalle Svensson <kalle@gnupung.net>
>>To: tutor@python.org
>>Subject: Re: [Tutor] Setting Path From Python Shell (IDLE 0.8)
>>
>>Sez Mr. Razak:
>>> I want to know, how can i change directory while working inside python s=
>hell.
>>
>>Use os.chdir() - http://www.python.org/doc/current/lib/os-file-dir.html
>>
>>> Let say i want to save my python program in C:\PY_PRG directory and i wa=
>nt
>>> to set default to this directory. How to do that.
>>
>>I suppose the above could help, but I don't know IDLE very well.
>>
>>Peace,
>>  Kalle
>>-- 
>>Email: kalle@gnupung.net     | You can tune a filesystem, but you
>>Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8)
>>PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD
>> [ Not signed due to lossage.  Blame Microsoft Outlook Express. ]
>>
>>
>>
>>-- __--__-- 
>>
>>_______________________________________________
>>Tutor maillist  -  Tutor@python.org
>>http://mail.python.org/mailman/listinfo/tutor
>>
>>
>>End of Tutor Digest
>>
>
>
>_________________________________________________________
>FREE Corporate Web-hosting, 20MB space, 30 Email accounts
>Get Your Own Domain at http://www.iRepublics.com
>
>
>
>--__--__--
>
>_______________________________________________
>Tutor maillist  -  Tutor@python.org
>http://mail.python.org/mailman/listinfo/tutor
>
>
>End of Tutor Digest
>

_________________________________________________________
FREE Corporate Web-hosting, 20MB space, 30 Email accounts
Get Your Own Domain at http://www.iRepublics.com