C Smith wrote:
###
class Ring(list):
def __init__(self, l):
self[:] = l
self._zero = 0
def turn(self, incr=1):
self._zero+=incr
def __getitem__(self, i):
return self[(i-self._zero)%len(self)]
l=Ring(range(10))
print l
l.turn(5)
print l#same a
Sean Perry wrote:
C Smith wrote:
###
class Ring(list):
def __init__(self, l):
self[:] = l
self._zero = 0
def turn(self, incr=1):
self._zero+=incr
def __getitem__(self, i):
return self[(i-self._zero)%len(self)]
l=Ring(range(10))
print l
l.turn(5)
pr
Kent Johnson wrote:
Paul Tremblay wrote:
So I just make a file called /etc/router_passwords and include
something like
WRT54G username password
Then parse the file, and supply the info to the password handler? This
is easy to do, and I guess it is secure.
The book "Foundations of Python Network P
Danny Yoo wrote:
[Windows bashing cut]
Python's support for Windows stuff is actually quite good, thanks to the
work of Mark Hammond:
http://starship.python.net/crew/mhammond/
A lot of us here do use Windows for COM programming. Let's get back to
talking about Python programming and let's help
Dave,
> >>>
> >>>
> >>> import os.path
> >>> print os.path.expanduser('~/memo.txt')
> C:\Documents and Settings\Administrator/memo.txt
> >>> f = open(os.path.expanduser('~/memo.txt'))
> Traceback (most recent call last):
> File "", line 1, in ?
> f = open(os.path.expanduser('~/memo.txt'))
> I
I'm having some strange results using the "or" operator. In every test
I do I'm matching both sides of the "|" metacharacter, not one or the
other as all documentation says it should be (the parser supposedly
scans left to right, using the first match it finds and ignoring the
rest). It should
Hi Mike,
Do you get the same results for a search pattern of 'A|B'?
On Wed, 9 Mar 2005 11:11:57 -0800, Mike Hall
<[EMAIL PROTECTED]> wrote:
> I'm having some strange results using the "or" operator. In every test
> I do I'm matching both sides of the "|" metacharacter, not one or the
> other a
Indeed I do:
>>> import re
>>> x = re.compile('A|B')
>>> s = " Q A R B C"
>>> r = x.sub("13", s)
>>> print r
Q 13 R 13 C
On Mar 9, 2005, at 12:09 PM, Liam Clarke wrote:
Hi Mike,
Do you get the same results for a search pattern of 'A|B'?
On Wed, 9 Mar 2005 11:11:57 -0800, Mike Hall
<[EMAIL PROTECT
But I only want to ignore "B" if "A" is a match. If "A" is not a match,
I'd like it to advance on to "B".
On Mar 9, 2005, at 12:07 PM, Marcos Mendonça wrote:
Hi
Not and regexp expert. But it seems to me that if you want to ignora
"B" then it should be
(A) | (^B)
Hope it helps!
On Wed, 9 Mar 2005
Actually, you should get that anyway...
"""
|
Alternation, or the ``or'' operator. If A and B are regular
expressions, A|B will match any string that matches either "A" or "B".
| has very low precedence in order to make it work reasonably when
you're alternating multi-character strings. Crow|S
Oops
I mean
for i in range(len(k)):
i f k[i] == 'A' or k[i]=='B':
k[i ]= 13
On Thu, 10 Mar 2005 09:28:59 +1300, Liam Clarke <[EMAIL PROTECTED]> wrote:
> Actually, you should get that anyway...
>
> """
> |
> Alternation, or the ``or'' operator. If A and B are regular
> express
but yeah, it
seems you're expecting it to examine the string as a whole.
I guess I was, good point.
On Mar 9, 2005, at 12:28 PM, Liam Clarke wrote:
Actually, you should get that anyway...
"""
|
Alternation, or the ``or'' operator. If A and B are regular
expressions, A|B will match any string t
> > >>>
> > >>>
> > >>> import os.path
> > >>> print os.path.expanduser('~/memo.txt')
> > C:\Documents and Settings\Administrator/memo.txt
> > >>> f = open(os.path.expanduser('~/memo.txt'))
> > Traceback (most recent call last):
> > File "", line 1, in ?
> > f = open(os.path.expanduser('~/memo.txt'
On Wed, Mar 09, 2005 at 08:29:46AM -0500, Kent Johnson wrote:
>
> Kent Johnson wrote:
> >Paul Tremblay wrote:
> >
> >>So I just make a file called /etc/router_passwords and include
> >>something like
> >>WRT54G username password
> >>
> >>Then parse the file, and supply the info to the password ha
Mike Hall wrote:
A simple example will show what I mean:
>>> import re
>>> x = re.compile(r"(A) | (B)")
>>> s = "X R A Y B E"
>>> r = x.sub("13", s)
>>> print r
X R 13Y13 E
...so unless I'm understanding it wrong, "B" is supposed to be ignored
if "A" is matched, yet I get both matched. I get
[EMAIL PROTECTED] wrote:
import os.path
print os.path.expanduser('~/memo.txt')
C:\Documents and Settings\Administrator/memo.txt
f = open(os.path.expanduser('~/memo.txt'))
Traceback (most recent call last):
File "", line 1, in ?
f = open(os.path.expanduser('~/memo.tx
Thanks to Sean and Kent for replies. I found a site that provided some
good examples, too, at
http://www.cafepy.com/articles/python_attributes_and_methods/
ch03s02.html
Here's a blurb from the title page:
wep page excerpt
Shalabh Chaturvedi
Copyright © 2004 Shalabh Chaturvedi
This book
C Smith wrote:
Alternatively, the list class can be appended with helpers like 'turn'
and 'segment' which can actually turn the "ring" and remove a piece
from it without worrying about the endpoint:
###
>>> class ring(list):
def turn(self, incr=1):
incr%=len(self)
self[:]
> mmm ... I kind of see what you mean.
>
> Does anyone have like a realy large shovel so I can dig a hole and hide ?
No worries, we've all been there before. Sometimes you just can't see
what's right in front of your face.
Don't let it stop you, or stop you from asking questions.
Peace
Bill Mil
19 matches
Mail list logo