Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #48071

Re: My son wants me to teach him Python

Path csiph.com!usenet.pasdenom.info!gegeweb.org!newsfeed.kamp.net!newsfeed.kamp.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.007
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'encoding': 0.05; 'output': 0.05; 'subject:Python': 0.06; 'imported': 0.09; 'mind,': 0.09; 'non-text': 0.09; 'postgresql.': 0.09; 'wrong,': 0.09; '(mysql': 0.16; 'dump': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'headaches': 0.16; 'sql)': 0.16; 'statements,': 0.16; 'subject:son': 0.16; 'think?': 0.16; 'files.': 0.16; 'followed': 0.16; 'wrote:': 0.18; 'directory.': 0.24; 'integer': 0.24; 'replace': 0.24; 'certain': 0.27; 'header:In-Reply-To:1': 0.27; 'leave': 0.29; 'restrict': 0.30; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; "d'aprano": 0.31; 'directory,': 0.31; 'perl': 0.31; 'so-called': 0.31; 'steven': 0.31; "they'll": 0.31; 'file': 0.32; 'another': 0.32; 'text': 0.33; 'fri,': 0.33; 'table': 0.34; "i'd": 0.34; 'something': 0.35; 'editor': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; '14,': 0.36; "i'll": 0.36; 'to:addr:python-list': 0.38; 'files': 0.38; 'pm,': 0.38; 'extremely': 0.39; 'to:addr:python.org': 0.39; 'challenge': 0.61; 'guarantee': 0.63; 'name': 0.63; 'hear': 0.63; 'containing': 0.69; 'subject:wants': 0.74; '100%': 0.77; 'you:': 0.81; 'cheating': 0.84; 'proves': 0.84; 'yelling': 0.84; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=8ICo7IKwfcHCponPIGdGZ6aWS5lF21a02b2Nb8vMIn4=; b=Mw2vSitMxAKabMRsr37bWzRC6qrKHO9MJnd6TArl9JlPlA14B5fCTYLD/EL1l5UDY6 j1p4dkPTaL93PwsU6dypJ6eLiFrubIKP57/SA6gRkxOjqYUHCCwG95IxQOjEhrjLE4ZP qh8gfx6fUDeVEG6Q0C+KmN+Q49EuL0VEVWjLClWUi7q+Tz6dPLkZZr8w2Mr29gNjkvZg 2Gk6bQMtx9tRVu8ax2JLtFtvHNPJ6xOUsVEax++mjwteMPhT7u+fSxXv03oU9Ok3F2nM bdCg5kA2XCZRN0MQYtCSHVDZPC1o4kPp+f03YBzv+QBpOjB23AXNB0qyIeCOhz5EW7Tf ZtdA==
MIME-Version 1.0
X-Received by 10.220.109.66 with SMTP id i2mr449024vcp.51.1371194512946; Fri, 14 Jun 2013 00:21:52 -0700 (PDT)
In-Reply-To <51bab49a$0$29997$c3e8da3$5496439d@news.astraweb.com>
References <Pine.LNX.4.64.1306131844240.11512@tau.ceti.pl> <mailman.3219.1371154780.3114.python-list@python.org> <637daa98-9a0e-46ab-bb9a-f5638b7c0038@googlegroups.com> <51bab49a$0$29997$c3e8da3$5496439d@news.astraweb.com>
Date Fri, 14 Jun 2013 17:21:52 +1000
Subject Re: My son wants me to teach him Python
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3256.1371194515.3114.python-list@python.org> (permalink)
Lines 38
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1371194515 news.xs4all.nl 15952 [2001:888:2000:d::a6]:54090
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:48071

Show key headers only | View raw


On Fri, Jun 14, 2013 at 4:13 PM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
> Here's another Pepsi Challenge for you:
>
> There is a certain directory on your system containing 50 text files, and
> 50 non-text files. You know the location of the directory. You want to
> locate all the text files in this directory containing the word
> "halibut", then replace the word "halibut" with "trout", but only if the
> file name begins with a vowel.

That sounds extremely contrived, to be honest. Try this one: Massage a
set of MySQL dump files (text, pure SQL) so they can be imported into
PostgreSQL. I'll leave out my Wednesday's encoding headaches (MySQL
produced so-called "UTF-8" output that contained "don\222t" - boggle!)
and restrict this challenge to one thing:

CREATE TABLE blah
(
    blah INT(11) blah blah
);

All through the CREATE TABLE statements, integer fields are followed
by (11), and smallint fields by something else - (9) I think? - and
you have no guarantee that they'll be exactly these numbers, but they
will immediately follow the word INT.

Okay. I can hear some of you screaming "Regular expression!!", and
others yelling "Search across files, any good editor can do that!!". I
happened to use sed for the job. Bear in mind, there are heaps of
other files in the directory, so do this only on *.sql.

Any point-and-click solution to this is likely to end up cheating and
calling on some system that uses text strings (eg regexps). I'd like
to see any solution that proves me wrong, if only out of morbid
curiosity. I'm 100% confident that it won't be faster than me with
sed, or a Perl fanatic with a good regex.

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: My son wants me to teach him Python Joshua Landau <joshua.landau.ws@gmail.com> - 2013-06-13 21:18 +0100
  Re: My son wants me to teach him Python Rick Johnson <rantingrickjohnson@gmail.com> - 2013-06-13 20:33 -0700
    Re: My son wants me to teach him Python Chris Angelico <rosuav@gmail.com> - 2013-06-14 14:02 +1000
      Re: My son wants me to teach him Python Anssi Saari <as@sci.fi> - 2013-06-14 15:02 +0300
        Re: My son wants me to teach him Python Chris Angelico <rosuav@gmail.com> - 2013-06-15 03:12 +1000
    Re: My son wants me to teach him Python Chris Angelico <rosuav@gmail.com> - 2013-06-14 14:05 +1000
      Re: My son wants me to teach him Python Rick Johnson <rantingrickjohnson@gmail.com> - 2013-06-16 12:04 -0700
        Re: My son wants me to teach him Python Chris Angelico <rosuav@gmail.com> - 2013-06-17 07:52 +1000
          Re: My son wants me to teach him Python Rick Johnson <rantingrickjohnson@gmail.com> - 2013-06-16 15:33 -0700
            Re: My son wants me to teach him Python Alister <alister.ware@ntlworld.com> - 2013-06-17 21:11 +0000
    Re: My son wants me to teach him Python Joshua Landau <joshua.landau.ws@gmail.com> - 2013-06-14 06:11 +0100
    Re: My son wants me to teach him Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-14 06:13 +0000
      Re: My son wants me to teach him Python Chris Angelico <rosuav@gmail.com> - 2013-06-14 17:21 +1000
      Re: My son wants me to teach him Python Tim Chase <python.list@tim.thechases.com> - 2013-06-14 05:41 -0500
        Re: My son wants me to teach him Python Alister <alister.ware@ntlworld.com> - 2013-06-14 15:35 +0000
      Re: My son wants me to teach him Python Neil Cerutti <neilc@norwich.edu> - 2013-06-14 16:01 +0000
        Re: My son wants me to teach him Python Chris Angelico <rosuav@gmail.com> - 2013-06-15 03:14 +1000
      Re: My son wants me to teach him Python Jason Swails <jason.swails@gmail.com> - 2013-06-14 13:03 -0400
    Re: My son wants me to teach him Python Jason Swails <jason.swails@gmail.com> - 2013-06-14 02:28 -0400
    Re: My son wants me to teach him Python Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-06-14 20:12 -0400

csiph-web