VirtualEnvs (venv) and Powershell

2017-03-31 Thread Carl Caulkett
o Powershell to manage my Virtual Environments. Has anyone dicovered tools or techniques to achieve this? Thanks for any response -- Carl -- https://mail.python.org/mailman/listinfo/python-list

Re: How well do you know Python?

2016-07-05 Thread Carl Meyer
e of pathological setups where a path and its parent are both on sys.path, so all import paths have an "optional" prefix (but you actually get a different copy of the module depending on whether you use that prefix). Carl signature.asc Description: OpenPGP digital signature -- https://mail.python.org/mailman/listinfo/python-list

Re: pytz and Python timezones

2016-06-12 Thread Carl Meyer
f you are masochistic enough to want to understand how this bad situation came to be, and what might be done about it, you can read through PEPs 431 and 495. Carl signature.asc Description: OpenPGP digital signature -- https://mail.python.org/mailman/listinfo/python-list

Re: recursive methods require implementing a stack?

2016-04-06 Thread Carl Meyer
here a way out of that? Do I have to push and pop my own >> simulated >> stack frame entry? > > No, and I'm not sure why you would think that. Sounds like a confusion that might arise due to using a mutable default arg? Or generally passing a mutable arg and n

Re: Missing something about timezones

2016-03-14 Thread Carl Meyer
imezone('America/Chicago') >>> tz >>> import datetime >>> dt = datetime.datetime.now() >>> dtl = tz.localize(dt) >>> dtl datetime.datetime(2016, 3, 14, 10, 11, 13, 514375, tzinfo=) Carl signature.asc Description: OpenPGP digital signature -- https://mail.python.org/mailman/listinfo/python-list

Re: Continuing indentation

2016-03-02 Thread Carl Meyer
a new function. The pressure to do this type of refactor more frequently is one reason I continue to prefer relatively short (80 char) line length limits. This is closely related to the XP guideline "when you're tempted to add a comment, instead extract that bit of code into a function or variable and give it a name that clarifies the same thing the comment would have." Names are important! Carl signature.asc Description: OpenPGP digital signature -- https://mail.python.org/mailman/listinfo/python-list

Re: Importing two modules of same name

2016-02-09 Thread Carl Meyer
t the future-import in Python 2.7, `import config` will import the neighboring app/config.py by default, and there is no way to import the top-level config.py. Carl signature.asc Description: OpenPGP digital signature -- https://mail.python.org/mailman/listinfo/python-list

Turtle

2016-01-15 Thread Stallone Carl
Dear sir/madam I am currently using python 3.5.0 and I have been trying to write a program using turtle but is not seem to be working. I have followed all tutarial on the web and when i compare it with my code my am duing everything the same way but it still don't seems to be working I tryed repair

Re: does the order in which the modules are placed in a file matters ?

2015-12-16 Thread Carl Meyer
ing may be the python modules like os , shlex etc come > first and later the user defined modules like import > plaftform.cluster .etc come latter > > Sorry if my question sounds dump , I was running pep8 and don't see > its bothered much about it AFAIK the pep8 module doesn

Re: Python 3 virtualenvs

2015-11-30 Thread Carl Meyer
On 11/30/2015 10:20 AM, Laura Creighton wrote: > In a message of Mon, 30 Nov 2015 09:32:27 -0700, Carl Meyer writes: >>> I think it is only meant to be used by people who want to install >>> packages but not site-wide, but I am not sure about that. >> >> I don&#x

Re: Python 3 virtualenvs

2015-11-30 Thread Carl Meyer
u? > I don't think > there are any plans to give venv the functionality of virtualenv, What functionality do you mean? > so > presumably there are people who like it just fine the way it is now. > They must have very different needs than I do. I don't know, since you never said what it is about venv that doesn't meet your needs :-) Carl signature.asc Description: OpenPGP digital signature -- https://mail.python.org/mailman/listinfo/python-list

Re: List comprehension with if-else

2015-10-28 Thread Carl Meyer
n here, you're just using a ternary if-else in the result expression. List comprehension if clauses go at the end, and don't require an else: [l.foo for l in wblist if l.bar == "baz"] Carl signature.asc Description: OpenPGP digital signature -- https://mail.python.org/mailman/listinfo/python-list

Re: Understanding WSGI together with Apache

2015-10-12 Thread Carl Meyer
"sub-interpreters", meaning that even multiple mod-wsgi sites on the same server can run in sub-interpreters of the same Python process, and certain global state (e.g. os.environ, apparently also the localization context) is shared between those sub-interpreters, which can cause

Re: True == 1 weirdness

2015-09-16 Thread Carl Meyer
;> care to elaborate? >> >> >> Best, >> Sven > > Simple, straight forward easy to read bit of Python, where is the > problem? node is bound to the boolean ptr is greater than or equal to > left and right. Except it's a SyntaxError because Python has

Re: [Datetime-SIG] Are there any "correct" implementations of tzinfo?

2015-09-14 Thread Carl Meyer
Can we please stop cross-posting this thread to python-list and move it to datetime-sig only? I think anyone here on python-list who is sufficiently interested in it can subscribe to datetime-sig. Or the other way around, whatever. I'd just like to stop getting all the messages twice.

Re: Are there any "correct" implementations of tzinfo?

2015-09-12 Thread Carl Meyer
to solve the "no way to disambiguate ambiguous local times other than using fixed-offset tzinfos" problem, which would make it possible to implement tzinfo classes following the dateutil model while still having loss-less conversions. Carl signature.asc Description: OpenPGP digital signature -- https://mail.python.org/mailman/listinfo/python-list

Re: Searching for a usable X509 implementation

2015-07-03 Thread Carl Meyer
usable module out there to enable straightforward > certificate handling? I'm not aware of anything better than PyOpenSSL. Carl signature.asc Description: OpenPGP digital signature -- https://mail.python.org/mailman/listinfo/python-list

Re: Using a particular python binary with venv

2015-06-01 Thread Carl Meyer
On 06/01/2015 04:07 PM, greenbay.gra...@gmail.com wrote: > On Tuesday, 2 June 2015 09:43:37 UTC+12, Carl Meyer wrote: >> On 06/01/2015 03:33 PM, orotau wrote: >>> According to this >>> https://docs.python.org/3.4/library/venv.html#module-venv 'Each >>&g

Re: Using a particular python binary with venv

2015-06-01 Thread Carl Meyer
hich looks very similar from the end-user side. See https://virtualenv.pypa.io/en/latest/ Carl signature.asc Description: OpenPGP digital signature -- https://mail.python.org/mailman/listinfo/python-list

Re: mixing set and list operations

2015-04-30 Thread Carl Meyer
x27;t think this is surprising, nor implementation dependent, nor dangerous. Lists have an `extend()` method, sets have an `update()` method. Both of these methods take any iterable as input, they don't needlessly constrain the input to be of the same type as the base object. That's the Pythonic way to do it; I'd be surprised if it didn't work. Carl signature.asc Description: OpenPGP digital signature -- https://mail.python.org/mailman/listinfo/python-list

Re: Python 3 lack of support for fcgi/wsgi.

2015-03-29 Thread Carl Meyer
shape on Python 2 than on Python 3, because Python 2 is older. So when it comes to "the community's interest in fixing problems" or John's assertion that "nobody uses this stuff," in both cases I think it's far more about FastCGI vs WSGI than it'

Re: Daylight savings time question

2015-03-25 Thread Carl Meyer
since Nov 1883 [1] and which is 7 minutes offset from modern timezones, resulting in a very surprising result when you then convert that to UTC. In contrast, localize() does the right thing, using PST instead of LMT because it knows that's the correct offset for US/Pacific at 1am on March 8, 2015:

Re: Daylight savings time question

2015-03-25 Thread Carl Meyer
is also part of the Olson database (though I guess it's considered an "old" name for the timezone): https://github.com/eggert/tz/blob/master/backward Carl signature.asc Description: OpenPGP digital signature -- https://mail.python.org/mailman/listinfo/python-list

Re: Python 3.4.1 on W2K?

2014-10-07 Thread Carl Distefano
Tim G.: > Of course, if you're happy to work with a slightly older > version of Python, such as 3.2, then you should be fine. Well, I just installed 3.2.5 in W2K and all of my "stuff" seems to work. I'm a happy camper. Many thanks for the information and link! ChrisA: > Wow. I wonder, since you

Re: daemon thread cleanup approach

2014-05-29 Thread Carl Banks
On Thursday, May 29, 2014 1:15:35 AM UTC-7, Chris Angelico wrote: > On Thu, May 29, 2014 at 11:20 AM, Carl Banks wrote: > > > Most threads have cleanup work to do (such as deleting temporary > > directories and killing spawned processes). > > > > >

daemon thread cleanup approach

2014-05-28 Thread Carl Banks
to ensure the program doesn't hang.) This is Python 2.7, and it's only ever going to run on Windows. Thanks for any advice/warnings. Carl Banks -- https://mail.python.org/mailman/listinfo/python-list

Re: [Chicago] Getting ASCII encoding where unicode wanted under Py3k

2013-05-13 Thread Carl Karsten
u'\u0161' } ) 123š But that works. may need a few other lines, or something. It is also possible that there is a setting in your OS that has an effect. What OS? -- Carl K -- http://mail.python.org/mailman/listinfo/python-list

Re: Python education survey

2011-12-26 Thread Carl Smith
On Dec 25, 5:44 pm, Rick Johnson wrote: > On Dec 19, 9:51 pm, Raymond Hettinger > wrote: > > > Do you use IDLE when teaching Python? > > If not, what is the tool of choice? > > I believe IDLE has the potential to be a very useful teaching tool and > even in it's current abysmal state, i find it t

Re: Python education survey

2011-12-26 Thread Carl Smith
On Dec 20, 10:58 am, Andrea Crotti wrote: > On 12/20/2011 03:51 AM, Raymond Hettinger wrote: > > > > > > > > > > > Do you use IDLE when teaching Python? > > If not, what is the tool of choice? > > > Students may not be experienced with the command-line and may be > > running Windows, Linux, or Mac

Re: (don't bash me too hard) Python interpreter in JavaScript

2011-11-15 Thread Carl Banks
VM-to-Javascript project is called emscripten. https://github.com/kripken/emscripten/wiki Demo of Python (and a bunch of other languages) here: http://repl.it/ Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: revive a generator

2011-10-22 Thread Carl Banks
). But if you allow a downstream user to recreate the generator at will, then the writer will always have to be wary of adverse side-effects if the generator is iterated through twice. So, although I can see it being occasionally useful, I'm going to opine that it is more trouble than it's worth. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Language Enhancement Idea to help with multi-processing (your opinions please)

2011-10-15 Thread Carl Banks
On Friday, October 14, 2011 6:23:15 PM UTC-7, alex23 wrote: > On Oct 14, 4:56 pm, Carl Banks > wrote: > > But you can see that, fully realized, syntax like that can do much more > > than can be done with library code. > > Well sure, but imaginary syntax can do _anyt

Re: argparse zero-length switch

2011-10-15 Thread Carl Banks
On Friday, October 14, 2011 12:41:26 AM UTC-7, Peter Otten wrote: > Carl Banks wrote: > > > Is it possible to specify a zero-length switch? Here's what I mean. > > > > I have a use case where some users would have to enter a section name on > > the command li

Re: Language Enhancement Idea to help with multi-processing (your opinions please)

2011-10-14 Thread Carl Banks
iler is free to execute asynchronously relative to each other (I'll call it async). async: a += 1 f *= a async: b += 1 e *= b async: c += 1 d *= c There is utterly no chance of this syntax entering Python. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Language Enhancement Idea to help with multi-processing (your opinions please)

2011-10-14 Thread Carl Banks
it. But you can see that, fully realized, syntax like that can do much more than can be done with library code. Obviously that extra capability is a very long way off for being useful in CPython. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

argparse zero-length switch

2011-10-13 Thread Carl Banks
ince the current behavior of the above code seems to do nothing useful, it could be added to argparse with very low risk of backwards incompatibility. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Race condition deadlock in communicate when threading?

2011-09-27 Thread Carl Banks
n try running it on a pty device (if you're on Unix). If worse comes to worst, see if there's a way to get the external task to print lots of extra output (a verbosity setting, for instance); that could work in a pinch until you can debug it more thoroughly. Carl Banks -- http://mail

Re: Python Mixins

2011-09-24 Thread Carl Banks
A Dog is whatever it can do. If a Cat is yamlafiable, then it's coorect to say that a Cat is a Yamlafible (even if a cat isn't). Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Mixins

2011-09-24 Thread Carl Banks
I find that I almost never use mixins, though I have absolutely nothing against them and I use MI and metaclasses all the time. It's just that for most things I'd use a mixin for, I find that one or two regular functions work perfectly well. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: PC locks up with list operations

2011-09-13 Thread Carl Banks
han > you have, just more RAM than you have free. Last time I faced a > situation like this, I just decided it was better to stick to the > 32-bit program and let it crash if it got too big. On my 64-bit Linux system, I got a memory error in under a second, no thrashing. I have no swap.

Re: Why doesn't threading.join() return a value?

2011-09-03 Thread Carl Banks
ece of data for the different properties. The API provides a void* so that the extension writer can pass arbitrary data to the get and set functions. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Why doesn't threading.join() return a value?

2011-09-03 Thread Carl Banks
would have been the most convenient.  I'm > > curious why threading wasn't implemented this way. > > I assume it is because the underlying operating system APIs do not > support it. Nope. This could easily be implemented by storing the return value in the Thread objec

Re: sqlite3 with context manager

2011-09-03 Thread Carl Banks
it has a SQL extension that allows you to specify error semantics. It looks something like this: UPDATE OR IGNORE UPDATE OR FAIL UPDATE OR ROLLBACK I'm not sure exactly how this interacts with pysqlite3, but using one of these might help it throw exceptions when you want it to. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Optparse buggy?

2011-09-01 Thread Carl Banks
evelopers that this stuff would be useful for positional arugments, too. They just dropped the ball there.) Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: fun with nested loops

2011-09-01 Thread Carl Banks
reak if you need to break further. Something like this, for example: break_level = 99 while loop1: while loop2: while loop3: if some_condition: break_level = (1, 2, or 3) break if break_level < 3: break break_level = 99 if break_level < 2: break break_level = 99 Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Why do closures do this?

2011-08-28 Thread Carl Banks
eople that it will behave this way (not to mention it's a lot more useful). It's only for the less common and much more advanced case of creating a closure in a loop that the other behavior would be preferred. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Run time default arguments

2011-08-27 Thread Carl Banks
ction like coalesce being helpful if you have a list of several options to check, though. Also, SQL doesn't give you a lot of flexibility, so coalesce is a lot more needed there. But for simple arguments in Python, I'd recommend sticking with "if arg is not None: arg = whatever" Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Help on PyQt4 QProcess

2011-08-19 Thread Carl Banks
an argument to the lambda (v) that accepts the int argument of the signal. If you don't have that argument there, the int argument goes into x, which is why Python prints 0 instead of "finished". Second, processess run asynchrously, and because of line-buffering, IO can output asynchronously, and so there's no guarantee what order output occurs. You might try calling the python subprocess with the '-u' switch to force unbuffered IO, which might be enough to force synchronous output (depending on how signal/slot and subprocess semantics are implemented). Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Help with regular expression in python

2011-08-19 Thread Carl Banks
could have done something like this: row = [ float(x) for x in re.findall(r'\d+\.\d+e\+d+',line) ] And regexp matching is often overkill for a particular problem; this may be of them. line.split() could have been sufficient: row = [ float(x) for x in line.split() ] Of course, thes

Re: thread and process

2011-08-13 Thread Carl Banks
nt  processes  use one  mainthread!! They don't use one main thread; it's just that each process's main thread has the same name. Which makes sense: when you fork a process all the data in the process has to remain valid in both parent and child, so any pointers would have to have the same value (and the -1216477504 happens to be the value of that pointer cast to an int). Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: list comprehension to do os.path.split_all ?

2011-07-29 Thread Carl Banks
#x27;.split(os.sep) > ['C:/windows'] It's not even fullproof on Unix. '/home//h1122/bin///ghi/'.split('/') ['','home','','bin','','','ghi',''] The whole point of the os.path functions are to take care of whatever oddities there are in the path system. When you use string manipulation to manipulate paths, you bypass all of that and leave yourself open to those oddities, and then you find your applications break when a user enters a doubled slash. So stick to os.path. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Aw: python.org back up ?(was Re: python.org is down?)

2011-07-25 Thread Carl Banks
rg goes down, and will help keep the load off the server when it's up. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: list(), tuple() should not place at "Built-in functions" in documentation

2011-07-15 Thread Carl Banks
cumentation that is > in the 'built-in types' section (which could now be called the > built-isssn classes section. Built in functions and contructors? Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Functional style programming in python: what will you talk about if you have an hour on this topic?

2011-07-14 Thread Carl Banks
the top of my head, I can think of using functools module to help with logging or to apply patches, whereas in Java they'd have to resort to a code weaver or lots of boilerplate. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: "Python Wizard," with apologies to The Who

2011-07-12 Thread Carl Banks
ure codes some mean Python! That's pretty funny. I knew what it would be even when I saw the cut-off subject line, and I am too young to remember it. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Function docstring as a local variable

2011-07-11 Thread Carl Banks
On Sunday, July 10, 2011 4:06:27 PM UTC-7, Corey Richardson wrote: > Excerpts from Carl Banks's message of Sun Jul 10 18:59:02 -0400 2011: > > print __doc__ > > > > Python 2.7.1 (r271:86832, Jul 8 2011, 22:48:46) > [GCC 4.4.5] on linux2 > Type "help"

Re: Function docstring as a local variable

2011-07-10 Thread Carl Banks
akwebsoft dot com > > ## Is it possible to get the module docstring > ## from the module itself? print __doc__ Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: What makes functions special?

2011-07-09 Thread Carl Banks
ine. Code objects are also used directly by the interpreter when executing byte code. A function object is only one of several "interfaces" to a code object. A minor reason is that code objects are constant (in fact, any object that is built at compile time must be a

Re: Does hashlib support a file mode?

2011-07-06 Thread Carl Banks
licit that the default arguments are executed only once, when creating the function, *not* when calling it. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Nested/Sub Extensions in Python

2011-07-02 Thread Carl Banks
On Saturday, July 2, 2011 6:35:19 AM UTC-7, H Linux wrote: > On Jul 2, 2:28 am, Carl Banks > wrote: > > On Friday, July 1, 2011 1:02:15 PM UTC-7, H Linux wrote: > > > Once I try to nest this, I cannot get the module to load anymore: > > > >import smt.bar >

Re: Nested/Sub Extensions in Python

2011-07-01 Thread Carl Banks
; PyMODINIT_FUNC > initbar(void) > { > Py_InitModule("smt.bar", bar_methods); > } This should be: Py_InitModule("bar", bar_methods); That's probably it; other than that, it looks like you did everything right. What does the installed file layout look like after runni

Re: writable iterators?

2011-06-22 Thread Carl Banks
self.set(iterable) def __iter__(self): return self def next(self): return self.current_iter.next() def set(self,iterable): self.current_iter = iter(iterable) s = IteratorByProxy(xrange(10)) for i in s: print i if i == 6: s.set(xrange(15,20)) Ca

Re: how to inherit docstrings?

2011-06-13 Thread Carl Banks
On Friday, June 10, 2011 7:30:06 PM UTC-7, Steven D'Aprano wrote: > Carl, I'm not exactly sure what your opposition is about here. Others > have already given real-world use cases for where inheriting docstrings > would be useful and valuable. Do you think that they are w

Re: how to inherit docstrings?

2011-06-10 Thread Carl Banks
On Friday, June 10, 2011 2:51:20 AM UTC-7, Steven D'Aprano wrote: > On Thu, 09 Jun 2011 20:36:53 -0700, Carl Banks wrote: > > Put it this way: if Python doesn't automatically inherit docstrings, the > > worst that can happen is missing information. If Python does inher

Re: how to inherit docstrings?

2011-06-10 Thread Carl Banks
cstrings, part of that bargain is that the language will go out of its way to support flat-out wrong docstrings, and that trumps any ostensible benefit. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: how to inherit docstrings?

2011-06-09 Thread Carl Banks
he worst that can happen is missing information. If Python does inherit docstrings, it can lead to incorrect information. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: how to inherit docstrings?

2011-06-09 Thread Carl Banks
On Thursday, June 9, 2011 6:42:44 PM UTC-7, Ben Finney wrote: > Carl Banks > writes: > > > Presumably, the reason you are overriding a method in a subclass is to > > change its behavior; I'd expect an inherited docstring to be > > inaccurate more often than not

Re: how to inherit docstrings?

2011-06-09 Thread Carl Banks
wever, I'd be +1 easily on a little help from the language to explicitly request to inherit the docstring. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: how to inherit docstrings?

2011-06-09 Thread Carl Banks
docstring(base): def set_docstring(f): f.__doc__ = getattr(base,f.func_name).__doc__ return f return set_docstring where you have to repeat the base class every time: class Bar(Foo): @inherit_docstring(Foo) def somefunction(self): pass Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: GIL in alternative implementations

2011-06-07 Thread Carl Banks
change its meaning from one iteration to the next, > so a complete name lookup is required at each iteration. This is very > useful sometimes, but affects performance a lot. It's main affect performance is that it prevents an optimizer from inlining a function call(wh

Re: float("nan") in set or as key

2011-06-03 Thread Carl Banks
On Wednesday, June 1, 2011 5:53:26 PM UTC-7, Steven D'Aprano wrote: > On Tue, 31 May 2011 19:45:01 -0700, Carl Banks wrote: > > > On Sunday, May 29, 2011 8:59:49 PM UTC-7, Steven D'Aprano wrote: > >> On Sun, 29 May 2011 17:55:22 -0700, Carl Banks wrote: > &g

Re: float("nan") in set or as key

2011-06-01 Thread Carl Banks
On Wednesday, June 1, 2011 11:10:33 AM UTC-7, Ethan Furman wrote: > Carl Banks wrote: > > For instance, say you are using an implementation that uses > > floating point, and you define a function that uses Newton's > > method to find a square root: > > > >

Re: float("nan") in set or as key

2011-06-01 Thread Carl Banks
On Wednesday, June 1, 2011 10:17:54 AM UTC-7, OKB (not okblacke) wrote: > Carl Banks wrote: > > > On Tuesday, May 31, 2011 8:57:57 PM UTC-7, Chris Angelico wrote: > >> On Wed, Jun 1, 2011 at 1:30 PM, Carl Banks wrote: > > Python has several non-integer number types

Re: float("nan") in set or as key

2011-05-31 Thread Carl Banks
On Tuesday, May 31, 2011 8:57:57 PM UTC-7, Chris Angelico wrote: > On Wed, Jun 1, 2011 at 1:30 PM, Carl Banks > wrote: > > I think you misunderstood what I was saying. > > > > It's not *possible* to represent a real number abstractly in any digital > >

Re: float("nan") in set or as key

2011-05-31 Thread Carl Banks
On Tuesday, May 31, 2011 8:05:43 PM UTC-7, Chris Angelico wrote: > On Wed, Jun 1, 2011 at 12:59 PM, Carl Banks > wrote: > > On Sunday, May 29, 2011 7:53:59 PM UTC-7, Chris Angelico wrote: > >> Okay, here's a question. The Python 'float' value - is it meant to

Re: float("nan") in set or as key

2011-05-31 Thread Carl Banks
er"? The former. Unlike the case with integers, there is no way that I know of to represent an abstract real number on a digital computer. Python also includes several IEEE-defined operations in its library (math.isnan, math.frexp). Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: float("nan") in set or as key

2011-05-31 Thread Carl Banks
On Sunday, May 29, 2011 8:59:49 PM UTC-7, Steven D'Aprano wrote: > On Sun, 29 May 2011 17:55:22 -0700, Carl Banks wrote: > > > Floating point arithmetic evolved more or less on languages like Fortran > > where things like exceptions were unheard of, > > I

Re: float("nan") in set or as key

2011-05-29 Thread Carl Banks
On Sunday, May 29, 2011 6:14:58 PM UTC-7, Chris Angelico wrote: > On Mon, May 30, 2011 at 10:55 AM, Carl Banks > wrote: > > If exceptions had commonly existed in that environment there's no chance > > they would have chosen that behavior; comparison against NaN (or any

Re: float("nan") in set or as key

2011-05-29 Thread Carl Banks
ver be used as a dictionary key or in a set (of course). If it weren't for compatibility with IEEE, there would be no sane argument that defining an object that is not equal to itself isn't a bug. But because there's a lot of code out there that depends on NaN != NaN, Python has to tolerate it. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: float("nan") in set or as key

2011-05-29 Thread Carl Banks
to handle exceptional conditions. The only reason to keep NaN's current behavior is to adhere to IEEE, but given that Python has trailblazed a path of correcting arcane mathematical behavior, I definitely see an argument that Python should do the same for NaN, and if it were done Python would be a better language. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Why did Quora choose Python for its development?

2011-05-27 Thread Carl Banks
\b # beginning of line > (?P\w+) # a word > \s+# some whitespace > (?P=word)(?!\w)# the same word again >""" > double_word_re = re.compile(pattern, re.I | re.X) Perl has the X fla

Re: bug in str.startswith() and str.endswith()

2011-05-26 Thread Carl Banks
er looks pretty useless for .startswith() and is probably only present for consistency with other string search methods like .index(). Yet on .index() using None as an argument works as intended: >>> "cbcd".index("c",None,None) 0 So it's there for consistency, yet is not consistent. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: super() in class defs?

2011-05-25 Thread Carl Banks
e I don't have Python 3 handy to test it, but as far as I can tell it will.) It's just one of the quirks of Python's type system. I don't agree with Ian's recommendation not to use super() in general, but I'd probably agree that one should stick to using it only in its intended way (to invoke base-class methods directly). Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Why did Quora choose Python for its development?

2011-05-22 Thread Carl Banks
list tells us nothing. In any case it's ridiculous to claim envy as factor nowadays, as Python is clearly on the rise while Perl is on the decline. Few people are choosing Perl for new projects. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: in search of graceful co-routines

2011-05-17 Thread Carl Banks
sually catch StopIteration whenever calling send() or next() by hand. Untested: result = None while True: try: item = provider.send(result) except StopIteration: break try: consumer.handleItem(item) except: result = 'failure' else: result = 'success' Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Composition instead of inheritance

2011-04-29 Thread Carl Banks
On Friday, April 29, 2011 2:44:56 PM UTC-7, Ian wrote: > On Fri, Apr 29, 2011 at 3:09 PM, Carl Banks > wrote: > > Here is my advice on mixins: > > > > Mixins should almost always be listed first in the bases.  (The only > > exception is to work around a technicali

Re: Composition instead of inheritance

2011-04-29 Thread Carl Banks
On Thursday, April 28, 2011 6:43:35 PM UTC-7, Ethan Furman wrote: > Carl Banks wrote: > > The sorts of class that this decorator will work for are probably not > > the ones that are going to have problems cooperating in the first place. > > So you might as well just use

Re: Composition instead of inheritance

2011-04-28 Thread Carl Banks
y in base.__dict__.keys(): u[key] += 1 for key in dct.keys(): u[key] += 1 if any(u[key] > 1 for key in u.keys()): raise TypeError("base classes and this class share some class attributes") return type.__new__(metatype,na

Re: A question about Python Classes

2011-04-22 Thread Carl Banks
dler, and it is incorrect to say it is not. The call to HomeHandler does create an instance of BaseHandler. The Python language itself validates this usage. isinstance(test,BaseHandler) returns True. If you are looking for a term to indicate an object for which type(test) == BaseHandler, then I would suggest "proper instance". test is an instance of BaseHandler, but it is not a proper instance. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Python CPU

2011-04-03 Thread Carl Banks
be possible but not too practical or likely. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Why aren't copy and deepcopy in __builtins__?

2011-03-27 Thread Carl Banks
in reason they're not builtin is that they aren't really that simple. The functions make use of a lot of knowledge about Python types. Builtins tend to be for straightforward, simple, building-block type functions. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Guido rethinking removal of cmp from sort method

2011-03-25 Thread Carl Banks
e to on sorting time." (Fits your criterion "performs really badly when done so".) 3. You evidently also overlooked the use-case example posted on Python- dev that you followed up to. Call me crazy, but you seem to be overlooking a lot of things in your zeal to prove your point. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: dynamic assigments

2011-03-25 Thread Carl Banks
also want to avoid boilerplate of binding all of them explicitly. Not a common use case, but it happens. (I've faced it several times, but the things I work on make it more common for me. I bit the bullet and wrote out the boilerplate.) Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Guido rethinking removal of cmp from sort method

2011-03-24 Thread Carl Banks
an just write their own cmp function, and as an added bonus they can work around any peculiarities with an incomplete comparison set. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Guido rethinking removal of cmp from sort method

2011-03-23 Thread Carl Banks
On Mar 23, 1:38 pm, Paul Rubin wrote: > Carl Banks writes: > > It's kind of ridiculous to claim that cmp adds much complexity (it's > > maybe ten lines of extra C code), so the only reason not to include it > > is that it's much slower than using key. > &

Re: Guido rethinking removal of cmp from sort method

2011-03-23 Thread Carl Banks
On Mar 23, 10:51 am, Stefan Behnel wrote: > Carl Banks, 23.03.2011 18:23: > > > > > > > On Mar 23, 6:59 am, Stefan Behnel wrote: > >> Antoon Pardon, 23.03.2011 14:53: > > >>> On Sun, Mar 13, 2011 at 12:59:55PM +, Steven D'Aprano wrote: &g

Re: Guido rethinking removal of cmp from sort method

2011-03-23 Thread Carl Banks
a clever key function or an adapter class than the 0.2 seconds I'd save to on sorting time. Removing cmp from sort was a mistake; it's the most straightforward and natural way to sort in many cases. Reason enough for me to keep it. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Abend with cls.__repr__ = cls.__str__ on Windows.

2011-03-18 Thread Carl Banks
agree with you. But it's ok, it's not unreasonable to call attention to (actual) bugs here. I was surprised, though, when several people confirmed but no one reported it, especially since it was a crash, which is quite a rare thing to find. (You should feel proud.) Carl Banks --

Re: Abend with cls.__repr__ = cls.__str__ on Windows.

2011-03-18 Thread Carl Banks
:\python32\python bug.py > > generates a popup: > >     python.exe - Application Error >     The exception unknown software exception (0xcfd) occurred in the >     application at location 0x1e08a325. > >     Click on OK to terminate the program >     Click on CAN

Re: having both dynamic and static variables

2011-03-05 Thread Carl Banks
to inline functions for potentially big speed increases. It can't do that now because the name of the function can always be rebound to something else. BTW, a function object is definitely mutable. def squared(x): return x*x squared.foo = 'bar' Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

  1   2   3   4   5   6   7   8   9   10   >