A little disappointed so far

Anand Pillai pythonguy at Hotpop.com
Tue May 20 07:16:04 EDT 2003


Graham Nicholls <graham at rockcons.co.uk> wrote in message news:<VyWxa.502$573.400 at news-binary.blueyonder.co.uk>...
> Jay O'Connor wrote:
> 
> > On Mon, 19 May 2003 02:11:54 +0100, Graham Nicholls
> > <graham at rockcons.co.uk> wrote:
> > 
> >>> What things seem very hard?
> >>Regular expressions.
> > 
> > Import the re module (refulare expression).  I don't use it a lot so I
> > can't type a little example from memory, but it's served me well in
> > the past.
> > 
> > http://www.python.org/doc/current/lib/module-re.html
> > 
> >>Running external programs.
> > 
> >  Can be done a number of ways, either using the exec family (like the
> > C equivalents) or the popen family (includes support for using stdin,
> > stdout between the two programs)  Give me an example of what you'd
> > like to do and I'll give you a short example of how to do it.  It's
> > pretty easy 
> > http://www.python.org/doc/current/lib/os-process.html
> > http://www.python.org/doc/current/lib/module-popen2.html
> > 
> > 
> >>Opening sockets.
> > 
> > Again, pretty easy.  The socket module supports basic low level socket
> > client and server capabilites.
> > 
> > http://www.python.org/doc/current/lib/module-socket.html
> > 
> > example:
> > http://www.python.org/doc/current/lib/socket-example.html
> > 
> > Specific proptocals suchs as POP, HTTP and FTP are supported in other
> > modules
> > 
> > See Internet Protocols and Support
> > http://www.python.org/doc/current/lib/internet.html
> > 
> >>No case statement - or is it simply that my documentation is out of date?
> >>I _know_ I can do if elif else constructs, but in a language which prides
> >>itself in its readability, this is laughable.
> > 
> > Actually, from a Smalltalk pure OO background I find that case
> > statements are superflous in OO languages and had been programming
> > Python for about 8 months before I even wondered if the language had
> > them :)
> >
> How do you handle, say 
> if arg == 'd':
>         switch on debug
> if arg == 'v':
>         switch on verbose
>       

   I dont find anything to gain out of blaming a language if you
cannot
master its tools. I learned python from just internet documentation
and has
not found the need to buy a single python book so far. I am proud to
say
I can solve almost any problem in python, with the python I learned
from the internet and standard documentation that comes along with the
language.

 Especially, python is a language most suited for newbies and
experienced
programmers alike since it has the reputation for being suited to fast
learning.
I picked up my basic python in a week and learned the modules
(essential
for a hobbyist like me) in a matter of 2 months. I solve most of my
scripting
tasks using python and has not faced a problem or bottleneck so far.

 The above problem is a breeze if you know 'getopt' and its proper
usage.
 Anyway I will just give a small, dirty solution.

  import getopt

  optlist, args = getopt.getopt(sys.argv[1:], 'dv')
  if len(optlist):
      for o,a in optlist:
          if o == '-v':
               verbose=1 # switch on verbose
          elif o == '-d':
               debug=1 # switch on debug
          else 
              ...

  It is that simple. If you would like to see a more extensive use of
  getopt, see the following python recipe in ASPN.

  http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/189858

 
Your humble 'Python Guy', 

Anand Pillai
http://members.fortunecity.com/anandpillai 
  
> etc ? 
> > Take care,
> > Jay
>  Thanks again.  I'll be browsing for a while :-)




More information about the Python-list mailing list