sajuptpm wrote:
> More details
> I have a list of tuples l = [((cpu_util,mem_util),(disk_util)),
> ((cpu_util,mem_util),(disk_util))]
> ie, l = [((30,50),(70)), ((50,20),(20))]
>
> l.sort(key=lambda x:(-x[0][0], x[1][0])) # sorting cpu_util asc and
> disk_util desc
>
> suppose i changed order th
On 7 Sep, 07:42, sajuptpm wrote:
> More details
> I have a list of tuples l = [((cpu_util,mem_util),(disk_util)),
> ((cpu_util,mem_util),(disk_util))]
> ie, l = [((30,50),(70)), ((50,20),(20))]
>
> l.sort(key=lambda x:(-x[0][0], x[1][0])) # sorting cpu_util asc and
> disk_util desc
>
> suppose i c
Hello Stephen,
Thanks for the prompt response!
>How would you, a human being, determine if the program was being run directly
>after startup?
I'm not going to claim that I am a computer systems expert; I don't
know a whole lot about what goes on in the Windows start up. I know
services and prog
sajuptpm wrote:
> I have a list of tuples l = [((cpu_util,mem_util),(disk_util)),
> ((cpu_util,mem_util),(disk_util))]
> ie, l = [((30,50),(70)), ((50,20),(20))]
>
> l.sort(key=lambda x:(-x[0][0], x[1][0]))
> # sorting cpu_util asc and disk_util desc
One thing here: Without knowing what special m
Nally Kaunda-Bukenya wrote:
> I am very sorry to bother you, but I need help understanding the code that
> you assisted me with. It does exactly what I needed done, I can't thank
> you enough for that. I am just learning Python, and would appreciate all
> the help. please see my comments below
- Original Message -
From: Stefan Behnel
To:
Sent: Tuesday, September 07, 2010 2:55 PM
Subject: Re: Bit fields in python?
If you can tell us what these structs are being used for in the original C
code, we might be able to point you to a suitable way to implement the
same
thing eff
Hi,
I want to define the relationship for my users and their groups with
declarative style (so that the relating model can inherit Timestamp
mixin and Tablename mixin):
class User(DeclarativeBase, Tablename, TimestampMixin):
'''User avatar is named after its id.
A user may be a student or
Hi Ryan,
Maybe I'm missing something, but wouldn't creating a shortcut and
putting that shortcut in your Start - Programs - Startup section of
the Windows menu not work for this program? Or if really needed you
can edit the start-up programs in the registry.
If you add some logging ability to you
"Steven D'Aprano" wrote in message
news:4c85adfe$0$5$c3e8...@news.astraweb.com...
On Mon, 06 Sep 2010 11:38:22 +0100, BartC wrote:
Manually unrolling such a loop four times (ie. 4 copies of the body, and
counting only to 25 million) increased the speed by between 16% and 47%
(ie. runtime
Hi all you experts,
This has me beat. Has anyone any ideas about what might be going wrong?
This is code from within a windows service (hence no print statements -
no sys.stdout to print on!).
I am trying to trace through to find where the code is not working. No
stdout so I have to log to a
On Tue, Sep 7, 2010 at 11:43 AM, Dennis Verdonschot wrote:
> Hi Ryan,
>
> Maybe I'm missing something, but wouldn't creating a shortcut and
> putting that shortcut in your Start - Programs - Startup section of
> the Windows menu not work for this program? Or if really needed you
> can edit the sta
Ian Hobson a écrit :
Hi all you experts,
This has me beat. Has anyone any ideas about what might be going wrong?
This is code from within a windows service (hence no print statements -
no sys.stdout to print on!).
I am trying to trace through to find where the code is not working. No
stdout
On Mon, 2010-09-06 at 20:48 -0700, Phlip wrote:
> Pythonistas:
>
> The "Samurai Principle" says to return victorious, or not at all. This
> is why django.db wisely throws an exception, instead of simply
> returning None, if it encounters a "record not found".
How does that compare to, say, the "K
On Sep 7, 1:16 pm, Ulrich Eckhardt wrote:
> sajuptpm wrote:
> > I have a list of tuples l = [((cpu_util,mem_util),(disk_util)),
> > ((cpu_util,mem_util),(disk_util))]
> > ie, l = [((30,50),(70)), ((50,20),(20))]
>
> > l.sort(key=lambda x:(-x[0][0], x[1][0]))
> > # sorting cpu_util asc and disk_uti
On 7 sep, 02:18, Ben Finney wrote:
> Ben Finney writes:
> > We value respect for people here, and that's what you've been shown
> > consistently. But respect for opinions, or for delicacy about
> > learning, is not welcome here.
>
> Sloppy wording, I apologise. This should say “… is not respect f
On 7 September 2010 10:56, MRAB wrote:
>
>
> Incidentally, there's a builtin function called 'input' so using it as
> a variable name is a discouraged! :-)
Right-o!
Cheers,
Xav
--
http://mail.python.org/mailman/listinfo/python-list
On 7 sep, 13:39, Baba wrote:
> On 7 sep, 02:18, Ben Finney wrote:
>
>
>
>
>
> > Ben Finney writes:
> > > We value respect for people here, and that's what you've been shown
> > > consistently. But respect for opinions, or for delicacy about
> > > learning, is not welcome here.
>
> > Sloppy wordi
Hi
I am working on an exercise which requires me to write a funtion that
will check if a given word can be found in a given dictionary (the
hand).
def is_valid_word(word, hand, word_list):
"""
Returns True if word is in the word_list and is entirely
composed of letters in the hand. Ot
In article ,
"BartC" wrote:
> (BTW why doesn't Python 3 just accept 'xrange' as a
> synonym for 'range'?)
If you've ever tried to maintain a legacy code base, you'll understand
why "there's only one way to do it" is A Good Thing.
Imagine that you're looking at some code which was written yea
Hi All,
Pydev 1.6.2 has been released
Details on Pydev: http://pydev.org
Details on its development: http://pydev.blogspot.com
Release Highlights:
---
* Pydev is now also distributed with Aptana Studio 3, so it can be
gotten in a version that doesn't require installi
On 7 September 2010 22:05, Baba wrote:
>
> It would be great if someone could give me a brief explanantion of the
> mutation concept.
>
In this case, to mutate is to change. If you must not mutate the list, you
must not change it.
In another words, reading from the list is fine. Writing to it i
I have a list of tuples.
l = [((30,50),(70)), ((50,20),(20))]
for i in range(10):
k = ((i+30,i+50),(i+70))#suppose creating new tuple in each iteration
using some random value and in sert it into list.
flag=True
for i, v in enumerate(l):
if v >= k:
> How does that compare to, say, the "Kamikaze Principle"? ;)
Return victorious AND not at all!
(All return values are packed up and thrown...;)
--
http://mail.python.org/mailman/listinfo/python-list
Baba a écrit :
(snip)
If i had
received a friendly response from Benjamin (as opposed to "Please do
us a favor and at least try to figure things out on your own")
According to usenet standards and given your initial question, this is a
_very_ friendly answer.
--
http://mail.python.org/mailman
Baba a écrit :
Hi
I am working on an exercise which requires me to write a funtion that
will check if a given word can be found in a given dictionary (the
hand).
def is_valid_word(word, hand, word_list):
"""
Returns True if word is in the word_list and is entirely
composed of letter
Phlip a écrit :
How does that compare to, say, the "Kamikaze Principle"? ;)
Return victorious AND not at all!
(All return values are packed up and thrown...;)
... and then it raises a SystemError !-)
--
http://mail.python.org/mailman/listinfo/python-list
Ian Hobson a écrit :
(snip)
you may also want to read the recent "using modules" thread...
--
http://mail.python.org/mailman/listinfo/python-list
sajuptpm wrote:
> i need to implement l.sort(key=lambda x:(x[0][0], -x[1][0])) in
> another way .I want to know what the modification needed in the 'if'
> check to sort this list of tuples in k[0][0] ascending and k[0][1]
> descending.
It seems you are not getting any closer to your goal. Perhap
Baba writes:
> Hi
>
> I am working on an exercise which requires me to write a funtion that
> will check if a given word can be found in a given dictionary (the
> hand).
>
> def is_valid_word(word, hand, word_list):
> """
> Returns True if word is in the word_list and is entirely
> co
On Tue, Sep 7, 2010 at 6:56 AM, Bruno Desthuilliers
wrote:
> Phlip a écrit :
>>>
>>> How does that compare to, say, the "Kamikaze Principle"? ;)
>>
>> Return victorious AND not at all!
>>
>> (All return values are packed up and thrown...;)
>
> ... and then it raises a SystemError !-)
general prot
On Sep 7, 7:03 pm, Peter Otten <__pete...@web.de> wrote:
> sajuptpm wrote:
> > i need to implement l.sort(key=lambda x:(x[0][0], -x[1][0])) in
> > another way .I want to know what the modification needed in the 'if'
> > check to sort this list of tuples in k[0][0] ascending and k[0][1]
> > descend
i've got toto.py :
import titi
def niwhom():
pass
and titi.py :
def nipang():
pass
how can i know in titi.py that's it's toto.py that is calling titi.py
and the path of toto ?
And
why :
bidule.py :
class bidetmusique:
pass
truc.py :
X = __import__("bidule")
why exec("X
sajuptpm wrote:
> On Sep 7, 7:03 pm, Peter Otten <__pete...@web.de> wrote:
>> sajuptpm wrote:
>> > i need to implement l.sort(key=lambda x:(x[0][0], -x[1][0])) in
>> > another way .I want to know what the modification needed in the 'if'
>> > check to sort this list of tuples in k[0][0] ascending
Hi Bruno,
Thanks for your quick response. I still do not understand.
On 07/09/2010 11:50, Bruno Desthuilliers wrote:
Ian Hobson a écrit :
Hi all you experts,
This has me beat. Has anyone any ideas about what might be going wrong?
This is code from within a windows service (hence no print s
Baba writes:
> to say "Please do us a favour and at least try to figure things out on
> your own" is in my view inappropriate.
That's what the person wanted you to see. How would you prefer that
exact information to be imparted to you? How could it have been
communicated so that it was not misun
In article ,
BartC wrote:
>"Steven D'Aprano" wrote in message
>news:4c85adfe$0$5$c3e8...@news.astraweb.com...
>>
>> xrange = range
>>
>> There, that wasn't hard, was it?
>
>I think I just learned more about Python than from months of reading this
>group.
>
>So 'range' is just a class like an
de...@web.de writes:
> Objects can be mutable or immutable. For example, in Python, integers,
> strings, floats and tuples are immutable. That means that you can't
> change their value.
Yes. Importantly, wherever you see code that you *think* is changing the
value of an immutable object, you're t
bussiere bussiere a écrit :
i've got toto.py :
import titi
def niwhom():
pass
and titi.py :
def nipang():
pass
how can i know in titi.py that's it's toto.py that is calling titi.py
and the path of toto ?
You'd have to inspect the call stack. Not for the faint at heart...
And
w
Hi everyone,
My name is Prashant Kumar and I wish to contribute to the Python
development process by helping convert certain existing python over to
python3k.
Is there anyway I could obtain a list of libraries which need to be
ported over to python3k, sorted by importance(by importance i mean
pac
On 2010-09-07, Baba wrote:
> Sloppy wording, I apologise. This should say: If you find the
> question you're reading too easy then just don't answer. Noone is the
> owner of a democratic forum where freedom to ask the question one
> likes is paramount (as long of course as it is related to the
>
On Sep 6, 10:31 pm, Steven D'Aprano wrote:
> On Tue, 07 Sep 2010 11:00:45 +1000, Ben Finney wrote:
> > If you're going to use the list of float objects, you can convert them
> > all with a list comprehension.
> [...]
> > >>> numbers_as_float = [float(x) for x in numbers_as_str]
>
> That's awfu
Does anyone know of a Python module for *moderate* "time-stretching"[1]
an MP3 (or AIFF) file?
FWIW, the audio I want to time-stretch is human speech.
TIA!
~K
[1] By "moderate time stretching" I mean, for example, taking an
audio that would normally play in 5 seconds, and stretch it so that
i
Back to the topic, I tend to do this:
for record in Model.objects.filter(pk=42):
return record
return sentinel
Having lots of short methods helps, because return provides both
control-flow and a result value. But it abuses 'for' to mean 'if'. I
feel _rally_ guilty about that!
But I
On Tue, Sep 7, 2010 at 4:39 AM, Baba wrote:
> On 7 sep, 02:18, Ben Finney wrote:
>> Ben Finney writes:
>> > We value respect for people here, and that's what you've been shown
>> > consistently. But respect for opinions, or for delicacy about
>> > learning, is not welcome here.
>>
>> Sloppy word
In an HTML page that I'm scraping using urllib2, a \xc2\xa0
bytestring appears.
The page's charset = utf-8, and the Chrome browser I'm using displays
the characters as a space.
The page requires authentication:
https://www.nolaready.info/myalertlog.php
When I try to concatenate strings containi
Phlip a écrit :
Back to the topic, I tend to do this:
for record in Model.objects.filter(pk=42):
return record
return sentinel
WTF alert here...
Having lots of short methods helps, because return provides both
control-flow and a result value. But it abuses 'for' to mean 'if'. I
fee
Brian D writes:
> In an HTML page that I'm scraping using urllib2, a \xc2\xa0
> bytestring appears.
>
> The page's charset = utf-8, and the Chrome browser I'm using displays
> the characters as a space.
>
> The page requires authentication:
> https://www.nolaready.info/myalertlog.php
>
> When I
On Sep 7, 10:12 am, Bruno Desthuilliers wrote:
> Phlip a écrit :
>
> > Back to the topic, I tend to do this:
>
> > for record in Model.objects.filter(pk=42):
> > return record
>
> > return sentinel
>
> WTF alert here...
I don't see how anyone could WTF that. Are you pretending to be a ne
Hello
Learning python datetime somewhat similar to SQL type timestamp my
attempt creating a 24 h 2 months ago is
str(datetime.now () - timedelta (days = 60)) +' cron '+
str(datetime.now () - timedelta (days = 59))
Do you agree? Can I improve this declaration?
Regards
Niklas Rosencrantz
--
http:/
In article ,
Roy Smith wrote:
>
>Imagine that you're looking at some code which was written years ago, by
>people who are no longer around to answer questions. In one place, you
>see:
>
>for i in range(n):
> blah
>
>and in another, you see:
>
>for j in xrange(n):
> blah
>
>If you are truly
On Tue, Sep 7, 2010 at 10:02 AM, Phlip wrote:
> Back to the topic, I tend to do this:
>
> for record in Model.objects.filter(pk=42):
> return record
>
> return sentinel
How is that any better than just catching the exception?
try:
return Model.objects.get(pk=42)
except Model.DoesNotExi
On 7 sep, 16:50, Grant Edwards wrote:
> On 2010-09-07, Baba wrote:
>
> > Sloppy wording, I apologise. This should say: If you find the
> > question you're reading too easy then just don't answer. Noone is the
> > owner of a democratic forum where freedom to ask the question one
> > likes is param
On Sep 7, 10:36 am, Ian Kelly wrote:
> On Tue, Sep 7, 2010 at 10:02 AM, Phlip wrote:
> > Back to the topic, I tend to do this:
>
> > for record in Model.objects.filter(pk=42):
> > return record
>
> > return sentinel
>
> How is that any better than just catching the exception?
>
> try:
>
On Sep 7, 11:01 am, Brian D wrote:
> In an HTML page that I'm scraping using urllib2, a \xc2\xa0
> bytestring appears.
>
> The page's charset = utf-8, and the Chrome browser I'm using displays
> the characters as a space.
>
> The page requires authentication:https://www.nolaready.info/myalertlog.
On 9/7/2010 9:24 AM, sajuptpm wrote:
I have a list of tuples.
l = [((30,50),(70)), ((50,20),(20))]
for i in range(10):
k = ((i+30,i+50),(i+70))
The (i+70) parens do nothing, as already explained to (20)
Your set of test data are not very good as they do not test all the
insertion po
On Tue, Sep 7, 2010 at 11:52 AM, Phlip wrote:
> And no it's not "much clearer".
It's clearer because it does exactly what it says it does, unlike your
approach that masquerades as a loop.
> Exceptions are for catastrophic errors
No, they're for flagging "exceptional" states. /Errors/ are for
c
On 9/7/2010 12:06 AM, Kwan Lai Cheng wrote:
Hi,
I'm trying to rewrite a c program in python & encountered several
problems. I have some data structures in my c program like below:
typedef struct
{
unsigned short size;
unsigned short reserved:8;
unsigned short var_a1:2;
unsigned short var_a2:2;
un
On 09/07/10 12:52, Phlip wrote:
try:
return Model.objects.get(pk=42)
except Model.DoesNotExist:
return sentinel
The flow of control is much clearer this way.
It reminds me of Visual Basic.
And no it's not "much clearer". Exceptions are for catastrophic errors
that the caller should
On Sep 7, 11:36 am, Tim Chase wrote:
> > And no it's not "much clearer". Exceptions are for catastrophic errors
> > that the caller should care not to handle. A "record not found" is not
> > a catastrophe.
>
> Exceptions are not limited to catastrophic errors, simply
> exceptional (not the common
There's a bug in Python 2.6's "urllib.urlencode". If you pass
in a Unicode character outside the ASCII range, instead of it
being encoded properly, an exception is raised.
File "C:\python26\lib\urllib.py", line 1267, in urlencode
v = quote_plus(str(v))
UnicodeEncodeError: 'ascii' codec
On 9/6/2010 11:55 PM, Stefan Behnel wrote:
Kwan Lai Cheng, 07.09.2010 06:06:
I'm trying to rewrite a c program in python& encountered several
problems. I have some data structures in my c program like below:
def __init__(self, size=0)
Any equivalent for c data structures& bit fields in pytho
In article <4c868c2d$0$1581$742ec...@news.sonic.net>,
John Nagle wrote:
> Is it worth reporting 2.x bugs any more? Or are we in the
> version suckage period, where version N is abandonware and
> version N+1 isn't deployable yet.
Yes!! 2.7 is being actively maintained for bug fixes. (2.6 o
Lawrence D'Oliveiro writes:
> But you’ll notice that Free Software comes with no such
> restrictions. In fact, it is contrary to commonly-accepted Free
> Software guidelines to impose any sort of restrictions on areas of use.
Free software comes with an explicit disclaimer of liability (you get
w
On 09/07/10 13:53, Phlip wrote:
On Sep 7, 11:36 am, Tim Chase wrote:
And no it's not "much clearer". Exceptions are for catastrophic errors
that the caller should care not to handle. A "record not found" is not
a catastrophe.
Exceptions are not limited to catastrophic errors, simply
exceptio
level: beginner
word= 'even'
dict2 = {'i': 1, 'n': 1, 'e': 1, 'l': 2, 'v': 2}
i want to know if word is entirely composed of letters in dict2
my approach:
step 1 : convert word to dictionary(dict1)
step2:
for k in dict1.keys():
if k in dict2:
if dict1[k] != dict2[k]:
Hi Ian,
On Tue, Sep 7, 2010 at 20:00, Ian wrote:
> On 07/09/2010 11:50, Bruno Desthuilliers wrote:
>
> note the order of the above - log is defined before the import.
>
> And ? Do you think it will affect the imported module in any way ? Like,
> say, magically "inject" your log function in the
Hi Ian,
On 2010-09-07 12:18, Ian Hobson wrote:
> f = open('d:\logfile.txt','a')
Just a note: Using a backslash in a non-raw string will get
you in trouble as soon as the backslash is followed by a
character which makes a special character sequence, like "\n".
For example,
f = open('d:\nice_
Baba writes:
> word= 'even'
> dict2 = {'i': 1, 'n': 1, 'e': 1, 'l': 2, 'v': 2}
>
> i want to know if word is entirely composed of letters in dict2
set(word) <= set(dict2.keys())
--
http://mail.python.org/mailman/listinfo/python-list
Hello.
I'm trying to send email using python 2.6.1 under snow leopard, but I
can't get it to work. I'm trying one of the many examples I found on
the web
EXAMPLE 1
import smtplib
fromaddr = 'fromu...@gmail.com'
toaddrs = 'tou...@gmail.com'
msg = 'There was a terrible error that occured and I wan
On 09/07/2010 12:46 PM, Baba wrote:
word= 'even'
dict2 = {'i': 1, 'n': 1, 'e': 1, 'l': 2, 'v': 2}
Just go through each letter of word checking for its existence in
dict2. Return False if one misses, and True if you get through the
whole word:
def ...():
for c in word:
if c not in
On Tue, Sep 7, 2010 at 1:12 PM, Bob wrote:
> Hello.
> I'm trying to send email using python 2.6.1 under snow leopard, but I
> can't get it to work. I'm trying one of the many examples I found on
> the web
> The error I get is this
>
> python email.py
> Traceback (most recent call last):
> File "
On 7 sep, 22:08, Gary Herron wrote:
> On 09/07/2010 12:46 PM, Baba wrote:
>
> > word= 'even'
> > dict2 = {'i': 1, 'n': 1, 'e': 1, 'l': 2, 'v': 2}
>
> Just go through each letter of word checking for its existence in
> dict2. Return False if one misses, and True if you get through the
> whole word
On Sep 7, 10:27 pm, Chris Rebert wrote:
> On Tue, Sep 7, 2010 at 1:12 PM, Bob wrote:
> > Hello.
> > I'm trying to send email using python 2.6.1 under snow leopard, but I
> > can't get it to work. I'm trying one of the many examples I found on
> > the web
>
> > The error I get is this
>
> > pytho
In article
,
Bob wrote:
>[...]
> The error I get is this
>
> python email.py
> Traceback (most recent call last):
> File "email.py", line 2, in
> import smtplib
> File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/
> python2.6/smtplib.py", line 46, in
> import emai
On 07/09/2010 21:06, Paul Rubin wrote:
Baba writes:
word= 'even'
dict2 = {'i': 1, 'n': 1, 'e': 1, 'l': 2, 'v': 2}
i want to know if word is entirely composed of letters in dict2
set(word)<= set(dict2.keys())
Do the numbers in dict2 represent the maximum number of times that the
letter can
On Wed, Sep 8, 2010 at 1:56 AM, Baba wrote:
> On 7 sep, 22:08, Gary Herron wrote:
> > On 09/07/2010 12:46 PM, Baba wrote:
> >
> > > word= 'even'
> > > dict2 = {'i': 1, 'n': 1, 'e': 1, 'l': 2, 'v': 2}
> >
> > Just go through each letter of word checking for its existence in
> > dict2. Return Fal
Baba wrote:
> On 7 sep, 22:08, Gary Herron wrote:
>> On 09/07/2010 12:46 PM, Baba wrote:
>>
>> > word= 'even'
>> > dict2 = {'i': 1, 'n': 1, 'e': 1, 'l': 2, 'v': 2}
>>
>> Just go through each letter of word checking for its existence in
>> dict2. Return False if one misses, and True if you get th
Hi All,
I have another question about formatted input. Suppose I am reading a
text file, and that I want it to be something like this
word11 = num11, word12 = num12, word13 = num13 etc...
word21 = num21, word22 = num12, word23 = num23 etc...
etc...
where wordx1 belongs to a certain dictionary of
On 7 sep, 22:37, MRAB wrote:
> On 07/09/2010 21:06, Paul Rubin wrote:
>
> > Baba writes:
> >> word= 'even'
> >> dict2 = {'i': 1, 'n': 1, 'e': 1, 'l': 2, 'v': 2}
>
> >> i want to know if word is entirely composed of letters in dict2
>
> > set(word)<= set(dict2.keys())
>
> Do the numbers in dict2 r
Hi Rami, Stefan, Bruno.
First a big thanks for your replies.
On 07/09/2010 20:54, Rami Chowdhury wrote:
Hi Ian,
I think I see where you're going wrong -- this bit me too when I was
learning Python, having come from PHP. Unlike PHP, when you import a
module in Python it does *not* inherit th
Baba writes:
> for k in word.keys():
> if k not in hand:
> return False
> elif k in hand:
> if word[k] > hand[k]:
> return False
> return True
Untested:
all(word[k] <= hand.get(k,0) for k in word)
--
http://
Bob writes:
> Hi All,
> I have another question about formatted input. Suppose I am reading a
> text file, and that I want it to be something like this
>
> word11 = num11, word12 = num12, word13 = num13 etc...
> word21 = num21, word22 = num12, word23 = num23 etc...
> etc...
>
> where wordx1 belon
Phlip a écrit :
> On Sep 7, 10:12 am, Bruno Desthuilliers 42.desthuilli...@websiteburo.invalid> wrote:
>> Phlip a écrit :
>>
>>> Back to the topic, I tend to do this:
>>> for record in Model.objects.filter(pk=42):
>>> return record
>>> return sentinel
>> WTF alert here...
>
> I don't see
Phlip a écrit :
> On Sep 7, 10:36 am, Ian Kelly wrote:
>> On Tue, Sep 7, 2010 at 10:02 AM, Phlip wrote:
>>> Back to the topic, I tend to do this:
>>> for record in Model.objects.filter(pk=42):
>>> return record
>>> return sentinel
>> How is that any better than just catching the exception?
On Sun, Sep 5, 2010 at 8:28 PM, BartC wrote:
>
> One order of magnitude (say 10-20x slower) wouldn't be so bad. That's what
> you might expect for a dynamically typed, interpreted language.
10/20x slower than C is only reached by extremely well optimized
dynamic languages. It would be a tremendo
On Sep 7, 1:06 pm, Bruno Desthuilliers
wrote:
> try:
> return Model.objects.get(pk=42)
> except Model.DoesNotExist:
> return sentinel
Visual Basic Classic had a Collection Class, which worked essentially
like a real language's Hash, Map, or Dict.
Except - it had no operation to test membe
Bob (roberto.pagli...@gmail.com) wrote:
> Hi All,
> I have another question about formatted input. Suppose I am reading a
> text file, and that I want it to be something like this
>
> word11 = num11, word12 = num12, word13 = num13 etc...
> word21 = num21, word22 = num12, word23 = num23 etc...
> et
On 09/07/2010 01:26 PM, Baba wrote:
On 7 sep, 22:08, Gary Herron wrote:
On 09/07/2010 12:46 PM, Baba wrote:
word= 'even'
dict2 = {'i': 1, 'n': 1, 'e': 1, 'l': 2, 'v': 2}
Just go through each letter of word checking for its existence in
dict2. Return False if one misses, an
On 07/09/2010 22:36, Baba wrote:
On 7 sep, 22:37, MRAB wrote:
On 07/09/2010 21:06, Paul Rubin wrote:
Babawrites:
word= 'even'
dict2 = {'i': 1, 'n': 1, 'e': 1, 'l': 2, 'v': 2}
i want to know if word is entirely composed of letters in dict2
set(word)<= set(dict2.keys())
Do the numb
Paul Rubin wrote:
Now extrapolate that error rate from 30 lines to a program the size of
Firefox (something like 5 MLOC), and you should see how fraught with
danger that style of programming is.
But you don't write 5 MLOC of code using that programming style.
You use it to write a small core s
On Tue, Sep 7, 2010 at 6:20 PM, Phlip wrote:
> On Sep 7, 1:06 pm, Bruno Desthuilliers
> wrote:
>
>> try:
>> return Model.objects.get(pk=42)
>> except Model.DoesNotExist:
>> return sentinel
>
> Visual Basic Classic had a Collection Class, which worked essentially
> like a real language's Has
Thanks all for your response i will try out this week, you have give
me sufficient hint.
Thanks again.
Bussiere
On Mon, Sep 6, 2010 at 9:50 AM, Niklasro(.appspot) wrote:
> On Sep 5, 10:57 pm, bussiere bussiere wrote:
>> i've got a python.txt that contain python and it must stay as it (python.txt
Will this webcast/webinar perform on Linux?
Jason
On Tue, 2010-09-07 at 14:08 -0700, Kendra Penrose wrote:
> Connecting the Dots: US SEC, ABS Mandates, Financial Modeling and Python
>
> Date: Wednesday September 22, 2010python-announce-l...@python.org,
> Time: 10:00am PST/1:00pm EST/ 17:00 UTC
>
Baba writes:
> However the following Wiki excerpt seems to go in my direction:
No, it doesn't. It advises that people show kindness; as I've been
arguing, that's exactly what you were shown. You haven't shown how the
information being imparted could have been fully imparted in a way
that's kinde
On 9/7/2010 6:00 AM, BartC wrote:
Why should it? But if you want it, you can do it:
xrange = range
There, that wasn't hard, was it?
I think I just learned more about Python than from months of reading this
group.
So 'range' is just a class like any other. And that a class is something
you
c
On 9/7/2010 3:02 PM, John Nagle wrote:
There's a bug in Python 2.6's "urllib.urlencode". If you pass
in a Unicode character outside the ASCII range, instead of it
being encoded properly, an exception is raised.
File "C:\python26\lib\urllib.py", line 1267, in urlencode
v = quote_plus(str(v))
U
On 9/7/2010 2:53 PM, Phlip wrote:
They are for situations which the caller should care not to handle.
Python is simply not designed that way. Exception raising and catching
is a common flow-control method in Python. If you cannot stand that,
Python is not for you.
--
Terry Jan Reedy
--
h
In message
<74587da9-8861-4400-bbd7-1ea4f8182...@l38g2000pro.googlegroups.com>, Phlip
wrote:
> Pythonistas:
>
> The "Samurai Principle" says to return victorious, or not at all. This
> is why django.db wisely throws an exception, instead of simply
> returning None, if it encounters a "record not
Thomas Jollans wrote:
Hmm. Modifying an object while iterating over it isn't a great idea, ever:
I wouldn't say never. Algorithms that calculate some kind of
transitive closure can be expressed rather neatly by appending
items to a list being iterated over.
You can accommodate that kind of th
"David Cournapeau" wrote in message
news:mailman.546.1283897932.29448.python-l...@python.org...
On Sun, Sep 5, 2010 at 8:28 PM, BartC wrote:
One order of magnitude (say 10-20x slower) wouldn't be so bad. That's
what
you might expect for a dynamically typed, interpreted language.
10/20x s
1 - 100 of 118 matches
Mail list logo