[FAQTS] Python Knowledge Base Update -- July 13th, 2000

Fiona Czuczman fiona at sitegnome.com
Thu Jul 13 00:09:17 EDT 2000


Hi!

Below are the latest entries into http://python.faqts.com

cheers,

Fiona

Including:

- What Python code can I use to find all the network ports that are in 
use on a server?
- Can I use python to access web (eg.yahoo) email account?
- Is there any way to find the mount point of a filesystem given the 
path to a file within the file system?
- How can I create a wxBitmap image from a Python Imaging Library (PIL) 
image?
- How can I compare two strings in a case-insensitive way?


## New Entries #################################################


-------------------------------------------------------------
What Python code can I use to find all the network ports that are in use on a server?
http://www.faqts.com/knowledge-base/view.phtml/aid/4684
-------------------------------------------------------------
Fiona Czuczman
Aaron Berg

to figure out what ports are used on a server you could use netstat -a 
-n

import os 
popen("netstat -a -n")


-------------------------------------------------------------
Can I use python to access web (eg.yahoo) email account?
http://www.faqts.com/knowledge-base/view.phtml/aid/4685
-------------------------------------------------------------
Fiona Czuczman
Steve Purcell

For web mail accounts that have POP access, such as Yahoo, check out
the 'poplib' standard library module:

  http://www.python.org/doc/current/lib/pop3-example.html


-------------------------------------------------------------
Is there any way to find the mount point of a filesystem given the path to a file within the file system?
http://www.faqts.com/knowledge-base/view.phtml/aid/4686
-------------------------------------------------------------
Fiona Czuczman
John Clonts

I didn't find anything already extant, so here's this:

def mountpoint(s):
    import os
    if (os.path.ismount(s) or len(s)==0): return s
    else: return mountpoint(os.path.split(s)[0])

def testit():
    print mountpoint("/home/john/scheme/cmucl")
    print mountpoint("/usr/local")
    print mountpoint("/lib/")
    print mountpoint("lib")


-------------------------------------------------------------
How can I create a wxBitmap image from a Python Imaging Library (PIL) image?
http://www.faqts.com/knowledge-base/view.phtml/aid/4687
-------------------------------------------------------------
Fiona Czuczman
Greg Landrum

Here's some sample code:
def PilImgToWxBmp(pilImg):
  wxImg = wxEmptyImage(pilImg.size[0],pilImg.size[1])
  wxImg.SetData(pilImg.tostring())
  bmp = wxImg.ConvertToBitmap()
  return bmp


-------------------------------------------------------------
How can I compare two strings in a case-insensitive way?
http://www.faqts.com/knowledge-base/view.phtml/aid/4688
-------------------------------------------------------------
Fiona Czuczman
Bjorn Pettersen

import string

if string.lower("FOO") == string.lower("Foo"):
   <do something useful>







More information about the Python-list mailing list