Re: Mutating an HTML file with BeautifulSoup

2022-08-21 Thread Buck Evan
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

Re: New Python implementation

2021-02-15 Thread Buck Evan
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

Re: Binary Sort on Python List __xor__

2020-05-31 Thread Evan Schalton
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

Re: I cannot download python files from external source.

2020-05-31 Thread Evan Schalton
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

Re: Binary Sort on Python List __xor__

2020-05-31 Thread Evan Schalton
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,

Re: Binary Sort on Python List __xor__

2020-05-30 Thread Evan Schalton
@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

Binary Sort on Python List __xor__

2020-05-30 Thread evan . schalton
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

Re: Explicit vararg values

2018-09-22 Thread Buck Evan
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): > .

Explicit vararg values

2018-09-17 Thread Buck Evan
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

Re: Python's method-resolution algorithm: An implementation question

2017-08-15 Thread Evan Aad
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) = > ..

Re: Python's method-resolution algorithm: An implementation question

2017-08-15 Thread Evan Aad
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,

Python's method-resolution algorithm: An implementation question

2017-08-15 Thread Evan Aad
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

Is this PEP viable?

2017-07-17 Thread Evan Adler
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

Re: Arent these snippets equivalent?

2013-01-23 Thread Evan Driscoll
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

Re: Beginner Tutorials

2013-01-18 Thread Evan Driscoll
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

Re: wiki.python.org

2013-01-09 Thread Evan Driscoll
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

Re: Re: Python lists

2012-12-30 Thread Evan Driscoll
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 ...

Re: Iterating over files of a huge directory

2012-12-17 Thread Evan Driscoll
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

Re: Re: Iterating over files of a huge directory

2012-12-17 Thread Evan Driscoll
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

Re: Re: re.search when used within an if/else fails

2012-11-28 Thread Evan Driscoll
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

Re: Re: Managing multiple packages

2012-11-26 Thread Evan Driscoll
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

Re: Re: How to get a "screen" length of a multibyte string?

2012-11-25 Thread Evan Driscoll
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

Re: Re: 10 sec poll - please reply!

2012-11-20 Thread Evan Driscoll
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

Managing multiple packages

2012-11-20 Thread Evan Driscoll
n the install directory (which will just be overwritten). Evan signature.asc Description: OpenPGP digital signature -- http://mail.python.org/mailman/listinfo/python-list

Re: Re: Immutability and Python

2012-10-29 Thread Evan Driscoll
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

Re: Re: Simple Python question for some

2012-10-28 Thread Evan Driscoll
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

Re: Re: while expression feature proposal

2012-10-24 Thread Evan Driscoll
? 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

Re: The pty module, reading from a pty, and Python 2/3

2012-10-23 Thread Evan Driscoll
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

The pty module, reading from a pty, and Python 2/3

2012-10-23 Thread Evan Driscoll
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:

Re: The pty module, reading from a pty, and Python 2/3

2012-10-23 Thread Evan Driscoll
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

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread Evan Driscoll
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

Re: Re: Providing a Python wrapper to a C++ type.

2012-10-16 Thread Evan Driscoll
#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

Re: + in regular expression

2012-10-05 Thread Evan Driscoll
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 '*?', '+?&

Re: Re: + in regular expression

2012-10-05 Thread Evan Driscoll
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

Re: Re: + in regular expression

2012-10-04 Thread Evan Driscoll
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

Re: Re: Algorithms using Python?

2012-09-21 Thread Evan Driscoll
. (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

Re: Re: Objects in Python

2012-08-25 Thread Evan Driscoll
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

Re: Re: Objects in Python

2012-08-25 Thread Evan Driscoll
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

Re: Re: Objects in Python

2012-08-24 Thread Evan Driscoll
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

Variables vs names [was: Objects in Python]

2012-08-23 Thread Evan Driscoll
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

Re: Objects in Python

2012-08-23 Thread Evan Driscoll
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

Re: Re: Objects in Python

2012-08-23 Thread Evan Driscoll
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

Re: Re: Objects in Python

2012-08-22 Thread Evan Driscoll
ill call their bindings "variables", e.g. Scheme. Evan signature.asc Description: OpenPGP digital signature -- http://mail.python.org/mailman/listinfo/python-list

Re: Re: Objects in Python

2012-08-22 Thread Evan Driscoll
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

Re: Re: Objects in Python

2012-08-22 Thread Evan Driscoll
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

Re: Re: Gender, Representativeness and Reputation in StackOverflow

2012-07-23 Thread Evan Driscoll
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.

Re: Re: 2 + 2 = 5

2012-07-05 Thread Evan Driscoll
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

Re: 2 + 2 = 5

2012-07-04 Thread Evan Driscoll
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

Re: Re: code review

2012-07-01 Thread Evan Driscoll
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

Re: code review

2012-06-30 Thread Evan Driscoll
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

Re: Re: code review

2012-06-30 Thread Evan Driscoll
< 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

Re: Þ how can I implement "cd" like shell in Python?

2012-06-28 Thread Evan Driscoll
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

Re: Re: Is python a interpreted or compiled language?

2012-06-20 Thread Evan Driscoll
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

Re: using identifiers before they are defined

2012-06-12 Thread Evan Driscoll
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

Re: Re: why () is () and [] is [] work in other way?

2012-04-26 Thread Evan Driscoll
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

Re: Re: How do you refer to an iterator in docs?

2012-04-20 Thread Evan Driscoll
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

Re: Python one-liner?

2012-04-13 Thread Evan Driscoll
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

Re: Python one-liner?

2012-04-13 Thread Evan Driscoll
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

Python one-liner?

2012-04-13 Thread Evan Driscoll
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

Re: Python Gotcha's?

2012-04-05 Thread Evan Driscoll
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

Re: Re: Re: Python Gotcha's?

2012-04-05 Thread Evan Driscoll
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

Re: Re: Python Gotcha's?

2012-04-05 Thread Evan Driscoll
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

Re: Re: No os.copy()? Why not?

2012-04-03 Thread Evan Driscoll
oblems with all the other suggestions. Evan -- http://mail.python.org/mailman/listinfo/python-list

Re: Re: string interpolation for python

2012-04-02 Thread Evan Driscoll
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

Re: Re: Re: Re: "convert" string to bytes without changing data (encoding)

2012-03-29 Thread Evan Driscoll
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'

Re: Re: Re: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread Evan Driscoll
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. > >

Re: Re: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread Evan Driscoll
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

Re: RE: Advise of programming one of my first programs

2012-03-27 Thread Evan Driscoll
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

Re: Re: Python is readable

2012-03-21 Thread Evan Driscoll
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

Re: Programming D. E. Knuth in Python with the Deterministic Finite Automaton construct

2012-03-17 Thread Evan Driscoll
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

Re: RE: What's the best way to write this regular expression?

2012-03-07 Thread Evan Driscoll
ialog for a "extract .tar.gz files in one go" setting.) Evan -- http://mail.python.org/mailman/listinfo/python-list

Re: Re: lang comparison: in-place algorithm for reversing a list in Perl, Python, Lisp

2012-02-29 Thread Evan Driscoll
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

Re: Re: frozendict

2012-02-08 Thread Evan Driscoll
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

Re: Re: frozendict

2012-02-08 Thread Evan Driscoll
uiltin, per se. I know how to spell 'import'. :-) Evan signature.asc Description: OpenPGP digital signature -- http://mail.python.org/mailman/listinfo/python-list

frozendict

2012-02-08 Thread Evan Driscoll
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

Re: copy on write

2012-02-02 Thread Evan Driscoll
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

Re: PyWart: Python regular expression syntax is not intuitive.

2012-01-25 Thread Evan Driscoll
: "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

Re: Where to put data

2012-01-25 Thread Evan Driscoll
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

Re: The devolution of English language and slothful c.l.p behaviors exposed!

2012-01-23 Thread Evan Driscoll
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

Re: while True or while 1

2012-01-23 Thread Evan Driscoll
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

Extension module question

2012-01-14 Thread Evan Driscoll
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

Re: PyWarts: time, datetime, and calendar modules

2012-01-14 Thread Evan Driscoll
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

Re: copy on write

2012-01-13 Thread Evan Driscoll
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

Re: copy on write

2012-01-13 Thread Evan Driscoll
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

Re: Ctypes compatibility

2012-01-11 Thread Evan Driscoll
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

Re: Introspecting optparse/argparse objects

2012-01-11 Thread Evan Driscoll
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

Ctypes compatibility

2012-01-10 Thread Evan Driscoll
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

Introspecting optparse/argparse objects

2012-01-10 Thread Evan Driscoll
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

Re: help me get excited about python 3

2012-01-04 Thread Evan Driscoll
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

Re: python philosophical question - strong vs duck typing

2012-01-04 Thread Evan Driscoll
quot; of a certain type represent a proof that that the sentence can be proved. Evan -- http://mail.python.org/mailman/listinfo/python-list

Re: python philosophical question - strong vs duck typing

2012-01-03 Thread Evan Driscoll
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

Re: Python education survey

2012-01-02 Thread Evan Driscoll
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

Re: .format vs. %

2011-12-31 Thread Evan Driscoll
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

Re: Pythonification of the asterisk-based collection packing/unpacking syntax

2011-12-18 Thread Evan Driscoll
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

Re: Pythonification of the asterisk-based collection packing/unpacking syntax

2011-12-18 Thread Evan Driscoll
;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

Re: Pythonification of the asterisk-based collection packing/unpacking syntax

2011-12-18 Thread Evan Driscoll
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

Re: Pythonification of the asterisk-based collection packing/unpacking syntax

2011-12-17 Thread Evan Driscoll
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

Re: Pythonification of the asterisk-based collection packing/unpacking syntax

2011-12-17 Thread Evan Driscoll
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

Re: Pythonification of the asterisk-based collection packing/unpacking syntax

2011-12-17 Thread Evan Driscoll
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

Re: Pythonification of the asterisk-based collection packing/unpacking syntax

2011-12-17 Thread Evan Driscoll
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   2   3   >