Thus spoke Paul McGuire (on 2006-10-04 17:34):
> <[EMAIL PROTECTED]> wrote in message
>> this is my first post. my "programming" background is perlish
> I'll see your perlish line noise, and raise you this obfuscapython: :)
>
> data = """\
> 2 1 2 3 4
> 7 7 8 9 10
> 5 1 3 5 7 9
> 2 6 8 10""".s
Thus spoke Diez B. Roggisch (on 2006-10-08 10:49):
> Certainly true, and it always gives me a hard time because I don't know
> to which extend a regular expression nowadays might do the job because
> of these extensions. It was so much easier back in the old times
Right, in perl, this would be
Thus spoke John Salerno (on 2006-06-15 15:50):
> Did you have to learn it for a job?
No, I was just interested in things
that are found interesting ;-)
> Or did you just like what you saw and decided to learn it for fun?
I read some remarks, from "both sides", on
the feasibility of a programmin
Thus spoke Preben Randhol (on 2006-06-16 10:36):
> A short newbie question. I would like to extract some values from a
> given text file directly into python variables. Can this be done simply
> by either standard library or other libraries? Some pointers where to
> get started would be much appre
Thus spoke Mirco Wahab (on 2006-06-16 21:21):
> I used your example just to try that in python
> (i have to improve my python skills), but waved
> the white flag after realizing that there's no
> easy string/var-into-string interpolation.
I did another try on it, using all my
Thus spoke Sybren Stuvel (on 2006-06-17 22:01):
> Rune Strand enlightened us with:
>> But back on university, I met a very, very pretty C++ girl who said
>> many favourable things about Python.
>
> Rr a very, very pretty girl that likes C++ and Python.
> Does it get better?
It does:
http://
Thus spoke Preben Randhol (on 2006-06-17 23:25):
> The code is a very good starting point for me! I already
> managed to change it and I see I need to make it a bit more robust.
I think, the only thing you have to look at - is
the congruence of the regex-based filter rule and the text.
suppose
Thus spoke Dennis Lee Bieber (on 2006-06-18 06:29):
> On Sun, 18 Jun 2006 03:12:23 +0200, Mirco Wahab
> <[EMAIL PROTECTED]> declaimed the following in comp.lang.python:
>> - you have to explicitly instantiate a dictionary value
>> (with 0) if/before you want in-plac
Thus spoke Preben Randhol (on 2006-06-18 13:34):
> On Sun, 18 Jun 2006 10:54:01 +0200
> Mirco Wahab <[EMAIL PROTECTED]> wrote:
>> - no DWIM-ism (do what I mean) on 'value' addition
>
> But you don't add two values. you add two strings. If you
> want n
Thus spoke Marc 'BlackJack' Rintsch (on 2006-06-18 18:54):
> In <[EMAIL PROTECTED]>, Mirco Wahab wrote:
>> they use the _same_ operator (+) for number _addition_
>> and string _concatenation_, which is, imho, cumbersome.
>
> And ``+`` means also list/tuple
Thus spoke Kay Schluehr (on 2006-06-18 19:07):
> I have a list of strings ls = [s_1,s_2,...,s_n] and want to create a
> regular expression sx from it, such that sx.match(s) yields a SRE_Match
> object when s starts with an s_i for one i in [0,...,n]. There might
> be relations between those strin
Thus spoke Dennis Lee Bieber (on 2006-06-18 22:37):
> The only cure for that is complete and painful bone marrow
> transplant As a start, after six months of no PERL go back and try
> reading some of your code.
Uhhh, this is like giving the
mounted knight a longbow and
push him onto the ba
Thus spoke [EMAIL PROTECTED] (on 2006-06-19 22:51):
> It uses Aho-Corasick for the implementation which is fast and does what
> you expect it to do. Nor does it have a problem of matching more than
> 99 possible strings as the regexp approach may have.
If you pull the strings into (?>( ... )) (a
Thus spoke [EMAIL PROTECTED] (on 2006-06-20 01:39):
Hi, are you the A.Dalke from the Schulten group (VMD) as
listed here: http://www.ks.uiuc.edu/Overview/People/former.cgi
> Replying to me Mirco Wahab wrote:
>> If you pull the strings into (?>( ... )) (atomic groups),
>> t
Thus spoke [EMAIL PROTECTED] (on 2006-06-21 03:51):
> I want to learn a language that I can use in my networking duties that
> is most likely to be of use to me. I have a few choices I can think of
> being:
>
> Python
> Perl
> C
C is not really a choice in the perimeter
of Perl and Python.
Perl
Hi,
I have a 2D array,
maybe irregular, like
arr = [[2,2,2,2],
[2,2,2,2],
[2,2,2,2]]
if tried to pull an index list
(tuples or array elements) of
all positions - via the map funtion,
but failed.
I tried to get sth. like
[
[0,0],
[0,1],
[0,2],
...
]
for each element which reall
Thus spoke [EMAIL PROTECTED] (on 2006-06-23 00:57):
> Maybe you want something like this (but this doesn't use map):
> [(r,c) for r, row in enumerate(m) for c in xrange(len(row))]
Ahh, its a 'list comprehension', nice. Now,
lets see how the decorate/undecorate sort
turns out to look in Python:
Thus spoke [EMAIL PROTECTED] (on 2006-06-23 17:40):
> Does anyone know of a way to embed python scripts into html, much like
> you would javascript or php? I do not want to use this to connect to a
> database, but rather for a functional script to be called when a user
> clicks on a link to open a
Thus spoke Andy Dingley <[EMAIL PROTECTED]> (on 2006-06-23 18:10):
> [EMAIL PROTECTED] wrote:
>
>> Python, like it's (evil?) cousin Perl,
>
> Isn't that evil cousin Ruby? Perl's the mad old grandmother in the
> attic, spewing out incomprehensible [EMAIL PROTECTED]&% swearing all day.
There's a
Thus spoke Cameron Laird (on 2006-06-25 13:08):
> I'll gratuitously add that, even though I'm personally fond of
> C++, I think teaching it as is done in colleges and high schools
> (!) amounts to child abuse. It's wildly inappropriate.
C++ programming requires you to
massively invest your think
Thus spoke Lawrence D'Oliveiro (on 2006-06-26 09:21):
> In article <[EMAIL PROTECTED]>,
> Mirco Wahab <[EMAIL PROTECTED]> wrote:
>
>>C++ programming requires you to massively invest your thinking
>>first into the setup of your build environment ...
>
&
Thus spoke Xah Lee (on 2006-09-27 05:03):
> This page gives a visual report of computer languages's
> popularity, as indicated by their traffic level in newsgroups.
> ...
> http://xahlee.org/lang_traf/index.html
When the Samurai of medieval Japan were confronted
with new 'battlefield language',
Thus spoke Ramon Diaz-Uriarte (on 2006-09-27 11:01):
>> When the Samurai of medieval Japan were confronted
>> with new 'battlefield language', e.g. early Shotguns,
>> they resisted because one could push any peasant
>
> shouldn't this be "they [the Samurai] did not resist"?
The "resisted" believ
Thus spoke Chris Mattern (on 2006-09-27 19:09):
> In article <[EMAIL PROTECTED]>, Mirco Wahab wrote:
>>
>>When the Samurai of medieval Japan were confronted
>>with new 'battlefield language', e.g. early Shotguns,
>
> "early Shotguns" :D. Yo
Thus spoke [EMAIL PROTECTED] (on 2006-09-28 09:10):
> String formatting can be used to converting an integer to its octal or
> hexadecimal form:
> >>> a = 199
> >>> "%o" % a
> '307'
> >>> "%x" % a
> 'c7'
>
> But, can string formatting be used to convert an integer to its binary
> form ?
I d
Thus spoke Gabriel Genellina (on 2006-09-28 11:05):
> At Thursday 28/9/2006 05:22, Mirco Wahab wrote:
>> > But, can string formatting be used to convert an integer to its binary
>> > form ?
>>
>> a = 199
>> a_bin_str = pack('L', a)
>
>
Thus spoke Frederic Rentsch (on 2006-09-28 20:43):
> [EMAIL PROTECTED] wrote:
>> Mirco Wahab:
>>
>>> But where is the %b in Python?
>>
>> Python doesn't have that. ...
>> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/44052
Thus spoke Marc 'BlackJack' Rintsch (on 2006-09-28 23:38):
>> def int2bin(num, width=32):
>> return ''.join(['%c'%(ord('0')+bool((1<> range((width-1),-1,-1)])
>
> Yeah, I wonder why not everybody sees the beauty in this cool and
> straightforward one liner. ;-)
Right. I see this is BS, ma
Thus spoke Fredrik Lundh (on 2006-09-28 23:35):
> Mirco Wahab wrote:
>
>> - why doesn't have Python such a simple and useful thing as to_binstr(...)
>
> useful? really? for what?
I don't really know, but according to google,
people often ask exactly for that and t
Thus spoke John Salerno (on 2006-09-29 21:13):
> Irmen de Jong wrote:
>> John Salerno wrote:
>>> Ok, this is completely unnecessary so I don't intend to get into stuff
>>> that's beyond my skill, but I'm wondering how simple it would be to
>>> use Python to create a server that runs on my compute
Thus spoke Mirco Wahab (on 2006-09-29 21:32):
> Thus spoke John Salerno (on 2006-09-29 21:13):
>> Irmen de Jong wrote:
>>> John Salerno wrote:
>>>> Ok, this is completely unnecessary so I don't intend to get into stuff
>>> Why do you need to use Pyt
Thus spoke Antoine De Groote (on 2006-09-30 11:24):
> Can anybody tell me the reason(s) why regular expressions are not built
> into Python like it is the case with Ruby and I believe Perl? Like for
> example in the following Ruby code
> I'm sure there are good reasons, but I just don't see them
Thus spoke Jorge Godoy (on 2006-09-30 14:37):
> Antoine De Groote <[EMAIL PROTECTED]> writes:
>> I'm sure there are good reasons, but I just don't see them.
>> Python Culture says: 'Explicit is better than implicit'. May it be related to
>> this?
>
> See if this isn't better to read:
>
> def prin
Thus spoke Jorge Godoy (on 2006-09-30 17:50):
> Mirco Wahab <[EMAIL PROTECTED]> writes:
>
> I could make it shorter in Python as well. But for a newbie that haven't seen
> the docs for strings in Python I thought the terse version would be more
> interesting.
OK
Thus spoke Jorge Godoy (on 2006-09-30 19:04):
> Mirco Wahab <[EMAIL PROTECTED]> writes:
>> sub print_message {
>> if (/^track="(.+?)"/ ){ print "Your track is $1\n" }
>> ...
>
> Specially the non-greedy part. :-) I don't be
Thus spoke MRAB (on 2006-09-30 20:54):
> Antoine De Groote wrote:
>> I just have to learn accept the fact that Python is more verbose more
>> often than Ruby (I don't know Perl really).
>
> One of the differences between the Python way and the Perl way is that
> the Perl way has a side-effect: Per
Thus spoke Steve Holden (on 2006-09-30 23:58):
> Mirco Wahab wrote:
>> Thus spoke MRAB (on 2006-09-30 20:54):
>>>One of the differences between the Python way and the Perl way is that
>>>the Perl way has a side-effect: ...
>> I fail to see the benefit of a re-objec
Thus spoke A.M. Kuchling (on 2006-09-30 19:26):
> On Sat, 30 Sep 2006 09:10:14 +0100,
> Steve Holden <[EMAIL PROTECTED]> wrote:
>> My God, Perl 6 is going to be even less comprehensible that Perl 5,
>> which was at least usable. Is »=>« really a Perl6 operator? That's too
>> funny!
>
> While we
Nick Maclaren wrote:
> For reasons that I won't explain, as they are too complicated
> and not terribly relevant, I am interested in discovering what
> people actually use regular expressions for. Not the subject
> domain, but the construction of the regular expressions.
After I figured out how t
James Stroud wrote:
there's a serious bug waiting here
> This idiot is a troll. This idiot is a troll. ThThis idiot is a troll.
> This idiot is a troll. is idiot is a troll. This idiot is a troll. This
Remember, rockets went back to earth on such things (in pieces) ...
> idiot is a troll. Thi
Markus E Leypold wrote:
> Trying to correct Xah's behaviour is probably impossible. People who
> publish pictures of themselves as he does on the WWW probably don't
> have any sense of embarrasment left ...
you think of stuff like this
www DOT m-e-leypold DOT de SLASH leypold-small.jpg
;-)
>
Hi skip
> Sorry to ask a Perl question here, but... Does Perl have something like
> Python's repr() function? I want to print out a string and have CR print as
> \r, LF as \n, etc. I looked in the Perl/Python phrasebook:
Have a look at this:
# cmp_rep.pl --- #
#!/usr/bin/perl
Hi Davy wrote:
> I am a C/C++/Perl user and want to switch to Python
OK
> (I found Python is more similar to C).
;-) More similar than what?
> Does Python support robust regular expression like Perl?
It supports them fairly good, but it's
not 'integrated' - at least it feels not
integrated f
Hi Davy
> > More similar than Perl ;-)
But C has { }'s everywhere, so has Perl ;-)
> > And what's 'integrated' mean (must include some library)?
Yes. In Python, regular expressions are just
another function library - you use them like
in Java or C.
In Perl, it's part of the core language, you
Hi John
>>import re
>>
>>t = 'blue socks and red shoes'
>>p = re.compile('(blue|white|red)')
>>if p.match(t):
>
> What do you expect when t == "green socks and red shoes"? Is it possible
> that you mean to use search() rather than match()?
This is interesting.
What's in this exam
Hi Duncan
> There is no need to compile the regular expression in advance in Python
> either:
> ...
> The only advantage to compiling in advance is a small speed up, and most of
> the time that won't be significant.
I read 'some' introductions into Python Regexes
and got confused in the first
Hi John
>> But what would be an appropriate use
>> of search() vs. match()? When to use what?
>
> ReadTheFantasticManual :-)
>From the manual you mentioned, i don't get
the point of 'match'. So why should you use
an extra function entry match(),
re.match('whatever', t):
which is, according
Hi,
> Is it possible to import data from Excel for
> doing numerical analysis in Python? If so how?
use John Machins glamouros 'xlrd'
http://www.lexicon.net/sjmachin/xlrd.htm
form his documentation:
import xlrd
book = xlrd.open_workbook("myfile.xls")
print "The number of worksheets
Hi Duncan
> Nick Craig-Wood wrote:
>> Which translates to
>> match = re.search('(blue|white|red)', t)
>> if match:
>> else:
>> if match:
>> else:
>> if match:
>
> This of course gives priority to colours and only looks for garments or
> footwear if the it hasn't matched o
Hi Davy
> When I type 3.0/5.0, the result is 0.5...
try:
>>> print (3.0/5.0)
0.6
> Is there some precision loss? And how to overcome it?
Make sure the result gets piped
through some floating point con-
version (like print, %s etc.)
BTW, the 0.59998 value
is the "exact" calcul
Hi blair.bethwaite
> I want a tool that can enumerate a regex,
> with support for generating each string
> described by the regex in some predefined order.
If you run the regex against some target
string, this is gonna be easy (but maybe
not what you want).
If you have the string 'Python' and
Hi mpeters42 & John
> With a more complex pattern (like 'a.a': match any character between
> two 'a' characters) this will get the length, but not what character is
> between the a's.
Lets take this as a starting point for another example
that comes to mind. You have a string of characters
inters
AndyL wrote:
>> $ python some_program.py | tee output.log
> Thx again. Python is cool, do that in C++ or Java :-)
Yes, thats obviously true ;-)
$> javac someprogram.java;
$> java someprogram | tee output.log
$> g++ someother.cpp -o someother
$> ./someother | tee output.log
SCNR,
Mirco
--
http
Hi John
> rg = r'(\w)(?=(.)\1)'
>
> That would at least isolate the number, although you'd still have to get
> it out of the list/tuple.
I have no idea how to do this
in Python in a terse way - but
I'll try ;-)
In Perl, its easy. Here, the
"match construct" (\w)(?=(.)\1)
returns all captures in
Hi don
> I have a string from a clearcase cleartool ls command.
> /main/parallel_branch_1/release_branch_1.0/dbg_for_python/CHECKEDOUT
> from /main/parallel_branch_1/release_branch_1.0/4
> I want to write a regex that gives me the branch the file was
> checkedout on ,in this case - 'dbg_for_python
Hi John
> Ah, I see the difference. In Python you get a list of tuples, so there
> seems to be a little extra work to do to get the number out.
Dohh, after two cups of coffee
ans several bars of chocolate
I eventually mad(e) it ;-)
In Python, you have to deconstruct
the 2D-lists (here: long lis
Hi John
> Ah, I see the difference. In Python you get a list of
> tuples, so there seems to be a little extra work to do
> to get the number out.
Dohh, after two cups of coffee
ans several bars of chocolate
I eventually mad(e) it ;-)
In Python, you have to deconstruct
the 2D-lists (here: long
Hi David
> I have a hash function written by another organization that I need to use.
> It is implemented in perl. I've been attempting to decode what they are
> doing in their hash function and it is taking way too long. I've
> identified two functions in a perl module that I would like to 'call
Hi Fredrik
you brought up some terse and
somehow expressive lines with
their own beauty ...
> [this] is best done by a list comprehension:
>l = [m[1] for m in re.findall(r, t)]
>
> or, [...] a generator expression:
>g = (m[1] for m in re.findall(r, t))
>
> or
>process(m[1] for m in
Hi Edward
>Raw -Blanks -Comments
>lines chars lines chars lines chars
> mirror.py 16746321324597 1184009
> mirror.pl 30958362115647 1844790
Maybe somebody would chang
after all, somebody dumped some
backup of his brain to use-net:
> Software Needs Philosophers
> by Steve Yegge, 2006-04-15.
including lots of personal details.
So what I basically took from it
is written in this paragraph:
> I was born and raised a Roman Catholic, and I renounced it when I was
Thus spoke D H (on 2006-05-25 23:12):
> Fredrik Lundh wrote:
>> if you don't know how to do things, you don't need to post.
>
> He already posted ...
Based on your Text, you can (in Perl, of course ;-)
extract the Goedel-Number sequence (prime number
sequence) of it:
use Acme::Goedelize;
Hello vj
> I'll try and do as much as possible in pexpect but am sure I'll have do
> some significant perl. Any suggestions on what is the best way to get
> upto speed on perl?
Perl is (imho) much more complex and
somehow more powerful than Python
(if you can handle it) - it has more
development
Hi momobear
> then how can I convert it to a int list? I read about struct and array,
> I think they are not suitable, since I don't know how long will the
> buffer is. I know if I write a plugins modules in C should works, but
> that's really upset to tell to myself there is no way in Python.
th
John Salerno wrote:
> There is an article on oreilly.net's OnLamp site called "The World's
> Most Maintainable Programming Language"
> (http://www.oreillynet.com/onlamp/blog/2006/03/the_worlds_most_maintainable_p.html).
There is one really interessting (imho) point
in the last part that struck me
Hi Ralf
>> Perl, named after Pearl Biggar (Larry Wall’s fiancée),
>
> His wife was Gloria since at least 1979, perl was published
> in 1987. This seems to be an insider joke (he wanted to call
> the language "Gloria" first, then "pearl", then "perl").
Thanks for pointing this out ;-)
This mak
Jay wrote:
> I have compleated the beginers guide to python
> http://www.freenetpages.co.uk/hp/alan.gauld/.
> then i found the Toolkit Tkinter and started on that. its graight and
> av made lots of apps to help me with litle things but i have a big
> problem. the CLASS method.
Ledds viddy, m
Hi John
> Because of my 'novice-ness' in programming, I had always thought that C
> was replaced by C++ and wasn't really used anymore today. I know that's
> not the case at all now, but I'm still curious how much C is used
> anymore in programming today, and what purpose it serves.
There is
Hi John
> It's just that I obessively like to learn new things,
> and I keep moving on to new subjects once I've 'learned'
> something well enough.
Ha!
So learn 'Perl' then - you'll never ever
get over this point ... ;-))
And if you, against all odds, think you
master it now - zon, a new P
Hi Scott
your summary looks very concise and
good to read. I'd like to make some
minor additions,
> C can express neither exceptions nor coroutines (nor their fancy cousin,
> continuations), which could be and were expressed in assembly. Nor does
> C provide memory management. A few library fu
70 matches
Mail list logo