Re: Simple addition to random module - Student's t

2009-09-02 Thread Raymond Hettinger
> To get this into core Python, you'd usually submit a feature request > athttp://bugs.python.org. If you do submit a patch, please assign it to me. I've been the primary maintainer for that module for several years. Raymond Hettinger -- http://mail.python.org/mailman/listinfo/python-list

Re: An iteration idiom (Was: Re: [Guppy-pe-list] loading files containing multiple dumps)

2009-09-02 Thread Raymond Hettinger
or protocol in a way that is consistent with the rest of the language. The second way, using the two argument form of iter(), is the standard way of creating an iterator from a function that has a sentinel return value. IOW, it is not normal to use StopIteration in a function that isn't an ite

Re: Performance: sets vs dicts.

2010-08-29 Thread Raymond Hettinger
. There is no significant difference. All three are implemented using substantially the same code. Raymond -- http://mail.python.org/mailman/listinfo/python-list

Re: in place functions from operator module

2010-08-29 Thread Raymond Hettinger
a = [1, 2] then > >     a += [3] > > will first append 3 to the list and then reassign the list to 'a' (it is > unnecessary in this case but if this step was omitted, the "in place" > operators wouldn't work on immutables types). This is an excellent explanation. Perhaps, you can submit a documentation patch for the operator module so this doesn't get lost. Raymond -- http://mail.python.org/mailman/listinfo/python-list

Re: Performance: sets vs dicts.

2010-09-01 Thread Raymond Hettinger
about the performance characteristics of various data structures. Raymond Raymond -- http://mail.python.org/mailman/listinfo/python-list

How Python works: What do you know about support for negative indices?

2010-09-09 Thread Raymond Hettinger
lists tuples and string do support slicing and some objects like deque do not. Interestingly, the grammar has rules for slicing, but that is implemented as making a slice instance as the argument to the lookup. The actual lookup work is dispatched to the concrete class and there is no fast path along the way. Hope you all found this to be informative, Raymond -- http://mail.python.org/mailman/listinfo/python-list

Re: How Python works: What do you know about support for negative indices?

2010-09-13 Thread Raymond Hettinger
inane concerns with newline placement overwhelmed the substance of the post. Raymond -- http://mail.python.org/mailman/listinfo/python-list

Re: How Python works: What do you know about support for negative indices?

2010-09-13 Thread Raymond Hettinger
port it, and that else where it is optional. Another way of saying it is: if you are ever writing a __getitem__() method in Python (even for a subclass of a builtin sequence), then it is up to you to decide whether to add support for negative indices and slicing. Raymond -- http://mail.python.org

Re: Combinations or Permutations

2010-09-21 Thread Raymond Hettinger
b],[a,c],[a,d],...,[x,z],[y,z]] Try this: >>> from itertools import combinations >>> list(combinations('abcde', 2)) [('a', 'b'), ('a', 'c'), ('a', 'd'), ('a', 'e'), ('b', 'c'), ('b', 'd'), ('b', 'e'), ('c', 'd'), ('c', 'e'), ('d', 'e')] Raymond -- http://mail.python.org/mailman/listinfo/python-list

Re: Overriding dict constructor

2010-09-21 Thread Raymond Hettinger
[Steven D'Aprano] > But if I try to create a regular dict from this, dict() doesn't call my > __getitem__ method: > > >>> dict(d) > > {0: ('a', 'extra_data'), 1: ('b', 'extra_data')} > > instead of {0: '

Re: ConFoo spam?

2010-10-08 Thread Raymond Hettinger
rest to people tracking this list. I learned quite a bit last year. Raymond -- http://mail.python.org/mailman/listinfo/python-list

Nested Mapping

2010-10-21 Thread Raymond Hettinger
.root # find the outermost enclosing context f = c.new_child() # create a subcontext of c, independent of d & e I would appreciate any feedback on the API and on how well it fits with various use cases that you've found in the wild. Raymond -- http://mail.python.org/ma

Re: Nested Mapping

2010-10-21 Thread Raymond Hettinger
On Oct 21, 4:28 pm, Paul Rubin wrote: > Raymond Hettinger writes: > What I really want is a Haskell-like persistent (i.e. purely functional) > dictionary implemented as an AVL tree or something like that. Hopefully, that discussion can be in a separate thread. This is really about ke

Re: Nested Mapping

2010-10-21 Thread Raymond Hettinger
ue, it removes 'foo' from the parent context, c. Depends on whether you want parent contexts to be mutable or not. With Python's nonlocal keyword, we can set values in an enclosing scope. This tool lets you do that also. Raymond -- http://mail.python.org/mailman/listinfo/python-list

Re: Nested Mapping

2010-10-22 Thread Raymond Hettinger
gt; b["x"] = 2 > >>> len(b) > 2 > >>> b.keys() > > ['x', 'x'] > > I would have expected equal keys to occur/count just once. Thanks for reviewing the recipe. Since only the first (unshadowed) 'x' is accessible, I can see why it would make sense to count it only once. Raymond -- http://mail.python.org/mailman/listinfo/python-list

Re: Nested Mapping

2010-10-22 Thread Raymond Hettinger
On Oct 22, 8:48 am, Robert Kern wrote: > On 10/21/10 6:19 PM, Raymond Hettinger wrote: > > > I would appreciate any feedback on the API and on how well it fits > > with various use cases that you've found in the wild. > > We've done something similar in the past:

Re: Nested Mapping

2010-10-22 Thread Raymond Hettinger
On Oct 21, 6:13 pm, Paul Rubin wrote: > Raymond Hettinger writes: > > The c.parent.parent.parent chain finds successive enclosing contexts: > > I was asking about finding the child contexts, not the parents.  This is > analogous to how you can find the keys in a dict with dict

Re: Why "flat is better than nested"?

2010-10-27 Thread Raymond Hettinger
ptive nor a bible ... This is Tim we're talking about. I would put his work during commercial breaks against most programmer's work during uninterrupted full days at the office. He probably created the Timsort routine while playing Farmville in another window :-) Raymond -- htt

Re: Final state of underlying sequence in islice

2010-11-05 Thread Raymond Hettinger
ep] # only when b == a+n*step So, it's not obvious what the semantics should be when b != a+n*step. Raymond -- http://mail.python.org/mailman/listinfo/python-list

Re: Final state of underlying sequence in islice

2010-11-05 Thread Raymond Hettinger
looks like there is a good reason to do so. The OP doesn't have any use cases to light the way and I don't yet see any useful invariants that would arise out of either definition. And since the ambiguity only shows-up in a somewhat rare case, I'm inclined to just mark it as undefined.

Re: Final state of underlying sequence in islice

2010-11-05 Thread Raymond Hettinger
On Nov 5, 3:52 pm, Ian wrote: > On Nov 5, 2:51 pm, Raymond Hettinger wrote: > > > You may have missed my point.  I wrote the tools, the docs, and the > > tests. > > If you interpret a "promise" in text, I can assure you it was not > > intended.  The

Re: Split iterator into multiple streams

2010-11-06 Thread Raymond Hettinger
rators are going to accumulate a ton of data unless they are consumed roughly in parallel. Of course, if they are consumed *exactly* in lockstep, the you don't need to split them into separate iterables -- just use the tuples as they come. Raymond -- http://mail.python.org/mailman/listinfo/python-list

Is a 32-bit build faster than a 64-bit build

2010-11-12 Thread Raymond Hettinger
may enable a single server to handle a greater traffic load. Has anyone here tried that? Raymond -- http://mail.python.org/mailman/listinfo/python-list

Re: CRC16

2005-09-23 Thread Raymond L. Buvel
Tuvas wrote: > Anyone know a module that does CRC16 for Python? I have an aplication > that I need to run it, and am not having alot of sucess. I have a > program in C that uses a CRC16 according to CCITT standards, but need > to get a program that tests it with python as well. Thanks! > Try this

Re: any python module to calculate sin, cos, arctan?

2005-11-08 Thread Raymond L. Buvel
Shi Mu wrote: > any python module to calculate sin, cos, arctan? The other answers in this thread point you to the standard modules. If you need arbitrary precision floating point versions of these functions check out: http://calcrpnpy.sourceforge.net/clnumManual.html -- http://mail.python.org/

Re: gmpy/decimal interoperation

2005-11-14 Thread Raymond L. Buvel
Alex Martelli wrote: > As things stand now (gmpy 1.01), an instance d of decimal.Decimal cannot > transparently become an instance of any of gmpy.{mpz, mpq, mpf}, nor > vice versa (the conversions are all possible, but a bit laborious, e.g. > by explicitly going through string-forms). > > I'm thin

[ANN] rpncalc-2.2 RPN Calculator for Python

2005-12-03 Thread Raymond L. Buvel
The rpncalc package adds an interactive Reverse Polish Notation (RPN) interpreter to Python. This interpreter allows the use of Python as an RPN calculator. You can easily switch between the RPN interpreter and the standard Python interpreter. Home page: http://calcrpnpy.sourceforge.net/ Chang

Re: binascii.crc32 results not matching

2005-12-10 Thread Raymond L. Buvel
Peter Hansen wrote: > Larry Bates wrote: > >> I'm trying to get the results of binascii.crc32 >> to match the results of another utility that produces >> 32 bit unsigned CRCs. > > > What other utility? As Tim says, there are many CRC32s... the > background notes on this one happen to stumble

Re: binascii.crc32 results not matching

2005-12-10 Thread Raymond L. Buvel
Tim Peters wrote: > [Raymond L. Buvel] > >>Check out the unit test in the following. >> >>http://sourceforge.net/projects/crcmod/ > > > Cool! > > >>I went to a lot of trouble to get the results to match the results of >>binascii.crc32. As y

Re: exposing C array to python namespace: NumPy and array module.

2005-01-01 Thread Raymond L. Buvel
Bo Peng wrote: Dear list, I am writing a Python extension module that needs a way to expose pieces of a big C array to python. Currently, I am using NumPy like the following: PyObject* res = PyArray_FromDimsAndData(1, int*dim, PyArray_DOUBLE, char*buf); Users will get a Numeric Array object an

[ANN] rpncalc-1.2 RPN Calculator For Python

2005-01-02 Thread Raymond L. Buvel
The rpncalc package adds an interactive Reverse Polish Notation (RPN) interpreter to Python. This interpreter allows the use of Python as an RPN calculator. You can easily switch between the RPN interpreter and the standard Python interpreter. Home page: http://calcrpnpy.sourceforge.net/ Changes

[ANN] ratfun-1.0 Polynomials And Rational Functions

2005-01-02 Thread Raymond L. Buvel
The ratfun module provides classes for defining polynomial and rational function (ratio of two polynomials) objects. These objects can be used in arithmetic expressions and evaluated at a particular point. Home page: http://calcrpnpy.sourceforge.net/ratfun.html Note: If you are using rpncalc-1.

Re: DOS problem (simple fix??)

2005-01-08 Thread Raymond L. Buvel
Robert Brewer wrote: Gavin Bauer wrote: My DOS window (running in windows ME) closes the second it finishes running my programs. As you can imagine, this makes it hard to see the results. I've gotten in the habit of putting raw_input("Press enter to exit") at the end of every program, and in additi

Windows Porting Help Requested

2005-07-23 Thread Raymond L. Buvel
I am preparing to release an extension module that interfaces Python to the Class Library for Numbers (http://www.ginac.de/CLN/). This module will provide Python types for arbitrary precision floating point numbers, rational numbers, and their complex counterparts. The module also includes most o

Class Library for Numbers

2005-08-20 Thread Raymond L. Buvel
I have just released a new module that interfaces the Class Library for Numbers (CLN) to Python. The CLN library is a C++ library that provides rational and arbitrary precision floating point numbers in real and complex form. The clnum module exposes these types to Python and also provides arbitr

Re: Lossless Number Conversion

2005-08-29 Thread Raymond L. Buvel
Chris Spencer wrote: > Is there any library for Python that implements a kind of universal > number object. Something that, if you divide two integers, generates a > ratio instead of a float, or if you take the square root of a negative, > generates a complex number instead of raising an exception?

Find roots of ill-conditioned polynomials

2005-09-10 Thread Raymond L. Buvel
If you are using the root finder in Numeric, and are having problems, check out the root finder in the ratfun module. My testing indicates that it will give the exact roots of a Wilkinson polynomial of degree 100. For more information see http://calcrpnpy.sourceforge.net/ratfun.html -- http://m

Re: 2.3 -> 2.4: long int too large to convert to int

2005-09-16 Thread Raymond L. Buvel
Grant Edwards wrote: > I give up, how do I make this not fail under 2.4? > > fcntl.ioctl(self.dev.fileno(),0xc0047a80,struct.pack("HBB",0x1c,0x00,0x00)) > > I get an OverflowError: long int too large to convert to int > > ioctl() is expecting a 32-bit integer value, and 0xc0047a80 has > the hi

Re: newbie question on python 2.4 and tkinter

2005-02-19 Thread Raymond L. Buvel
David Joyner wrote: Hi: I'm trying to compile python 2.4 with tkinter. (I'm trying to write a gui interface which calls a program called GAP - I'm hoping to use subprocess, a python 2.4 module, since I was getting deadlocks using popen). The instructions at the python web site said basically to edi

Re: any Python equivalent of Math::Polynomial::Solve?

2005-02-26 Thread Raymond L. Buvel
Just wrote: SciPy indeed appear to contain a solver, but I'm currently stuck in trying to _get_ it for my platform (OSX). I'm definitely not going to install a Fortran compiler just to evaluate it (even though my name is not "Ilias" ;-). Also, SciPy is _huge_, so maybe a Python translation of

Re: any Python equivalent of Math::Polynomial::Solve?

2005-02-27 Thread Raymond L. Buvel
Alex Renelt wrote: Alex Renelt wrote: in addition: I'm writing a class for polynomial manipulation. The generalization of the above code is: definitions: 1.) p = array([a_0, a_i, ..., a_n]) represents your polynomial P(x) = \sum _{i=0} ^n a_i x^i 2.) deg(p) is its degree 3.) monic(p) makes P moni

Re: python -i (interactive environment)

2005-03-06 Thread Raymond L. Buvel
I posted the following a while back. I think this is what you are looking for. This can be done fairly easily by creating a module (lets call it interactive) with the following code in it. --- import sys,os def debug_exception(type, value, traceback): # Restore redirected standard I

Re: A rational proposal

2004-12-18 Thread Raymond L. Buvel
Mike Meyer wrote: PEP: XXX Title: A rational number module for Python I think it is a good idea to have rationals as part of the standard distribution but why not base this on the gmpy module (https://sourceforge.net/projects/gmpy)? That module already provides good performance. However, it d

Re: A rational proposal

2004-12-19 Thread Raymond L. Buvel
Alex Martelli wrote: Raymond L. Buvel <[EMAIL PROTECTED]> wrote: Mike Meyer wrote: PEP: XXX Title: A rational number module for Python I think it is a good idea to have rationals as part of the standard distribution but why not base this on the gmpy module (https://sourceforge.net/pr

[ANN] rpncalc-1.1 RPN Calculator For Python

2004-12-21 Thread Raymond L. Buvel
The rpncalc package adds an interactive Reverse Polish Notation (RPN) interpreter to Python. This interpreter allows the use of Python as an RPN calculator. You can easily switch between the RPN interpreter and the standard Python interpreter. Home page: http://calcrpnpy.sourceforge.net/ Changes

Re: binascii.crc32 results not matching

2005-12-10 Thread Raymond L. Buvel
Larry Bates wrote: Looking over the code, it seems very inefficient and hard to understand. You really should check out the following. http://sourceforge.net/projects/crcmod/ It will allow you to generate efficient CRC functions for use in Python and in C or C++. The only thing you need to in

Re: Python C/API - *arg,**kwds variable argumnents

2005-12-14 Thread Raymond L. Buvel
[EMAIL PROTECTED] wrote: > I am writing a C extension with python 2.3.5 and need constructs > similar to python >func(*args, **kwds) > What's a neat way to do that? > I found pyrex has a __Pyx_GetStarArgs - > is there something I'm missing from the regular C/API maybe using one > of the PyArg_P

[ANN] clnum-1.3 Class Library For Numbers Python Binding

2006-08-19 Thread Raymond L. Buvel
The clnum package adds rational numbers and arbitrary precision floating point numbers in real and complex form to Python. Also provides arbitrary precision floating point replacements for the functions in the math and cmath standard library modules. Home page: http://calcrpnpy.sourceforge.net/cln

[ANN] ratfun-2.3 Polynomials and Rational Functions

2006-08-19 Thread Raymond L. Buvel
The ratfun module provides classes for defining polynomial and rational function (ratio of two polynomials) objects. These objects can be used in arithmetic expressions and evaluated at a particular point. Home page: http://calcrpnpy.sourceforge.net/ratfun.html Note: If you are using rpncalc-1.2

[ANN] rpncalc-2.4 RPN Calculator for Python

2006-08-19 Thread Raymond L. Buvel
The rpncalc package adds an interactive Reverse Polish Notation (RPN) interpreter to Python. This interpreter allows the use of Python as an RPN calculator. You can easily switch between the RPN interpreter and the standard Python interpreter. Home page: http://calcrpnpy.sourceforge.net/ Chang

Re: ratfun-2.3 Polynomials and Rational Functions

2006-08-19 Thread Raymond L. Buvel
Bas wrote: > Are there any differences between this module and the one already > present in numpy? > > http://www.scipy.org/doc/numpy_api_docs/numpy.lib.polynomial.html > > Cheers, > Bas > Yes, there are quite a few. This module uses a multi-precision library (clnum) to make the calculations m

[ANN] clnum-1.2.1 Class Library For Numbers Python Binding

2006-06-11 Thread Raymond L. Buvel
The clnum package adds rational numbers and arbitrary precision floating point numbers in real and complex form to Python. Also provides arbitrary precision floating point replacements for the functions in the math and cmath standard library modules. Home page: http://calcrpnpy.sourceforge.net/cln

Re: math.pow(x,y)

2006-06-11 Thread Raymond L. Buvel
Felipe Almeida Lessa wrote: > Em Dom, 2006-06-11 às 11:19 -0700, fl1p-fl0p escreveu: >> import math >> math.pow(34564323, 456356) >> >> will give math range error. >> >> how can i force python to process huge integers without math range >> error? Any modules i can use possibly? > > 34564323**45635

Re: math.pow(x,y)

2006-06-11 Thread Raymond L. Buvel
K.S.Sreeram wrote: > Raymond L. Buvel wrote: >> I just tried this and it is taking an extremely long time even on a fast >> machine with 4 Gb of RAM. Killed it after a couple of minutes. > > Thats odd. > 34564323**456356 completed on my laptop in 28 seconds. > [Pyt

[ANN] clnum-1.4 Class Library For Numbers Python Binding

2006-11-19 Thread Raymond L. Buvel
The clnum package adds rational numbers and arbitrary precision floating point numbers in real and complex form to Python. Also provides arbitrary precision floating point replacements for the functions in the math and cmath standard library modules. Home page: http://calcrpnpy.sourceforge.net/cln

[ANN] ratfun-2.4 Polynomials and Rational Functions

2006-11-19 Thread Raymond L. Buvel
The ratfun module provides classes for defining polynomial and rational function (ratio of two polynomials) objects. These objects can be used in arithmetic expressions and evaluated at a particular point. Home page: http://calcrpnpy.sourceforge.net/ratfun.html Note: If you are using rpncalc-1.2

[ANN] rpncalc-2.5 RPN Calculator for Python

2006-11-19 Thread Raymond L. Buvel
The rpncalc package adds an interactive Reverse Polish Notation (RPN) interpreter to Python. This interpreter allows the use of Python as an RPN calculator. You can easily switch between the RPN interpreter and the standard Python interpreter. Home page: http://calcrpnpy.sourceforge.net/ Chang

Re: Using fractions instead of floats

2007-10-03 Thread Raymond L. Buvel
Neil Cerutti wrote: >> Another guess could be that real numbers being closed under the >> four arithmetic operations, there is no danger to accidentally >> step into complex numbers. OTOH floats and rationals are two >> (conflicting) ways of extending integers. > > You would have to adopt a few s

[ANN] crcmod-1.3 CRC Generator

2006-04-23 Thread Raymond L. Buvel
Crcmod is a Python package for creating functions computing the Cyclic Redundancy Check (CRC). Any generating polynomial producing 8, 16, 32, or 64 bit CRCs is allowed. Generated functions can be used in Python or C/C++ source code can be generated. Home page: http://crcmod.sourceforge.net/ Chang

Re: CRC calculation

2006-05-05 Thread Raymond L. Buvel
[EMAIL PROTECTED] wrote: > Does anyone know where I can get python code to perform a CRC > calculation on an IP packet? > Check out http://crcmod.sourceforge.net/ -- http://mail.python.org/mailman/listinfo/python-list

[ANN] clnum-1.2 Class Library For Numbers Python Binding

2006-05-06 Thread Raymond L. Buvel
The clnum package adds rational numbers and arbitrary precision floating point numbers in real and complex form to Python. Also provides arbitrary precision floating point replacements for the functions in the math and cmath standard library modules. Home page: http://calcrpnpy.sourceforge.net/cln

Class Library for Numbers now available for Windows

2006-05-06 Thread Raymond L. Buvel
Due to the contribution of Frank Palazzolo, a Windows binary installer and build instructions are available for the clnum package. This also makes ratfun and rpncalc usable on the Windows platform. The clnum package adds rational numbers and arbitrary precision floating point numbers in real and c

Re: python rounding problem.

2006-05-07 Thread Raymond L. Buvel
Gary Wessle wrote: > Erik Max Francis <[EMAIL PROTECTED]> writes: > > >>chun ping wang wrote: >> >> >>>Hey i have a stupid question. >>>How do i get python to print the result in only three decimal >>>place... >>>Example>>> round (2.9954254, 3) >>>2.9951 >>>but i want to get r

Re: printing list

2006-05-07 Thread Raymond L. Buvel
compboy wrote: > How do you print elements of the list in one line? > > alist = [1, 2, 5, 10, 15] > > so it will be like this: > 1, 2, 5, 10, 15 > > because if I use this code > > for i in alist: > print i > > the result would be like this > > 1 > 2 > 5 > 10 > 15 > > Thanks. > There ar

Re: installing numpy

2006-05-09 Thread Raymond L. Buvel
Gary Wessle wrote: > Hi > > I am trying to install NumPy in my debian/testing linux > 2.6.15-1-686. > When installing from source on a Debian system, you want the installed package to wind up in /usr/local/lib/python2.x/site-packages (where x represents the version of Python you are running th

Re: installing numpy

2006-05-09 Thread Raymond L. Buvel
Robert Kern wrote: > Gary Wessle wrote: > >>"Raymond L. Buvel" <[EMAIL PROTECTED]> writes: > > >>>When installing from source on a Debian system, you want the installed >>>package to wind up in /usr/local/lib/python2.x/site-packages (where x

Re: installing numpy

2006-05-10 Thread Raymond L. Buvel
Gary Wessle wrote: > Robert Kern <[EMAIL PROTECTED]> writes: > > >>Raymond L. Buvel wrote: >> >> >>>Since you are a new Linux user, you should definitely follow Robert's >>>advice about building as an ordinary user separately from the

Re: Decimal and Exponentiation

2006-05-20 Thread Raymond L. Buvel
elventear wrote: > Hi, > > I am the in the need to do some numerical calculations that involve > real numbers that are larger than what the native float can handle. > > I've tried to use Decimal, but I've found one main obstacle that I > don't know how to sort. I need to do exponentiation with re

Re: Decimal and Exponentiation

2006-05-20 Thread Raymond L. Buvel
Tim Peters wrote: > The GNU GMP library (for which Python bindings are available) also > supports "big floats", but their power operation is also restricted to > integer powers and/or exact roots. This can be painful even to try; > e.g., > >>>> from gmpy import mpf >>>> mpf("1e1") *

Re: Decimal and Exponentiation

2006-05-20 Thread Raymond L. Buvel
Tim Peters wrote: > [Raymond L. Buvel, on >http://calcrpnpy.sourceforge.net/clnumManual.html > ] > >> The clnum module handles this calculation very quickly: >> >> >>> from clnum import mpf >> >>> mpf("1e1") ** mpf("3.

Re: math module for Decimals

2008-12-29 Thread Raymond L. Buvel
Since the interest is more in extended precision than in decimal representation, there is another module that may be of interest. http://calcrpnpy.sourceforge.net/clnum.html It interfaces to the Class Library for Numbers (CLN) library to provide both arbitrary precision floating point and comp

Dock box order

2008-08-20 Thread Rev. Raymond Anderson
Hello, My name is Rev. Raymond Anderson. Can you Please provide unit cost on your dock boxes with the dimension ( 46"W x 26"D x 27"H ) to enable me choose the quantities i will like to purchase. Hope to hear back from you. with kind regards Rev. Raymond Anderson. D -- http://

Python graphics question:pixel scrolling

2008-08-29 Thread Raymond Luxury-Yacht
To learn python, I've been trying to write a simple graphics program which displays a 1D cellular automaton's evolution. The last time I wrote this program, it was in C for a CGA adaptor (!) in which the display was mapped to two interlaced blocks of memory, and scrolling up two lines of pixels wa

RE: Context without manager

2023-11-27 Thread David Raymond via Python-list
> I *must* do: > > with device_open() as device: >device.do_something() > > Nevertheless, I _need_ to have a class > where the device is opened in the __init__() > and used in some methods. > > Any ideas? Perhaps take a look at contextlib.ExitStack and see if you can do something with it.

Two python issues

2024-11-05 Thread Raymond Boute via Python-list
nt for slices, only lists with the same length as the slice should be acceptable, otherwise an error should be given.  Anything that re-indexes items not covered by the slice is against the essential idea of assignment. For changes that imply re-indexing (e.g., inserting a list longer than the slice), Python offers cleaner solutions. Comments are welcome. With best regards, Raymond -- https://mail.python.org/mailman/listinfo/python-list

<    4   5   6   7   8   9