euglug.org

[작성자:] admin

  • [Eug-lug] Python help – more elegant way to do this…



    horstTue Mar 28 03:09:04 PST 2006

    > Date: Mon, 27 Mar 2006 22:14:16 -0800
    > From: Martin Kelly <aomighty at gmail.com>
    ...>
    > Anyway, do you have anything in mind for how to use isfil, isdir, etc. in 
    > this program?
    >
    Interesting!  --I haven't used os.walk() for a while, and just looking at 
    it(as in late at night): it seems like os.walk() doesn't dive into 
    directories that are sym-links. So since directories and files are 
    separated by os.walk(), all that would apply to your original code would 
    be 'islink'.
    So in the hot debated 'file' section you could say, to give an example, 
    and if that's what you want to do (e.g. if symlinks point outside of your 
    'top'
         for file in files:
             if islink(file):
                 continue
    
    In my environment, and more recently, I have used mostly 
    glob.glob('pattern') , and that result wants to be filtered through 
    isfile, isdir, islink most of the time.
    My original comment about checking also the file type was meant to be of 
    more general nature.
    
      - Horst
    
    
  • [Eug-lug] An actual book review?



    Bob MillerTue Mar 28 02:43:42 PST 2006

    An actual book review?  No way.  O'Reilly sends us books, we make
    vague noises about round tuits, but actually writing and publishing
    a book review?  Can't happen.
    
    So this URL is probably some kind of freak filesystem corruption.
    http://www.lug.corvallis.or.us/drupal/node/93
    
    <snipe>
    Boy, was it easy for a non-core-member of the Corvallis LUG to drop
    some content onto their front page!  I wonder how they make their site
    so accessible.  It must be a special Corvallis thing, not something we
    could do in Eugene...
    </snipe>
    
    -- 
    Bob Miller                              K<bob>
                                            kbob at jogger-egg.com
    
  • [Eug-lug] Python help – more elegant way to do this…



    horstTue Mar 28 01:35:41 PST 2006

      {merged stuff}
    > Date: Mon, 27 Mar 2006 23:45:14 -0800
    > From: Bob Miller <kbob at jogger-egg.com>
    > To: python at euglug.org
    > Subject: [Python] Re: [Eug-lug] Python help - more elegant way to do this...
    ...>
    > I've given up on this guideline.  I use those words for local
    > variables when they're the most descriptive.  Since the names are
    > statically scoped, and since I try not write functions more an 10-15
    > lines long, I don't see it as a significant concern.
    ...
    
    Sure, I trust *you* know what you are doing.
      But what if other people continue working on your code, or you have to 
    work on other people's code who left you with a function of 10 pages of 
    code, not 10 lines ?
    
    Getting back to the original post,
      http://www.euglug.org/pipermail/euglug/2006-March/006534.html
    my comment was addressed to someone new to python, to be aware that an 
    identifier that sounds intuitive may be already 'taken' by builtins.
      Beside, what's wrong about being more descriptive than using 'file': is 
    it a file name or a file handle, or is it an inStream or an outStream, 
    feeling more verbose, or more cryptic...(anything but the 'reserved' name)
    
    So I stick to what I said: be aware of builtins functions and avoid 
    conflicts if you know better.
    There is no price to pay for doing so.
    
      - Horst
    
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~> 
    > Over on that other list, horst wrote:
    >
    >> Naming a fileName 'file' is generally not a good idea: 'file' is a
    >> function of the ever present "module" __builtins__ (actually more like a
    >> constructor of an I/O handle). It replaced the more procedural sounding
    >> 'open' in version 2.2, about 3 years ago (if I remember correctly).
    >> By doing so you are overriding the builtins function.
    >>  There are about two dozen, intuitive sounding identifiers, that collide
    >> with __builtins__ , you want to stay clear off, like list, dict, map, min,
    >> max,...  To see those from within the interactive interpreter just say:
    >> >>> dir(__builtins__)
    >
    > I've given up on this guideline.  I use those words for local
    > variables when they're the most descriptive.  Since the names are
    > statically scoped, and since I try not write functions more an 10-15
    > lines long, I don't see it as a significant concern.
    >
    > Besides, we get new builtins are coming every release.  2.5 introduces
    > "any" and "all".  I wouldn't want to revisit all my existing code to
    > check for those names.
    
      No, I am not asking to do so -- you'll figure out when things breaks.
      If you are using a more descriptive naming scheme, and avoid common 
    terminology you just have to do less figuring out.
    
    >
    > -- 
    > Bob Miller                              K<bob>
    >                                        kbob at jogger-egg.com
    > _______________________________________________
    > Python mailing list
    > Python at euglug.org
    > http://www.euglug.org/mailman/listinfo/python
    >
    
    
  • [Eug-lug] RAID



    Rob HudsonMon Mar 27 22:40:41 PST 2006

    You're right about the onboard part.
    
    I did get it working eventually.  I turned off RAID and am just using 
    the SCSI drivers to see both drives.  I set up software RAID with md. 
    So far it's working well and Gentoo installed just fine.
    
    This page was helpful:
    http://gentoo-wiki.com/HOWTO_Gentoo_Install_on_Software_RAID_mirror_and_LVM2_on_top_of_RAID
    
    Thanks,
    Rob
    
    Garl Grigsby wrote:
    > Mr O wrote:
    >> Not quite. Onboard RAID typically has a BIOS to setup arrays. A
    >> driver is needed by the OS so it recognizes the controller BUT
    >> onboard RAID is like cheap modems. It works best with Windows.
    >> Alot of the load is offset to the CPU whereas a true hardware
    >> RAID controller will have its own processor. Thus my use of
    >> WinRAID.   
    > Now this is all from memory, but the PE2850 does not have an 'on board' 
    > raid controller, but comes with an optional PERC4something/something, 
    > which is a renamed LSI card, SCSI hardware raid controller. What Mark 
    > said previously is correct. There should be a brief screen during the 
    > per-OS boot up process, that you access through something like ctrl-I or 
    > ctrl-k, that allows you to setup the array. You also need to make sure 
    > the megaraid driver is loaded prior to starting the install process. I 
    > know nothing about Gentoo (I've got better things to do with my time), 
    > but you can find instructions for Redhat and Debian on the following 
    > page in the 'megaraid' section.
    > 
    > http://linux.dell.com/storage.shtml
    > 
    > Garl
    > _______________________________________________
    > EUGLUG mailing list
    > euglug at euglug.org
    > http://www.euglug.org/mailman/listinfo/euglug
    > 
    
  • [Eug-lug] Python help – more elegant way to do this…



    Martin KellyMon Mar 27 22:14:16 PST 2006

    Thank you for the comments; this is the way I will improve. Definetely 
    not too cricical.
    
    Yes, I know about those functions and must remeber them for later use... 
    I often find myself hand-coding things too much rather than using the 
    greatness that is python :). I recently made a program that had taken me 
    a very long time (since November). It involved saving a text file and 
    then loading it by reading it. It was an incredible pain to debug, and 
    then I learned about the shelve module and finished a few days later! :)
    
    Anyway, do you have anything in mind for how to use isfil, isdir, etc. 
    in this program?
    
    It has now been changed to triple quotes... hadn't thought of that, thanks.
    
    -Martin
    
    horst wrote:
    >> Date: Mon, 27 Mar 2006 10:28:30 -0800
    >> From: Martin Kelly <aomighty at gmail.com>
    > ...>
    >> I will join the python group... I didn't know it existed :).
    > 
    >   GOOD!
    > 
    > As others already commented on strategy I'm just adding some peripheral 
    > remarks.
    > 
    > a) You can make the 'sha-bang' line more general:
    >  #!/usr/bin/env python
    > 
    > b) When working on the file system you often want selectively control if 
    > your operation in/excludes directories (or topectories :-) and symlinks.
    > python comes with functions that are at your fingertips if you say:
    >  from os.path import isfile, isdir, islink
    > 
    > c) One of the many nice features of python are comments/string 
    > definitions using triple quotes, single or double. So you could say:
    > usage = """
    > Usage: To replace all of "foo" with "bar" in /home:
    >        rename /home foo bar
    >        more stuff goes here..."""
    > Then you don't have to escape the "quotes"; can modify more easily, or 
    > add the % string formatters, and so forth...
    >  None of that may be needed for that specific usage message -- but I 
    > encourage you to look into triple quote definitions for future apps.
    > 
    > d) Naming your identifiers:
    > Naming a fileName 'file' is generally not a good idea: 'file' is a 
    > function of the ever present "module" __builtins__ (actually more like a 
    > constructor of an I/O handle). It replaced the more procedural sounding 
    > 'open' in version 2.2, about 3 years ago (if I remember correctly).
    > By doing so you are overriding the builtins function.
    >  There are about two dozen, intuitive sounding identifiers, that collide 
    > with __builtins__ , you want to stay clear off, like list, dict, map, 
    > min, max,...  To see those from within the interactive interpreter just 
    > say:
    >  >>> dir(__builtins__)
    > 
    > Above doesn't hurt in your code as is, but on the long run it may bite 
    > you, and your example also indicates you appreciate clean coding style:-)
    >  (unintentionally(!) rebinding builtins functions simply isn't)
    > 
    > I hope I didn't sound too critical, those are just comments/suggestions.
    > Welcome to the 'python club'..................Horst
    > 
    > _______________________________________________
    > EUGLUG mailing list
    > euglug at euglug.org
    > http://www.euglug.org/mailman/listinfo/euglug
    > 
    
  • [Eug-lug] Python help – more elegant way to do this…



    horstMon Mar 27 21:08:56 PST 2006

    > Date: Mon, 27 Mar 2006 10:28:30 -0800
    > From: Martin Kelly <aomighty at gmail.com>
    ...>
    > I will join the python group... I didn't know it existed :).
    
       GOOD!
    
    As others already commented on strategy I'm just adding some peripheral 
    remarks.
    
    a) You can make the 'sha-bang' line more general:
      #!/usr/bin/env python
    
    b) When working on the file system you often want selectively control if 
    your operation in/excludes directories (or topectories :-) and symlinks.
    python comes with functions that are at your fingertips if you say:
      from os.path import isfile, isdir, islink
    
    c) One of the many nice features of python are comments/string definitions 
    using triple quotes, single or double. So you could say:
    usage = """
    Usage: To replace all of "foo" with "bar" in /home:
            rename /home foo bar
            more stuff goes here..."""
    Then you don't have to escape the "quotes"; can modify more easily, or add 
    the % string formatters, and so forth...
      None of that may be needed for that specific usage message -- but I 
    encourage you to look into triple quote definitions for future apps.
    
    d) Naming your identifiers:
    Naming a fileName 'file' is generally not a good idea: 'file' is a 
    function of the ever present "module" __builtins__ (actually more like a 
    constructor of an I/O handle). It replaced the more procedural sounding 
    'open' in version 2.2, about 3 years ago (if I remember correctly).
    By doing so you are overriding the builtins function.
      There are about two dozen, intuitive sounding identifiers, that collide 
    with __builtins__ , you want to stay clear off, like list, dict, map, min, 
    max,...  To see those from within the interactive interpreter just say:
      >>> dir(__builtins__)
    
    Above doesn't hurt in your code as is, but on the long run it may bite 
    you, and your example also indicates you appreciate clean coding style:-)
      (unintentionally(!) rebinding builtins functions simply isn't)
    
    I hope I didn't sound too critical, those are just comments/suggestions.
    Welcome to the 'python club'..................Horst
    
    
  • [Eug-lug] Python help – more elegant way to do this…



    Martin KellyMon Mar 27 19:35:45 PST 2006

    Not needed anymore, since I put in an os.chdir(topdir).
    
    It seems to be working now.
    
    Bob Miller wrote:
    > Martin Kelly wrote:
    > 
    >> Thanks for the help. I have attached a changed version that I believe is 
    >> better.
    > 
    > I don't think it will work anymore.  You took out the two
    > calls to os.path.join() but they were needed.
    > 
    
    -- 
    -Martin
    
  • [Eug-lug] Meeting this week



    Ben BarrettMon Mar 27 15:25:06 PST 2006

    I also wanted to point out that there is a EUGLUG-related event on Saturday
    eve:
    
    The OCF VIllage Dance -- and EUGLUG is a member of the "Doors of Expression"
    booth in the OCF Community Village.  Please come support the village!!  And
    fwiw, nobody is getting in for free, even the event coordinators like myself
    are buying tickets.... rare finds of the night shall include Joules Graves
    and Reverend Chumleigh  :-)
    
    
    Here is the "press release":
    The Oregon Country Fair Community Village and the Rainforest Action Network
    presents the 2nd Annual Village Dance Benefit Concert. The event will be
    held at the McDonald Theater in Downtown Eugene on Saturday, April 1st, 2006
    at 7pm. The April Fool's Day Dance and Event is $14 advance and $16 at the
    door, featuring President Brown (roots reggae), Joules Graves (rare
    appearance) Jorah Leheur (spoken word) and Rev Chumleigh (new vaudeville
    legend) with special guest Samba Ja! (a favorite local samba marching band).
     Proceeds benefit the Community Village and Old Growth Forest Campaigns.
    
     The Community Village is the non profit part of the Oregon Country Fair. We
    have about 90 501c3 non profits and not for profits groups working for
    social change who participate in the Community Village.
    
    
    Don't forget to buy your tickets at the McDonald Theater ticket window to
    avoid ticketbastard fees... they have an exclusive contract with the
    theater, so we cannot publically sell tickets ourselves.  I do have a fefw
    pre-pre-sale tickets if someone is interested, please email me off-list.
    
    Hope to see you there!!
    
        Ben
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: http://www.euglug.org/pipermail/euglug/attachments/20060327/942033af/attachment.htm
    
  • [Eug-lug] Meeting this week



    Bob MillerMon Mar 27 13:27:27 PST 2006

    Mike Cherba wrote:
    
    > 	Because I wasn't able to get the EWEB location in March, there isn't
    > currently a second formal meeting this month.  What I'd like to know is,
    > would people prefer a second clinic?  Or would everyone just like to get
    > together thursday informally?  I may have to go out of town on business
    > already, so my vote is informal as it is less hassle for me to make sure
    > we get in at the meeting site.  Any other input?
    
    I met Alexis Gonzales last week at the Tech Brewpub.  He's a Linux
    newbie and wants to bring his computer to a clinic so he can get Linux
    working on it.  Alexis has joined the mailing list.
    
    So I vote for a clinic.
    
    I also have more books and CDs for the library...  (backlog from
    February)
    
    -- 
    Bob Miller                              K<bob>
                                            kbob at jogger-egg.com
    
  • [Eug-lug] Meeting this week



    Mike CherbaMon Mar 27 12:40:29 PST 2006

    Guys,
    	Because I wasn't able to get the EWEB location in March, there isn't
    currently a second formal meeting this month.  What I'd like to know is,
    would people prefer a second clinic?  Or would everyone just like to get
    together thursday informally?  I may have to go out of town on business
    already, so my vote is informal as it is less hassle for me to make sure
    we get in at the meeting site.  Any other input?
    				-Mike
    
    
    "There are two major products that come out of Berkeley: LSD and UNIX.
    We don't believe this to be a coincidence." --— Jeremy S. Anderson