I've had much success doing round trips through the lxml.html parser.
https://lxml.de/lxmlhtml.html
I ditched bs for lxml long ago and never regretted it.
If you find that you have a bunch of invalid html that lxml inadvertently
"fixes", I would recommend adding a stutter-step to your project: p
On Thu, Feb 11, 2021 at 1:49 PM dn via Python-list
wrote:
> When I first met it, one of the concepts I found difficult to 'wrap my
> head around' was the idea that "open software" allowed folk to fork the
> original work and 'do their own thing'. My thinking was (probably)
> "surely, the original
I think you're arguing both sides of the argument -- numpy arrays do have a lot
of similar, related operations (because numpy uses them internally -- since
they're more efficient) which means they're not fringe.
I'm advocating that the built-in list class add the efficient, convenience
methods
Michio,
Are you trying to open the ipynb file with python? You need Jupyter Notebook to
run ipynb files. Try installing jupyter notebook (cmd: pip install jupyter)
then launching the jupyter notebook py server (cmd: jupyter notebook). You
should be able to use the file browser in the notebook w
Peter,
This isn't a ram consideration as much it's a logical consideration. There are
a lot of ways to handle this, I REALLY don't want to use a package here. Bit
masking is incredibly useful for permutations/combinatoric algorithms. I can
create my own class wrapper or functions, and optimize,
@MRAB,
Yes -- good point, it should be the __and__ operator.
do I need a new class? No, but based on this use case and other formatting
techniques adding a filter method to the list class that takes in either bit
mask or bool list would streamline a lot of code and not change any existing
func
I frequently use binary as bool placeholders and find myself filtering lists
based on those bools, this seems to have a similar semantic meaning as the bit
wise ^ or __xor__ operator and could add syntactic sugar to the base list class.
Use Case:
Controlling a stepper at half-step has the follo
Received?
On Sun, Sep 16, 2018 at 3:39 PM Buck Evan wrote:
> I started to send this to python-ideas, but I'm having second thoughts.
> Does tihs have merit?
>
> ---
> I stumble on this a lot, and I see it in many python libraries:
>
> def f(*args, **kwargs):
> .
I started to send this to python-ideas, but I'm having second thoughts.
Does tihs have merit?
---
I stumble on this a lot, and I see it in many python libraries:
def f(*args, **kwargs):
...
f(*[list comprehension])
f(**mydict)
It always seems a shame to carefully build up an object in order
Thanks!
On Tue, Aug 15, 2017 at 10:41 PM, Ian Kelly wrote:
>
> On Tue, Aug 15, 2017 at 12:57 PM, Evan Aad wrote:
> > I don't see how, since the L(B*)'s are listed in order in the argument
> > list: L(B1), L(B2), ..., and each L(B*) starts with B*: L(B1) = > ..
I don't see how, since the L(B*)'s are listed in order in the argument
list: L(B1), L(B2), ..., and each L(B*) starts with B*: L(B1) = , L(B2) = , ...
Could you please give a counter-example?
On Tue, Aug 15, 2017 at 9:44 PM, Ian Kelly wrote:
>
> On Tue, Aug 15, 2017 at 9:56 AM,
According to the description of Python's method resolution order (mro)
(https://www.python.org/download/releases/2.3/mro/), a.k.a. C3
linearization (see Wikipedia), the algorithm can be described as
follows:
"the linearization of C is the sum of C plus the merge of the
linearizations of the parent
I would like to submit the following proposal. In the logging module, I
would like handlers (like file handlers and stream handlers) to have a
field for exc_info printing. This way, a call to logger.exception() will
write the stack trace to the handlers with this flag set, and only print
the messag
will
set data again, while the lower one will not.
So if what you mean is "are they equivalent no matter what legal Python
code you put in the ...", no, they aren't.
Evan
signature.asc
Description: OpenPGP digital signature
--
http://mail.python.org/mailman/listinfo/python-list
climbing is very different from why I
continued it. And I feel that the same could be said of programming.
Just because you don't enjoy parts of programming when you're starting
out doesn't mean that you're a lost cause by ANY means.
Evan
--
http://mail.python.org/mailman/listinfo/python-list
t about the best
domain name ever) and it says it's down too.
Evan
signature.asc
Description: OpenPGP digital signature
--
http://mail.python.org/mailman/listinfo/python-list
it(l2[0], ", ")
Um, that doesn't copy the list:
>>> l = ["C100, C117", "X7R ..."]
>>> l2 = l
>>> import string
>>> l2[0] = string.split(l2[0], ", ")
>>> l
[['C100', 'C117'], 'X7R ...
On 12/17/2012 01:50 PM, Oscar Benjamin wrote:
> On 17 December 2012 18:40, Evan Driscoll wrote:
>> On 12/17/2012 09:52 AM, Oscar Benjamin wrote:
>>> https://github.com/benhoyt/betterwalk
>>
>> This is very useful to know about; thanks.
>>
>> I actually
record and anyone looking for other posts, I'd guess
said discussion was on Python-dev. I don't look at even remotely
everything on python-list (there's just too much), but I do skim most
subject lines and I haven't noticed any discussion on it before now.)
Evan
signature.a
e
second level with tabs (consistently), indent from the second to third
level with spaces (consistently), and indent from the third to fourth
level with tabs (consistently), it should not complain. Or perhaps I
should say "it should complain that you're a bad person and should feel
ba
install to a prefix
that doesn't exist, says "you want me to MAKE DIRECTORIES?! what are
you, some kind of slave driver?!". Admittedly that second reason is not
so rational and very occasionally putting up with that in exchange for
development mode is plenty worth it, but being a
cute accent.)
So far the discussion has been on single Unicode code points which
appear as a double-wide glyph (I did not know about those!); depending
on how you want to look at it, combining characters result in sequences
of Unicode code points which result in a single glyph, or combining
characters are zero-width code points.
Evan
--
http://mail.python.org/mailman/listinfo/python-list
s a noun, not a
verb. What does it do? Tell you if its parameters are keystrokes?
(gen_keystrokes is fine, though personally I'd probably stick with
generate_keystrokes of the two.)
Evan
--
http://mail.python.org/mailman/listinfo/python-list
n the install
directory (which will just be overwritten).
Evan
signature.asc
Description: OpenPGP digital signature
--
http://mail.python.org/mailman/listinfo/python-list
rth the hassle
and have done the __getattribute__/__setattribute__ thing the couple of
times I wanted immutability.
Evan
signature.asc
Description: OpenPGP digital signature
--
http://mail.python.org/mailman/listinfo/python-list
le in one rather widely-used one.
If you are PerHaPs talking about the language I think you are, my
favorite fact about that is I'm that I think a while back I saw a bug
entry about something like that and they weren't sure how or even if it
should be fixed.
Evan
--
http://mail.python.org/mailman/listinfo/python-list
? I don't think I like 'from' on a couple counts,
but there's probably some word that fits.
Evan
signature.asc
Description: OpenPGP digital signature
--
http://mail.python.org/mailman/listinfo/python-list
rious if anyone know why it worked in 2 though.
Evan
On 10/23/2012 10:03 PM, Evan Driscoll wrote:
Oh, and a little more information:
The log.txt file I create has the message that it's "about to execlp",
and the exec() *does* actually happen -- the IOError is raised after
the c
s I've mostly only worked with 2.)
I'm not 100% sure how this will come through, so I've also put it at
http://pastebin.com/60wjXSF3.
Evan
import sys
import pty
import os
def get_text(filename):
try:
( child_pid, fd ) = pty.fork()# OK
except OSError as e:
Oh, and a little more information:
The log.txt file I create has the message that it's "about to execlp",
and the exec() *does* actually happen -- the IOError is raised after the
child process quits.
Evan
On 10/23/2012 09:59 PM, Evan Driscoll wrote:
I have the fo
se; for mine, I'd say I'm
trying to keep subexpressions together in space (both horizontal and
vertical). I'm not sure that "drawing boxes" is exactly the right thing
to say what I'm doing, but I think it at least serves to illustrate my
point in this case.
Evan
signature.asc
Description: OpenPGP digital signature
--
http://mail.python.org/mailman/listinfo/python-list
#x27;t do it for speed, I did it because it seemed like a
reasonable way to get access to those APIs. (ctypes was insufficient for
my needs.)
So wrapping a C++ class using Cython also seems pretty natural to me,
assuming that Cython does OK with C++ and isn't restricted to C (which I
have no idea ab
On 10/05/2012 10:27 AM, Evan Driscoll wrote:
On 10/05/2012 04:23 AM, Duncan Booth wrote:
A regular expression element may be followed by a quantifier.
Quantifiers are '*', '+', '?', '{n}', '{n,m}' (and lazy quantifiers
'*?', '+?&
a lie in most real-world regex implementations (in
part because they're not actually regular expressions) and repeated
quantifiers cause problems with the parsing techniques that actually get
used?
Evan
--
http://mail.python.org/mailman/listinfo/python-list
ssive quantifier which Python doesn't support. But that
still doesn't explain why my expectation isn't what happened.)
In what way is that an unreasonable question?
Evan
--
http://mail.python.org/mailman/listinfo/python-list
. (I didn't actually look.)
> You can probably implement them, but they're not going to be very
> efficient. (And never "remove" an element from the linked-list
> implementation because Python would shift all the other elements, hence
> your "links&q
ive ranges would wind up in memory.)
Third, and more wackily, you could technically create a C implementation
that works like Python, where it stores variables (whose addresses
aren't taken) in a dict keyed by name, and generates code that on a
variable access looks up the value by accessing that dict using the name
of the variable.
Evan
--
http://mail.python.org/mailman/listinfo/python-list
y think of variables as naming data, and addresses
mostly come into play when thinking about points-to and aliasing
information at a more abstract level, much the same as I do in Python.
Evan
--
http://mail.python.org/mailman/listinfo/python-list
t this way. If C removed the & operator -- and thus you couldn't
tell what address a variable (or "variable instance", if you prefer) was
at -- would "int x;" cease to be a variable?
Evan
signature.asc
Description: OpenPGP digital signature
--
http://mail.python.org/mailman/listinfo/python-list
On 08/23/2012 12:56 PM, Steven D'Aprano wrote:
> On Thu, 23 Aug 2012 12:17:03 -0500, Evan Driscoll wrote:
>
>> I definitely *wouldn't* say "Python
>> classes aren't really classes" -- even though (I assert) Python classes
>> are *far* further
ing "Python doesn't have variables" is, IMO, at least as silly as
what Jussi said. To me, dancing around the issue just leads to more
confusing terminology and makes things worse.
(And this is reinforced by the fact that neither I nor Google seems to
have really seen "Python doesn't have classes" ever used, when that
statement is at least as true as "Python doesn't have variables".)
Evan
signature.asc
Description: OpenPGP digital signature
--
http://mail.python.org/mailman/listinfo/python-list
le Java programming so can't point to any concrete cases if
you would (reasonably) reject the example of java.util.collections being
used in their non-generic form.)
Anyway, the point wasn't that 'foo(Object o)' is common, just that
you've probably seen something whi
ill call their
bindings "variables", e.g. Scheme.
Evan
signature.asc
Description: OpenPGP digital signature
--
http://mail.python.org/mailman/listinfo/python-list
On 08/22/2012 02:45 PM, lipska the kat wrote:
> On 22/08/12 20:03, Evan Driscoll wrote:
>> Second, this concept isn't *so* unfamiliar to you. If I give you the
>> following Java code:
>>
>>void foo(Object o) { ... }
>>
> looking at this method decla
aught up in categorizing everything
into "strong" and "weak"; that's a spectrum, and where things fall is a
lot more interesting than just "here or there". Really it's even more
complex than just a linear spectrum -- Language A can be stronger than
Language B in one respect but weaker in another.
In particular, it's possible to have rather stronger typing than Python
(especially with respect to Booleans, but in some other respects as well).
Evan
signature.asc
Description: OpenPGP digital signature
--
http://mail.python.org/mailman/listinfo/python-list
valuable
free data from freely donated time.
Leaving aside questions of relevance to the email list and the quality
of results from a self-selected survey, the PDF is linked directly from
the Google Scholar link in the original post: "[PDF] from tue.nl".
Evan
--
http://mail.
On 01/-10/-28163 01:59 PM, Alexander Blinne wrote:
5+0 is actually 4+0, because 5 == 4, so 5+0 gives 4.
5+1 is actually 4+1, which is 5, but 5 is again 4.
5+2 is 4+2 which is 6.
Now all I can think is "Hoory for new math, new-hoo-hoo math" :-)
Evan
--
http://mail.python.org/mailma
the values of literals by passing them to a function by
reference and then modifying the value.
Evan
signature.asc
Description: OpenPGP digital signature
--
http://mail.python.org/mailman/listinfo/python-list
On 7/1/2012 4:54, Alister wrote:
> On Sat, 30 Jun 2012 23:45:25 -0500, Evan Driscoll wrote:
>> If I had seen that in a program, I'd have assumed it was a bug.
>
> You would?
> I have only been using python for 6 - 12 months but in my past I
> programmed microcontrollers
On 6/30/2012 23:45, Evan Driscoll wrote:
> You may also
> want to put Java in there as well, as < is effectively not commutative
> in that language. (I didn't try C#.)
I guess you could actually put Lua and Ruby into the roughly same
category as Java too.
But things get a
< is not associative and "a < b < c"
is a syntax error. (FWIW this is my favorite approach.) You may also
want to put Java in there as well, as < is effectively not commutative
in that language. (I didn't try C#.)
I've been programming in Python for a few year
ight thing to the new-directory script, e.g. that it
works with whitespace in the arguments and that it isn't including the
equivalent to argv[0] in the script.
Evan
--
http://mail.python.org/mailman/listinfo/python-list
retically this isn't necessary)
- pure compiled
I'd say these categories tend to be qualitative "I know it when I see
it" rather than hard divisions.
Evan
>
> java has available a "runtime" environment, for those who don't want or
> need the compil
llustrate, in a different manner that doesn't
use this "undefined" thing:
def foo():
print "Inside the first version of foo"
def call_foo():
foo()
call_foo()
def foo():
print "Inside the second version of foo"
call_foo()
This prints:
Inside t
vior
(in the technical C++ sense of "your program is now allowed to set your
cat on fire").
Evan
--
http://mail.python.org/mailman/listinfo/python-list
r dismissed it.)
Personally though, I'd probably say an iterator *to* Foos.
Evan
signature.asc
Description: OpenPGP digital signature
--
http://mail.python.org/mailman/listinfo/python-list
On 4/13/2012 22:42, Evan Driscoll wrote:
> Though I might as well ask another question... if I have a dict with
> values which are lists, what's a good way to say "append x to the list
> at key k, creating a list if it's not there"? dict.setdefault seems
> potent
On 4/13/2012 22:33, Evan Driscoll wrote:
> d = {}
> def appender(e):
> d.get(f(e), []).append(e)
> map(appender, l)
Just in case it isn't clear, the above has at least two problems and
won't even come close to working. :-)
Though I might as well ask an
rehension or itertools expression or something. At
this point I'm asking mostly out of curiosity and less for some code to
actually use, so either Python 2 or 3 is acceptable (but I'm writing in
3 at the moment).
Evan
signature.asc
Description: OpenPGP digital signature
--
http://mail.python.org/mailman/listinfo/python-list
On 4/5/2012 17:11, Evan Driscoll wrote:
> In particular, the translation of 'a+=b' to 'temp = a + b; a = temp' is
> *not* a very natural one to me.
To expand on this point slightly, because of common C++ idioms guided by
efficiency, I would be much more likely to thi
eally work with Python because more stuff is
immutable, and Python's behavior is arguably the least-bad solution, but
it WAS definitely surprising for me (and others!) when I learned about
Python's behavior.
In particular, the translation of 'a+=b' to 'temp = a + b; a = te
unorderable:
>>> 0 < True
True
I think it also has bearing on the ' vs " issue. For instance, I totally
think it's not at all surprising that one can be accepted and the other
not, or that they behave differently. (Though I *do* find it surprising
in the c
oblems with all the other suggestions.
Evan
--
http://mail.python.org/mailman/listinfo/python-list
t;eval from *this dictionary* if
you want, which solves Steven D'Aprano's objection that your
suggestion is too weak.
4. Languages changes should be viewed suspiciously in general.
Evan
--
http://mail.python.org/mailman/listinfo/python-list
On 01/-10/-28163 01:59 PM, Ross Ridge wrote:
Evan Driscoll wrote:
People like you -- who write to assumptions which are not even remotely
guaranteed by the spec -- are part of the reason software sucks.
...
This email is a bit harsher than it deserves -- but I feel not by much.
I don'
On 3/28/2012 14:43, Ross Ridge wrote:
> Evan Driscoll wrote:
>> So yes, you can say that pretending there's not a mapping of strings to
>> internal representation is silly, because there is. However, there's
>> nothing you can say about that mapping.
>
>
not a mapping of strings to
internal representation is silly, because there is. However, there's
nothing you can say about that mapping.
Evan
--
http://mail.python.org/mailman/listinfo/python-list
ever
unpickle data received from an untrusted or unauthenticated
source.
- http://docs.python.org/library/pickle.html
Evan
--
http://mail.python.org/mailman/listinfo/python-list
27;stack' while #1/2
won't, but even that isn't true of course. For instance, CLOS will let
you write '(push stack item)' (which is the direct analogy in that
language to #1) and do even more powerful dynamic dispatch than what a
language like C++, Java, or Python will let you
rk
label .A4
# do something
if : goto .A1
label .A5
# something more
if : goto .A2
Clearly the best solution of all.
(Note: do not actually do this.)
Evan
signature.asc
Description: OpenPGP digital signature
--
http://mail.python.org/mailman/listinfo/python-list
ialog for a
"extract .tar.gz files in one go" setting.)
Evan
--
http://mail.python.org/mailman/listinfo/python-list
mporary list, which is why this
idiom would even fit in pretty well in Scheme.
Evan
signature.asc
Description: OpenPGP digital signature
--
http://mail.python.org/mailman/listinfo/python-list
d that takes a bunch of functions. I didn't
know about the ABTs in 'collections' though, so that helps a bit.
However, I'd still prefer something that guaranteed immutability better
than that. I might just be fighting the language too much at that point
though...
Evan
uiltin, per se. I know how to spell
'import'. :-)
Evan
signature.asc
Description: OpenPGP digital signature
--
http://mail.python.org/mailman/listinfo/python-list
which is why it's not already provided.
Does anyone know why Python doesn't already come with a frozendict, or
why there seem to only be a couple attempts to write one?
Evan
signature.asc
Description: OpenPGP digital signature
--
http://mail.python.org/mailman/listinfo/python-list
On 01/-10/-28163 01:59 PM, 8 Dihedral wrote:
If you're working in C++ and overload your operators so that 'a +='
and 'a = + b' have different observable behaviors (besides perhaps
time), then either your implementation is buggy or your design is very
bad-mannered
: "About as good of an idea as no longer
calling PCRE-alikes 'regular expressions', because they aren't." Ahhh,
got that out of my system. :-))
Evan
signature.asc
Description: OpenPGP digital signature
--
http://mail.python.org/mailman/listinfo/python-list
I would just like to make a strong plea that you make it possible to
install in places other than /usr. Bascially, 'python setup.py install
--prefix /some/alternative/place' should work.
Evan
On 01/25/2012 11:26 AM, bvdp wrote:
I'm having a disagreement with a buddy on the
On 1/23/2012 23:57, Rick Johnson wrote:
> Of
> course, "used to" and "supposed to" will require people to rethink
> there lazy and slothful ways.
I'll go repent in the corner, over their.
signature.asc
Description: OpenPGP digital signature
--
http://mail.python.org/mailman/listinfo/python-list
off, I'd hate to see what you do when you learn that Python accepts
loops like 'while x' where the condition evaluates to true if x is a
non-zero integer and false if x is 0.
All that said, I like the 'while "stuff to do"' idea.
Evan
--
http://mail.python.org/mailman/listinfo/python-list
ned long (so "k") and add a static
assertion that sizeof(long)==sizeof(void*). Is this the canonical way of
doing something like this, or am I missing a better way?
Evan
signature.asc
Description: OpenPGP digital signature
--
http://mail.python.org/mailman/listinfo/python-list
nfusion would
be how things like your code completion and dir() display the results,
not anything fundamental about the language. (And also the datetime
API.) PyDev, for instance, tries to show you what "kind" of thing each
entry in its completion menu are.
Evan
--
http://mail.python.org/mailman/listinfo/python-list
go and assign the result to and
return a reference to 'a', just like how 'a += b' will return a
reference to 'a'.
If you're working in C++ and overload your operators so that 'a += b'
and 'a = a + b' have different observable behaviors
likely to wonder that much at all
because he or she wouldn't view the objects as immutable to begin with.
:-) 'x = 5; x += 1;' makes perfect sense in C++, just for a somewhat
different reason.
Evan
--
http://mail.python.org/mailman/listinfo/python-list
wrapper). If you're saying I should use c_size_t on the Python side, I
think that's outright wrong since I think some of the fields in the
dirent struct are 64 bits even on 32-bit systems. (I might be wrong
about that though.)
And even neglecting that, the types of the fields is on
On 1/11/2012 19:37, alex23 wrote:
> On Jan 11, 11:26 am, Evan Driscoll wrote:
>> (For a concrete idea of a use case, suppose that it did not
>> directly support the --help option and I wanted to write code that took
>> its place.)
> That's a pretty weird definitio
C. Is that just how it is with ctypes? Or is there
some way around it? I'm sort of tempted to write a C module whose sole
purpose is to wrap readdir...
Evan
signature.asc
Description: OpenPGP digital signature
--
http://mail.python.org/mailman/listinfo/python-list
rticular reason that this API *isn't* provided, and
if I asked for it I might get it in a future version?
Evan
signature.asc
Description: OpenPGP digital signature
--
http://mail.python.org/mailman/listinfo/python-list
thon
Python 2.7.1 (r271:86832, May 3 2011, 10:31:28)
>>> True, False = False, True
>>> "True is " + ("True" if True else "False")
'True is False'
~ : python3
Python 3.2 (r32:88445, May 3 2011, 13:26:55)
>>> True, False = False, True
File "", line 1
SyntaxError: assignment to keyword
Evan
--
http://mail.python.org/mailman/listinfo/python-list
quot; of a certain type represent a proof that that the
sentence can be proved.
Evan
--
http://mail.python.org/mailman/listinfo/python-list
L's optional
type annotations as providing a mechanism for getting near-C-like
performance. I haven't tested that myself though.
Evan
signature.asc
Description: OpenPGP digital signature
--
http://mail.python.org/mailman/listinfo/python-list
On 1/3/2012 0:27, Rick Johnson wrote:
> Yes, i used the word "work" improperly here. Just another example of
> the corrupting influence of garage verbiage. Thanks for bring this to
> my attention!
"Diction" would be a far better word than "verbiage" th
How 'bout just:
>>> s = "{0} {1} {2} {3}"
>>> s.format(1, 2, 3, 4)
'1 2 3 4'
Evan
On 12/31/2011 13:44, davidfx wrote:
> Thanks for your response. I know the following code is not going to be
> correct but I want to show you what I was
quot; or whatever is just changing the syntax a bit and adding
several more characters for me to type.
Evan
signature.asc
Description: OpenPGP digital signature
--
http://mail.python.org/mailman/listinfo/python-list
;m not an expert on Google's syntax, but if you search for "python,
> optionally with function", isn't that the same as just searching for
> "python" since it will return hits either with or without "function"?
Chris Angelico's interpretat
don't feel I can answer very well. I was giving my
thoughts on what I would do or consider doing with the proposal assuming
the fundamental idea is sound. Whether it should be accepted at all is a
matter for someone else. :-)
Evan
signature.asc
Description: OpenPGP digital signature
--
http://mail.python.org/mailman/listinfo/python-list
On 12/17/2011 23:33, Evan Driscoll wrote:
> I do have one more thing to point out, which is that currently the
> Python vararg syntax is very difficult to Google for. In the first pages
> of the four searches matching "python (function)? (star | asterisk)",
> there was ju
n we
could say:
def foo(varargs l, kwargs d):
bar(varargs l, kwargs d)
and varargs would be equivalent to * and kwargs would be equivalent to
**. But then you could also say
def foo(varargs(list) l, kwargs(dict) d)
Evan
signature.asc
Description: OpenPGP digital signature
--
http://mail.python.org/mailman/listinfo/python-list
co wrote:
> Not quite; 1 + "one" will be "ne", which might happen to be at memory
> location 2. The data type is going to be char* (or, in a modern
> compiler, const char*), not int.
I'm not quite sure I'd say that it could be 2, exactly, but I definitely
disagr
On 12/17/2011 21:03, Evan Driscoll wrote:
> Personally I'd put Python even weaker on account of things such as
> '[1,2]*2' and '1 < True' being allowed, but on the other hand it
> doesn't allow "1"+1.
Not to mention duck typing, which under m
1 - 100 of 261 matches
Mail list logo