Opinion on Pyrex

2005-09-30 Thread Carl
ython code snippets, how do you practically achieve this using Pyrex? I have come to the conclusion that it is not possible without some rewriting and adaptation (translation) of available C source code (if you don't want to compile and link all your C source into a statical or dynamical library).

Long integer arrays in Python; how? /Carl

2005-11-28 Thread Carl
s to large to be assigned to an array element. Is there a way around this problem in Python? Yours /Carl -- http://mail.python.org/mailman/listinfo/python-list

Re: Installing Numeric with ATLAS and LAPACK

2005-01-28 Thread Carl
X 3600 covariance matrix. > > Calculating the eigenvalues for this matrix requires a mere 7 min > in Matlab 6.5...which uses ATLAS and LAPACK. > > > Thanks, > > > Daran What functions from ATLAS and LAPACK are you using? Carl -- http://mail.python.org/mailman/listinfo/python-list

Bitwise operations in Python?

2005-08-18 Thread Carl
Dear friends, I am currently porting a fortran program to Python but am stuck on the intrinsic IBITS function. Does anyone know about a replacement function for IBITS in Python? Yours, Carl >>>>>>>>>>>>>>>> IBITS(I, POS, LEN) Extracts a

Re: Bitwise operations in Python?

2005-08-18 Thread Carl
Incredible, Paul! Thanks a thousand times! /Carl -- http://mail.python.org/mailman/listinfo/python-list

Python and version control

2005-02-09 Thread Carl
opers working in a Windows environment? Carl -- http://mail.python.org/mailman/listinfo/python-list

namespace in Python?

2005-12-12 Thread Carl
What is the equivalent of a C++ (or C#) namespace in Python? Yours /Carl -- http://mail.python.org/mailman/listinfo/python-list

f2py and common blocks /Carl

2006-01-01 Thread Carl
: How can one declare arrays passed as parameters via common block variables? Yours/ Carl -- http://mail.python.org/mailman/listinfo/python-list

Re: Starting New Process

2006-06-01 Thread Carl
eactor.listenTCP(, f) >> reactor.run() >> >> Jean-Paul Use import socket ifyou don't want to use twisted (which is incredibly good). Google for "+socket +python +server" and you will find what you are looking for. See, for example, http://floppsie.comp.glam.ac.uk/Glamorgan/gaius/wireless/5.html Carl -- http://mail.python.org/mailman/listinfo/python-list

Re: pythoncode in matlab

2006-05-11 Thread Carl
rl command (ie a Matlab script that calls perl). You can use this perl command for building a python command in Matlab. Carl -- http://mail.python.org/mailman/listinfo/python-list

Re: Calling C/C++ functions in a python script

2006-05-11 Thread Carl
what I'm trying to do. > Unfortunately, apparently I need a > "pyhton24_d.lib" to link to that does not seem to exists. Do you know a > solution for this? > > Thanks a lot, > > Jean-Claude You can be build it from source! /Carl -- http://mail.python.org/mailman/listinfo/python-list

Embedding end extending /Carl

2006-05-21 Thread Carl
I have just started to look at Python's C API and the possibilities for embedding Python within another application. Where should I look for examples and documentation? I have already glanced through Python's documentation, but need more examples for guidance towards proficie

How do I change the font size for the default coordinates in matplotlib?

2008-03-20 Thread Carl
I've searched the user manual (and this forum) but I don't see anything that helps. -- http://mail.python.org/mailman/listinfo/python-list

Re: How do I change the font size for the default coordinates in matplotlib?

2008-03-21 Thread Carl
On Mar 20, 10:12 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > On Mar 20, 8:20 pm, Carl <[EMAIL PROTECTED]> wrote: > > > I've searched the user manual (and this forum) but I don't see > > anything that helps. > > Did you mean the

Looking for a pure python Mysql module

2008-10-27 Thread Carl
Does anyone know of a package that can connect and query a mysql server that is platform independent and does not need to compile any extra c modules (IE a pure python module)? -- http://mail.python.org/mailman/listinfo/python-list

Re: Python/Numeric users be aware!

2008-10-29 Thread Carl
Confirmed Benyang wrote: Maybe it has been reported somewhere, but it is a big surprise to me. # Try the following: import Numeric a = Numeric.ones(10) a[5:] = -1 print a It works correctly on 32-bit linux machines and on 32-bit Windows XP: [ 1 1 1 1 1 -1 -1 -1 -1 -1] It is totally screwe

Re: read web page that requires javascript on client

2009-03-18 Thread Carl
ating a browser via Python. So, you can programmatically launch the browser, point it to the JavaScript afflicted page, let the JS run and grab the page source. As an added bonus you can later interact with the page by programatically, filling form fields, selecting options from lists and clicking buttons. HTH, Carl -- http://mail.python.org/mailman/listinfo/python-list

user site-packages, --prefix, --home and friends

2009-03-24 Thread Carl
differences and what is the best practice in various situations? Thanks, Carl -- http://mail.python.org/mailman/listinfo/python-list

Re: Tkinter popup menu

2008-08-27 Thread Carl
"Test3", command=self.selected) #self.menupopup = tk.Menu(self.myparent, tearoff=0) self.menupopup.add_cascade(label="Test1", menu=self.menupopup1) self.menupopup.add_cascade(label="Test2", menu=self.menupopup2) ...end code changes -- Hope that helps. Carl. -- http://mail.python.org/mailman/listinfo/python-list

Re: help using py2app

2008-10-02 Thread Carl
Joe Strout wrote: I'm trying to use py2app to convert the pySketch wxPython example into a stand-alone OS X app. I've found the documentation at , but it wasn't terribly enlightening for me. My setup.py looks like this: #!/usr/bin/env python """ setu

Calling Python from Matlab

2006-04-15 Thread Carl
ne know of good techniques (or readily available software) for achieving a cross-language support between Python and Matlab? Carl -- http://mail.python.org/mailman/listinfo/python-list

Re: Calling Python from Matlab

2006-04-16 Thread Carl
feel disadvantaged being confined to using only Matlab. I have learnt that Matlab provides a facility for executing Perl commands and running Perl scripts, but I have not used it yet. It would have been nice to have the possibility of mixing Matlab and Python code, by using inlining, for example! One option could be to use Perl to call Python from within Matlab. Carl -- http://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: 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: 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: 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: 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
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
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-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-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-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: 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: 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: 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: 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: 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: 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: 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: "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: 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: 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: 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 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: ctypes inheritance issue

2011-02-24 Thread Carl Banks
pes. But I don't want a derived class to overwrite its parent's entry in the subtype dict--it should define its own key. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Python C Extensions

2011-02-24 Thread Carl Banks
ference, it does increase the reference count. I don't know if there's a simple rule to know of a function borrows or creates a new reference; I've never noticed one. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Checking against NULL will be eliminated?

2011-03-02 Thread Carl Banks
ypes it means "this is a value of this type as opposed to None". That causes conflicts when more than one of those tests makes sense for a given type, as it does with Elements. This change is only for ElementTree as far as I know. (Incidentally, Numpy arrays are another notable type that's disabled implicit booleans, but it did it a long time ago.) Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Checking against NULL will be eliminated?

2011-03-03 Thread Carl Banks
ally and reliably, doesn't mean the rest of us > shouldn't. Perl works deterministically and reliably. In fact, pretty much every language works deterministically and reliably. Total non-argument. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Checking against NULL will be eliminated?

2011-03-03 Thread Carl Banks
On Mar 3, 5:16 am, Neil Cerutti wrote: > On 2011-03-03, Tom Zych wrote: > > > Carl Banks wrote: > >> Perl works deterministically and reliably.  In fact, pretty much every > >> language works deterministically and reliably.  Total non-argument. > > > We

Re: Checking against NULL will be eliminated?

2011-03-03 Thread Carl Banks
On Mar 3, 7:12 pm, Carl Banks wrote: [snip] Accidental post before I was done. To complete the thought: I actually can think of one indeterminate behavior in C (although it's not certain whether this qualifies as interaction with the environment): int main(void) {     int a;     printf(

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

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: 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: 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: 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
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-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: 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-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: 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: 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: 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: 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: 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-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: 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: 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: 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: 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: 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: 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: 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
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-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-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 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
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-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-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: 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: 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: 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: PEP 308 accepted - new conditional expressions

2005-09-30 Thread Carl Banks
Reinhold Birkenfeld wrote: > X if C else Y Oh well. Just about any conditional is better than no conditional. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Python, COM Servers, and Multi-Threading

2005-10-10 Thread Carl Waldbieser
If so, can anybody offer suggestions as to a design that would be better able to take advantage of a multi-processor machine? Thanks, Carl Waldbieser -- http://mail.python.org/mailman/listinfo/python-list

Re: Intersection of lists/sets -- with a catch

2005-10-18 Thread Carl Banks
_hash__(self): return hash((self.obj.att_a,self.obj.att_b)) set_a = set(CmpProxy(x) for x in list_a) set_b = set(CmpProxy(y) for y in list_b) overlaps = [ z.obj for z in set_a.intersection(set.b) ] Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: import statement / ElementTree

2005-11-04 Thread Carl Banks
hanging each of > the calls to the Element(), SubElement(), XML() and tostring() methods. Well, if you arrange it as I advise, you shouldn't have a problem. However, if you want to change only the import statements, you don't want to do this: import elementtree.ElementTree That will import ElementTree but the you'd have to access it as elementtree.ElementTree. Instead you should do this: from elementtree import ElementTree Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

FTP over TLS

2005-11-23 Thread Carl Waldbieser
Does anyone know of any good examples for writing client side code to upload files over a secure FTP connection? I am referring to FTPS, *not* SFTP, which I found out the hard way are two different things. I am not really all that familiar with FTPS, but from what I understand, when the client se

Embedding a CPython Script engine in a .NET application.

2005-11-23 Thread Carl Waldbieser
Has anyone had any experience embedding a CPython engine in a .NET application? In the COM/ActiveX world, it was pretty easy to use Mark Hammond's win32 modules to create a script engine component that you could expose other COM objects to, but I was not sure how I would go about doing something s

Re: FTP over TLS

2005-11-26 Thread Carl Waldbieser
David Isaac wrote: > > "Carl Waldbieser" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> Does anyone know of any good examples for writing client side code to > upload >> files over a secure FTP connection? > > http://trevp.net/tlsl

Using SSL in socket module.

2005-11-26 Thread Carl Waldbieser
I am trying to understand how the SSL object in the socket module is supposed to be used. From looking at the documentation, I can work out that you need to pass a socket into the ssl() function, and you get back an SSL object that has write() and read() methods similar to a file object. However,

  1   2   3   4   5   6   7   8   9   10   >