Sorry, scratch that P.S.! The act of hitting Send seems to be a great
way of realising one's mistakes.
Of course you need colnr - m for those times when m is set to 26.
Remembered that when I wrote it, forgot it 2 paragraphs later!
--
http://mail.python.org/mailman/listinfo/python-list
Jason Drew wrote:
##def tuple2coord(tupl):
[snip]
##rowfromzero, colfromzero = tupl
Just a side note here that if you want a better function signature, you
might consider writing this as:
tuple2coord((rowfromzero, colfromzero)):
...
Note that the docstrings are nicer this way:
py
Hey, that's good. Thanks Steve. Hadn't seen it before. One to use.
Funny that Pythonwin's argument-prompter (or whatever that feature is
called) doesn't seem to like it.
E.g. if I have
def f(tupl):
print tupl
Then at the Pythonwin prompt when I type
f(
I correctly get (tupl) in the argument
On 20 May 2005 10:07:55 -0700, Jason Drew [EMAIL PROTECTED] wrote:
Hey, that's good. Thanks Steve. Hadn't seen it before. One to use.
Funny that Pythonwin's argument-prompter (or whatever that feature is
called) doesn't seem to like it.
E.g. if I have
def f(tupl):
print tupl
Then
Hi All,
While I know there is a zillion ways to do this.. What is the most
efficient ( in terms of lines of code ) do simply do this.
a=1, b=2, c=3 ... z=26
Now if we really want some bonus points..
a=1, b=2, c=3 ... z=26 aa=27 ab=28 etc..
Thanks
--
On 19 May 2005 06:56:45 -0700,
rh0dium [EMAIL PROTECTED] wrote:
Hi All,
While I know there is a zillion ways to do this.. What is the most
efficient ( in terms of lines of code ) do simply do this.
a=1, b=2, c=3 ... z=26
(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z) = range( 1,
On 19 May 2005 06:56:45 -0700, rh0dium [EMAIL PROTECTED] wrote:
Hi All,
While I know there is a zillion ways to do this.. What is the most
efficient ( in terms of lines of code ) do simply do this.
a=1, b=2, c=3 ... z=26
Now if we really want some bonus points..
a=1, b=2, c=3 ...
Bill Mill wrote:
py alpha = 'abcdefghijklmnopqrstuvwxyz'
py for i, digraph in enumerate(sorted([''.join((x, y)) for x in alpha
...for y in [''] + [z for z in alpha]], key=len)):
... locals()[digraph] = i + i
...
It would probably be better to get in the habit of writing
Hi rh0dium,
Your request gives me the opportunity of showing a more realistic
example of the technique of self-modification coding.
Although the coding is not as short as that suggested by the guys who
replayed to you, I think that it can be interesting
# newVars.py
lCod=[]
for n in
Call me crazy.. But it doesn't work..
for i, digraph in enumerate(sorted([''.join((x, y)) for x in alpha for
y in [''] + [z for z in alpha]], key=len)):
globals()[digraph]=i+1
How do you implement this sucker??
Thanks
--
http://mail.python.org/mailman/listinfo/python-list
This is great but backwards...
Ok because you all want to know why.. I need to convert Excel columns
A2 into , [1,0] and I need a simple way to do that..
( The way this works is A-0 and 2-1 -- Yes they interchange -- So
B14 == [13,1] )
So my logic was simple convert the A to a number and then
On 19 May 2005 11:52:30 -0700, rh0dium [EMAIL PROTECTED] wrote:
Call me crazy.. But it doesn't work..
What doesn't work? What did python output when you tried to do it? It
is python 2.4 specific, it requires some changes for 2.3, and more for
earlier versions of python.
for i, digraph in
On 19 May 2005 11:59:00 -0700, rh0dium [EMAIL PROTECTED] wrote:
This is great but backwards...
Ok because you all want to know why.. I need to convert Excel columns
A2 into , [1,0] and I need a simple way to do that..
( The way this works is A-0 and 2-1 -- Yes they interchange -- So
B14
On 19 May 2005 12:20:03 -0700, rh0dium [EMAIL PROTECTED] wrote:
Python 2.3.5 (#1, Mar 20 2005, 20:38:20)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1809)] on darwin
Traceback (most recent call last):
File stdin, line 1, in ?
NameError: name 'sorted' is not defined
I think you're
Bill Mill wrote:
Traceback (most recent call last):
File stdin, line 1, in ?
NameError: name 'sorted' is not defined
I think you're probably using 2.4 ??
Yes, sorted() is new in python 2.4 .You could use a very lightly
tested pure-python partial replacement:
By the way, sorted() can be
On 5/19/05, Peter Otten [EMAIL PROTECTED] wrote:
Bill Mill wrote:
Traceback (most recent call last):
Filestdin,line1,in?
NameError: name 'sorted' is not defined
I think you're probably using 2.4 ??
Yes, sorted() is new in python 2.4 .You could use a very lightly
tested
Peter Otten wrote:
[Something stupid]
You are right. I finally got it.
Peter
--
http://mail.python.org/mailman/listinfo/python-list
We weren't really backwards; just gave a full solution to a half-stated
problem.
Bill, you've forgotten the least-lines-of-code requirement :-)
Mine's still a one-liner (chopped up so line breaks don't break it):
z = lambda cp: (int(cp[min([i for \
i in xrange(0, len(cp)) if \
Gary Wilson Jr wrote:
alpha = 'abcdefghijklmnopqrstuvwxyz'.upper()
pairs = [x for x in alpha] + [''.join((x,y)) for x in alpha for y in alpha]
I forget, is string concatenation with '+' just as fast as join()
now (because that would look even nicer)?
--
Bill Mill [EMAIL PROTECTED] writes:
On 19 May 2005 11:59:00 -0700, rh0dium [EMAIL PROTECTED] wrote:
This is great but backwards...
Ok because you all want to know why.. I need to convert Excel columns
A2 into , [1,0] and I need a simple way to do that..
( The way this works is A-0 and
Jason Drew wrote:
z = lambda cp: (int(cp[min([i for \
i in xrange(0, len(cp)) if \
cp[i].isdigit()]):])-1,
sum(((ord(cp[0:min([i for i in \
xrange(0, len(cp)) if \
cp[i].isdigit()])][x])-ord('A')+1) \
* (26 ** (len(cp[0:min([i for i in \
xrange(0, len(cp)) if \
Gary Wilson Jr wrote:
Gary Wilson Jr wrote:
alpha = 'abcdefghijklmnopqrstuvwxyz'.upper()
pairs = [x for x in alpha] + [''.join((x,y)) for x in alpha for y in alpha]
I forget, is string concatenation with '+' just as fast as join()
now (because that would look even nicer)?
Certain looping
Oh yeah, oops, thanks. (I mean the line continuations, not the alleged
sin against man and nature, an accusation which I can only assume is
motivated by jealousy :-) Or fear? They threw sticks at Frankenstein's
monster too. And he turned out alright.
My elegant line of code started out without
rh0dium [EMAIL PROTECTED] writes:
Now can you reverse this process tuple2coord??
You didn't provide enough context to know who you're asking, but
here's the inverse of my coord2tuple2 function:
from string import uppercase
def tuple2coord(number):
if 1 number or number 26:
raise
24 matches
Mail list logo