Remember us? It's your friendly CPython release team and we have something
we think you may like: The new alpha release of Python 3.10 is here, now
with 100% more pattern matching. If I were you, I would download it and
start playing with it. Extra points if you report us any bugs you find
Remember us? It's your friendly CPython release team and we have something
we think you may like: The new alpha release of Python 3.10 is here, now
with 100% more pattern matching. If I were you, I would download it and
start playing with it. Extra points if you report us any bugs you find
I am looking to see if there is prior work, or design ideas for implementing
pattern-matched guard statements in a very natural format for python
programmers.
For those not familiar with pattern matching in [SCALA][1], [Erlang][2], or
[F#][3]
They all have constructs similiar to:
When
Thanks works fine : )
--
https://mail.python.org/mailman/listinfo/python-list
On 30 May 2016 at 10:03, Ganesh Pal wrote:
> Thanks Matt for the reply and lovely analysis . I was trying to complicate
> the simple task :(
>
> Here is how the code looks now , the whole idea was just to match the
> pattern and return it
>
>
> def get_block(block):
>
> cmd = "get_block_info
On Sun, May 29, 2016 at 10:32 PM, Matt Wheeler wrote:
>
>
> This doesn't seem to exactly match your code below, i.e. your code is
> attempting to construct a tuple from groups 1 through 4. To meet this
> specification I could just `return re.search('(?<=\(block
> )[^(]*(?=\))', stdout).group()`
>
On 28 May 2016 at 19:12, Ganesh Pal wrote:
> Dear Python friends,
>
> I am on Python 2.7 and Linux . I am trying to extract the address
> "1,5,147456:8192" from the below stdout using re.search
>
> (Pdb) stdout
> 'linux-host-machine-1: Block Address for 1,5,27320320:8192 (block
> 1,5,147456:8192)
The matched.groups() will group the pattern based with ","
(Pdb) matched.groups()
*('1', '0', '1375772672', '8192')*
but I wanted to retain the output as *'1,0,1375772672:8192' ,*
(Pdb) matched.groups()
('1', '0', '1375772672', '8192')
(Pdb) matched.group()
'Block Address for 1,0,1376034816:81
> Perhaps:
> map(int, re.search(search_pat, stdout).groups())
>
>
>
Thanks Albert map saved me many lines of code but map returns a list I
will have to convert the list to string again
Below is how Iam planning to teh conversion
>>> block = map(int, re.search(search_pat, stdout).groups())
>>> p
> Date: Sat, 28 May 2016 23:48:16 +0530
> Subject: re.search - Pattern matching review ( Apologies re sending)
> From: ganesh1...@gmail.com
> To: python-list@python.org
>
> Dear Python friends,
>
> I am on Python 2.7 and Linux . I am trying to extract the address
>
Dear Python friends,
I am on Python 2.7 and Linux . I am trying to extract the address
"1,5,147456:8192" from the below stdout using re.search
(Pdb) stdout
'linux-host-machine-1: Block Address for 1,5,27320320:8192 (block
1,5,147456:8192) --\nlinux-host-machine-1: magic
0xdeaff2fe mark_c
Dear Python friends,
I am on Python 2.7 and Linux . I am trying to extract the address
"1,5,147456:8192" from the below stdout using re.search
(Pdb) stdout
'linux-host-machine-1: Block Address for 1,5,27320320:8192 (block
1,5,147456:8192) --\nlinux-host-machine-1: magic
0xdeaff2fe mark_c
On Feb 24, 2:11 am, monkeys paw wrote:
> if I have a string such as '01/12/2011' and i want
> to reformat it as '20110112', how do i pull out the components
> of the string and reformat them into a DDMM format?
>
> I have:
>
> import re
>
> test = re.compile('\d\d\/')
> f = open('test.html')
On Feb 23, 9:11 pm, monkeys paw wrote:
> if I have a string such as '01/12/2011' and i want
> to reformat it as '20110112', how do i pull out the components
> of the string and reformat them into a DDMM format?
>
> I have:
>
> import re
>
> test = re.compile('\d\d\/')
> f = open('test.html')
if I have a string such as '01/12/2011' and i want
to reformat it as '20110112', how do i pull out the components
of the string and reformat them into a DDMM format?
I have:
import re
test = re.compile('dd/')
f = open('test.html') # This file contains the html dates
for line in f:
if
by my previous statement, however. If you're
trying to parse HTML, use an HTML parser. Using a regex like this is
perfectly fine for parsing the CDATA text inside the HTML element,
but pattern matching the HTML markup itself is madness.
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, Feb 23, 2011 at 6:37 PM, Steven D'Aprano
wrote:
> On Wed, 23 Feb 2011 21:11:53 -0500, monkeys paw wrote:
>> if I have a string such as '01/12/2011' and i want to reformat
>> it as '20110112', how do i pull out the components of the string and
>> reformat them into a DDMM format?
>
> da
On Wed, 23 Feb 2011 21:11:53 -0500, monkeys paw wrote:
> if I have a string such as '01/12/2011' and i want to reformat
> it as '20110112', how do i pull out the components of the string and
> reformat them into a DDMM format?
data = '01/12/2011'
# Throw away tags.
data = data[4:-5]
# Separat
In article ,
monkeys paw wrote:
> if I have a string such as '01/12/2011' and i want
> to reformat it as '20110112', how do i pull out the components
> of the string and reformat them into a DDMM format?
>
> I have:
>
> import re
>
> test = re.compile('\d\d\/')
> f = open('test.html') #
if I have a string such as '01/12/2011' and i want
to reformat it as '20110112', how do i pull out the components
of the string and reformat them into a DDMM format?
I have:
import re
test = re.compile('\d\d\/')
f = open('test.html') # This file contains the html dates
for line in f:
On Thu, Dec 16, 2010 at 2:34 AM, Chris Rebert wrote:
> On Wed, Dec 15, 2010 at 6:22 PM, Katie T wrote:
>> On Wed, Dec 15, 2010 at 9:21 PM, jupiter wrote:
>>> Hi People,
>>>
>>> I need some ideas on how to find pattern in random data series like stock
>>> chart.
>>>
>>> What I want is to be able
On Wed, Dec 15, 2010 at 6:22 PM, Katie T wrote:
> On Wed, Dec 15, 2010 at 9:21 PM, jupiter wrote:
>> Hi People,
>>
>> I need some ideas on how to find pattern in random data series like stock
>> chart.
>>
>> What I want is to be able to find Head & Shoulder pattern in chart.
>
> Have a look at t
On Wed, Dec 15, 2010 at 9:21 PM, jupiter wrote:
> Hi People,
>
>
> I need some ideas on how to find pattern in random data series like stock
> chart.
>
>
> What I want is to be able to find Head & Shoulder pattern in chart.
Have a look at the references in:
http://www.dpem.tuc.gr/fel/fm2009/Pap
Hi People,
I need some ideas on how to find pattern in random data series like stock
chart.
What I want is to be able to find Head & Shoulder pattern in chart.
Thanx
Anil
--
http://mail.python.org/mailman/listinfo/python-list
On 07/16/2010 02:20 PM, Chad Kellerman wrote:
Greetings,
I have some code that I wrote and know there is a better way to
write it. I wonder if anyone could point me in the right direction
on making this 'cleaner'.
I have two lists: liveHostList = [ app11, app12, web11, web12, hos
Chad Kellerman wrote:
Greetings,
I have some code that I wrote and know there is a better way to
write it. I wonder if anyone could point me in the right direction
on making this 'cleaner'.
I have two lists: liveHostList = [ app11, app12, web11, web12, host11 ]
Greetings,
I have some code that I wrote and know there is a better way to
write it. I wonder if anyone could point me in the right direction
on making this 'cleaner'.
I have two lists: liveHostList = [ app11, app12, web11, web12, host11 ]
stageHos
> BTW, Please don't ask "Why do you want to do like this"
No, I don't ask although it would be the interesting aspect for me ;)
--
http://mail.python.org/mailman/listinfo/python-list
In article <358b227c-d836-4243-b79a-57258590a...@a10g2000pre.googlegroups.com>,
metal wrote:
>
>I want to get pattern matching like OCaml in python(ref:http://
>en.wikipedia.org/wiki/Tagged_union)
>
>I consider the syntax:
>
>def decl():
> def Plus(expr, expr
I want to get pattern matching like OCaml in python(ref:http://
en.wikipedia.org/wiki/Tagged_union)
I consider the syntax:
def decl():
def Plus(expr, expr): pass
def Minus(expr, expr): pass
def Times(expr, expr): pass
def Divide(expr, expr): pass
def Value
Peter Otten wrote:
Terry Reedy wrote:
>>> a,b,*rest = list(range(10))
The list() call is superfluous.
Agreed, even in Py3 when range() returns a range object rather than a list.
--
http://mail.python.org/mailman/listinfo/python-list
On Thu, May 28, 2009 at 3:57 PM, Terry Reedy wrote:
> guthrie wrote:
>>
>> I want to do a functional like pattern match to get teh first two
>> elements, and then the rest of an array return value.
>>
>> For example, assume that perms(x) returns a list of values, and I want
>> to do this:
>> se
Terry Reedy wrote:
> >>> a,b,*rest = list(range(10))
The list() call is superfluous.
--
http://mail.python.org/mailman/listinfo/python-list
Many thanks to all; perfect solution!
--
http://mail.python.org/mailman/listinfo/python-list
On Thu, 28 May 2009 18:57:42 -0400, Terry Reedy wrote:
> >>> a,b,*rest = list(range(10))
That fails in Python 2.5 and 2.6.
>>> a,b,*rest = list(range(10))
File "", line 1
a,b,*rest = list(range(10))
^
SyntaxError: invalid syntax
--
Steven
--
http://mail.python.org/mailman/li
Terry Reedy:
> >>> a,b,*rest = list(range(10))
> >>> a,b,rest
> (0, 1, [2, 3, 4, 5, 6, 7, 8, 9])
> >>> a,*rest,b = 'abcdefgh'
> >>> a,rest,b
> ('a', ['b', 'c', 'd', 'e', 'f', 'g'], 'h')
For the next few years I generally suggest to specify the Python
version too (if it's 2.x or 3.x).
This is P
On May 28, 5:43 pm, guthrie wrote:
> I want to do a functional like pattern match to get teh first two
> elements, and then the rest of an array return value.
>
> For example, assume that perms(x) returns a list of values, and I want
> to do this:
> seq=perms(x)
>
> a = seq[0]
> b = se
guthrie wrote:
I want to do a functional like pattern match to get teh first two
elements, and then the rest of an array return value.
For example, assume that perms(x) returns a list of values, and I want
to do this:
seq=perms(x)
a = seq[0]
b = seq[1]
rest = seq[2:]
Of course I
I want to do a functional like pattern match to get teh first two
elements, and then the rest of an array return value.
For example, assume that perms(x) returns a list of values, and I want
to do this:
seq=perms(x)
a = seq[0]
b = seq[1]
rest = seq[2:]
Of course I can shorten to:
> Fair enough. To help you understand the method I used, I'll give you
> this hint. It's true that regex on works on strings. However, is there
> any way to convert arbitrarily complex data structures to string
> representations? You don't need to be an experienced Python user to
> answer to this ;
something like:
>
> > > Another solution is to use a better (different) language, that has
> > > built-in pattern matching, or allows to create one.
>
> > > Bye,
> > > bearophile
>
> > Btw, Python's stdlib includes a regular expression lib
On Jun 20, 1:45 am, Chris <[EMAIL PROTECTED]> wrote:
> On Jun 17, 1:09 pm, [EMAIL PROTECTED] wrote:
>
> > Kirk Strauser:
>
> > > Hint: recursion. Your general algorithm will be something like:
>
> > Another solution is to use a better (different) language,
On Jun 20, 1:44 am, Chris <[EMAIL PROTECTED]> wrote:
> Thanks for your help. Those weren't quite what I was looking for, but
> I ended up figuring it out on my own. Turns out you can actually
> search nested Python lists using simple regular expressions.
Strange?
How do you match nested '[' ... ']
On Jun 20, 10:45 am, Chris <[EMAIL PROTECTED]> wrote:
> On Jun 17, 1:09 pm, [EMAIL PROTECTED] wrote:
>
> > Kirk Strauser:
>
> > > Hint: recursion. Your general algorithm will be something like:
>
> > Another solution is to use a better (different) language,
On Jun 17, 1:09 pm, [EMAIL PROTECTED] wrote:
> Kirk Strauser:
>
> > Hint: recursion. Your general algorithm will be something like:
>
> Another solution is to use a better (different) language, that has
> built-in pattern matching, or allows to create one.
>
> Bye,
Thanks for your help. Those weren't quite what I was looking for, but
I ended up figuring it out on my own. Turns out you can actually
search nested Python lists using simple regular expressions.
--
http://mail.python.org/mailman/listinfo/python-list
Kirk Strauser:
> Hint: recursion. Your general algorithm will be something like:
Another solution is to use a better (different) language, that has
built-in pattern matching, or allows to create one.
Bye,
bearophile
--
http://mail.python.org/mailman/listinfo/python-list
At 2008-06-17T05:55:52Z, Chris <[EMAIL PROTECTED]> writes:
> Is anyone aware of any prior work done with searching or matching a
> pattern over nested Python lists? I have this problem where I have a
> list like:
>
> [1, 2, [1, 2, [1, 7], 9, 9], 10]
>
> and I'd like to search for the pattern [1, 2
Is anyone aware of any prior work done with searching or matching a
pattern over nested Python lists? I have this problem where I have a
list like:
[1, 2, [1, 2, [1, 7], 9, 9], 10]
and I'd like to search for the pattern [1, 2, ANY] so that is returns:
[1, 2, [1, 2, [6, 7], 9, 9], 10]
[1, 2, [6,
ry to do this with regex pattern
> matching.
>
> Would someone be able to provide pointers regarding how do I approach
> this? Any code samples would be greatly appreciated.
The ultimate tool for handling HTML is
http://www.crummy.com/software/BeautifulSoup/
where you can do stuff like:
soup
with regex pattern
matching.
Would someone be able to provide pointers regarding how do I approach
this? Any code samples would be greatly appreciated.
Thanks.
Sam
\\ there are hundreds of thousands of items
\\Item1
123
Text1: What do I do with these lines
That span several rows
azrael wrote:
> can someone give me good links for pattern matching in images using
> python
There is a python-binding available for the OpenCV library, a collection of
state-of-the-art CV algorithms.
And it comes with a free manual
Diez
--
http://mail.python.org/mailman/listinfo/
can someone give me good links for pattern matching in images using
python
--
http://mail.python.org/mailman/listinfo/python-list
Steve Holden wrote:
> Xah Lee wrote:
...
> > This project was undertaken as a response to a challenge put forth to
> > me with a $100 reward, on 2005-04-12 on comp.lang.python newsgroup. I
> > never received the due reward.
> >
> Your reading skills must be terrible. You never received the reward
>
Xah Lee wrote:
> Xah Lee wrote:
> « the Python regex documentation is available at:
> http://xahlee.org/perl-python/python_re-write/lib/module-re.html ...»
>
> Jürgen Exner wrote:
> «Yeah, sure, and the Perl regex documentation is available at 'perldoc
> perlre'. So what? Is that anything new or
Xah Lee wrote:
« the Python regex documentation is available at:
http://xahlee.org/perl-python/python_re-write/lib/module-re.html ...»
Jürgen Exner wrote:
«Yeah, sure, and the Perl regex documentation is available at 'perldoc
perlre'. So what? Is that anything new or surprising?»
It is of inter
Ilias Lazaridis wrote:
> Xah Lee wrote:
>> the Python regex documentation is available at:
>> http://xahlee.org/perl-python/python_re-write/lib/module-re.html
Yeah, sure, and the Perl regex documentation is available at 'perldoc
perlre'.
So what? Is that anything new or surprising?
jue
--
ht
Paul McGuire wrote:
> "Steve Holden" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
>
> >
> > Ilias Lazardis meets Xah Lee. I just *know* we're in for trouble now ...
> >
> > regards
> > Steve
>
> A sign of the End Times, perhaps?
>
Indeed. Armageddon outa here ;-)
--
http://
"Steve Holden" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
> Ilias Lazardis meets Xah Lee. I just *know* we're in for trouble now ...
>
> regards
> Steve
A sign of the End Times, perhaps?
-- Paul
--
http://mail.python.org/mailman/listinfo/python-list
Ilias Lazaridis wrote:
> [followup to c.l.py]
>
> Xah Lee wrote:
>
>>the Python regex documentation is available at:
>>http://xahlee.org/perl-python/python_re-write/lib/module-re.html
>>
>>Note that, i've just made the terms of use clear.
>>
>>Also, can anyone answer what is the precise terms of
[followup to c.l.py]
Xah Lee wrote:
> the Python regex documentation is available at:
> http://xahlee.org/perl-python/python_re-write/lib/module-re.html
>
> Note that, i've just made the terms of use clear.
>
> Also, can anyone answer what is the precise terms of license of the
> official python
e:
• Scsh manual, Chapter 6: Pattern-matching strings with regular
expressions
http://www.scsh.net/docu/html/man-Z-H-7.html
• Mathematica Book, section 2.8.4 String Patterns
http://documents.wolfram.com/mathematica/book/section-2.8.4
Xah
[EMAIL PROTECTED]
∑ http://xahlee.org/
--
http://mail.
>You can do this with a regular expression...
I tried the plain RE approach and found it no faster than my
direct-coded version. Anyone have any ideas on how to code this problem
elegantly without RE? My code is long and cumbersome - 200 lines! Speed
is my primary concern but low LOC would be nice
[EMAIL PROTECTED] wrote:
> Thanks to all for the various good approaches. Kent's plain RE approach
> seems the most straightforward - did not know that RE can handle this
> situation - good to know!
Thanks to Eddie Corns also who showed how to express the problem as a
parsing problem.
I am also
Thanks to all for the various good approaches. Kent's plain RE approach
seems the most straightforward - did not know that RE can handle this
situation - good to know!
--
http://mail.python.org/mailman/listinfo/python-list
Kent Johnson <[EMAIL PROTECTED]> writes:
>Eddie Corns wrote:
>> If I get time I'll try to get this working in Sam Wilmott's Python pattern
>> matching library.
>>
>> What fun!
>Cool! I have to get in on the fun :-)
>This program uses Sa
Jim Lewis wrote:
> Anyone have experience with string pattern matching?
> I need a fast way to match variables to strings. Example:
>
> string - variables
>
> abcaaab - xyz
> abca - xy
> eeabcac - vxw
>
> x matches abc
> y matches a
> z mat
Eddie Corns wrote:
> Off topic I know but I've been learning snobol pattern matching recently so I
> thought I'd give this one a bash. Here is my effort:
>
> define('foo(str)')
> &fullscan = 1
> '/abcaaab/abca/
"Jim Lewis" <[EMAIL PROTECTED]> writes:
>Anyone have experience with string pattern matching?
>I need a fast way to match variables to strings. Example:
>string - variables
>
>abcaaab - xyz
>abca - xy
>eeabcac - vxw
>x matches abc
>y matc
Thanks for the interesting and detailed analysis. In my case I don't
need all possible answers by rather the first "greedy" match. Seems
like there might be some recursive approach.
--
http://mail.python.org/mailman/listinfo/python-list
Firstly sort variable expressions by its length
xy = 'abca'
xyz = 'abcaaab'
vxw = 'eeabcac'
Expand all expressions by its values except itself
xy = 'abca'
'abca' z = 'abcaaab'
vxw = 'eeabcac'
Cut all left and right matches
xy = 'abca'
z = 'aab'
vxw = 'eeabcac'
Repeat until you
Anyone have experience with string pattern matching?
I need a fast way to match variables to strings. Example:
string - variables
abcaaab - xyz
abca - xy
eeabcac - vxw
x matches abc
y matches a
z matches aab
w maches ac
v maches ee
--
http://mail.python.org/mailman/listinfo/python
BartlebyScrivener wrote:
> Even without the marker, can't you do:
>
> sentence = "the fabric is red"
> colors = ["red", "white", "blue"]
>
> for color in colors:
> if (sentence.find(color) > 0):
> print color, sentence.find(color)
>
That depends on whether you're only looking for who
Even without the marker, can't you do:
sentence = "the fabric is red"
colors = ["red", "white", "blue"]
for color in colors:
if (sentence.find(color) > 0):
print color, sentence.find(color)
--
http://mail.python.org/mailman/listinfo/python-list
Taking you literally, I'm not sure you need regex. If you know or can
find position n, then can't you just:
sentence = "the color is $red"
patterns = ["blue","red","yellow"]
pos = sentence.find("$")
for x in patterns:
if x==sentence[pos+1:]:
print x, pos+1
But maybe I'm oversimplifyin
On Mon, 12 Dec 2005 [EMAIL PROTECTED] wrote:
> I'd need to perform simple pattern matching within a string using a list
> of possible patterns. For example, I want to know if the substring
> starting at position n matches any of the string I have a list, as
> below:
>
>
[EMAIL PROTECTED] wrote:
> Hi,
>
> I'd need to perform simple pattern matching within a string using a
> list of possible patterns. For example, I want to know if the substring
> starting at position n matches any of the string I have a list, as
> below:
>
>
Hi,
I'd need to perform simple pattern matching within a string using a
list of possible patterns. For example, I want to know if the substring
starting at position n matches any of the string I have a list, as
below:
sentence = "the color is $red"
patterns = ["blue&
Sorry for the confusion, I think my example was unclear. Thank you Mike
for this piece of code who solves a part of my problem. In fact, the
sequences are unknown at the beginning, so the first part of the code
has to find possible sequences and if those sequences are repeated,
counts how many time
"Séb" <[EMAIL PROTECTED]> writes:
> Hi everybody,
>
> Thanks for the time taken to answer my question. Unfortunatly, it seems
> that there's a little confusion about what I want to do.
>
> In fact, I don't want to search for a particular path between
> computers. What I really want is to detect se
Hi everybody,
Thanks for the time taken to answer my question. Unfortunatly, it seems
that there's a little confusion about what I want to do.
In fact, I don't want to search for a particular path between
computers. What I really want is to detect sequences of connection that
are repeated along t
"Séb" <[EMAIL PROTECTED]> writes:
>> Essentially, if I understand correctly, you want to detect LOOPS given a
>> sequence of directed connections A->B. "loop detection" and "graph"
>> would then be the keywords to search for, in this case.
>
> Exactly, but the sequence has to be discovered by the
Séb wrote:
> 1) I have a list of connexion between some computers. This list has
> this format :
It looks like you want graph theory.
> Ip A Date Ip B
> ...... ...
> 192.168.0.119.10.2005 192.168.0.2
> 192.168.0.319.10.2
> Essentially, if I understand correctly, you want to detect LOOPS given a
> sequence of directed connections A->B. "loop detection" and "graph"
> would then be the keywords to search for, in this case.
Exactly, but the sequence has to be discovered by the piece of code !
> Does this "then" imp
Séb <[EMAIL PROTECTED]> wrote:
> Hi everyone,
>
> I'm relatively new to python and I want to write a piece of code who do
> the following work for data mining purpose :
Essentially, if I understand correctly, you want to detect LOOPS given a
sequence of directed connections A->B. "loop detectio
Hi everyone,
I'm relatively new to python and I want to write a piece of code who do
the following work for data mining purpose :
1) I have a list of connexion between some computers. This list has
this format :
Ip A Date Ip B
...... ...
192
Hello!
I was trying to create a program to search for the largest common
subsetstring among filenames in a directory, them move the filenames
to the substring's name. I have succeeded, with help, in doing so and
here is the code.
Thanks for your help!
--- Code ---
#This program was created wit
tiissa <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>...
> Synonymous wrote:
> > tiissa <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>...
> >
> >>tiissa wrote:
> >>
> >>>If you know the number of characters to match can't you just compare
> >>>slices?
> >>
> >>If you
John Machin <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>...
> On 17 Apr 2005 18:12:19 -0700, [EMAIL PROTECTED] (Synonymous)
> wrote:
>
> >
> >I will look for a Left$(str) function that looks at the first X
> >characters for python :)).
> >
>
> Wild goose chase alert! AFAIK there
Synonymous wrote:
tiissa <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>...
tiissa wrote:
If you know the number of characters to match can't you just compare
slices?
If you don't, you can still do it by hand:
In [7]: def cmp(s1,s2):
: diff_map=[chr(s1[i]!=s2[i]) for i in r
On 17 Apr 2005 18:12:19 -0700, [EMAIL PROTECTED] (Synonymous)
wrote:
>
>I will look for a Left$(str) function that looks at the first X
>characters for python :)).
>
Wild goose chase alert! AFAIK there isn't one. Python uses slice
notation instead of left/mid/right/substr/whatever functions. I do
tiissa <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>...
> tiissa wrote:
> > If you know the number of characters to match can't you just compare
> > slices?
> If you don't, you can still do it by hand:
>
> In [7]: def cmp(s1,s2):
>: diff_map=[chr(s1[i]!=s2[i]) for i in
tiissa wrote:
Synonymous wrote:
Can regular expressions compare file names to one another. It seems RE
can only compare with input i give it, while I want it to compare
amongst itself and give me matches if the first x characters are
similiar.
Do you have to use regular expressions?
If you know the
tiissa wrote:
If you know the number of characters to match can't you just compare
slices?
If you don't, you can still do it by hand:
In [7]: def cmp(s1,s2):
: diff_map=[chr(s1[i]!=s2[i]) for i in range(min(len(s1),
len(s2)))]
: diff_index=''.join(diff_map).find(chr(True))
.
Synonymous wrote:
Can regular expressions compare file names to one another. It seems RE
can only compare with input i give it, while I want it to compare
amongst itself and give me matches if the first x characters are
similiar.
Do you have to use regular expressions?
If you know the number of cha
Hello,
Can regular expressions compare file names to one another. It seems RE
can only compare with input i give it, while I want it to compare
amongst itself and give me matches if the first x characters are
similiar.
For example:
cccat
cccap
cccan
dddfa
dddfg
dddfz
Would result in the 'ddd' a
Le 24 Mar 2005 06:16:12 -0800, Ben a écrit :
>
> Below is a few sample lines. There is the name followed by the class
> (not important) followed by 5 digits each of which can range 1-9 and
> each detail a different ability, such as fitness, attacking ability
> etc. Finally the preferred foot is st
George Sakkis wrote:
> B
> "Ben" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > I'm currently trying to develop a demonstrator in python for an
> > ontology of a football team. At present all the fit players are
> > exported to a text document.
> >
> > The program reads the docu
Ben,
Others have answered your specific questions, but I thought
I'd use this opportunity to make a general statement. Unlike
other programming languages, Python doesn't make its built-in
functions keywords. You should never, ever, ever name a
variable 'list' (the same is true of dict, tuple, st
First, if you're going to loop over each line, do it like this:
for line in file('playerlist.txt'):
#do stuff here
Second, this statement is referencing the *second* item in the list,
not the first:
match = ph.match(list[1])
Third, a simple splitting of the lines by some delimiter character
1 - 100 of 117 matches
Mail list logo