(zip(s2,s1))
s1[:] = (d[n] for n in sorted(d.keys()))
It's faster on my system because d.keys() is already sorted. But that
may not be the case on other versions of python.
Ron
--
http://mail.python.org/mailman/listinfo/python-list
Alex Martelli wrote:
Ron Adam [EMAIL PROTECTED] wrote:
[EMAIL PROTECTED] wrote:
Your solution Steven Bethard looks very intelligent, here is a small
speed test, because sorting a list according another one is a quite
common operation.
(Not all solutions are really the same, as Alex has
(d.keys()))
Ron
--
http://mail.python.org/mailman/listinfo/python-list
Alex Martelli wrote:
Ron Adam [EMAIL PROTECTED] wrote:
...
Considering the number time I sort keys after getting them, It's the
behavior I would prefer. Maybe a more dependable dict.sortedkeys()
method would be nice. ;-)
sorted(d) is guaranteed to do exactly the same thing as sorted
Delaney, Timothy (Tim) wrote:
Ron Adam wrote:
Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)]
on win32
I was a bit surprised by them being sorted. I just happend to try
d.keys() in place of s2, and it sped up. I was expecting it to be a
bit slower.
Purely
Actually, Python has the distinction of being both a great tool
language *and* a great Zen language. That's what makes Python so cool
;-)))
Ron Stephens
Python411
www.awaretek.com/python/index.html
--
http://mail.python.org/mailman/listinfo/python-list
/lib/python2.4/idlelib/idle.py
CronoCloud (Ron Rogers Jr.)
--
http://mail.python.org/mailman/listinfo/python-list
I have this line of code that's written with Linux in mind:
path_to_nethack_logfile = os.popen(locate logfile | grep
nethackdir).read()
and I'm wanting a Windows equivalent, any suestions?
Thanks.
CronoCloud (Ron Rogers Jr.)
--
http://mail.python.org/mailman/listinfo/python-list
Tim Golden wrote:
[Ron Rogers Jr.]
| I have this line of code that's written with Linux in mind:
|
| path_to_nethack_logfile = os.popen(locate logfile | grep
| nethackdir).read()
|
| and I'm wanting a Windows equivalent, any suestions?
Well, you could obviously use os.walk
])
exit
Thank you. I guess I should do more reading, since I hadn't read about
os.walk yet. I shouldn't even be trying to do what I'm doing so early in
my learning. It will eventually be a Nethack logfile parse script.
CronoCloud (Ron Rogers Jr.)
--
http://mail.python.org/mailman/listinfo
very new to Python.
CronoCloud (Ron Rogers Jr.)
--
http://mail.python.org/mailman/listinfo/python-list
help assertion
would not work, but
help ASSERTION
will.
Just figured this out myself, yesterday.
CronoCloud (Ron Rogers Jr.)
--
http://mail.python.org/mailman/listinfo/python-list
,
Ron Griswold
Character TD
R!OT Pictures
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
the other way ;)
Thanks,
Ron Griswold
Character TD
R!OT Pictures
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
Hi Cliff,
Looks like xist is exactly what I'm looking for.
Thank you,
Ron Griswold
Character TD
R!OT Pictures
[EMAIL PROTECTED]
-Original Message-
From: Cliff Wells [mailto:[EMAIL PROTECTED]
Sent: Tuesday, January 17, 2006 9:33 AM
To: Ron Griswold
Cc: python-list@python.org
Subject
with python code, or third party software, Id love to hear about it.
Thanks,
Ron Griswold
Character TD
R!OT Pictures
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
the server is
opening is already in use (even on the first try).
Does anyone know of a nice reliable app that already does this for you?
Open source preferably.
Ron Griswold
Character TD
R!OT Pictures
[EMAIL PROTECTED]
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED
not appear in a windows directory listing,
not that I really want it to.
As for os.link and os.symlink, these appear to be unix specific. It
would be nice if os.symlink, when run on windows, would create a
shortcut.
Thanks,
Ron Griswold
Character TD
R!OT Pictures
[EMAIL PROTECTED]
-Original Message
Hi Roger,
Thank you, I will look into this.
Ron Griswold
Character TD
R!OT Pictures
[EMAIL PROTECTED]
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf
Of Roger Upole
Sent: Friday, January 13, 2006 4:59 AM
To: python-list@python.org
Subject: Re: Creating
Does this do what you are looking for?
s = 'abcdefg';
a = [];
a += s;
a;
['a', 'b', 'c', 'd', 'e', 'f', 'g']
Ron Griswold
Character TD
R!OT Pictures
[EMAIL PROTECTED]
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf
Of Tim Chase
Sent: Thursday, January
Hi Folks,
Is it possible to create a shortcut to a file in Python? I need to do
this in both win32 and OSX. I've already got it covered in Linux by
system(ln...).
Thanks,
Ron Griswold
Character TD
R!OT Pictures
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
How 'bout:
X = 132.00;
Y = int(float(X));
Ron Griswold
Character TD
R!OT Pictures
[EMAIL PROTECTED]
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf
Of Mel Wilson
Sent: Wednesday, January 11, 2006 1:08 PM
To: python-list@python.org
Subject: Re: how
In article [EMAIL PROTECTED],
Roy Smith [EMAIL PROTECTED] wrote:
In article [EMAIL PROTECTED],
Sam Pointon [EMAIL PROTECTED] wrote:
Would this particular inconsistency be candidate for change in Py3k?
Seems to me the pos and endpos arguments are redundant with slicing,
and the
First let me apologize if this post offends, I am a real newbie to
Python having only used it for about
2 days. If this is the wrong place to post newbie questions, please
be polite.
I have the O'Reily Learning Python book and I am reading it.
Here's what I am working on..
I am trying to
False
Ron Griswold
Character TD
R!OT Pictures
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
appear to be the case. Can someone point me in the right
direction?
Thanks,
Ron Griswold
Character TD
R!OT Pictures
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
Just the ticket. Thank you!
Ron Griswold
Character TD
R!OT Pictures
[EMAIL PROTECTED]
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf
Of Fredrik Lundh
Sent: Monday, December 05, 2005 3:58 PM
To: python-list@python.org
Subject: Re: apply()?
Ron Griswold
Hello,
I'm attempting to develop a plugin framework for an application that I'm
working on. I wish to develop something in which all plugins exist in a
directory tree. The framework need only be given the root of the tree. The
framework then uses os.path.walk to search all for all files
to have it considered that this be
added to Tix?
Thanks for your help.
Ron Provost
--
http://mail.python.org/mailman/listinfo/python-list
one is faster depends on the average word length and number of
ignored characters.
Cheers,
Ron
Character count: 10
Word count: 16477
Average word size: 6.06906597075
word_counter: 0.06820057 (best of 3)
count_words: 0.07333837 (best of 3)
#
import string
import re
import
Fredrik Lundh wrote:
Ron Adam wrote:
The \w does make a small difference, but not as much as I expected.
that's probably because your benchmark has a lot of dubious overhead:
I think it does what the OP described, but that may not be what he
really needs.
Although the test to find
Bengt Richter wrote:
On Wed, 09 Nov 2005 00:42:45 GMT, Ron Adam [EMAIL PROTECTED] wrote:
Bengt Richter wrote:
On 08 Nov 2005 08:07:34 -0800, Paul Rubin http://[EMAIL PROTECTED] wrote:
dcrespo [EMAIL PROTECTED] writes:
hex(255)[2:]
'ff'
'%x'%255 is preferable since the format of hex
not sure
what the best behavior should be for it, but iterating a string is
faster than converting to int and back.
I doubt I can make these significantly faster at this point. Using
dictionary lookups really helped a lot going both ways.
Cheers,
Ron
import string
BaseDigits = sorted(list
[EMAIL PROTECTED] wrote:
which feature of python do you like most?
I've heard from people that python is very useful.
Many people switch from perl to python because they like it more.
I am quite familiar with perl, I've don't lots of code in perl.
Now, I was curious and interested in
and sometimes modify the values to the dialog and then return the
dialog.result value after it's closed.
Something like...
def domydialog(*args, **kwds):
#
# Check and modify args or kwds here if needed.
#
mydialog(*args, **kwds)
return mydialog.result
Cheers,
Ron
--
http
domydialog(*args, **kwds):
#
# check or change args or kwds
#
d = mydialog(*args, **kwds)
return d.result
I left out the returned object name 'd'. Which is needed to get the
result from the dialog instance.
Cheers,
Ron
--
http://mail.python.org/mailman/listinfo
= a + b
This should be enough to visualize the basic relationship. Hope it helped.
Cheers,
Ron
--
http://mail.python.org/mailman/listinfo/python-list
until you decide how else to do it. You can
easily write the dictionaries to a text file in the chosen format later
and that will tell you what you need to do to read the file back into
the dictionaries as it will just be reversed.
Cheers,
Ron
--
http://mail.python.org/mailman/listinfo
, and iter. What is it if not one of these?
And, how about the **something operator?
James
A dictionary would be pretty much the same except subclassed from a
dictionary of course.
Cheers,
Ron
--
http://mail.python.org/mailman/listinfo/python-list
. The return line above
is the same as...
cc = Chooser(**options)
color = cc.show()
return color
The other dialogs work in same way. They are all based on
tkCommonDialog, so look in tkCommonDialog.py to see exactly what's going on.
Cheers,
Ron
--
http://mail.python.org
Alex Martelli wrote:
Ron Adam [EMAIL PROTECTED] wrote:
James Stroud wrote:
And, how about the **something operator?
James
A dictionary would be pretty much the same except subclassed from a
dictionary of course.
I believe this one is correct (but I have not checked in-depth
)
Cheers,
Ron
--
http://mail.python.org/mailman/listinfo/python-list
Neal Norwitz wrote:
Ron Adam wrote:
Eval or exec aren't needed. Normally you would just do...
execfunc['key1'](**args)
If your arguments are stored ahead of time with your function...
Committed revision 41366.
Committed revision 41366 ?
You could then do...
func, args
():
self.exit(event=id)
return do_command
In this case it's a dialog button so it calls the exit method which sets
self.return to the button id before exiting.
Cheers,
Ron
--
http://mail.python.org/mailman/listinfo/python-list
Antoon Pardon wrote:
Op 2005-10-26, Ron Adam schreef [EMAIL PROTECTED]:
Adding complexity to cmp may not break code, but it could probably slow
down sorting in general. So I would think what ever improvements or
alternatives needs to be careful not to slow down existing sorting cases
Tkinter color string.
return '#%02x%02x%02x' % (red, green, blue)
Cheers,
Ron
--
http://mail.python.org/mailman/listinfo/python-list
particularly wrong with the program that might
cause the problem you are referring to. So I'm afraid I can't help much.
Maybe someone with 2.3 can reproduce it?
BTW, Nice puzzle, much harder than it looks.
Cheers,
Ron
--
http://mail.python.org/mailman/listinfo/python-list
the arguments. Probably I
should have equally lambasted Ron for the heinous crime of bottom-quoting.
I usually try to keep things in reasonable context and or order. I tend
to bottom quote only when either the message is short enough to fit on a
single page, or when I'm adding new content
not to slow down existing sorting cases.
Cheers,
Ron
--
http://mail.python.org/mailman/listinfo/python-list
(or search path) with
the same name as the directory or file they are in, you could be
importing the wrong file and then not be finding the sub modules.
Like I said this is a guess, but I thought it might be worth mentioning
if nothing else to rule out file path problems like these.
Cheers,
Ron
-- 0
print c_y.p2.ptype-- 'ob1'
print c_y.p2.number -- 1
etc...
print c_y.showall()
Cheers,
Ron
--
http://mail.python.org/mailman/listinfo/python-list
David Poundall wrote:
Sadly Ron, c_y can only see index and showall in your example.
Well, don't give up! The approach is sound and I did say it was
untested. Here's a tested version with a few corrections. :-)
Cheers,
Ron
class Pump(object):
def __init__(self, name, ptype
Alex Martelli wrote:
Ron Adam [EMAIL PROTECTED] wrote:
...
class namespace(dict):
def __getattr__(self, name):
return self.__getitem__(name)
...
Any thoughts? Any better way to do this?
If any of the keys (which become attributes through
of
creating a new object?
Cheers,
Ron
On Monday 24 October 2005 19:53, Ron Adam wrote:
James Stroud wrote:
Here it goes with a little less overhead:
py class namespace:
... def __init__(self, adict):
... self.__dict__.update(adict)
...
py n = namespace({'bob':1, 'carol':2, 'ted':3, 'alice
(dict):
__getattr__ = dict.__getitem__
__setattr__ = dict.__setitem__
__delattr__ = dict.__delitem__
This seems to work, and eliminates the indirect method calls.
Cheers,
Ron
--
http://mail.python.org/mailman/listinfo/python-list
Duncan Booth wrote:
Ron Adam wrote:
James Stroud wrote:
Here it goes with a little less overhead:
example snipped
But it's not a dictionary anymore so you can't use it in the same places
you would use a dictionary.
foo(**n)
Would raise an error.
So I couldn't do:
def foo
you are using.
Cheers,
Ron
--
http://mail.python.org/mailman/listinfo/python-list
Bengt Richter wrote:
On Tue, 25 Oct 2005 16:20:21 GMT, Ron Adam [EMAIL PROTECTED] wrote:
Or worse, the dictionary would become not functional depending on what
methods were masked.
And this approach reverses that, The dict values will be masked by the
methods, so the values can't effect
objects that were bound to names when the class was defined. They don't
share any objects that get bound to instance attribute names in methods
later.
Does this help any?
Cheers,
Ron
(hopefully, reasons will help me remeber why things are the way they
are, so I don't forget
awkward to have to use string keys in this situation.
This is easy and still retains the dictionary so it can be modified and
passed to another function or method as kwds again.
Any thoughts? Any better way to do this?
Cheers, Ron
--
http://mail.python.org/mailman/listinfo/python-list
you can't use it in the same places
you would use a dictionary.
foo(**n)
Would raise an error.
So I couldn't do:
def foo(**kwds):
kwds = namespace(kwds)
kwds.bob = 3
kwds.alice = 5
...
bar(**kwds) #--- do something with changed items
Ron
what you were referring to at first. But yes, I see the
similarity.
Cheers,
Ron
--
http://mail.python.org/mailman/listinfo/python-list
Steven D'Aprano wrote:
def replace_word(source, newword):
Replace the first word of source with newword.
return newword + + .join(source.split(None, 1)[1:])
import time
def test():
t = time.time()
for i in range(1):
s = replace_word(aa to become, /aa/)
.
Could you explain a little better what you are doing.
Since I'm working on the same (or similar) thing maybe we can share our
results, (or efforts).
Cheers,
Ron
--
http://mail.python.org/mailman/listinfo/python-list
Steven D'Aprano wrote:
On Sat, 22 Oct 2005 21:41:58 +, Ron Adam wrote:
Don't forget a string can be sliced. In this case testing before you
leap is a win. ;-)
Not much of a win: only a factor of two, and unlikely to hold in all
cases. Imagine trying it on *really long* strings
, and easier to create SVG files as
well, as it closes the gap between the canvas object and the VGA standard.
Anyway, I'm more than willing to get involved in a group to do this if
anyone is interested and also thinks it may be worth while.
Cheers,
Ron
--
http://mail.python.org
[EMAIL PROTECTED] wrote:
interesting. seems that if ' ' in source: is a highly optimized code
as it is even faster than if str.find(' ') != -1:' when I assume they
end up in the same C loops ?
The 'in' version doesn't call a function and has a simpler compare. I
would think both of those
the states because the list isn't ever reassigned after it's
created, so the values in it can change and all instances and subclasses
can see the changed values.
Cheers,
Ron
--
http://mail.python.org/mailman/listinfo/python-list
James wrote:
Doesn't work for classes because self has no global reference.
True. To make it work one would need to track instances and names and
do comparisons... and so on. So it's not worth it. ;-)
Cheers,
Ron
--
http://mail.python.org/mailman/listinfo/python-list
In article [EMAIL PROTECTED],
Sean Berry [EMAIL PROTECTED] wrote:
I am using MySQLdb to connect to a database and retrieve a timestamp from a
table. The problem is I want the timestamp as a long, unformatted and all.
In the table I have a timestamp like this
20051019111617
But, when I
to do it. So is there a better way? Is there a way to use properties
to do this same thing?
I'd also like a way to override the dictionary methods __getitem__,
__setitem__, and __delitem__. (Or an equivalent)
Cheers,
Ron
class Pobject(object):
an objects class that can have
This is what I like about Python, there's almost always a way to do it. ;-)
Here's an updated version that I think works, but it could use some review.
Any way to make this better? Should grouped properties share
references to objects?
Cheers,
Ron
Grouped properties:
This need
, in ?
NameError: name 'foo' is not defined
Cheers,
Ron
--
http://mail.python.org/mailman/listinfo/python-list
looking for. I think most Vim users just add what
they want to Vim.
Here's what I use to launch a script and capture the output into a read
only panel. I think it may still needs a little fine tuning. This is
on windows, but it should work on linux with some minor changes.
Cheers,
Ron
Add
in different behavior? Is it a Python thing or a
Tkinter thing?
Thanks for your feedback.
Ron
--
http://mail.python.org/mailman/listinfo/python-list
the tab for an hour and a half
of open bar and food. Additionally, if you're looking for a job as a
Python developer, bring your resume.
Please RSVP at http://rsvp.nylug.org to attend, as seating is limited.
PS: You may wish to bring ID and a GPG fingerprint to sign keys.
- Ron
(announcement
the tab for an hour and a half
of open bar and food. Additionally, if you're looking for a job as a
Python developer, bring your resume.
Please RSVP at http://rsvp.nylug.org to attend, as seating is limited.
PS: You may wish to bring ID and a GPG fingerprint for keysigning.
- Ron
(announcement
formats where
you have definitions before expressions. If I use keywords only, It
won't keep the order, and if I use args before keywords, I have to
pre-assign temporary 'None' values to the arguments in the parent or
global scope.
Any ideas?
Cheers,
Ron
--
http
Diez B. Roggisch wrote:
Ron Adam wrote:
Is there a way to preserve or capture the order which keywords are given?
def foo(**kwds):
...print kwds
...
foo(one=1, two=2, three=3)
{'three': 3, 'two': 2, 'one': 1}
I would love to reverse the *args, and **kwds as well so I can use
Ron Adam wrote:
def lamb(args):
for v in args: print v
def feedlamb():
print locals()
y = 20
lamb( (lambda x=10: (x,y,x+y))() )
print locals()
feedlamb()
{}
10
20
30
{'y': 20}
Cool, this is the exact behavior I was thinking of, but without
Kent Johnson wrote:
Ron Adam wrote:
drawshapes( triangle=3, square=4, color=red,
polygon(triangle, color),
polygon(square, color) )
This comes close to the same pattern used in SVG and other formats
where you have definitions before expressions.
Why
Bengt Richter wrote:
On Sun, 09 Oct 2005 12:10:46 GMT, Ron Adam [EMAIL PROTECTED] wrote:
Ron Adam wrote:
It seems I've found a bug in dis.py, or maybe a expected non feature.
When running dis from a program it fails to find the last traceback
because sys.last_traceback doesn't get set
')
0 LOAD_CONST 1 (1)
3 PRINT_ITEM
4 PRINT_NEWLINE
5 LOAD_CONST 0 (0)
8 RETURN_VALUE
It works! :-)
Cheers,
Ron
--
http://mail.python.org/mailman/listinfo/python-list
if they need to.
Cheers,
Ron
--
http://mail.python.org/mailman/listinfo/python-list
Christian Stapfer wrote:
Ron Adam [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Christian Stapfer wrote:
This discussion begins to sound like the recurring
arguments one hears between theoretical and
experimental physicists. Experimentalists tend
to overrate the importance
the outcome.
So the you could say: don't *depend* on the completeness of your
theoretical information, try to *verify* the validity of your results
with experiments.
Cheers,
Ron
--
http://mail.python.org/mailman/listinfo/python-list
Christian Stapfer wrote:
Ron Adam [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Christian Stapfer wrote:
Ron Adam [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Christian Stapfer wrote:
This discussion begins to sound like the recurring
arguments one hears between
know what you think?
Some of the things I want to add, but aren't exactly sure how at this time:
Nested groups
Use tags to be able to change sub items later
Have items get attribues from the group if it doesn't have them
Hope this isn't too long.
Cheers, Ron
Tkinter Color Vector
. Additionally, if you're looking for a job as a
Python developer, bring your resume.
Please RSVP at http://rsvp.nylug.org to attend, as seating is limited.
- Ron
(announcement follows)
The New York Linux User's Group Presents
Alex Martelli
George Sakkis wrote:
What date is it ? It isn't mentioned at the web site either.
Sorry about that, actually it is on the web site, right at the top in
the blue band.
October 26, 2005 6:00pm - 10:00pm
Hope to see you there.
- Ron
--
http://mail.python.org/mailman/listinfo/python-list
Gregory PiƱero wrote:
A reasonable question ...
Sure is. ;)
October 26, 2005 6:00pm - 10:00pm
- Ron
--
http://mail.python.org/mailman/listinfo/python-list
alike?
Hmmm.. I think maybe if if don't ever access shape (or Shape) directly
in my data structure, then __new__ would work? So my first default
object should be an instance of shape with a __new__ method to create
more? Ok, off to try it. But any comments will be welcome.
Cheers,
Ron
George Sakkis wrote:
Ron Adam [EMAIL PROTECTED] wrote:
I'm trying to implement simple svg style colored complex objects in
tkinter and want to be able to inherit default values from other
previously defined objects.
I want to something roughly similar to ...
class shape(object
Is this a bug or a feature?
class mydict(dict):
def __setitem__(self, key, val):
print 'foo'
dict.__setitem__(self, key, val)
d=mydict()
d[1]=2
foo
d.setdefault(2,3)
3
rg
--
http://mail.python.org/mailman/listinfo/python-list
):
File gen.py, line 26, in ?
raise your error
Error: your error
Hope this helps,
Ron
--
http://mail.python.org/mailman/listinfo/python-list
Ron Adam wrote:
Can anyone show me an example of of using dis() with a traceback?
Examples of using disassemble_string() and distb() separately if
possible would be nice also.
[cliped]
But I still need to rewrite disassemble_string() and need to test it
with tracebacks.
Cheers
, 'cache' and 'fn' are replaced by the
objects they reference before the cached_result function is returned.
Is this correct?
Cheers,
Ron
--
http://mail.python.org/mailman/listinfo/python-list
Fredrik Lundh wrote:
Ron Adam wrote:
In effect, 'cache' and 'fn' are replaced by the objects they reference
before the cached_result function is returned.
not really; accesses to free variables always go via special cell objects
(rather than direct object references), and the compiler
idea of what's going on.
Cheers,
Ron
--
http://mail.python.org/mailman/listinfo/python-list
out
where to start.
If I was forced to go back to MS C++ again, I think I would take up
painting instead of programing as my main hobby.
;-)
Cheers,
Ron
--
http://mail.python.org/mailman/listinfo/python-list
601 - 700 of 940 matches
Mail list logo