On Feb 11, 1:24 pm, "LL.Snark" wrote:
> Hi,
>
> I'm looking for a pythonic way to translate this short Ruby code :
> t=[6,7,8,6,7,9,8,4,3,6,7]
> i=t.index {|x| x
> If you don't know Ruby, the second line means :
> What is the index, in array t, of the first element x such that x
> If can write it
On Feb 2, 9:22 pm, Tim Roberts <[EMAIL PROTECTED]> wrote:
> Also, psycopg will do the quoting for you. You don't do it. So this is
> what you want:
Second the above, it is much cleaner to leave the quoting to
psycopg2. I know, I wrote my own quoting logic for dynamically
generated queries and
Back about 8 yrs ago, on pc hardware, I was reading twin 5 Mb files
and doing a 'fancy' diff between the 2, in about 60 seconds. Granted,
your file is likely bigger, but so is modern hardware and 20 mins does
seem a bit high.
Can't talk about the rest of your code, but some parts of it may be
opt
On Nov 12, 1:07 am, Davy <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I have a dictionary with n elements, and I want to get the m(m<=n)
> keys with the largest values.
>
> For example, I have dic that includes n=4 elements, I want m=2 keys
> have the largest values)
> dic = {0:4,3:1,5:2,7:8}
> So, the
On Nov 12, 1:07 am, Davy <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I have a dictionary with n elements, and I want to get the m(m<=n)
> keys with the largest values.
>
> For example, I have dic that includes n=4 elements, I want m=2 keys
> have the largest values)
> dic = {0:4,3:1,5:2,7:8}
> So, the
Ah, well, just noticed Ben's suggested this already. Mind you, his
code, while correct in intent, does look a bit fishy (missing those
square brackets), so don't dismiss it just because you had trouble
running it (or mine). Definitely worth a try and I'd be curious to
know if it makes a differenc
On Nov 11, 7:35 am, Michael Bacarella <[EMAIL PROTECTED]> wrote:
> Tried that already. No difference. :(
Not sure if it would make a difference, and it would imply re-
organizing your preceding lines, but what about doing the dictionary
build in one go, rather than incrementally? Using the dict
On Sep 13, 4:02 pm, Nikita the Spider <[EMAIL PROTECTED]>
wrote:
> My $.02 for someone such as yourself
> is to deal with Python and as little else as possible. So write your
> code in a simple text editor like UltraEdit or Notepad
Second that opinion. Use _your_ favorite basic text editor and ru
I respectfully disagree with Shawn, in this case.
Don't skim Nutshell, unless you know very little Python, and even then
it is really the wrong book. It is rather dry reading and provides
very little of the usual user-friendly introductions to language
features by solving simple problems.
Doesn'
Agree that what you are looking for may not be a good idea. So make
sure you don't shoot yourself in the foot with it. You should
probably look into your problem some more.
>>> def once(obj,attrname,value):
... if hasattr(obj,attrname):
... return
... else:
... se
Ok, it does look a bit mangled. I re-posted it on www.pastebin.com,
at http://python.pastebin.com/m7b1f9ab5.
Cheers
--
http://mail.python.org/mailman/listinfo/python-list
Sadly lacking in multi-media bells and whistles. But my daughter
actually likes playing with it.
Coded on windows, but no reason it shouldn't work on Linux/OS X.
(hopefully the indentation won't be too mangled by usenet. apologies
in advance if that is the case)
Enjoy.
Sample session:
D:\use
> how can i define my variables so that there are valid outside the
> class???
Not to be obnoxious, but your sample code has a number of fairly big
conceptual issues (like subclassing self and assigning 32 at the big
class level and printing 'list' which is a built-in type). Been there
myself -
Wise choice + welcome to the club.
Though Python is open source and well appreciated on Linux, I think you
will find that most people in this newsgroup will be fairly courteous
about _your_ choice of platform. Some will not know about the weird
process forking stuff on windows and helpfully sugge
14 matches
Mail list logo