Style question for conditional execution

2010-11-24 Thread Gerald Britton
Have you used the second approach and, if so, what was your motivation? Is there a good/bad reason to choose one over the other? -- Gerald Britton -- http://mail.python.org/mailman/listinfo/python-list

RE: PEP8 compliance and exception messages ?

2010-12-08 Thread Gerald Britton
e 3, in Exception: Long exception text Then, you can indent the individual lines any way you like. -- Gerald Britton -- http://mail.python.org/mailman/listinfo/python-list

RE: Code review request

2010-12-22 Thread Gerald Britton
ng (the trailing comma suppresses the new line) and you'll never have to count the number of items in lst. You also have some statements like: sqlchk = "select * from employees where id = \"%s\"" % (arg) Since a Python list can be enclosed in apostrophes as well as quotations, you can get the same thing without the escapes: sqlchk = 'select * from employees where id = "%s"' % (arg) Anyway -- just some food for thought. -- Gerald Britton -- http://mail.python.org/mailman/listinfo/python-list

PEP8, line continuations and string formatting operations

2011-01-21 Thread Gerald Britton
;s the general feeling about this? Adhere to the PEP 8 binary operators style, or modify it for string formatting? -- Gerald Britton -- http://mail.python.org/mailman/listinfo/python-list

Slice lists and extended slicing

2011-01-26 Thread Gerald Britton
ld do this: >>> l = [1,2,3,4,5] >>> l[0:1, 3:4] Traceback (most recent call last): File "", line 1, in TypeError: list indices must be integers, not tuple but that clearly doesn't work! So, when and how can one use slice lists? -- Gerald Britton -- http://mail.python.org/mailman/listinfo/python-list

Style question: Nicknames for deeply nested objects

2011-01-30 Thread Gerald Britton
roach 2 sets up loop machinery which you don't really need in this case. I have a couple of questions: 1. If you had to choose between approaches 1 and 2, which one would you go for, and why? 2. What other techniques have you used in such a situation? -- Gerald Britton -- http://mail.python.org/mailman/listinfo/python-list

How can I tell if I am inside a context manager?

2011-02-01 Thread Gerald Britton
ot in a context manager on f: with h as f(): # insert code here to return True, since I am in a context manager on f: -- Gerald Britton -- http://mail.python.org/mailman/listinfo/python-list

How can I tell if I am inside a context manager?

2011-02-01 Thread Gerald Britton
On Dienstag 01 Februar 2011, Gerald Britton wrote: > I'd like to know how (perhaps with the inspect module) I can > tell if I am running in a context manager. >>class f(object): >> def __init__(self): >> self.inContext = False >>def __enter__(sel

Re: How can I tell if I am inside a context manager?

2011-02-01 Thread Gerald Britton
ss of how it was created. Whatever the test, it needs to return False in the first case and True in the second case, without modifying the class definition. Gerald Britton -- http://mail.python.org/mailman/listinfo/python-list

How can I print a traceback without raising an exception?

2011-02-13 Thread Gerald Britton
ack (most recent call last): File "", line 1, in File "", line 2, in f File "", line 2, in g File "", line 2, in h Exception >>> -- Gerald Britton -- http://mail.python.org/mailman/listinfo/python-list

lint warnings

2011-02-15 Thread Gerald Britton
ter. BTW, if you like: [item for item in iterable if predicate(item)] you can use: filter(predicate, item) I find the latter neater for the same reasons as above -- Gerald Britton -- http://mail.python.org/mailman/listinfo/python-list

lint warnings

2011-02-15 Thread Gerald Britton
0 loops, best of 3: 879 usec per loop granted, but not on topic here. we're talking about map vs list comps when you want to use a function. >map is only likely to be faster if you wanted to call a function in both cases. Which is exactly the point. >f you have an expression that can be inlined you save the function call >overhead with the list comprehension. Of course, but that's not the point. -- Gerald Britton -- http://mail.python.org/mailman/listinfo/python-list

Map vs. List Comprehensions (was "lint warnings")

2011-02-15 Thread Gerald Britton
gt; Timer('map(g, s)', 'from __main__ import s, g').timeit() 1.8645310401916504 >>> Timer('[x.__class__ for x in s]', 'from __main__ import s').timeit() 1.7232599258422852 >>> Timer('map(a, s)', 'from __main__ import s, a').timeit() 2.4131419658660889 >>> So, what's the feeling out there? Go with map and the operators or stick with the list comps? -- Gerald Britton -- http://mail.python.org/mailman/listinfo/python-list

Python 3.2 and html.escape function

2011-02-20 Thread Gerald Britton
I see that Python 3.2 includes a new module -- html -- with a single function -- escape. I would like to know how this function differs from xml.sax.saxutils.escape and, if there is no difference (or only a minor one), what the need is for this new module and its lone function -- Gerald Britton

Python 3.2 and html.escape function

2011-02-20 Thread Gerald Britton
&& x < 7') 'x > 2 && x < 7' -- Gerald Britton -- http://mail.python.org/mailman/listinfo/python-list

RE: [Python-ideas] Proposal: Query language extension to Python (PythonQL)

2017-03-26 Thread Gerald Britton
(Forgot the subject) > >* On 25 Mar 2017, at 15:51, Gerald Britton ><https://mail.python.org/mailman/listinfo/python-ideas>> wrote: > *> >* On 25 March 2017 at 11:24, Pavel Velikhov <http://gmail.com> <http://gmail.com/ <http://gmail.com/>>> wrot

How to save an image created from multiple images?

2006-07-05 Thread Gerald Marie Nelly
Did u get the answer to that question??? To find out more about Reuters visit www.about.reuters.com Any views expressed in this message are those of the individual sender, except where the sender specifically states them to be the views of Reuters Ltd. -- http://mail.python.org/m

<    1   2