accept
it as a given and get on with more productive activities?
That's all very well if the language has a compromised and ad-hoc
syntax. But since Python has a nice clean syntax, it makes me
want to be associated with it by investing in its discussions. ;-)
--
Neil Cerutti
--
http
of
troubling about mutating the list. Unless the list is needed in
more than one place.
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
On 2006-11-29, Roberto Bonvallet [EMAIL PROTECTED] wrote:
BTW, iterating over range(len(a)) is an anti-pattern in Python.
Unless you're modifying elements of a, surely?
--
Neil Cerutti
You can't give him that cutback lane. He's so fast, and he sees it so well. He
can also run away from you
)
type 'str'
i = 0
type(i)
type 'int'
That makes me wonder how he manages to store Python objects in
xml.
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
On 2006-11-29, Roberto Bonvallet [EMAIL PROTECTED] wrote:
Neil Cerutti wrote:
On 2006-11-29, Roberto Bonvallet [EMAIL PROTECTED] wrote:
BTW, iterating over range(len(a)) is an anti-pattern in Python.
Unless you're modifying elements of a, surely?
enumerate is your friend :)
for n
, ordinary file objects
qualify. Instantiation reads headers from the input object up
to a delimiter line (normally a blank line) and stores them
in the instance. The message body, following the headers, is
not consumed.
--
Neil Cerutti
We dispense with accuracy --sign at New York drug
as
the best way of removing the manual counters.
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
]
--
Neil Cerutti
I guess there are some operas I can tolerate and Italian isn't one of them.
--Music Lit Essay
--
http://mail.python.org/mailman/listinfo/python-list
On 2006-11-30, Neil Cerutti [EMAIL PROTECTED] wrote:
On 2006-11-30, John Henry [EMAIL PROTECTED] wrote:
If I have a list of say, 10 elements and I need to slice it into
irregular size list, I would have to create a bunch of temporary
variables and then regroup them afterwords, like:
# Just
-(content)-relaying sends you around in a circle
through a complex handler chain.
Being in a cycle doesn't actually prove your program will never
halt for that particular input, does it?
--
Neil Cerutti
Customers who consider our waitresses uncivil ought to see the manager --sign
at New York
']
Ok, I go out...
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
On 2006-12-02, John Machin [EMAIL PROTECTED] wrote:
Neil Cerutti wrote:
On 2006-12-02, Michel Claveau [EMAIL PROTECTED] wrote:
Hi!
Yes.
But...
Try:d = {'a': 1, 'b': 2, 'def': 123}
Ok, I go out...
How to convert a list of strings into a list of integers:
a = ['82', '4
Design and implement a full-size game. Submit it to testing,
fix all resulting bugs, help marketing design a package, ship
the game, and sell at lest 250,000 units.
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
. That
may help.
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
, but the rest seems at too
low a level for me to understand which statements are causing
the slow execution.
hw6r3.py:276(main) hw6r3.py:73(findw)(100) 26700.865
Is this the print_callees output?
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
another programmer who might be in the middle of
something. The stuffed animal often provided all the assistance
that was needed.
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
.
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
with practice.
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
think the decent people of this newsgroup are sick and tired of
being told that the decent people of this newsgroup are sick and
tired. I'm certainly not! And I'm sick and tired of being told
that I am.
--
Neil Cerutti
Sermon Outline: I. Delineate your fear II. Disown your fear III. Displace your
was supposed to be in the midst of the mind-boggling. I
meant to get back to it but haven't yet.
--
Neil Cerutti
We will sell gasoline to anyone in a glass container. --sign at Santa Fe gas
station
--
http://mail.python.org/mailman/listinfo/python-list
.
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
On 2006-12-13, hit_the_lights [EMAIL PROTECTED] wrote:
Neil Cerutti schrieb:
a[i] = b[n]
with
(setf (aref a i) (aref b n))
and the attractions of Python may make more sense.
Here Python and Lisp are equal, 7 tokens vs 7 tokens, but in
Python one has to write less since
it cannot read the original programmer's mind, and you have to
fix it manually, and risk screwing it up.
It is very easy a manual process, possibly as simple as selecting
the correct s-expr and pasting it into the right place in your
code.
--
Neil Cerutti
--
http://mail.python.org/mailman
they
would be redundant?
This could be more convenient to you, but certainly not
pythonic. Cheers,
I tried it once myself. It seemed like a feasible thing that
might work in Python. It didn't annoy me that it didn't work, but
it did seem natural to me given the syntax of comprehensions.
--
Neil
On 2006-12-14, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
Neil Cerutti wrote:
On 2006-12-13, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:
Expressions keep the same meaning even if you have to start
breaking them across lines, etc.
Yes, it's the same way in Python. Of course, not everything
On 2006-12-14, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
Neil Cerutti wrote:
On 2006-12-14, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
Neil Cerutti wrote:
On 2006-12-13, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:
Expressions keep the same meaning even if you have to start
in textwrap.wrap(text,
width=75)]
The solution will need to be instrumented in case of text that is
already quotes to one level. All in all, I recommend using Vim's
gq command or Emacs' autofill mode, which arlready do the right
thing.
--
Neil Cerutti
The Rev. Merriwether spoke briefly, much to the delight
applies to strings, which now
have plenty of methods.
--
Neil Cerutti
Weight Watchers will meet at 7 p.m. Please use large double door at the side
entrance. --Church Bulletin Blooper
--
http://mail.python.org/mailman/listinfo/python-list
()
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
a house. It doesn't make me want to
live in a cave. ;-)
--
Neil Cerutti
The third verse of Blessed Assurance will be sung without musical
accomplishment. --Church Bulletin Blooper
--
http://mail.python.org/mailman/listinfo/python-list
:
a.extend(hello)
Traceback (most recent call last):
File stdin, line 1, in module
TypeError: an integer is required
Try:
a.fromstring(hello)
--
Neil Cerutti
I have opinions of my own -- strong opinions -- but I don't always agree with
them. --George W. Bush
--
http://mail.python.org/mailman
of choice (by historical accident) Vim, doesn't yet
support it.
--
Neil Cerutti
I've had a wonderful evening, but this wasn't it. --Groucho Marx
--
http://mail.python.org/mailman/listinfo/python-list
:
int x, y;
};
The only difference between struct and class in C++ is the
default access specification of its members.
--
Neil Cerutti
For those of you who have children and don't know it, we have a nursery
downstairs. --Church Bulletin Blooper
--
http://mail.python.org/mailman/listinfo/python
.
a = [(Neil Cerutti, 8025552954), (Ted Smith, 8025552281), (Barny
Fife, 8025551105)]
b = [( .join(reversed(x.split())), y) for (x, y) in a]
b
[('Cerutti Neil', '8025552954'), ('Smith Ted', '8025552281'), ('Fife Barny',
'8025551105')]
b.sort()
b
[('Cerutti Neil', '8025552954'), ('Fife Barny
On 2007-01-04, Peter Otten [EMAIL PROTECTED] wrote:
Neil Cerutti wrote:
Another trick is to factor the key application out of the
sort. This may be a good idea if when you want to minimize the
number of times your key function is called.
The idea is to mangle the list temporarily so you can
a = A()
a.foo()
print a._B__x
a.bar()
print a._B__x
Sure enough, mod2 messes up mod1's private variable.
When faced with this situation, is there any way to proceed
besides using composition instead?
--
Neil Cerutti
We've got to pause and ask ourselves: How much clean air do we
, in this case it should return:
[((3, 4), (5, 4), (16, 1)), ((3, 4), (21, 3), (0, 2)), ((5, 8), (19,
2), (0, 2))]
What do you mean by most inner tuple?
A simple list comprehension would be enough if only I knew the
number of keys/lists beforehand
len(dict.keys()).
--
Neil Cerutti
Next
struct idiom to hide data.
For example, the standard FILE pointer.
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
On 2007-01-08, Jussi Salmela [EMAIL PROTECTED] wrote:
Neil Cerutti kirjoitti:
In C one uses the pointer to opaque struct idiom to hide data.
For example, the standard FILE pointer.
To Neil Cerutti: If a programmer in C has got a pointer to some
piece of memory, that piece is at the mercy
way to determine
where the block is supposed to end.
--
Neil Cerutti
Remember in prayer the many who are sick of our church and community. --Church
Bulletin Blooper
--
http://mail.python.org/mailman/listinfo/python-list
Dog(Animal):
pass
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
)
ix = m(o_bracket, ix)
ix = m(c_bracket, ix)
ix = m(colon, ix)
if ix == old:
print Parse error at %s of %s % (proto[ix:], proto)
ix = len(proto)
return lexed_line
if __name__ == __main__:
import doctest
doctest.testmod()
--
Neil Cerutti
= self.iter.next()
except StopIteration:
if self.exhausted:
raise
else:
self.exhausted = True
return item
--
Neil Cerutti
We've got to pause and ask ourselves: How much clean air do we really need?
--Lee Iacocca
--
http
in r.groupindex:
if m.group(k):
# Find the token type.
token = (k, m.group())
I wish I could do something obvious instead, like m.name().
--
Neil Cerutti
After finding no qualified candidates for the position of principal, the
school board is pleased to announce the appointment of David
.
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
On 2007-01-10, Fredrik Lundh [EMAIL PROTECTED] wrote:
Neil Cerutti wrote:
A found some clues on lexing using the re module in Python in
an article by Martin L÷wis.
Here, each alternative in the regular expression defines a
named group. Scanning proceeds in the following steps:
1
.
--
Neil Cerutti
The concert held in Fellowship Hall was a great success. Special thanks are
due to the minister's daughter, who labored the whole evening at the piano,
which as usual fell upon her. --Church Bulletin Blooper
--
http://mail.python.org/mailman/listinfo/python-list
On 2007-01-10, Steven Bethard [EMAIL PROTECTED] wrote:
Neil Cerutti wrote:
For use in a hand-coded parser I wrote the following simple
iterator with look-ahead.
There's a recipe for this:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/304373
Note that the recipe efficiently
because Python on those platforms in
a console application, which on NT, 2000 and XP doesn't support
ANSI escape sequences. It makes IPython's appearance less cool. :-(
Try http://effbot.org/downloads/#console for color output that
works.
--
Neil Cerutti
We're going to be exciting. Of course
, base_object):
# ( copy all attributes )
...
This looks expensive. Moreover __init__ () may not be available
if it needs to to something else.
Thanks for suggestions
How does it make sense to cast a base to a derived in your
application?
--
Neil Cerutti
I'm traveling to all 51 states
the
below idiom might save you from a gotcha someday.
class JsubroutineParameters(list):
def __init__(self, alist=None):
if alist is None:
alist = []
for objekt in alist: _validateParameter(objekt)
list.__init__(self, alist)
You will no longer need to call append.
--
Neil Cerutti
/projects/spe/
--
Neil Cerutti
We don't necessarily discriminate. We simply exclude certain types of people.
--Colonel Gerald Wellman
--
http://mail.python.org/mailman/listinfo/python-list
see
any problem with it. It sounds cool.
--
Neil Cerutti
It isn't pollution that is hurting the environment; it's the impurities in our
air and water that are doing it. --Dan Quayle
--
http://mail.python.org/mailman/listinfo/python-list
' + pathname + '\test.vbs')
Use / instead of \, or \\ instead of \.
--
Neil Cerutti
Ushers will eat latecomers. --Church Bulletin Blooper
--
http://mail.python.org/mailman/listinfo/python-list
, to suppress
that trailing blank line, but I kept getting confused and
couldn't sort it out.
It would better to use the os.path module, but I couldn't find
the function in there lets me pull out path tails.
I didn't filter out stuff that didn't match the date path
convention you used.
--
Neil
]
Anyone want to argue that this is a worthwhile optimization? :)
Perhaps. But first test it with ==.
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
releases.
In other words, dir is just for fun, like monkey bars. ;)
--
Neil Cerutti
The eighth-graders will be presenting Shakespeare's Hamlet in the church
basement on Friday at 7 p.m. The congregation is invited to attend this
tragedy. --Church Bulletin Blooper
--
http://mail.python.org
('value')
AttributeError: 'NoneType' object has no attribute 'group'
When the regex doesn't match, match returns None.
--
Neil Cerutti
Strangely, in slow motion replay, the ball seemed to hang in the air for even
longer. --David Acfield
--
http://mail.python.org/mailman/listinfo/python-list
. ;-)
--
Neil Cerutti
Facts are stupid things. --Ronald Reagan
--
http://mail.python.org/mailman/listinfo/python-list
= re.search('\*\s+(\d+)', g)
r.group()
'* 4'
r.group(1)
'4'
--
Neil Cerutti
We're not afraid of challenges. It's like we always say: If you want to go out
in the rain, be prepared to get burned. --Brazillian soccer player
--
http://mail.python.org/mailman/listinfo/python-list
On 2007-01-16, Victor Polukcht [EMAIL PROTECTED] wrote:
On Jan 16, 5:40 pm, Neil Cerutti [EMAIL PROTECTED] wrote:
On 2007-01-16, Victor Polukcht [EMAIL PROTECTED] wrote:
Actually, i'm trying to get the values of first field (Global) , fourth
(200, 4), and fifth (100%) and sixth (100
++'s
std::priority_queue for that reason (unless I'm confused again).
--
Neil Cerutti
We will sell gasoline to anyone in a glass container. --sign at Santa Fe gas
station
--
http://mail.python.org/mailman/listinfo/python-list
(5.16.3).
def grouper(n, iterable, padvalue=None):
grouper(3, 'abcdefg', 'x') -- ('a','b','c'), ('d','e','f'), ('g','x','x')
return izip(*[chain(iterable, repeat(padvalue, n-1))]*n)
It's more general and cryptic than what you asked for, though.
--
Neil Cerutti
We're not afraid of challenges
On 2007-01-18, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
Neil Cerutti:
One more idea, cribbed from the linked list thread elsewhere:
it might be nice if your Heap could optionally use an
underlying collections.deque instead of a list. I don't know
how excellent Python's deque is, but it's
to help yourself. Also, use
more helpful names. With names like var1 and var2 you might as
well not used named groups.
r = re.compile(r(?x)
(?Perror [^(]+ )
(?Perrno \d+ )
\)
\s+
(?Plineno \d+ ))
This way it's clearer that there's a \) with no matching \(.
--
Neil Cerutti
On 2007-01-18, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
Neil Cerutti:
One more idea, cribbed from the linked list thread elsewhere:
it might be nice if your Heap could optionally use an
underlying collections.deque instead of a list. I don't know
how excellent Python's deque is, but it's
--
Neil Cerutti
--
Posted via a free Usenet account from http://www.teranews.com
--
http://mail.python.org/mailman/listinfo/python-list
case in cdr, but I couldn't figure out a neat way
to do it.
--
Neil Cerutti
I've had a wonderful evening, but this wasn't it. --Groucho Marx
--
Posted via a free Usenet account from http://www.teranews.com
--
http://mail.python.org/mailman/listinfo/python-list
, to Lotus Notes (ARRGH!), then a happy time using IMAP, and
now back to (ARRGH!).
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
, *objects):
return format % tuple(objects)
Since strings are immutable it's not convenient to provide a
pass-out parameter as in C. If you want to check for errors
you'll have to catch the exceptions, rather than inspect the
return value as you can in C.
--
Neil Cerutti
Symphonies of the Romantic
() at the interactive prompt to get started.
--
Neil Cerutti
Will the last person to leave please see that the perpetual light is
extinguished --sign at New England church
--
Posted via a free Usenet account from http://www.teranews.com
--
http://mail.python.org/mailman/listinfo/python-list
. A stack-based
solution (implemented using a list as a stack) should be easy enough.
--
Neil Cerutti
And now the sequence of events in no particular order. --Dan Rather
--
Posted via a free Usenet account from http://www.teranews.com
--
http://mail.python.org/mailman/listinfo/python-list
string.
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
solution informs the design of something
better.
2. a) Got to 1. a)
In the case above, I've tried to figure out what you're
specifically doing, and failed. So I don't have more specific
advice.
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
in range(5):
... foo(!)
...
0 !
1 !
2 !
3 !
4 !
The latter is not as nice, since your static variable is easy
to clobber by passing something into the function.
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
without needing to copy
them. Unfortunately it only works for one level of call. I think.
--
Neil Cerutti
--
Posted via a free Usenet account from http://www.teranews.com
--
http://mail.python.org/mailman/listinfo/python-list
to
display those chars.
What have you tried?
--
Neil Cerutti
--
Posted via a free Usenet account from http://www.teranews.com
--
http://mail.python.org/mailman/listinfo/python-list
have
#!/usr/local/bin/python
#coding: iso8859-15
Be sure to write your non-ASCII strings as unicode literals, and
then encode them just before displaying or storing them
somewhere.
--
Neil Cerutti
--
Posted via a free Usenet account from http://www.teranews.com
--
http://mail.python.org
On 2007-01-27, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
How can I convert a string to a char list?
for example
hello -- ['h','e','l','l','o']
I have been searching but I can't find my answers
list(hello)
--
http://mail.python.org/mailman/listinfo/python-list
On 2007-01-27, Thomas Dickey [EMAIL PROTECTED] wrote:
Neil Cerutti [EMAIL PROTECTED] wrote:
I don't really expect it to work, but if anything will, that
is it. Curses supports only ASCII and a some special symbol
codes defined by curses.
un - no. Curses supports whatever the flavor
| enclosure
literal ::= stringliteral | integer | longinteger | floatnumber |
imagnumber
An integer is a primary so 2.__add(1) should be valid.
Not if the tokenizer passes the parser a float.
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
div7 (700)
98
div7 (7000)
984
Heh, heh. That's reminding of the fabulous O(n) Dropsort
algorithm I saw linked from Effbot's blog.
--
Neil Cerutti
I'm tired of hearing about money, money, money, money, money. I just want to
play the game, drink Pepsi, wear Reebok. --Shaquille O'Neal
--
http
sequences.
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
, with your teacher.
Also: comp.algorithms is the usual Usenet place for discussion of
algorithms and data structures.
However most of the talk there is pretty high-falutin'.
--
Neil Cerutti
It isn't pollution that is hurting the environment; it's the impurities in our
air and water that are doing
here. You can
override most of the operators, but you cannot change their
arity, associativity, or precedence level.
--
Neil Cerutti
Let us join David and Lisa in the celebration of their wedding and bring their
happiness to a conclusion. --Church Bulletin Blooper
--
http://mail.python.org
itertools import groupby
def key_func(t):
return t[0]
groups = groupby(sorted(seq, key=key_func), key_func)
seq = []
for item in groups:
seq.append([item[0], [a[1] for a in item[1]]])
return seq
--
Neil Cerutti
Music gets more chromatic and heavy towards
On 2007-02-02, Laurent Pointal [EMAIL PROTECTED] wrote:
Neil Cerutti a écrit :
On 2007-02-02, ardief [EMAIL PROTECTED] wrote:
zip
This is a job for... duhn-duhn-DH! Captain CHAOS!
Er... I mean itertools.groupby.
zip
def key_func(t):
return t[0]
Not needed: -- from
subclasses!)
to access the member. Difficult though -- not impossible.
I think it's best to never use such names in new code. Python's
mangling is troubled, since it uses unqualified names in the
mangle, resulting in ambiguity.
--
Neil Cerutti
Ushers will eat latecomers. --Church Bulletin Blooper
if the user
supplies the second argument, and a list otherwise.
def foo(x, *args):
if len(args) == 0:
y_provided = True
y = bar
else:
y_provided = False
y = args[0]
if y_provided:
return (x, y)
else:
return [x, y]
--
Neil Cerutti
Wonderful bargains for men with 16
:
warnings.simplefilter(ignore,DeprecationWarning)
(same as using option -Wignore::DeprecationWarning on the python command
line)
Ah, yes! The null module. Python should have more of these. I
mean shouldn't. ;)
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
will come
fairly close to Python semantics.
--
Neil Cerutti
Eddie Robinson is about one word: winning and losing. --Eddie Robinson's agent
Paul Collier
--
http://mail.python.org/mailman/listinfo/python-list
On 2007-02-03, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
I am trying to work out a regular expression in a PyQt
environment for time in hh:mm:ss format. Any suggestions?
After you find your time in hh:mm:ss format, be sure to check out
time.strptime for a quick conversion.
--
Neil Cerutti
on that
must uses a Latin-1 byte-encoding internally, but displays on
stdout in ascii.
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
for os.error rather than error. How to set this, any Idea?
It's will to break things, but you can do this by editing the
iskeyword string and adding in the '.'. :h 'iskeyword'.
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
done in these cases is create a file containing my test
input, and before running the doctests I remap sys.stdin to my
file of test data. Then you don't need test code cluttering up
your functions.
--
Neil Cerutti
We don't necessarily discriminate. We simply exclude certain types of people
simple, or even absent.
Note that sequestering the test input in a file doesn't allow for
good examples, unfortunately.
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
for a
while.
--
Neil Cerutti
The recording I listened to had Alfred Brendel doing the dirty work of
performing this sonata (Liszt B minor) --Music Lit Essay
--
http://mail.python.org/mailman/listinfo/python-list
actual words for the word
you're looking for.
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
format_comments for the full dope.
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list
On 2007-02-10, Geoff Hill [EMAIL PROTECTED] wrote:
What's the way to go about learning Python's regular
expressions? I feel like such an idiot - being so strong in a
programming language but knowing nothing about RE.
A great way to learn regular expressions is to implement them.
--
Neil
501 - 600 of 1188 matches
Mail list logo