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
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 argumen
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>
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
Er, yes! It's REALLY ugly! I was joking (though it works)! I retract it
from the code universe. (But patent pending nr. 4040404.)
Here's how I really would convert your (row_from_zero, col_from_zero)
tuple to spreadsheet "A1" coords, in very simple and easy to read code.
##def tuple2coord(tupl):
"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:
ra
Now can you reverse this process tuple2coord??
Thats what I'm really after :)
--
http://mail.python.org/mailman/listinfo/python-list
Wow - now that is ugly.. But it is effective. I would love a cleaner
version - but I did say brevity :)
Nice work.
--
http://mail.python.org/mailman/listinfo/python-list
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 t
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 l
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)
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 wo
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)?
--
http://mail.python.org/mailman/listinfo
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 \
cp[i].isdi
Peter Otten wrote:
[Something stupid]
You are right. I finally got it.
Peter
--
http://mail.python.org/mailman/listinfo/python-list
Bill Mill wrote:
>> By the way, sorted() can be removed from your original post.
>>
>> Code has no effect :-)
>
> I'm gonna go ahead and disagree with you:
>
sorted([''.join((x, y)) for x in alpha \
> ...for y in [''] + [z for z in alpha]], key=len) == \
> ... [''.join((x,y)) for x in
Bill Mill wrote:
> On 5/19/05, Peter Otten <[EMAIL PROTECTED]> wrote:
>
>>Bill Mill wrote:
>>
>>
Traceback (most recent call last):
File"",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 coul
On 5/19/05, Peter Otten <[EMAIL PROTECTED]> wrote:
> Bill Mill wrote:
>
> >> Traceback (most recent call last):
> >>File"",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
Bill Mill wrote:
>> Traceback (most recent call last):
>>File "", 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(
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 "", line 1, in ?
> NameError: name 'sorted' is not defined
>
> I think you'
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 "", line 1, in ?
NameError: name 'sorted' is not defined
I think you're probably using 2.4 ??
--
http://mail.python.org/mailman/listinfo/python-list
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 --
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 i
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 the
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
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 range(
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
glob
It seems strange to want to set the values in actual variables: a, b,
c, ..., aa, ab, ..., aaa, ..., ...
Where do you draw the line?
A function seems more reasonable. "In terms of lines of code" here is
my terse way of doing it:
nrFromDg = lambda dg: sum(((ord(dg[x])-ord('a')+1) * (26 **
(len(dg
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,
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) = ra
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
--
http://mail.python.org/mailman/listinfo/p
31 matches
Mail list logo