I am having an idea on loosing the argument validity check when passing the
function arguments in keyword way.
For example:
---
deff(x, y):
print(x, y)
defcall_f():
f(x=7, y=9, z=9)
call_f()
--
In the current of python, the extra pass
The struct unpack API is inconvenient to use with files. I must do:
struct.unpack(fmt, file.read(struct.calcsize(fmt))
every time I want to read a struct from the file. I ended up having to
create a utility function for this due to how frequently I was using
struct.unpack with files:
def unpackS
On Mon, Dec 24, 2018 at 06:21:31PM +0800, 李默 wrote:
> I am having an idea on loosing the argument validity check when passing the
> function arguments in keyword way.
> For example:
> ---
> deff(x, y):
> print(x, y)
> defcall_f():
> f(x=7, y=9, z=9)
>
>
> call_f(
> On 24 Dec 2018, at 11:21, 李默 wrote:
>
> I am having an idea on loosing the argument validity check when passing the
> function arguments in keyword way.
> For example:
> ---
> def f(x, y):
> print(x, y)
> def call_f():
> f(x=7, y=9, z=9)
>
> call_f()
> -
Handling files overcomplicates both implementation and mental space for API
saving.
Files can be opened in text mode, what to do in this case? What
exception should be raised?
How to handle OS errors?
On Mon, Dec 24, 2018 at 1:11 PM Drew Warwick wrote:
> The struct unpack API is inconvenient to
On Mon, Dec 24, 2018 at 03:01:07PM +0200, Andrew Svetlov wrote:
> Handling files overcomplicates both implementation and mental space for API
> saving.
Perhaps. Although the implementation doesn't seem that complicated, and
the mental space for the API not that much more difficult:
unpack f
On 12/24/18 7:33 AM, Steven D'Aprano wrote:
> On Mon, Dec 24, 2018 at 03:01:07PM +0200, Andrew Svetlov wrote:
>> Handling files overcomplicates both implementation and mental space
>> for API saving.
> I haven't thought about this very deeply, but at first glance, I like
> Drew's idea of being a
Here's a snippet of semi-production code we use:
def read_and_unpack(handle, fmt):
size = struct.calcsize(fmt)
data = handle.read(size)
if len(data) < size: return None
return struct.unpack(fmt, data)
which was originally something like:
def read_and_unpac
On Mon, 24 Dec 2018 at 13:39, Steven D'Aprano wrote:
>
> > Files can be opened in text mode, what to do in this case? What
> > exception should be raised?
>
> That is easy to answer: the same exception you get if you pass text to
> unpack() when it is expecting bytes:
>
> py> struct.unpack(fmt, "a
On 12/24/2018 5:21 AM, 李默 wrote:
I am having an idea on loosing the argument validity check when passing
the function arguments in keyword way.
For example:
---
deff(x, y):
print(x, y) def call_f(): f(x=7, y=9, z=9)
call_f()
--
In the c
> I agree with other posters that we definitely do not want this as the default
> behavior in Python. However, it's also sometimes a useful pattern. I use it
> when I have a large plugin architecture that can take dozens or hundreds of
> possible parameters, but any given plugin is likely to o
On Mon, Dec 24, 2018 at 03:36:07PM +, Paul Moore wrote:
> > There should be no difference whether the text comes from a literal, a
> > variable, or is read from a file.
>
> One difference is that with a file, it's (as far as I can see)
> impossible to determine whether or not you're going to
The proposal can generate cryptic messages like
`a bytes-like object is required, not 'NoneType'`
To produce more informative exception text all mentioned cases should be
handled:
> - read partial structs from non-blocking files without failing
> - deal with file system errors without failing
> -
13 matches
Mail list logo