Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #86546 > unrolled thread
| Started by | Albert-Jan Roskam <fomcl@yahoo.com> |
|---|---|
| First post | 2015-02-26 21:05 +0000 |
| Last post | 2015-02-26 21:05 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Python Worst Practices Albert-Jan Roskam <fomcl@yahoo.com> - 2015-02-26 21:05 +0000
| From | Albert-Jan Roskam <fomcl@yahoo.com> |
|---|---|
| Date | 2015-02-26 21:05 +0000 |
| Subject | Re: Python Worst Practices |
| Message-ID | <mailman.19290.1424985071.18130.python-list@python.org> |
----- Original Message -----
> From: Simon Ward <simon+python@bleah.co.uk>
> To:
> Cc: "python-list@python.org" <python-list@python.org>
> Sent: Thursday, February 26, 2015 8:36 PM
> Subject: Re: Python Worst Practices
>
>
>
> On 25 February 2015 21:24:37 GMT+00:00, Chris Angelico <rosuav@gmail.com>
> wrote:
>> On Thu, Feb 26, 2015 at 7:45 AM, Mark Lawrence
>> <breamoreboy@yahoo.co.uk> wrote:
>>> http://www.slideshare.net/pydanny/python-worst-practices
>>>
>>> Any that should be added to this list? Any that be removed as not
>> that bad?
>>
>> Remove the complaint about id. It's an extremely useful variable name,
>> and you hardly ever need the function.
>
> You can add one character and avoid the conflict with "id_" and not
> require anyone else maintaining the code to think about it. As rare as the
> conflict is, I think the ease of avoiding it makes the extra character a
> practical defensive technique. I agree it is not a worst case.
>
I sometimes do:
import sys, functools
if sys.version_info.major > 2:
bytez = functools.partial(bytes, encoding="utf-8")
else:
bytez = bytes # nog encoding param in python 2.
I bitez you when you shadow 'bytes' (I can't remember when I couldn't use the functools.partial object), though it often works. Much easier to use 'bytez' or 'bytes_'. It is annoying to 'unshadow' your code and confusing for others who might read your code.
Albert-Jan
Back to top | Article view | comp.lang.python
csiph-web