Computer SW Languages Python - Berkeley CSUA MOTD
Berkeley CSUA MOTD:Computer:SW:Languages:Python:
Berkeley CSUA MOTD
2018/08/18 [General] UID:1000 Activity:popular

2011/12/23-2012/2/6 [Computer/SW/Languages/Python] UID:54272 Activity:nil
12/23   In Python, why is it that '好'=='\xe5\xa5\xbd' but
        u'好'!='\xe5\xa5\xbd' ? I'm really baffled. What
        is the encoding of '\xe5\xa5\xbd'?
        \_ '好' means '\xe5\xa5\xbd', which is just a string of bytes; it has
           length 3.  Python doesn't know what encoding it's in.  u'好' means
           u'\u597d', which is a string of Unicode characters; it has length 1,
           and Python recognizes it as a single Chinese character.  However,
           it doesn't have any particular encoding!  You have to encode it as
           a byte string before you can output it, and you can choose whatever
           encoding you want.  u'好'.encode('utf-8') returns '\xe5\xa5\xbd'.
           \_ wow thanks. I always thought unicode == utf-8, boy I was
              so wrong. This is all very confusing.
              \_ dear dumbass:
                 \_ If all you've used is UTF-8, you'd have no reason to
                    suspect there are other Unicode encodings (and really,
                    if UTF-8 had been designed first, there probably wouldn't
                    be).  Not knowing about them doesn't make you dumb.
2011/8/3-27 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Languages/Python] UID:54156 Activity:nil
           \_ this is sad
        \_ "An Update
            SICP will not be abandoned at Berkeley."
2018/08/18 [General] UID:1000 Activity:popular

2011/4/16-7/13 [Computer/SW/Languages/Python] UID:54086 Activity:nil
4/16    Whoa, I just heard that MIT discontinued 6.001 (classic scheme)
        to 6.01. In fact, 6.00, 6.01 and 6.02 all use Python. What the
        hell? What has the world become? It's a sad sad day. SICP forever!
        \_ old story, they've ditched that shitty book and lang for a while.
        \_ I used to think scheme was cool, then I saw Ka Ping Yee's
           "Beautiful Code" class aka 61a in python, and converted.
        \_ "SICP Forever" means you weren't listening when UCB CS said
           "we are trying to teach you computer science independent of
           implementation, since implementation fads come and go."
            \_ Well played.
        \_ I know someone who was there for the first year they offered it.
           They made it optional, and the curriculum really sucked when they
           were just getting started, or so I hear. Shame to see it go, but I
           hope they've improved it since. Python can be a really beautiful
           language, albeit nowhere near as elegantly minimal and pure as
           Scheme - which IMO made it easier to teach/learn. --toulouse
           Clearly MIT disagrees with you. _/
        \_ Since 61a is a shallow copy of 6.001 -to the extent that harvey
           made us watch a lecture of the MIT class during our lecture- when
           will Cal start using python as well?
        \_ Makes sense, Sergei and Larry need python and java, not scheme.
        \_ Glad to see MIT is keeping up with the times, this is why it is
           the NUMBER ONE CS school in the WORLD. "It showed some f'n
2011/3/31-4/20 [Computer/SW/Languages/Python] UID:54070 Activity:nil
3/20    Has anyone here had success in using python 3.0?  Any gotchas
        to worry about? I've got an entire set of apps in python 2.x
        and am wondering if it's worth it to upgrade?
2009/4/4-12 [Academia/Berkeley/Classes, Computer/SW/Languages/Python] UID:52797 Activity:nil
4/3     Anyone have any ideas on where to get a MIPS parser?  I need one
        for a class project, but it's not the point of the project, so there's
        no problem with using a pre-existing library.  I haven't found one
        though.  It seems simple enough that I could just get away with
        python's split(). (Language is also irrelevant, so I was going to go
        with python or ruby, but anything is fine.)
    \_ I assume you're steven and doing this for CS150. If you do it in python
       I can help. --toulouse
        \_ I assume you're steven and doing this for CS150. If you do it in
           python I can help. --toulouse
           \_ Nope, not steven in CS150, jrleek in a UC Davis grad class.
              I hacked out a simple lexer in python on the plane back from
              Korea last night before I ran out of batteries, but I would
              like something better if you know of it.  I'll email you. -jrleek
           \_ Assuming who people are on motd is inadvisable... ;)
2008/12/4-10 [Computer/SW/Languages/Python] UID:52167 Activity:low
12/4    FORTRAN, er, Python 3.0 / 3000 is out:
        \_ As someone who tried out Python and disliked it, is there a reason I
           should take a look at it again?
           \_ Not really. Why'd you dislike Python? I love it.
              \_ The whitespace was a killer, other syntax a bit clunky,
                 regular expression syntax was hideous.  Once I found Ruby, I
                 never looked back.  The problems with Ruby are: 1) threading
                 and 2) performance.  That's what they're dealing with in the
                 next release.
                 current release.
              \_ Passing around "self" alot and usage of convention in class
                 syntax shows that the OOP was added as an afterthought no
                 matter what guido says.  Also they are going to keep that GIL
                 forever which hurts their multithreaded performance.  Maybe
                 jython will fix that but i'm not hopeful.
                 \_ Ugh, not this again, there was a lengthy argument on the
                    Python mailing list on this. It's not that self was *added*,
                    but that an explicit self disambiguates variable resolution.
                    I happen to agree, and this is one of the reasons I'm so
                    fond of Python. It's a matter of personal preference. I have
                    little to say on the GIL since I either don't do parallel
                    with Python, or use processes to do it. --t
                    Python mailing list on this. It's not that self was
                    *added*, but that an explicit self disambiguates variable
                    resolution. I happen to agree, and this is one of the
                    reasons I'm so fond of Python. It's a matter of personal
                    preference. I have little to say on the GIL since I either
                    don't do parallel with Python, or use processes to do it.
                 \_ Let me expand a little. There's nothing keeping them from
                    making 'self' implicit *technically*; however, this was
                    debated several times over for Python 3k and the consensus
                    (not decree) was that Python is better with it than without.
                    (not decree) was that Python is better with it than
                    Also, if you want a multithreaded app, presumably you are
                    targeting performance, or you'd be writing it with processes
                    instead. At that point, why not use the Python API with C
                    or something to do threads? (This is an honest question, not
                    a hypothetical question.) I use Python for the speed of
                    development and the clear (IMO) semantics. Besides, isn't
                    Stackless Python what you're looking for? --t
                    targeting performance, or you'd be writing it with
                    processes instead. At that point, why not use the Python
                    API with C or something to do threads? (This is an honest
                    question, not a hypothetical question.) I use Python for
                    the speed of development and the clear (IMO) semantics.
                    Besides, isn't Stackless Python what you're looking for?
        \_ I always found regexp in Python to be insane.  Is this better in
           Python 3?
2008/7/28-8/5 [Computer/SW/Languages/Java, Computer/SW/Languages/Misc, Computer/SW/Languages/Python] UID:50705 Activity:nil
7/28    Python question:  I have a Python helper script/class that I want
        to use interactively.  The class needs a few path variables defined
        so that it runs on the correct files.  I may want to use different
        files, so I certainly don't want to hard code them.  There are also
        enough files that I don't want to pass them in as arguments.  I thought
        I might be able to have a file that defines them and import it.
        so, file defines "foo_path = 'blah'"
        >>> import test_config as foo_config
        >>> print foo_config.foo_path
        >>> foo_run()
        in the script file I have: print foo_config.foo_path
        I get: 'NameError: global name 'foo_config' is not defined'
        Why does my script file not get the 'global name' foo_config?
        \_ Is foo_run in a different module? Did you do something like
           'import foo_run from foo_run_module'? I'm guessing it would
           work if you imported foo_config from within foo_run_module.
           \_ Yes, that works, but I would prefer to be able to interactively
              load different modules as foo_config.
2008/7/28-8/5 [Computer/SW/Languages/OCAML, Computer/SW/Languages/Functional, Computer/SW/Languages/Python] UID:50704 Activity:nil
7/28    So, I'd like to try playing with a functional language.  Any
        \_ Haskel.  Why would you start with anything else?
        \_ Haskell if you want a _functional_ language.  Ocaml if you want to
           see what a proper language implementation looks like.  LISP if
           you want old fogies to think you are cool. -- ilyas
        \_ Haskell.  Why would you start with anything else?
           \_ I don't know.  I've heard Erlang has been used more in industry.
              (Isn't Google using it for something?)  I don't really know
              the differences.
              the differences.  Sisal was for scientific computing, which is
              the area I work in.  F# includes OOP (but I'd rather work in
              \_ Are you learning this to learn or are you learning it to
                 get industry experiance?  If the second I'd say spend your
                 time elsewhere.  Haskell is one of those languages where once
                 you start to understand how to actually use it this light
                 will come on in your brain and suddenly you will never see
                 programming in quite the same light.  Erlang is cool, but
                 has a lot less support library support/people out there
                 messing with it, so actually trying to do anything with
                 it is hard.  OCaml is pretty damn cool as well, but really,
                 if you want to wrap your head around pure functional
                 programming, the language you should start with is Haskell.
                 Oh, and you want this book:
                 \_ Oh, and another thing.  Haskell is also good because it
                    makes it really hard to cheat and do things in a non
                    functional manner.  Its purity is its strength.
                    \_ Ah, that's a good point. -op
                 \_ Well, mostly I would just like to learn about functional
                    programming to learn.  But I generally like languages I
                    learn to be useful for something as well, otherwise I
                    never get to use it.  For example, I like Ruby better than
                    Python, and learned it to learn it.  However, everything at
                    work uses Python, so now I've forgotten most of the Ruby.
                    Thanks for the book ref.
                    \_ Really learning Haskell will make you a much better
                       programmer, even if you never use it for anything.
                       It really forces you to relearn a lot of things in
                       ways you probably never even considered, and once you
                       finish bashing your head against it and it starts
                       making sense you will be a much stronger coder.
2008/6/19-23 [Computer/SW/Languages/Python] UID:50298 Activity:nil
6/19    Any reason why Python's random.randint() is 10X slower than
        random.random() (returns 0-1.0)?
        \_ Use the source, Luke. random() is basically a single operation
           implemented in C, whereas randint() is a non-negligible amount
           of Python code.
           \_ Thanks! Where can I find the source?
              \_ Umm, you're kidding, right? If not, here's a hint:
                 Python is open source software.
2008/4/29-5/5 [Computer/SW/Languages/Perl, Computer/SW/Languages/Python] UID:49852 Activity:moderate
4/29    Scaling your web app in the real world:
        \_ This article is crap.  While yes, 99.9% of all websites don't
           need any serious scalability plans, if any of them become worth
           anything they will need to scale.  If you write a web application
           without careing about scalability you are writing a webapp that can
           never be more than niche.  Any developer should know where the
           next few scaling bottlenecks live in his application and have some
           basic plan for how to solve them when they become an issue.
        \_ I feel the same way about language Nazis. "Java is the best!"
           "No C is the best!" "Perl sucks it's not readable!" "Python rules!"
           Dumb asses blame the language and not the stupid programmers.
           \_ Different tools for different jobs.  That said, I particularly
              like python.  Its syntax is very clean.
              \_ I don't know python.  I like Pascal the best, although I
                 haven't used it in 18 years.
                 \_ If you liked Pascal, you will love python, unless you
                    get hung up on the fact that blocks in python are
                    defined by indentation rather than by "begin/end"
                    \_ Yeah, I like python, but that blocks by indentation
                       thing drives me up the wall.  Couldn't they at least
                       make it optional? -!pp
              \_ My experience is that Ruby is a lot cleaner than Python, and
                 doesn't have stupid syntactical whitespace. However, I have
                 only used Perl for stuff at jobs etc due to familiarity.
                 Python's object orientedness was less complete than Ruby's
                 and I definitely don't like the indentation thing.
                 \_ I struggled, trying to like Python.  Then I found Ruby and
                    it's the most fun I've had programming in a *long* time.
                    The fact that regexes are as easy as Perl in Ruby was a big
                 \_ Ruby is whitespace sensitive. -- ilyas
                    \_ Far less so than Python.
                       \_ I am not a huge python fan, and I don't like python's
                          whitespace indentation, but I found ruby's specific
                          whitespace sensitivity far more confusing. -- ilyas
                          \_ Interesting, I've never noticed a problem.
                             \_ Perhaps this is because you are not used to
                                programming with closures (blocks are
                                the closest thing in ruby to closures).
                                Ruby blocks have very odd whitespace
                                (1..3).each {|x| puts x} works
                                (1..3).each {|x|
                                                puts x} works
                                            {|x| puts x} does not work.
                                        -- ilyas
                                \_ No, I use closures, just never have had to
                                   break across the line.
                                   \_ I write fairly hairy closures sometimes,
                                      and often my closure code is nested.
                                      I find this behavior completely bizarre
                                      and unintuitive.  I can't even imagine
                                      why Ruby would insist on this. -- ilyas
                                      \_ I got yer hairy closure right here,
        \_ This is funny, but not really applicable to real world scaling.
           I have been doing this stuff for 15 years and scaling is more of
           a system architecture and capacity planning issue than a developer
           issue. Of course, if your code is bad enough, no one can make
           it scale.
           \_ I disagree completely. I've taken courses on optimizing
              applications for performance and the best bang for the buck
              is almost always received by altering the code to run
              faster. Sure, things like high-speed interconnects to reduce
              latency can solve problems not easily solved by modifying
              code, but the majority of problems are developer issues that
              they (I would say unknowingly, but maybe because they don't
              care) foist upon the systems people.
              \_ Most cases of performance scaling problems I have encountered
                 have been due to the volume of data being written to disk.
                 These problems can be fixed by using the right RAID type,
                 better use of filesystem caching, a better filesystem, or
                 most often, simply by throwing more disks at the problem.
                 These are not the kinds of issues I would expect a programmer
                 to know or even care too much about. I haven't "taken courses"
                 on it, but I have worked on numerous overloaded web and
                 application sites in the Real World.
                 \_ Sounds like you have haven't encountered a large
                    variety of problems then. Often when a developer
                    profiles his code he can find all sorts of
                    bottlenecks. Often it seems easier to throw h/w at
                    problems, but the biggest gains come from writing
                    better code. For instance, don't write so much data to
                    disk or be smarter about how you do it. You are
                    correct that programmers don't know and care about
                    these issues, but they should. They usually only care
                    when they are forced to because their code doesn't
                    meet requirements, because it compares unfavorably to
                    competing code, or because the hardware solution has
                    failed or is too costly to implement.
                    \_ "In nearly every case the most serious bottleneck
                        is an overloaded or slow disk." -Adrian Cockcroft
                        Sun_Performance_And_Tuning (Ch 1, Paragraph 1)
                        \_ You ever wondered why Google search is so fast?
                           They have the world's largest RAM disk. They
                           index and keep most of their search data
                           ***IN MEMORY***. Last time I attended a talk
                           I learned that they have more a shitload more
                           RAM than many corporations have on disk. It
                           is ridiculous.
                           \_ Thanks for making my point.
                        \_ Well no shit, but this is tangential. The
                           question isn't "Is disk slower than RAM?". It
                           question isn't "Is disk faster than RAM?". It
                           is "Is there a way to do this such that it
                           doesn't write to disk as much?" One example is
                           when developers decide to write 6 million
                           small files in one directory and the filesystem
                           bogs down. Sure, you can buy a faster
                           filesystem but that's correcting the symptom
                           and not the problem. You don't need to buy $$$
                           hardware that probably still can't handle that
                           particular issue if the code didn't do something so
                           \_ I heard reiserfs is really good at storing lots
                              of little files.
                           \_ I heard reiserfs is really good at storing lots of
                              little files.
                              \_ unfortunately, it stores them in a dumpster
                                 in San Leandro.
                           \- lexis/nexis was pretty fast at seearch +20 yrs
                              go. the old bell labs people [who after all were
                              working for a phone company] have lots of
                              interesting stories about optimizations for
                              various phone company applications. one of
                              the main altavista people wrote some code to
                              use a cache that was physically closer to a
                              processing unit to avoid die-crossing latency
                              [and had numbers to show the difference it
                              made]. google is mostly read data and it's not
                              authoritative but a cache/copy for much.
                              contrast this with say ebay. for a somewhat
                              interesting discussion of scaling look at
                              randy shoup's presentation/talk on ebay scaling.
                              [trivia: randy was a high school acquaintance of
                              mine. i thought he was going to become a lawyer
                              and i was mighty surprised he went into cs/
                              \_ Getting all your caches right is not really
                                 a developer responsibility, but I admit that
                                 it starts to cross disciplines. Most people
                                 are just sort of confused how it works, so
                                 in this case, the one eyed man is king.
                                 \_ Whose responsibility do you think it is
                                    if not the developer? If he doesn't
                                    have the knowledge then he needs to
                                    consult with someone who does, but
                                    he's the implementer. Too often the
                                    developer has no idea, doesn't ask
                                    anyone, and implements something stupid.
                                    \_ I guess I would have to say that it
                                       is a shared responsibility between the
                                       system architect and the developers.
                                       A lot of times developers don't know
                                       what is possible, especially what is
                                       possible at a reasonable price point.
                                       How big a RAM disk cache can you expect
                                       to have available for your application
                                       in a shared disk array? How would a
                                       developer hope to possibly know that?
                                       But far too often system administrator
                                       types don't share this kind of info,
                                       even if they do know it themselves.
                                       \_ I would argue that developers
                                          should know what they don't know -
                                          or at least consider these issues
                                          early (before they become a problem).
                                          Part of the problem is that people
                                          with systems knowledge often come
                                          into the project late in the
                                          development of it - too late to
                                          make major changes. We see this
                                          problem in spacecraft operations.
                                          The hardware guys build a shiny new
                                          spacecraft without consulting with
                                          the people who are going to fly it.
                                          They make "sound technical decisions"
                                          and h/w design decisions that are
                                          intended to save lots of money, but
                                          they have no knowledge (or, worse,
                                          just enough to hang themselves) about
                                          how to operate the h/w they build.
                                          This often ends up being a case
                                          of saving $$ on the h/w and spending
                                          $$$$ on the operations (or not being
                                          able to operate at all - or with
                                          greatly increased risk). The *good*
                                          h/w guys know who to involve early in
                                          the process and why, but they are a
                                          small minority even in large,
                                          experienced companies like Lockheed.
                                          With scaled systems it's rather
                                          the opposite. The s/w guys design and
                                          build a system without considering
                                          h/w (or the systems environment).
                            \_ I had that exact problem at one place (millions
                               of files in one directory). We talked about
                               various ways to fix this and decided that
                               switching from WAFL to VxFS was the best
                               solution. In some ways this was just because
                               the developers were too lazy to figure out how
                               to use a database, but it worked.
                               \_ Why not spread those millions of files
                                  over many directories? In itself that
                                  helps a lot and it's a simple fix. A
                                  database is another idea. Switching
                                  filesystems sounds pretty drastic to me.
                                  \_ It was already hashed, so what we really
                                     had was billions of files, millions in
                                     each directory. There is no magic bullet
                                     for dealing with that quantity of data.
                                     Millions of directories is not really
                                     a good solution either, for reasons that
                                     should be obvious. By the time I left
                                     the company, they had started work on
                                     what was essentially their own filesystem
                                     but I don't know what happened to that
                                     \_ What a disaster. This sounds like poor
                                        s/w design.
                                     \_ All that because the devs don't want to
                                        figure out how to use a db?
                                        \_ Yeah, well it was 1999 and good
                                           developers (or sysadmins) were hard
                                           to come by. The new filesystem I was
                                           referring to had a DB included.
                                           \_ You think they are easier to come
                                              by now? If anything, it
                                              seems to be getting worse as
                                              a lot of Microsoft-trained,
                                              Java-loving weenies have
                                              entered the field and very
                                              few hardcore assembler-loving
                                              PDP-11 weenies still exist.
                                              Over time it seems the
                                              average developer/sysadmin
                                              knows less and less about
                                              the details of the systems
                                              in favor of high-level constructs
                                              like WWW and GUI design. There's
                                              a place for both, of course,
                                              but I am horrified by what
                                              recent CS grads do not know.
           \- I disagree as well. Some simple problems are solved by
              throwing money at them ... say $20k - $100k problems.
              But at some point programmer time does become cheaper than
              cycles, space etc. And there are other cases where the best
              hardware cant do what brainpower can. Trivial example are new
              crypto attacks. Another case is reading 10gb traffic streams...
              you cant just naively throw hardware at the problem. It's
              combination of hardware [ASIC, FPGA other specialized network
              devices], OS/kernel/devce driver hackery, and application
              \_ Any network with 10gb of traffic on it that cannot be easily
                 broken up is not scalable.
                 \- what you control may affect your options. we want to
                    do IDS on 10G. We cant tell say ESNet to tailor bandwidth
                    provisioning around IDS. What we can ask for is $ for
                    hardware as long as we're not being stupid about it.
                    The "web application scaling" is a different problem
                    than some other scaling issues ... something like the
                    LHC has different scaling issues, for example.
2007/9/27-10/2 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Languages/Python] UID:48202 Activity:moderate
9/27    Ok so to do the equivalent of  the following:
        bool ? a : b
        In Python, it is:
        (bool and [a] or [b])[0]
        Uh, kick ass?
        \_ 99 times out of 100 if you use the trinary operator you are
           doing the wrong thing.
        \_ 99 times out of 100 if you use the ternary operator you are
           doing the wrong thing.  Oh and python should have
           "a if bool else b".
        \_ Python 2.5 adds the ternary operator with the syntax above.  See:
           The and-or trick was the most recognizable way to do this prior to
           2.5.  See:
           This also explains why you need to do the wonkiness with wrapping a
           and b into arrays and then extracting element 0.  Curious, why does
           the pp feel that using the ternary operator is a bad idea? -dans
           \_ ( -!pp
              \_ Most of this discussion convinces me that the ternary
                 operator is a good thing.  Many of the posters seem to miss
                 the forest for the trees wrt code readability.  At this
                 point, I don't 'parse' the ternary operator, I just think of
                 it as a (slightly) higher-level construct and find it easier
                 to read and understand.  YMMV -dans
                 \_ bad coders : ternary operator :: Dubya : U.S. presidency
                    \_ bad coders : code :: Dubya : U.S. presidency
                       "However, there is already controversy surrounding the
                       grant. Explains Dean Clancy, "Ok, so we got all this
                       deodorant and shaving equipment now. So-fricking-what?
                       What I want to know is how we are going to get this
                       stuff on the engineers. Whenever I ask an engineer in
                       Soda, "Why do you smell like Rick Starr's underwear,
                       only worse?", they always give me some story about
                       being allergic to deodorant or not having enough time
                       to shower. Like I always say, you can lead a mouse to a
                       window but you can't always make the mouse click on the
                       Telling bad coders to avoid the ternary operator is
                       like giving deodorant to EECS students.  It doesn't
                       address the core problem. -dans
                       \_ What about L&S CS?  Are they allowed to bathe?
                          \_ I'm not aware of there being any department
                             strictures forbidding EECS students to bathe.  I
                             don't know if I'm typical of L&S CS students, but
                             I managed to bathe more or less regularly (or
                             date hot women who have a thing for, possibly
                             stinky, geeks).  I suppose there was that one
                             semester Paolo took CS 150 and didn't leave the
                             lab for a week, but I definitely think that's an
                             outlier data point. -dans
                             \_ dans is channeling tjb.
                                \_ i miss tjb.  can we get him back?
                                   \_ Seconded.  The man's a national
                             \_ I think we can all agree that paolo is an outlier
                                data point.
                                \_ Nah, I'm not going to try to freestyle.
                                   Though I am pretty white. -dans
                             \_ I think we can all agree that paolo is an
                                outlier data point.
2007/8/2 [Computer/SW/Languages/Misc, Computer/SW/Languages/Python] UID:47516 Activity:nil
8/2     We're using python optparse to parse arguments to a python script
        that then calls another program.  The usage is supposed to be:
        script [options] program [program_options]
        The program_options are supposed to be passed to the program directly,
        optparse should not try to parse them.  Unfortunatly, it does, and
        crashes in a case I just found.  Does anyone know how to get it to
        not parse anything after program?
2006/12/14-16 [Computer/SW/Languages/Misc, Computer/SW/Languages/Python] UID:45449 Activity:kinda low
12/14   Does anyone know how to get python to return an exit status
        at the end of a script?  The only way I seem to be able to get it
        to work is to use sys.exit(), otherwise I always get 0.  Seems
        kinda lame to end all my scripts with sys.exit though.
        \_ Use sys.exit.  See:
2006/10/6-7 [Computer/SW/Languages/Perl, Computer/SW/Languages/Python] UID:44706 Activity:moderate
10/5    Python experts, help. I'd like to do the following Perl regexp
        and reg substitution equivalent in Python, what's the best way?
        if ($line=~/(foo\w+)/) {
           $myfoo = $1;
        } elsif ($line=~/(bar\w+)/) {
           $mybar = $1;
        My limited Python knowledge says I must do the followings which
        seems really awkward:
        import re
        matchFoo = http://re.compile('(foo\w+)')
        matchBar = http://re.compile('(bar\w+)')
        m = matchFoo.match(line)
        if (m):
          myfoo =
        \_ I don't know Perl so I'm not sure what you are trying to do,
           maybe this link will be of some help:
        \_ One of the reasons I gave up on Python and love Ruby is that Ruby
           has OO but maintains the nice regex syntax of Perl.
           \_ Its OO is also a lot cleaner and more consistent than Python's,
              and none of this indentation-is-important i-can't-paste-code
              \_ Yeah, those would be some more of the reasons.
        \_ I don't know python, but this would be the equivalent, AFAICT:
           import re
           line = re.sub(r'(?i)hello', 'world', line)
           m ='foo\w+', line)
           if m:
             myfoo =
             m ='bar\w+', line)
             if m:
               mybar =
           \_ Now I remember why I never learned python.
2006/9/22-25 [Computer/SW/Languages/Python] UID:44502 Activity:nil
9/22    Is there a good way in python to too select/poll a child process's
        stdout and stderr?  Right now I use popen2.popen3, and then
        childout.readlines() and childerr.readlines(), but that messes up
        the ordering and such.  Using the actual select mechanism seems a
        bit heavy handed.  Is there something easier?
        \_ stdout and stderr aren't synchronized w/ each other, and due to
           buffering there's no guarantee that a stderr line emitted by a
           program between two stdout prints will actually arrive and be
           consumable at that moment
           \_ That's true, I'm not (or wasn't) expecting perfection.
              After some further tests, it seems it's impossible to even
              get them near where you might expect them.  Oh well.
        \_ Can you redirect stderr to stdout before reading into your python
2006/9/14-16 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Languages/Perl, Computer/SW/Languages/Python] UID:44378 Activity:kinda low
        I never knew C++ was a higher-level language than BASIC
        \_ It's salon.  So what?
           \_ More specifically, it's David Brin, who writes decent hard sci-fi.
              Too bad he apparently didn't get a decent computer education
           \_ More specifically, it's David Brin, who writes decent hard
              sci-fi.  Too bad he apparently didn't get a decent computer
              education either.  [formatd]
              \_ Still doesn't bother me.  He's a fiction writer, not a
                 \_ A friend of mine was in a technology-related tv show
                    with David Brin, and reports that he's pretty
                    technically naive / clueless.  I do like his books,
                    though.  - niloc
                 \_ It doesn't bother you that he's saying "the problem with
                    doing X w.r.t educating our children is that <incorrect
                    \_ Not at all.  It's a slate article online, not an
                       official publication from anyone who has anything to do
                       with education.  I give it the weight it deserves: zero.
        \_ I once read an article by a tech analyst which said the internet was
           invented in year 1991.
           \_ Wow that guy is a total idiot.  Everyone knows it was the year
              1991 when they invented the 1nt@rw3b!1.
        \_ Quick, someone tell that man about ruby/python/scheme/whathaveyou
           \_ He already discarded Perl as "too high level"  He doesn't seem
              to understand that crappy != "low-level"
              \_ He mentions Python os well, and calls C++ "high-level."
2006/8/29-31 [Recreation/Media, Computer/SW/Languages/Python] UID:44181 Activity:nil
8/29    Halo meets Monty Python: (
2006/5/29-31 [Computer/SW/Unix, Computer/SW/Languages/Python] UID:43216 Activity:nil
5/29    What's the Python library for downloading a file via HTTP?  I'm
        thinking of something along the lines of http.get(url). (simple)
        \_ >>import urllib
           >>page= urllib.urlopen('<DEAD>').read<DEAD>
2006/4/16-17 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Languages/Perl, Computer/SW/Languages/Python] UID:42756 Activity:nil
4/16    I'm very disappointed with os x:
        I made an application bundle around a python script: it executes fine
        but dropping a file on it doesn't work
        turns out finder passes a ProcessInfo object
        and you get that as argv[1]
        well, you get its UID- and that is the only arg you get
        so far the on;y way i have found to translate the UID into a process
        info, and thus to get the path of the file i dragged, is with cocoa
        i.e. c++ or objective c.
        doesn't seem to be any decent applescript way to do it, or i could just
        shell out to osascript
        i guess this explains why all the droplet hacks use a binary executable
        to call shell, perl, or python scripts
        this man-made creation troubles me
2005/2/25-27 [Computer/SW/Languages/Perl, Computer/SW/Languages/Python] UID:36415 Activity:low
2/25    Any python guys on the motd?  I'm trying to find a python equivalent
        to $/ (the perl input record separator) so that I can parse a file
        with odd record separators (ie, not \n).  The data I got on google
        suggests that no such thing exists, but those posts were from 2003.
        Has support for this been added of late?
        \_ string.split('record_sep_char') I think.
           \_ Problem with this is having to read in data blocks from the
              file, because otherwise there's an implicit split on \n
              (which my records contain).
               \_is the file really big?
                 f = open("/usr/dict/words")
                 I'm curious too if there's a better answer
        \_ I don't do much work in Python so I don't know if this will
           actually work, but my copy of Python in a Nutshell mentions the os
           module has an attribute linesep which is set to '\n' on Unix and
           '\r\n' on Windows.  What happens if you try to set that attribute
           to your desired separator before sucking in your file? -dans
2005/2/7-8 [Computer/SW/Languages/Python] UID:36085 Activity:nil
2/7     What's the point of having os.getcwd() and os.path.abspath() in
        python? It seems that abspath() does everything getcwd() does and
        more. Is that not true?
        \_ Yes. Probably abspath calls getcwd and getcwd was implemented first.
           Probably just artifacts left over from language development, like
           deprecated crap in Java.
2004/9/3-4 [Computer/SW/Languages/Python] UID:33345 Activity:low
9/3     If you were to study 1 or 2 programming skills/standards/languages
        to improve your resume/marketability, what would they be?
        \_ Something which is not python.
           \_Why? Because it is easy to use and therefore won't impress?
        \_ Business degree.  Thick rolodex.
        \_ (1) Database programming, (2) .Net
        \_ Linux device drivers
           \_ very funny
        \_ Visual India .NET
2004/8/20-21 [Computer/SW/Languages/Python] UID:33048 Activity:very high
8/20    Are python's built-in sequence types thread safe (when using
        python's threads)? Thanks.
        \_ Threads are never safe.  Unroll all loops.  Stop using switch/case
           and other ugly branching mechanisms.  GOTO.  You want GOTO.  A
           properly written program with GOTO and LABEL statements is all you
           \_ But python doesn't have goto and label statements.
              What do I do now?!
              \_ GOTO :BASIC!
                 \_ Pfffffffft.  Kids these days with their symbolic identifiers
                    and high level features like 'arrays' and 'variables.'
                    Back when I was your age, all we had were punch cards and
                    machine code.  And we liked it!  We loved it!
                 \_ Pfffffffft.  Kids these days with their symbolic
                    identifiers and high level features like 'arrays'
                    and 'variables.' Back when I was your age, all we
                    had were punch cards and machine code.  And we
                    liked it!  We loved it!
                    \_ You had punch cards?  I wish I had punch cards.  Did
                       they give you more than 1?
                       \_  1000101110101001? 10101011111011001! 11111000010111
                           10110 101010000 up hill both ways!
                           \_ You had zeros and ones?  And hills?  You had
                              hills?  And directions?  Vectors?!!!  Whoa....
2004/7/10-12 [Computer/SW/Languages/Java, Computer/SW/Languages/Python] UID:32208 Activity:high
7/10    anyone figure out the google challenge?
        \_ what's that?
           \_ {first 10-digit prime found in consecutive digits e}.com
        \_ I got 7427466391 for phase 2. Did anyone else get this?
           Err, sorry, nevermind. I figured it out though.
        \_ it's kinda lame, actually.
        \_ Yes.  They call that a challenge?
2004/7/7-12 [Computer/SW/Languages/Python, Computer/SW/Languages/Misc] UID:31205 Activity:high
7/7     If you're interested in working at Lawrence Livermore National Lab,
        there are quite a few openings.  The first opening I heard about
        today was for working on parallel file systems in Linux, a good OS
        hacking job.  See it at: /csua/pub/jobs/LLNL.  However, there are
        always a lot of jobs for scientific programmers (Familiariry with
        Math, Physics, and/or biology are big pluses). There's also some sys
        admin jobs and other miscelleous things. You can check out: click "search by organization", and select
               \_ All I get is a PeopleSoft8 error page:
                  "Webserver appears to be incorrectly configured."
                  \_ It's a government facility.  Someone will take a look at
                     the logs next week and submit the "Form a committee to
                     discuss error log issue" paperwork a week later.  Quit
                     yer bitichin', take your pension and stop stirring the
                     water.  You trying to get someone in trouble?
                  \_ Works for me, but you could also go to
                     and click "Jobs" then click "advanced search"
        "Computation."  Or search more generally.  Or email me. -jrleek
        \_ thanks for the post.  can you comment on the quality of life issues
           of living out there?  I.e. rent, ease of getting around with or
           without a car, traffic, access to parks and such, how easy it is to
           get back to the bay area, etc.?  Could one buy a decent home
           out there on a LLNL salary?
        \_ Do you have to be a genius to work there?
           \_ I think you're confusing LLNL with the apple store
              \- LLNL has a reputation of having a lot of politics ...
                 although maybe a hacking job isnt especially affected.
                 what do you think? --psb
              \_ The genius I met at apple store is positively retarded.
           \_ No, but it helps.  Basically, LLNL is fully of
              self-modivated geniuses.  If you want to get ahead and be
              self-motivated geniuses.  If you want to get ahead and be
              really important, yeah, you should have both a PhD and a
              genius level intelect.
              To psb: Actually, yeah, the politics here can be pretty bad.
              Basically, you get a good income, great benifits, great job
              security, and you work with geninuses.  The downside is you
              have to put up with some petty acedemic-style politics.  I
              consider this a reasonable trade. -jrleek
              \_ 1.  What is academic politics like?  2.  Why does government
                 job well?  I thought government job pay sucks.
                 \_ My pay is a little less than my friends who started
                    work at the same time, but I work a lot less, and have
                    a lot more flexibility.  And oh man, THE BENIFITS are
                    stellar.  How would you like your retirement paycheck
                    to be 100% of what you were making when you retired?
                    That's pretty dang good.  Acedemic politics are all
                    the piss-posturing about Phds and worring about
                    whether something is really RESEARCH or not that you
                    see around Universities.  You know, the stuff like
                    what professors do where they get more worried about
                    who's who and who has what education and went where
                    than about who's doing a good job.  It's not really
                    that bad around here, but you see it sometimes.
                    \_ Ok, so maybe academic politics isn't worse than office
                       cubicle politics.  But you also need security clearance
                       to work there, right?  Do people get harrassed for
                       having brown skin?
                       \_ yes, you do, no they don't care that you're a heavy
                          pot user and queer, no they don't care but you will
                          care that they're all white and very conservative.
                       \_ This post above me ^^^^ is a little
                          unintelligible, but correct.  Brown skin's not a
                          problem, although not being a citizen is.  Our
                          biggest "minority" is easily Chinese, but yeah,
                          this place is mostly white.  It still feels
                          wierd after leaving Berkeley to end up in a room
                          where all the occupants are white.  That's
                          really just a function of the citizenship rule
                          though really. Oh, and having been a
                          druggie in the past isn't a problem, but
                          currently being "a big pot user" might be a
                          problem.  Being a big booze drinker is a
                          problem. -jrleek
                          \_ it was intelligible.  i simply chose to ignore
                             common english syntax like psb does but no one
                             calls him unintelligble.
                             \_ are you insane?  people call psb unintelligable
                                all the time.
        \_ jrleek, are you elite and what do you do?
           \_ I'm about as un-elite as they come, but here's what I do:
              \_ I hope you didn't pick the color scheme.
              \_ Why not SWIG (
                 \_ obItWorksWithOcaml! -- ilyas
                 \_ SWIG actually does provide pretty good functionality.
                    It is currently well used at the lab.  The main
                    problem is that since it's not specifically designed
                    for scientific programming, there are some features
                    we really need that SWIG just doesn't have, and
                    probably shouldn't add.
                 \_ More on SWIG.  Also, in SWIG all callers must be
                    script languages.  We want the whole call stack to be
                    mixed languages.  Python calls Java, which calls C,
                    Which calls fortran, which calls Python. Completely
                    impossible in SWIG. -jrleek
                    \_ Uh... what's a 'script language' jrleek?
        \_ Oh sure, end your hiring freeze right after I get another job
        \_ I guess I wouldn't mind but is there a Ranch 99 nearby with
           Boba Tea hang out place filled with cute Asian chicks? That's
           more important than say, pay or housing.             -chinese
           \_ Sorry, AFAIK the nearest Ranch 99 is in Albany and there are
              no Boba places.  As they meantion below, open a restraunt
              and either serve good foor or cheap prices and you'll be
              packed constantly.  As far as single h@t 4SI4N CH1X0R, I
              know one at church, and one at work.  This being a nerd
              town, there are quite a few asian chicks, but they're
              already married to white guys.
        \_ can you comment on the quality of life issues of living out there?
           what is the housing situation?  traffic?  easy access to decent
           stores, easy access to parks?  how long does it take to get back
           into the bay area?  do you have to own a car to get around out there?
           \_ I live in the area but don't work at LLNL.  Housing is much
              easier here than in SF,Oak,Berk,SJ,SC,Penninsula,etc.  You have
              the choice of paying less to get the same size but newer than in
              those places or paying the same to get much more and newer.
              Traffic: not too bad but getting worse.  Depends which direction
              you're going and when.  Decent stores: Costco is nearby, every
              chain imaginable is near by, Berkeley is 25 minutes for the rest.
              I live 90 seconds walk from a nice park.  It's 25 to Berk, 45 to
              SF.  Yes, you must have a car but contrary to popular opinion,
              you aren't legally required to drive an SUV in the suburbs.  The
              biggest problem here now is lack of restaurants.  The food is ok
                                          \_ The other side of the hills may
                                             not be Berkeley or SF, but
                                             Walnut Creek offers many fine
                                             eating choices, and the kickin'-est
                                             ribs in the Bay Area are to be
                                             found in Lafayette. -elizp
              but there simply aren't enough.  Come out here and open one and
              you'll be packed at every meal as long as you're not killing
              \_ yahoo maps gives a time for driving between llnl and berkeley
                 that is exactly double what you claim.  looking at the
                 map, it looks to me like walnut creek is just as far away
                 as berkeley...throw in traffic, and you've got a solid hour
                 or more to get *anywhere*.
                 \_ yeah plus it's hot as hell in the summer out there. and
                    you're making your living suckling at the gubmint's teat!
        \_ what's the pay?
           \_ they pay decently but not great.  if you spend your career
              there the pension more than makes up for it as well as the
              other perks and benes.
        \_ no Ranch 99, no Boba, no Chinese radio, only 1 foreign channel,
           forget it.                                           -chinese
           \_ For 100, do you try harder?
           \_ You can listen to RTHK over the Internet if you have
        \_ um, parallel file system? It's called the RAID. Stop
           reimplementing things that have been done decades ago.
                \_ That's all Linux is, isn't it?
2004/4/23 [Computer/SW/Languages/Misc, Computer/SW/Languages/Python] UID:13352 Activity:nil
4/23    What's a twink point?                                   -newbie
        \_ run ~tom/bin/twink_warriors
           \_ sucky interface
              \_ /accounts/tom/pub/twinks
                 \_ Wow, what's cmlee's claim to fame?
        \_ What is a "twinkish statement?"
           \_ "how many attachments can I send in a hotmail e-mail?"
              \_ Wow, so my above statement is recursive.  Do I now have
                 infinite twink points?  Or is there a recursion limit
                 like in Python?
        \_ I like this line:
        tom                       1                       1
           \_ I earned one for a bug I introduced into my script.  -tom
              \_ But naturally none for anything you have ever said. -- ilyas
              \_ boy, it looks like you spend a lot of time on this.  Why not
                 archive the offending statements as well.  I'd love to see
                 the particulars.
                 \_ don't be a twink
        \_ You missed me!  Either I'm not a twink, or I've managed to stay
           pretty anonynmous.
2004/3/27-28 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Languages/Python] UID:12891 Activity:moderate
3/27    Funny argument involving code, recursion, and a foxtrot comic:
        \_ somehow that thread neglects to provide a link to the 1.0.1 patch:
        \_ somehow that thread neglects to provide a link to the patch:
2004/3/19-20 [Computer/SW/Languages/Java, Computer/SW/Languages/Python] UID:12770 Activity:nil
3/19    Can anyone provide a reference to the origin of the term "mixin"
        (in programming contexts)? Thanks.
2003/7/22-23 [Computer/SW/WWW/Server, Computer/SW/Languages/Python] UID:29101 Activity:nil
        Where Python, Democracy and the Tragedy Of The Commons all come
        together on the same page!  I love this interweb thing!
2003/5/6-7 [Computer/SW/Languages/Python, Computer/SW/Languages/C_Cplusplus] UID:28355 Activity:low
5/6     How difficult is it to write a python wrapper around a small C++
        class?  Any references would be appreciated, thank you.
        \_ Pretty easy.  If you use the simplified wrapper and
           interface generator ( you can use the same
           C++ code from python, guile, tcl, perl, etc.
2001/7/28 [Computer/SW/Languages/Python] UID:21981 Activity:high
7/27    PriceCostco's selling a 10 volume Monty Python Flying Circus for
        only $100. Is it worth it?
        \_ I actually bought it last christmas.  I don't really regret it.
        \_ That's a good price.  I think I paid $150 for my set.
        \_ Dunno, i'd pay $100 for the full set of The Young Ones, or Black
           Adder, or Red Dwarf. Python used to be funny, but about the only
           interestnig one left is "meaning of life." - paolo (who saw Eric
           - paolo
           Idle at the warfield last year and really didn't laugh much).
           \_ Uhm, I'm guessing that this paolo.  Quite emphatic nowadays.
           \_ not that I didn't like python as a kid, I remember watching
              it on MTV a long time ago and really liking it.  But lately,
              it's not been funny at all. -paolo
              \_ It's called growing up. I thoroughly recommend it to
                 most sodans.
              \_ python was on tv?!? Damn don't tell that to lwall's #1 fan!
2001/4/29-30 [Computer/SW/Languages/Python] UID:21140 Activity:high
4/29    does anybody know which text wilensky uses in 188?
        does everyone just use the norvig book?  thanks.
        \_ everyone uses russell&norvig
           \_ Russell and Norvig is the standard.  AI textbook.
2001/4/9-10 [Computer/SW/Languages/Perl, Computer/SW/Languages/Python] UID:20925 Activity:very high
4/9     Does anyone here use the Python language on a regular basis?  What do
        you use it for?  What is your opinion of it as a language?
        \_ ML >> Perl >> Python.
           \_ Tcl >> ML >> ... >> PHP
                \_ I've seen Python, PHP, Perl, and TCL.  3 of 4 are crap.
                   Got a link for ML?  I can decide for myself.
           \_ Who is it that keeps putting ML into these Python comparisons?
              I seriously doubt anyone would consider ML where they were
              thinking of using either Perl or Python. Might as well put
              Prolog into these comparisons.
              \_ Ok!  ML >> Prolog >> Perl >> Python.
                 \_ Scheme >> ML >> Prolog >> Perl >> Python >> JavaScript
                    \_ ML >> Scheme.  Scheme doesn't have a type system.
                       \_ so what? you making fun of it? it gets by just fine
                          without one asshole.
                          \_ Silly troll.  I programmed lisp in the industry.
                             I _know_ how bad runtime type errors are in
                             lisp-like languages.  Train harder.
              To answer the original poster's question, Python is a nice
              language. It's a poor-man's Smalltalk. There are some weird
              quirks to the language, but i would prefer it to Perl for
              all but the simplest tasks.
2000/8/25 [Computer/SW/Languages/Python] UID:19095 Activity:nil
8/25    What is the best site for a primer on python?
1996/11/1 [Computer/SW/Languages/Python] UID:31976 Activity:nil
11/1    Python 1.4 installed.  What is Python?  Check out the homepage at a tutorial at
        and a new book that just came out:  Internet Programming with Python.
          -- cmlee
2018/08/18 [General] UID:1000 Activity:popular
Berkeley CSUA MOTD:Computer:SW:Languages:Python: