[EMAIL PROTECTED] a écrit :
> On Apr 17, 12:34 pm, Michael Torrie <[EMAIL PROTECTED]> wrote:
>> Another thing to consider is that referencing a member of a class or
>> instance already *is* a dictionary lookup. It's how python works. Thus
>> dictionaries are optimized to be fast. Since strings a
Michael Torrie schrieb:
> [EMAIL PROTECTED] wrote:
>> You didn't really write that at the Python's interpreter, did you?
>> It's wrong. The way that would really go at the interpreter is like
>
> I did actually run it through the interpreter, but I didn't copy and
> past it to the e-mail. Thought
[EMAIL PROTECTED] wrote:
> On Apr 17, 11:46 am, Arnaud Delobelle <[EMAIL PROTECTED]> wrote:
>> Why not do something like:
>>
>> class RequestHeadersManager:
>>
>> def __init__(self, string):
>> self._fields = {}
>> # Populate self.fields with fields defined in 'string'
>>
>>
On Thu, 2008-04-17 at 13:53 -0400, Steve Holden wrote:
> Gary Herron wrote:
> > [EMAIL PROTECTED] wrote:
> >> On Apr 17, 10:54 am, [EMAIL PROTECTED] wrote:
> >>
> >>> On 17 avr, 17:40, [EMAIL PROTECTED] wrote:
> >>>
> >>> Out of sheer curiosity, why do you need thirty (hand-specified and
> >>> d
On Apr 17, 5:56 pm, [EMAIL PROTECTED] wrote:
> class RequestHeadersManager:
> ...
> def __init__(self, headers, linesep):
> headersDict = parse_headers(headers, linesep)
>
> for header in headersDict.keys():
> ...[lots of code]
Your code is pretty much equivalent to
[EMAIL PROTECTED] wrote:
> You didn't really write that at the Python's interpreter, did you?
> It's wrong. The way that would really go at the interpreter is like
I did actually run it through the interpreter, but I didn't copy and
past it to the e-mail. Thought that I saw this behavior, but cle
On Apr 17, 12:34 pm, Michael Torrie <[EMAIL PROTECTED]> wrote:
>
> Another thing to consider is that referencing a member of a class or
> instance already *is* a dictionary lookup. It's how python works. Thus
> dictionaries are optimized to be fast. Since strings are immutable,
> python hashes t
Gary Herron wrote:
> [EMAIL PROTECTED] wrote:
>> On Apr 17, 10:54 am, [EMAIL PROTECTED] wrote:
>>
>>> On 17 avr, 17:40, [EMAIL PROTECTED] wrote:
>>>
>>> Out of sheer curiosity, why do you need thirty (hand-specified and
>>> dutifully commented) names to the same constant object if you know
>>> t
On Apr 17, 12:24 pm, Michael Torrie <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> >
> > There! That's the whole code. I guess the way you suggest is simpler
> > and a bit more intuitive, but I was figuring that the way I suggested
> > it is more stylish.
>
> Umm, doesn't defining all tho
Marco Mariani wrote:
> [EMAIL PROTECTED] wrote:
>
>> Yes, it makes it more readable. And yes, it does make it (a lot) more
>> maintainable. Mainly because I don't have those four variables, I have
>> about thirty. And I think I won't need to one or two of them, but
>> maybe all of them at once.
>
Michael Torrie wrote:
That's not how Python actually works:
> >>> a=myclass(3)
> >>> b=myclass(6)
> >>> a.classvar1=9
> >>> a.classvar1
> 9
> >>> b.classvar1
> 9
What actually happens is that the a.classvar1 = 9 assignment creates an
instance variable that shades the classvar:
>>> class A(objec
On Apr 17, 6:02 pm, [EMAIL PROTECTED] wrote:
[...]
> I do it with all the separate variables mainly for performance. If I
> had the headers in a dict, I'd be looking up a string in a list of
> strings (the keys of the dict) everytime I check for a header. Not
> that that's going to take more that 0
[EMAIL PROTECTED] wrote:
> I do it with all the separate variables mainly for performance. If I
> had the headers in a dict, I'd be looking up a string in a list of
> strings (the keys of the dict) everytime I check for a header. Not
> that that's going to take more that 0.1 seconds, but the progra
On Apr 17, 12:07 pm, Sion Arrowsmith <[EMAIL PROTECTED]>
wrote:
> <[EMAIL PROTECTED]> wrote:
> >In Python, you usually can use parentheses to split something over
> >several lines. But you can't use parentheses for an assignment of
> >several lines.
>
> Yes you can, you just need an iterable of th
[EMAIL PROTECTED] wrote:
>
> There! That's the whole code. I guess the way you suggest is simpler
> and a bit more intuitive, but I was figuring that the way I suggested
> it is more stylish.
Umm, doesn't defining all those members in the class lead to class
variables, not instance variables? I
<[EMAIL PROTECTED]> wrote:
>In Python, you usually can use parentheses to split something over
>several lines. But you can't use parentheses for an assignment of
>several lines.
Yes you can, you just need an iterable of the right length on
the other side for the tuple unpacking to work:
>>> (CON
On Apr 17, 11:46 am, Arnaud Delobelle <[EMAIL PROTECTED]> wrote:
>
> Why not do something like:
>
> class RequestHeadersManager:
>
> def __init__(self, string):
> self._fields = {}
> # Populate self.fields with fields defined in 'string'
>
> def __getitem__(self, fieldname):
On Apr 17, 11:44 am, Gary Herron <[EMAIL PROTECTED]> wrote:
> But. *What's the point* of doing it this way.I see 14 variables
> being assigned a value, but I don't see the value, they are getting.
> Reading this bit if code provides no useful information unless I'm
> willing to scan down the
On Apr 17, 5:19 pm, [EMAIL PROTECTED] wrote:
> On Apr 17, 10:54 am, [EMAIL PROTECTED] wrote:
>
> > On 17 avr, 17:40, [EMAIL PROTECTED] wrote:
>
> > Out of sheer curiosity, why do you need thirty (hand-specified and
> > dutifully commented) names to the same constant object if you know
> > there wil
[EMAIL PROTECTED] wrote:
> On Apr 17, 10:54 am, [EMAIL PROTECTED] wrote:
>
>> On 17 avr, 17:40, [EMAIL PROTECTED] wrote:
>>
>> Out of sheer curiosity, why do you need thirty (hand-specified and
>> dutifully commented) names to the same constant object if you know
>> there will always be only one
On 17 avr, 18:19, [EMAIL PROTECTED] wrote:
> On Apr 17, 10:54 am, [EMAIL PROTECTED] wrote:
>
> > On 17 avr, 17:40, [EMAIL PROTECTED] wrote:
>
> > Out of sheer curiosity, why do you need thirty (hand-specified and
> > dutifully commented) names to the same constant object if you know
> > there will
On Thu, 17 Apr 2008 09:19:32 -0700 (PDT)
[EMAIL PROTECTED] wrote:
> I'm building a web server. The many variables are names of header
> fields. One part of the code looks like this (or at least I'd like it
> to):
>
> class RequestHeadersManager:
>
> # General header fields
> Cache_Control
On Apr 17, 10:54 am, [EMAIL PROTECTED] wrote:
> On 17 avr, 17:40, [EMAIL PROTECTED] wrote:
>
> Out of sheer curiosity, why do you need thirty (hand-specified and
> dutifully commented) names to the same constant object if you know
> there will always be only one object?
I'm building a web server.
On 2008-04-17, Gary Herron <[EMAIL PROTECTED]> wrote:
>> For example, let's say I want to assign a bunch of variables to an
>> initial, single value. In C or a similar language you would do:
>>
>> CONSTANT1=
>> /* This is some constant */
>> CONSTANT2=
>> CONSTANT3=
>>
>> /*This is yet
On 17 avr, 17:40, [EMAIL PROTECTED] wrote:
> > Yuck! No way!! If you *want* to make your code that hard to read, I'm
> > sure you can find lots of ways to do so, even in Python, but don't
> > expect Python to change to help you toward such a dubious goal.
>
> Well, my actual code doesn't look lik
[EMAIL PROTECTED] wrote:
> Yes, it makes it more readable. And yes, it does make it (a lot) more
> maintainable. Mainly because I don't have those four variables, I have
> about thirty. And I think I won't need to one or two of them, but
> maybe all of them at once.
have fun with locals(), then (
[EMAIL PROTECTED] wrote:
>> Yuck! No way!! If you *want* to make your code that hard to read, I'm
>> sure you can find lots of ways to do so, even in Python, but don't
>> expect Python to change to help you toward such a dubious goal.
>>
>
> Well, my actual code doesn't look like that. Trust me,
> Yuck! No way!! If you *want* to make your code that hard to read, I'm
> sure you can find lots of ways to do so, even in Python, but don't
> expect Python to change to help you toward such a dubious goal.
>
Well, my actual code doesn't look like that. Trust me, I like clean
code.
> Seriously,
[EMAIL PROTECTED] wrote:
> I was shocked a while ago when a discovered that in Python you can't
> do a multiline assignment
> with comments between the lines.
>
> For example, let's say I want to assign a bunch of variables to an
> initial, single value. In C or a s
I was shocked a while ago when a discovered that in Python you can't
do a multiline assignment
with comments between the lines.
For example, let's say I want to assign a bunch of variables to an
initial, single value. In C or a similar language you would do:
CONSTANT1=
/* Th
30 matches
Mail list logo