Erik wrote:
Is there not a class that is somewhere between "dict" and "OrderedDict"
that provides what I need?
Such a class could exist, but the stdlib doesn't happen to provide
one as far as I know.
Note, though, that you're relying on implementation details of
OrderedDict when you use it to
Devin Jeanpierre wrote:
I vote the last one: you can read the .name attribute of the returned
file(-like) object from NamedTemporaryFile to get a path to a file,
which can be passed to other functions.
I don't think that helps. You would have to delete the file
first before you could create a l
On Sun, Apr 30, 2017 at 1:51 PM, Devin Jeanpierre
wrote:
> I guess ideally, one would use linkat instead of os.link[*], but that's
> platform-specific and not exposed in Python AFAIK.
It is actually - src_dir_fd and dst_dir_fd.
https://docs.python.org/3/library/os.html#os.link
ChrisA
--
https:
On Sat, Apr 29, 2017 at 11:45 AM, Tim Chase
wrote:
> Unfortunately, tempfile.mktemp() is described as deprecated
> since 2.3 (though appears to still exist in the 3.4.2 that is the
> default Py3 on Debian Stable). While the deprecation notice says
> "In version 2.3 of Python, this module was overh
On Sunday, April 30, 2017 at 2:30:25 AM UTC+1, Erik wrote:
> On 30/04/17 01:17, breamoreboy wrote:
> > On Sunday, April 30, 2017 at 12:23:19 AM UTC+1, Erik wrote:
> >> The other is that the documentation of collections.OrderedDict seems to
> >> be lacking (it is talking in terms of being a "dict" s
On 30/04/17 01:17, breamore...@gmail.com wrote:
On Sunday, April 30, 2017 at 12:23:19 AM UTC+1, Erik wrote:
The other is that the documentation of collections.OrderedDict seems to
be lacking (it is talking in terms of being a "dict" subclass, but it
actually isn't one).
E.
Could have fooled m
On Sun, 30 Apr 2017 09:41 am, Jason Friedman wrote:
> < start code >
>
> import itertools
>
> data = """Line1
> Line2
>
> Line4
> Line5"""
>
> def test_to_start(s):
> return "2" in s
>
> for line in itertools.dropwhile(test_to_start, data.splitlines()):
> print(line)
>
> <---
On 30/04/17 01:31, Ben Finney wrote:
Erik writes:
On 29/04/17 23:40, Ned Batchelder wrote:
For creating your own class that acts like a dict, you should derive
from collections.abc.MutableMapping, which only requires
implementing __getitem__, __setitem__, __delitem__, __iter__, and
__len__.
On 4/29/2017 7:41 PM, Jason Friedman wrote:
< start code >
import itertools
data = """Line1
Line2
Line4
Line5"""
def test_to_start(s):
return "2" in s
for line in itertools.dropwhile(test_to_start, data.splitlines()):
print(line)
< end code >
I expect:
$ python3
Working on some deduplication code, I want do my my best at
performing an atomic re-hard-linking atop an existing file, akin to
"ln -f source.txt dest.txt"
However, when I issue
os.link("source.txt", "dest.txt")
it fails with an OSError (EEXISTS). This isn't surprising as it's
documented. Un
On Sunday, April 30, 2017 at 12:23:19 AM UTC+1, Erik wrote:
> On 29/04/17 23:40, Ned Batchelder wrote:
> > For creating your own class that acts like
> > a dict, you should derive from collections.abc.MutableMapping, which
> > only requires implementing __getitem__, __setitem__, __delitem__,
> > __
Erik writes:
> On 29/04/17 23:40, Ned Batchelder wrote:
> > For creating your own class that acts like a dict, you should derive
> > from collections.abc.MutableMapping, which only requires
> > implementing __getitem__, __setitem__, __delitem__, __iter__, and
> > __len__.
>
> Or, I could derive f
Erik wrote:
That's one of the points I'm trying to make - why is it harder than it
needs to be to do something this simple?
The built-in dict class is used internally to implement
various namespaces (module, class, instance, etc.), so it
needs to be extremely efficient. Funnelling all updates
t
< start code >
import itertools
data = """Line1
Line2
Line4
Line5"""
def test_to_start(s):
return "2" in s
for line in itertools.dropwhile(test_to_start, data.splitlines()):
print(line)
< end code >
I expect:
$ python3 dropwhile.py
Line2
Line4
Line5
I get:
$ pyth
On 29/04/17 23:40, Ned Batchelder wrote:
For creating your own class that acts like
a dict, you should derive from collections.abc.MutableMapping, which
only requires implementing __getitem__, __setitem__, __delitem__,
__iter__, and __len__.
Or, I could derive from collections.OrderedDict and j
On Saturday, April 29, 2017 at 4:20:06 PM UTC-4, Erik wrote:
> It seems a little onerous that I have to put the key checks in several
> places and implement each of those APIs manually again (and keep on top
> of that if dict() grows some new methods that involve setting items). Is
> there a co
I have a subclass of dict that enforces which keys are allowed to be set
and only allows each key to be set at most once:
class StrictDict(dict):
def __init__(self, validkeys, *args, **kwargs):
self.validkeys = validkeys
super(StrictDict, self).__init__(*args, **kwargs)
def __setite
Hi,
I would like to ask how can I convert text file data into RDF fromat. data look
like this:
# sent_id = weblog-juancole.com_juancole_20051126063000_ENG_20051126_063000-0001
# text = Al-Zaman : American forces killed Shaikh Abdullah al-Ani, the preacher
at the mosque in the town of Qaim, nea
Hi Dennis,
My requirement is like,i want to send the static and dynamic traffic
together.while traffic sending i want to delete some config from device.
st and dy both the targets want to be run at the same time.
On Fri, Apr 28, 2017 at 6:10 PM, Dennis Lee Bieber
wrote:
> On Fri, 28 Apr 20
19 matches
Mail list logo