[issue17884] Try to reuse stdint.h types like int32_t

2013-05-01 Thread Devin Jeanpierre
Devin Jeanpierre added the comment: I don't know what context these types are being used in, but would int_least64_t suffice? C99 does require the existence of the [u]int_leastN_t types (for N in {8,16,32,64}), unlike [u]intN_t. -- ___ Python

[issue17870] Hard to create python longs from arbitrary C integers

2013-04-29 Thread Devin Jeanpierre
New submission from Devin Jeanpierre: As far as I can tell, the only safe and correct way to convert a (for example) intptr_t to a python long is something akin to the following: size_t repsize = sizeof(intmax_t)*8 + 2; char i_buf[repsize]; // enough to fit base 2 with sign, let alone

[issue17870] Hard to create python longs from arbitrary C integers

2013-04-29 Thread Devin Jeanpierre
Devin Jeanpierre added the comment: PyLong_FromVoidPtr works for uintptr_t, but not intptr_t. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17870

[issue17870] Python does not provide a PyLong_FromIntptr_t() function

2013-04-29 Thread Devin Jeanpierre
Devin Jeanpierre added the comment: With regards to the title change, I would prefer a FromIntMax_t (and FromUintMax_t) to a FromIntPtr_t. The former covers every use case of the latter, and more. -- ___ Python tracker rep...@bugs.python.org http

[issue17870] Python does not provide a PyLong_FromIntptr_t() function

2013-04-29 Thread Devin Jeanpierre
Devin Jeanpierre added the comment: Isn't it possible for a 64-bit architecture to have intptr_t be wider than long long? As for my use-case, I am wrapping the C-API for Rust. Rust can call and be called by C (and therefore Python), but a Rust int is a C intptr_t, and a Rust uint is a C

Adding new source types to distutils?

2013-04-28 Thread Devin Jeanpierre
Last night I wrote a toy prototype module that lets one compile Rust crates into extension modules for Python. The problem is, I don't know the right way to do this. Ideally I'd just want to tell build_ext that there's a new source type I want to handle (.rc and .rs), and also tell distutils that

Re: Adding new source types to distutils?

2013-04-28 Thread Devin Jeanpierre
On Sun, Apr 28, 2013 at 2:24 PM, Stefan Behnel stefan...@behnel.de wrote: That approach is discouraged for Cython. The compiler comes with a cythonize() function these days, which users can simply call from their setup.py scripts. It spits out a list of Extensions that you can pass into

Re: How to subclass a family

2013-04-08 Thread Devin Jeanpierre
On Mon, Apr 8, 2013 at 5:44 AM, Antoon Pardon antoon.par...@rece.vub.ac.be wrote: Now of course I could subclass every class from the original family from Foo1 to Foon but that would mean a lot of duplicated code. Is there a way to reduce the use of duplicated code in such circumstances? As a

Re: JIT compilers for Python, what is the latest news?

2013-04-05 Thread Devin Jeanpierre
On Fri, Apr 5, 2013 at 4:34 AM, John Ladasky john_lada...@sbcglobal.net wrote: On Thursday, April 4, 2013 7:39:16 PM UTC-7, MRAB wrote: Have you looked at Cython? Not quite the same, but still... I'm already using Numpy, compiled with what is supposed to be a fast LAPACK. I don't think I

[issue17473] -m is not universally applicable

2013-03-18 Thread Devin Jeanpierre
New submission from Devin Jeanpierre: Many executables in python are meant to be run on python scripts, but can't run python scripts that are part of a package. For example, one can do `python -m pdb foo.py`, but not `python -m pdb package.foo`. This makes it more difficult to interact

Re: Finding the Min for positive and negative in python 3.3 list

2013-03-12 Thread Devin Jeanpierre
min(a) This does not return a negative minimum on input [1] (because there is none). and min([e for e in a if e =0] This does not return a positive minimum on input [0] (because there is none). I would have said: pos_min = min(e for e in a if e 0) neg_min = min(e for e in a if e

Re: [Python-ideas] string.format() default variable assignment

2013-03-02 Thread Devin Jeanpierre
On Sat, Mar 2, 2013 at 1:54 AM, Chris Angelico ros...@gmail.com wrote: Yes, but reply-all sends a copy to the poster as well as the list. What I want is reply-list, acknowledging the list headers... and Gmail simply doesn't have that. I've been replying to the poster and the list for ages. Is

Re: Dealing with exceptions

2013-03-02 Thread Devin Jeanpierre
On Sat, Mar 2, 2013 at 1:21 PM, Chris Angelico ros...@gmail.com wrote: now, I need to figure out just what exceptions to handle. Here's a bit of a left-field thought: Maybe none of them. What are you actually doing when you get an exception? Can you plausibly recover? If not - that is, if

Re: [Python-ideas] string.format() default variable assignment

2013-03-02 Thread Devin Jeanpierre
On Sat, Mar 2, 2013 at 10:21 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: How the flying fuck does my choice of where and how *I* read this forum inconvenience YOU? Talk about an overactive sense of entitlement. The world does not revolve around you and I do not arrange my

Re: [Python-ideas] string.format() default variable assignment

2013-03-01 Thread Devin Jeanpierre
On Fri, Mar 1, 2013 at 10:54 PM, Chris Angelico ros...@gmail.com wrote: No offence Chris, but you're the only person I know who *regularly* replies to the wrong list. Does your mail client not have a Reply to List command, or Reply All? If so, then you should use it rather than manually typing

Re: Speeding up Python's exit

2013-02-28 Thread Devin Jeanpierre
On Thu, Feb 28, 2013 at 12:31 PM, Devin Jeanpierre jeanpierr...@gmail.com wrote: On Thu, Feb 28, 2013 at 12:06 PM, Chris Angelico ros...@gmail.com wrote: Is it any different if you create a deliberate reference loop and then stuff it into some module somewhere? That would force it to be kept

Re: Speeding up Python's exit

2013-02-28 Thread Devin Jeanpierre
On Thu, Feb 28, 2013 at 12:06 PM, Chris Angelico ros...@gmail.com wrote: Is it any different if you create a deliberate reference loop and then stuff it into some module somewhere? That would force it to be kept until interpreter shutdown, and then a cyclic garbage collection after that, which

Re: Do you feel bad because of the Python docs?

2013-02-26 Thread Devin Jeanpierre
On Tue, Feb 26, 2013 at 7:54 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: There's no doubt that one of PHP's strengths, perhaps its biggest strength, is the good state of documentation. But should we feel bad about Python's docs? I don't think that either the Python

Re: Do you feel bad because of the Python docs?

2013-02-26 Thread Devin Jeanpierre
On Tue, Feb 26, 2013 at 11:38 AM, Adam W. awasile...@gmail.com wrote: I think learning a language from the documentation is an unreasonable expectation and burden for the authors. That's how I learned it. The Python tutorial, together with the stdlib reference manual, are often recommended to

Re: How to write a language parser ?

2013-02-23 Thread Devin Jeanpierre
On Fri, Feb 22, 2013 at 9:14 PM, Mark Lawrence breamore...@yahoo.co.uk wrote: http://nedbatchelder.com/text/python-parsers.html Hm, that list is missing information. e.g. ANTLR 4 doesn't support python, and LEPL is dead now. -- Devin -- http://mail.python.org/mailman/listinfo/python-list

Re: Correct handling of case in unicode and regexps

2013-02-23 Thread Devin Jeanpierre
On Sat, Feb 23, 2013 at 10:11 AM, Vlastimil Brom vlastimil.b...@gmail.com wrote: you may check the new regex implementation https://pypi.python.org/pypi/regex which does support casefolding in case insensitive matches (beyond many other features and improvements comparing to re) Good point,

Re: Correct handling of case in unicode and regexps

2013-02-23 Thread Devin Jeanpierre
On Sat, Feb 23, 2013 at 10:26 AM, Devin Jeanpierre jeanpierr...@gmail.com wrote: However, regex has the same behavior. My apologies, I forgot to set the VERSION1 flag. Interesting. 'ss' matches 'ß', but 's+' does not. Is this desirable behavior? -- Devin -- http://mail.python.org/mailman

Re: Correct handling of case in unicode and regexps

2013-02-23 Thread Devin Jeanpierre
On Sat, Feb 23, 2013 at 12:41 PM, MRAB pyt...@mrabarnett.plus.com wrote: Getting full case folding to work can be tricky. There's always going to be a limit to what's worth doing. There are also areas where it's not clear what the result should be. You've already mentioned matching 's'

Re: Correct handling of case in unicode and regexps

2013-02-23 Thread Devin Jeanpierre
On Sat, Feb 23, 2013 at 1:12 PM, MRAB pyt...@mrabarnett.plus.com wrote: The basic rule is that a series of characters in the regex must match a series of characters in the text, with no partial matches in either. For example, 'ss' can match 'ß', but 's' can't match 'ß' because that would be

Re: What are the minimum requirements to get a job in?

2012-12-13 Thread Devin Jeanpierre
On Fri, Dec 14, 2012 at 1:13 AM, rusi rustompm...@gmail.com wrote: On Dec 14, 8:33 am, Dave Angel d...@davea.name wrote: Do you know any one computer language thoroughly? Or just a little of many languages? There is a quote by Bruce Lee to the effect: I am not afraid of the man who knows

Re: Immutability and Python

2012-10-29 Thread Devin Jeanpierre
On Mon, Oct 29, 2012 at 12:46 PM, Paul Rubin no.email@nospam.invalid wrote: andrea crotti andrea.crott...@gmail.com writes: Also because how doi I make an immutable object in pure Python? Numbers in Python are already immutable. What you're really looking for is a programming style where you

Re: a.index(float('nan')) fails

2012-10-26 Thread Devin Jeanpierre
On Fri, Oct 26, 2012 at 2:40 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: The problem isn't with the associativity, it's with the equality comparison. Replace x == y with abs(x-y)epsilon for some epsilon and all your statements fulfill people's expectations. O RYLY? Would

Re: while expression feature proposal

2012-10-26 Thread Devin Jeanpierre
On Fri, Oct 26, 2012 at 1:12 AM, Dan Loewenherz dloewenh...@gmail.com wrote: It seems the topic of this thread has changed drastically from the original message. 1) while EXPR as VAR in no way says that EXPR must be a boolean value. In fact, a use case I've run into commonly in web

Re: while expression feature proposal

2012-10-26 Thread Devin Jeanpierre
On Fri, Oct 26, 2012 at 2:23 AM, Chris Angelico ros...@gmail.com wrote: while (client.spop(profile_ids) as profile_id) is not None: print profile_id Why is everyone skirting around C-style assignment expressions as though they're simultaneously anathema and the goal? :) Why should these

Re: while expression feature proposal

2012-10-26 Thread Devin Jeanpierre
On Fri, Oct 26, 2012 at 6:03 PM, Cameron Simpson c...@zip.com.au wrote: Any doco would need to make it clear that no order of operation is implied, so that this: x = 1 y = (2 as x) + x does not have a defined answer; might be 2, might be 3. Just like any other function call with side

Re: while expression feature proposal

2012-10-26 Thread Devin Jeanpierre
On Fri, Oct 26, 2012 at 7:41 PM, Dan Loewenherz dloewenh...@gmail.com wrote: -- snip insanity -- But this is yucky. I'd much rather have something a bit more clear to the reader. That's why I said I wanted a better iter, not some equality-overriding object strawman thing. I was thinking more

Re: while expression feature proposal

2012-10-26 Thread Devin Jeanpierre
On Fri, Oct 26, 2012 at 7:56 PM, Cameron Simpson c...@zip.com.au wrote: No. Separate _expressions_ are evaluated left to right. So this: f(1), f(2) calls f(1) first, then f(2). But this: f(1) + f(2) need not do so. Counter-documentation welcomed, but the doco you cite does not

Re: while expression feature proposal

2012-10-26 Thread Devin Jeanpierre
On Fri, Oct 26, 2012 at 8:18 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: I would like a better iter(), rather than a better while loop. It is irritating to pass in functions that take arguments, and it is impossible to, say, pass in functions that should stop being iterated

Re: Quickie - Regexp for a string not at the beginning of the line

2012-10-25 Thread Devin Jeanpierre
On Thu, Oct 25, 2012 at 10:00 PM, Ed Morton mortons...@gmail.com wrote: Because there is no solution - there IS no _RE_ that will match a string not at the beginning of a line. Depending on what the OP meant, the following would both work: - r^(?!mystring) (the string does not occur at the

Re: fmap(), inverse of Python map() function

2012-10-05 Thread Devin Jeanpierre
On Fri, Oct 5, 2012 at 5:31 PM, Ian Kelly ian.g.ke...@gmail.com wrote: On Fri, Oct 5, 2012 at 2:19 PM, vasudevram vasudev...@gmail.com wrote: http://jugad2.blogspot.in/2012/10/fmap-inverse-of-python-map-function.html Your fmap is a special case of reduce. So is map. def map(f, seq):

Re: fmap(), inverse of Python map() function

2012-10-05 Thread Devin Jeanpierre
On Fri, Oct 5, 2012 at 7:24 PM, Ian Kelly ian.g.ke...@gmail.com wrote: I realize that. My point is that the function *feels* more like a variant of reduce than of map. If it's meant as a complaint, it's a poor one. It's not. Fair enough all around. Sorry for misunderstanding. -- Devin --

Re: Should one always add super().__init__() to the __init__?

2012-09-29 Thread Devin Jeanpierre
On Sat, Sep 29, 2012 at 1:17 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: No. Only add code that works and that you need. Arbitrarily adding calls to the superclasses just in case may not work: py class Spam(object): ... def __init__(self, x): ... self.x

Re: Article on the future of Python

2012-09-28 Thread Devin Jeanpierre
On Thu, Sep 27, 2012 at 8:59 PM, alex23 wuwe...@gmail.com wrote: On Sep 28, 2:17 am, Devin Jeanpierre jeanpierr...@gmail.com wrote: Uncharitably, it's just a way of hiding one's head in the sand, ignoring any problems Python has by focusing on what problems it doesn't have. But isn't

Re: write a regex matches 800-555-1212, 555-1212, and also (800) 555-1212.

2012-09-28 Thread Devin Jeanpierre
On Fri, Sep 28, 2012 at 9:58 PM, Mark Lawrence breamore...@yahoo.co.uk wrote: What's the run time speed like? How much memory does it use? Shouldn't you be using the regex module from pypi instead of the standard library re? Guess who's borrowed the time machine? O(n), O(1), and I used RE2.

Re: Article on the future of Python

2012-09-27 Thread Devin Jeanpierre
On Thu, Sep 27, 2012 at 2:13 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Tue, 25 Sep 2012 09:15:00 +0100, Mark Lawrence wrote: And a response: http://data.geek.nz/python-is-doing-just-fine Summary of that article: Sure, you have all these legitimate concerns, but look,

Re: #python archives?

2012-09-27 Thread Devin Jeanpierre
On Thu, Sep 27, 2012 at 2:13 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: My google-foo is failing me. Is the #python chatroom on freenode archived anywhere on the web? #python doesn't have a policy against quiet bots that log channel interaction, but AFAIK there are no

Re: Article on the future of Python

2012-09-27 Thread Devin Jeanpierre
On Thu, Sep 27, 2012 at 10:25 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Thu, 27 Sep 2012 08:11:13 -0400, Devin Jeanpierre wrote: On Thu, Sep 27, 2012 at 2:13 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Tue, 25 Sep 2012 09:15:00 +0100, Mark

Re: Article on the future of Python

2012-09-27 Thread Devin Jeanpierre
On Thu, Sep 27, 2012 at 12:45 PM, Mark Lawrence breamore...@yahoo.co.uk wrote: The article Steven D'Aprano referred to is not a direct response to the article I referred to, yet your words are written as if it were. May I ask why? Or have I missed something? Post hoc ergo propter hoc :( --

Re: test

2012-09-27 Thread Devin Jeanpierre
On Thu, Sep 27, 2012 at 5:28 PM, ForeverYoung rsn...@gmail.com wrote: Please ignore this post. I am testing to see if I can post successfully. Is there a reason you can't wait until you have something to say / ask to see if it works? You're spamming a large number of inboxes with nothing. --

Re: Java singletonMap in Python

2012-09-24 Thread Devin Jeanpierre
On Sun, Sep 23, 2012 at 7:14 PM, Mark Lawrence breamore...@yahoo.co.uk wrote: Purely for fun I've been porting some code to Python and came across the singletonMap[1]. I'm aware that there are loads of recipes on the web for both singletons e.g.[2] and immutable dictionaries e.g.[3]. I was

Re: newbie question : gedit as an ide

2012-09-16 Thread Devin Jeanpierre
On Sun, Sep 16, 2012 at 7:52 AM, Mayuresh Kathe mayur...@kathe.in wrote: new to the group, a quick hello to all. :-) does anyone use gedit as an 'ide' for python development? if yes, may i know the caveats against using 'idle', 'bpython', etc? bpython isn't an IDE, it's a good interactive

PyCon for students?

2012-07-27 Thread Devin Jeanpierre
Hey guys, I recently saw a post saying that PyCon for students' price was dropped to $100. If you are trying to attract students, why not move PyCon to take place during the summer? As far as I know, summer vs spring makes no difference to any members of the general working population (except for

Re: from future import pass_function

2012-07-26 Thread Devin Jeanpierre
On Thu, Jul 26, 2012 at 1:20 AM, Michael Hrivnak mhriv...@hrivnak.org wrote: If we want pass(), then why not break() and continue()? And also def() and class()? for(), while(), if(), with(), we can make them all callable objects! No, you actually can't. You omit the one control flow

Re: from future import pass_function

2012-07-26 Thread Devin Jeanpierre
On Thu, Jul 26, 2012 at 5:42 AM, Chris Angelico ros...@gmail.com wrote: You omit the one control flow statement that could actually be turned into a function, raise. None of the rest could in Python (except class), and one of the rest couldn't in any language (def). Well, if/while/for could

Re: from future import pass_function

2012-07-25 Thread Devin Jeanpierre
On Wed, Jul 25, 2012 at 4:40 AM, Ulrich Eckhardt ulrich.eckha...@dominolaser.com wrote: What do you think? retort: def foo(): None -- Devin -- http://mail.python.org/mailman/listinfo/python-list

Re: from future import pass_function

2012-07-25 Thread Devin Jeanpierre
On Wed, Jul 25, 2012 at 12:05 PM, Chris Angelico ros...@gmail.com wrote: Simple way of making the iterator display its yielded result. I cannot imagine any circumstance in which you'd want to map pass over everything. But then, as Teresa said, I'm only one, and possibly I'm wrong! True. But

Re: from future import pass_function

2012-07-25 Thread Devin Jeanpierre
On Wed, Jul 25, 2012 at 2:14 PM, Ian Kelly ian.g.ke...@gmail.com wrote: You can already use pass (or the equivalent) in a lambda. lambda: None This lacks my foolish consistency. -- Devin -- http://mail.python.org/mailman/listinfo/python-list

Re: What's wrong with this code?

2012-07-24 Thread Devin Jeanpierre
On Tue, Jul 24, 2012 at 2:23 AM, Mark Lawrence breamore...@yahoo.co.uk wrote: strictly speaking Python doesn't have variables, it has names. This will possibly start a flame war which, by the standards of this ng/ml, will be an intense conflagration, hence the duck and cover. The two terms

Re: python package confusion

2012-07-24 Thread Devin Jeanpierre
On Tue, Jul 24, 2012 at 1:38 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: I don't know about a bad idea or not, but it is certainly redundant, because Python automatically adds '' (equivalent to '.') to the very start of the search path. No, it only does that if Python is

Re: the meaning of rユ.......ï¾

2012-07-24 Thread Devin Jeanpierre
On Mon, Jul 23, 2012 at 12:09 PM, Chris Angelico ros...@gmail.com wrote: It is, in many places. It's one of the few truly international holidays. The next nearest, Pi Day, has two different dates (the American and the European - of course, here in Australia, we celebrate both). Here in Canada

Re: python package confusion

2012-07-23 Thread Devin Jeanpierre
On Mon, Jul 23, 2012 at 6:02 AM, Lipska the Kat lip...@lipskathekat.com wrote: The PYTHONPATH ev is set to /home/lipska/python/dev/mods:. in .bashrc Did you export it? Show us your .bashrc, or the relevant line in it exactly. (And make sure that it isn't defined multiple times). Also adding .

Re: the meaning of rユ.......ï¾

2012-07-23 Thread Devin Jeanpierre
On Mon, Jul 23, 2012 at 9:52 AM, Henrik Faber hfa...@invalid.net wrote: If you allow for UTF-8 identifiers you'll have to be horribly careful what to include and what to exclude. Is the non-breaking space a valid character for a identifier? Technically it's a different character than the

Re: the meaning of rユ.......ï¾

2012-07-23 Thread Devin Jeanpierre
On Mon, Jul 23, 2012 at 10:40 AM, Henrik Faber hfa...@invalid.net wrote: No, you misunderstood me. I didn't say people are going to write gibberish. What I'm saying is that as a foreigner (who doesn't know most of these characters), it can be hard to accurately choose which one is the correct

Re: Gender, Representativeness and Reputation in StackOverflow

2012-07-23 Thread Devin Jeanpierre
On Mon, Jul 23, 2012 at 9:30 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Leaving aside the point that this is not directly related to Python, my opinion is that if the authors will not make past and future papers freely available, not even an abstract, they should not ask

Re: default repr?

2012-07-22 Thread Devin Jeanpierre
On Sun, Jul 22, 2012 at 8:29 PM, Chris Angelico ros...@gmail.com wrote: On Mon, Jul 23, 2012 at 10:24 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Not quite: they have to be an instance of that class. 8 Hmm. I would have thought that methods were like all other

Re: A thread import problem

2012-07-22 Thread Devin Jeanpierre
On Sun, Jul 22, 2012 at 7:14 PM, Bruce Sherwood bruce.sherw...@gmail.com wrote: (2) My hand is forced by Apple no longer supporting Carbon. Among other aspects of this, Carbon can't be used with 64-bit Python, and more and more Mac users of VPython want to use 64-bit Python. So there has to be

Re: can someone teach me this?

2012-07-21 Thread Devin Jeanpierre
On Fri, Jul 20, 2012 at 11:15 PM, hamilton hamil...@nothere.com wrote: You are an idiot, or a scammer. Please be nice. -- Devin -- http://mail.python.org/mailman/listinfo/python-list

Re: Sudden doubling of nearly all messages

2012-07-21 Thread Devin Jeanpierre
On Sat, Jul 21, 2012 at 2:25 PM, Chris Angelico ros...@gmail.com wrote: On Sun, Jul 22, 2012 at 4:16 AM, Rick Johnson rantingrickjohn...@gmail.com wrote: It was a nice run Google. We had good times and bad times. A few smiles and cries. LMBTFY So, what... you reckon Microsoft is going to

Re: Basic question about speed/coding style/memory

2012-07-21 Thread Devin Jeanpierre
On Sat, Jul 21, 2012 at 5:06 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: So there is approximately 0.03 second difference per TWO MILLION if...else blocks, or about 15 nanoseconds each. This is highly unlikely to be the bottleneck in your code. Assuming the difference is

Re: Encapsulation, inheritance and polymorphism

2012-07-20 Thread Devin Jeanpierre
On Thu, Jul 19, 2012 at 5:01 PM, John Gordon gor...@panix.com wrote: Since the current evidence indicates the universe will just keep expanding, it's more of a deep freeze death... Heat death means *lack* of heat. But it doesn't mean low temperature! The term is agnostic as to what the

Re: Implicit conversion to boolean in if and while statements

2012-07-17 Thread Devin Jeanpierre
On Tue, Jul 17, 2012 at 2:25 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: It already is part of the collection interface: it is spelled __nonzero__ (Python 2) or __bool__ (Python 3), and like all dunder methods, it is called automatically for you when you use the right

Re: Encapsulation, inheritance and polymorphism

2012-07-17 Thread Devin Jeanpierre
On Tue, Jul 17, 2012 at 4:45 AM, Lipska the Kat lip...@lipskathekat.com wrote: Is Python truly OO or is it just one way to use the language. I see some documentation relating to classes but nothing on instantiation .. in fact the documentation appears to say that classes are used in a static

Re: Encapsulation, inheritance and polymorphism

2012-07-17 Thread Devin Jeanpierre
On Tue, Jul 17, 2012 at 1:07 PM, Terry Reedy tjre...@udel.edu wrote: 'type-bondage' is the requirement to restrict function inputs and output to one declared type, where the type declaration mechanisms are usually quite limited. This is interesting, I hadn't expected that sort of definition.

Re: Implicit conversion to boolean in if and while statements

2012-07-16 Thread Devin Jeanpierre
On Mon, Jul 16, 2012 at 12:03 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Sun, 15 Jul 2012 22:15:13 -0400, Devin Jeanpierre wrote: For example, instead of if stack: or if bool(stack):, we could use if stack.isempty():. This line tells us explicitly that stack

Re: Implicit conversion to boolean in if and while statements

2012-07-15 Thread Devin Jeanpierre
On Sun, Jul 15, 2012 at 9:51 PM, Chris Angelico ros...@gmail.com wrote: if bool(obj) and a==b: # Correct! if obj and a==b: # Incorrect! That still doesn't answer the question of what bool(obj) should do if obj is not a bool, and why if can't do the exact same thing, since if, by

Re: Python Interview Questions

2012-07-09 Thread Devin Jeanpierre
On Mon, Jul 9, 2012 at 5:22 PM, Peter peter.milli...@gmail.com wrote: One of my favourite questions when interviewing - and it was 100% reliable :-) - what are your hobbies? If the answer included programming then they were hired, if not, then they went to the B list. Woe is the poor

Re: why greenlet, gevent or the stackless are needed?

2012-07-07 Thread Devin Jeanpierre
On Sat, Jul 7, 2012 at 3:09 AM, self.python howmuchisto...@gmail.com wrote: it there somthing that yield can't do or just it is easier or powerful? couroutine-like generators can't give up control flow unless they are the top level function handled by the coroutine controller thing. For

Re: API design question for dbf.py

2012-07-06 Thread Devin Jeanpierre
On Fri, Jul 6, 2012 at 6:46 PM, Ethan Furman et...@stoneleaf.us wrote: It's checking for equality, not identity. x = float('nan') x in [x] True It's checking for equality OR identity. -- Devin -- http://mail.python.org/mailman/listinfo/python-list

Re: 2 + 2 = 5

2012-07-05 Thread Devin Jeanpierre
On Thu, Jul 5, 2012 at 10:34 AM, Laszlo Nagy gand...@shopzeus.com wrote: 5+1 4 4 + 1 is 5 is 4. (e.g. try 2+3 as well). -- Devin -- http://mail.python.org/mailman/listinfo/python-list

Re: adding a simulation mode

2012-07-04 Thread Devin Jeanpierre
For what it's worth, this is the reason that Allen Short wrote Exocet. This way, you can test your code without having to resort to sys.modules hackery, and you can better factor your applications by separating configuration and environment concerns from the rest of your code. See: -

Re: simpler increment of time values?

2012-07-04 Thread Devin Jeanpierre
On Thu, Jul 5, 2012 at 12:57 AM, Jason Friedman ja...@powerpull.net wrote: I have some thoughts on a solution, but first, what is 12:45 plus 12 hours? What is 12:45 minus 13 hours? Is there anything unusual that can happen for a notion of time that is dateless, timezone-unaware, and DST-free?

Re: code review

2012-07-01 Thread Devin Jeanpierre
On Sun, Jul 1, 2012 at 3:28 AM, Ben Finney ben+pyt...@benfinney.id.au wrote: Chris Angelico ros...@gmail.com writes: C, SQL, REXX, and many other languages. So, languages without strong typing then. In that case, I revise my statement: I know of no programming language with strong typing that

Re: code review

2012-07-01 Thread Devin Jeanpierre
On Sun, Jul 1, 2012 at 8:41 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Sun, 01 Jul 2012 05:18:09 -0400, Devin Jeanpierre wrote: Sheesh guys. Don't go hunting through the most obscure corners of mathematics for examples of computer scientists who have invented their own

Re: code review

2012-07-01 Thread Devin Jeanpierre
On Sun, Jul 1, 2012 at 9:28 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Technically, in Python is left-associative: a b c first evaluates a, not b or c. But it is left-associative under the rules of comparison operator chaining, not arithmetic operator chaining.

Re: Why has python3 been created as a seperate language where there is still python2.7 ?

2012-06-27 Thread Devin Jeanpierre
On Wed, Jun 27, 2012 at 7:02 AM, Chris Angelico ros...@gmail.com wrote: Much easier to simply say no. It's also easier to cease developing Python at all. By which I mean: just because something is hard doesn't mean it shouldn't be done. Lots of things Python does are hard, but they make users'

Re: Why has python3 been created as a seperate language where there is still python2.7 ?

2012-06-26 Thread Devin Jeanpierre
On Mon, Jun 25, 2012 at 11:35 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: There's no real difference between typing print(...) and all the other functions in Python. Do you lament having to type len(obj) instead of len obj or list(zip(a, b, c)) instead of list zip a b c?

[issue1677] Ctrl-C will exit out of Python interpreter in Windows

2012-06-26 Thread Devin Jeanpierre
Devin Jeanpierre jeanpierr...@gmail.com added the comment: For extra clarification, this issue can crop up with even a single press of ctrl-c. It's not really related to multiple presses, except that pressing it more increases the odds of it happening. -- nosy: +Devin Jeanpierre

Re: Conditional decoration

2012-06-18 Thread Devin Jeanpierre
On Mon, Jun 18, 2012 at 6:49 PM, Emile van Sebille em...@fenx.com wrote: On 6/18/2012 3:16 PM Roy Smith said... class myDecorator(object):    def __init__(self, f):        self.f = f    def __call__(self):        print Entering, self.f.__name__        self.f()        print Exited,

Re: How does python bytecode works?

2012-06-17 Thread Devin Jeanpierre
On Sun, Jun 17, 2012 at 5:54 AM, gmspro gms...@yahoo.com wrote: We know python is written in C. C is not portable. Badly written C is not portable. But C is probably the most portable language on the planet, by virtue of basically every system having a C compiler backend. The issue is that a

Re: mode for file created by open

2012-06-09 Thread Devin Jeanpierre
On Sat, Jun 9, 2012 at 7:42 AM, Neal Becker ndbeck...@gmail.com wrote: Doesn't anyone else think it would be a good addition to open to specify a file creation mode?  Like posix open?  Avoid all these nasty workarounds? I do, although I'm hesitant, because this only applies when mode == 'w',

Re: which one do you prefer? python with C# or java?

2012-06-09 Thread Devin Jeanpierre
On Sat, Jun 9, 2012 at 7:04 PM, becky_lewis bex.le...@gmail.com wrote: Lisp and Clojure are functional languages. Sorry, pet peeve. Lisps are a class of languages that are only united by their common syntax and their use of syntax transformations (macros). Most lisps are not really functional at

Re: mode for file created by open

2012-06-08 Thread Devin Jeanpierre
On Fri, Jun 8, 2012 at 2:36 PM, Neal Becker ndbeck...@gmail.com wrote: If a new file is created by open ('xxx', 'w') How can I control the file permission bits?  Is my only choice to use chmod after opening, or use os.open? For whatever it's worth, in Python 3.3 you have the additional option

Re: Import semantics?

2012-06-08 Thread Devin Jeanpierre
On Fri, Jun 8, 2012 at 6:24 PM, Dan Stromberg drsali...@gmail.com wrote: Am I misinterpreting this?  It seems like according to the PEP, I should have still been able to import treap.py despite having a treap/.  But I couldn't; I had to rename treap/ to treap-dir/ first. Only if treap/ and

Re: How to exec() a string like interactive python does?

2012-06-05 Thread Devin Jeanpierre
def myexec(s): ... eval(compile(s, 'string', 'single')) ... x = 3 myexec('x = 4') myexec('x') 3 myexec('print x') 3 On Tue, Jun 5, 2012 at 6:12 PM, News123 news1...@free.fr wrote: If I start Python in interactive mode, and I yype the commands, 'a=3', 'a', 'print a' Then the  

Re: python3 raw strings and \u escapes

2012-05-30 Thread Devin Jeanpierre
On Wed, May 30, 2012 at 2:52 AM, ru...@yahoo.com ru...@yahoo.com wrote: Was there a reason for dropping the lexical processing of \u escapes in strings in python3 (other than to add another annoyance in a long list of python3 annoyances?) And is there no choice for me but to choose between

Re: Namespace hack

2012-05-25 Thread Devin Jeanpierre
On Thu, May 24, 2012 at 9:04 AM, Daniel Fetchinson fetchin...@googlemail.com wrote: Funny, you got to the last line of import this but apparently skipped the second line: Explicit is better than implicit. And you didn't even post your message on April 1 so no, I can't laugh even though I'd

Re: Doctest documentation?

2012-05-20 Thread Devin Jeanpierre
This was previously reported as http://bugs.python.org/issue12947 -- Devin -- http://mail.python.org/mailman/listinfo/python-list

[issue14865] #doctest: directives removed from doctest chapter examples

2012-05-20 Thread Devin Jeanpierre
Devin Jeanpierre jeanpierr...@gmail.com added the comment: This is a duplicate of http://bugs.python.org/issue12947 -- nosy: +Devin Jeanpierre ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14865

[issue12947] doctest directive examples in library/doctest.html lack the flags

2012-05-20 Thread Devin Jeanpierre
Changes by Devin Jeanpierre jeanpierr...@gmail.com: -- title: Examples in library/doctest.html lack the flags - doctest directive examples in library/doctest.html lack the flags ___ Python tracker rep...@bugs.python.org http://bugs.python.org

Re: Difference between str.isdigit() and str.isdecimal() in Python 3

2012-05-17 Thread Devin Jeanpierre
On Wed, May 16, 2012 at 5:07 PM, Thomas 'PointedEars' Lahn pointede...@web.de wrote: RTFM. $ python3 -c 'print(42.isdecimal.__doc__ + \n); print(42.isdigit.__doc__)' Heh, don't print docstrings. Use pydoc. $ ( export PAGER=cat pydoc3 str.isdecimal pydoc3 str.isdigit ) Help on

Re: Where is the most recent Tkinter information

2012-05-17 Thread Devin Jeanpierre
On Thu, May 17, 2012 at 12:04 AM, Simon Cropper simoncrop...@fossworkflowguides.com wrote: The main page of the python 3.2.3 documentation for tkinter can be found here... http://docs.python.org/py3k/library/tkinter.html?highlight=tkinter#tkinter it is dated 2012. This seems to be duplicated

Re: non-pickle persistance for dicts?

2012-05-16 Thread Devin Jeanpierre
On Wed, May 16, 2012 at 6:53 PM, Charles Hixson charleshi...@earthlink.net wrote: Thanks.  It looks like either would do what I need.  Any suggestion as to how to choose between them?  E.g., is AST better supported?  faster?  (I'm tending towards AST purely because it seems more tied to Python,

Re: How to call and execute C code in Python?

2012-05-13 Thread Devin Jeanpierre
On Sun, May 13, 2012 at 11:58 AM, Stefan Behnel stefan...@behnel.de wrote: David Shi, 13.05.2012 15:25: Can anyone tell me how to call and exectute C code in Python? Take a look at Cython, a Python-like language that supports native calls to and from C/C++ code. It translates your code into

Re: Newbie naive question ... int() throws ValueError

2012-05-12 Thread Devin Jeanpierre
On Sat, May 12, 2012 at 8:27 AM, Karl Knechtel zahl...@gmail.com wrote: I really wish gmail picked up the mailing list as a default reply-to address... There is some labs thing that makes reply to all the default if you click the button on the top-right. Unfortunately, that applies for

Re: Retrieving result from embedded execution

2012-05-11 Thread Devin Jeanpierre
On Fri, May 11, 2012 at 12:45 AM, Stefan Behnel stefan...@behnel.de wrote: However, have you tried using a pipe for them instead of a real file? That would allow you to retrieve the output without needing to pass through a file in the file system. You can also replace sys.stdout/err with

<    1   2   3   4   5   >