473,396 Members | 1,866 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

type 'slice' is not an acceptable base type

That was the message I received when I imported a self
written module. All I wanted to do was experiment with
subclassing slice. So I write something like:

class iterslice(slice):
...
And when I fired up the python interpreter
from vslice import *

Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "vslice.py", line 48, in ?
class iterslice(slice):
TypeError: Error when calling the metaclass bases
type 'slice' is not an acceptable base type
So what is going on. I thought the class vs type
distinction was eliminated in order to be able
to subclass base types. So why doesn't this work?

--
Antoon Pardon
Dec 20 '05 #1
2 3494
Antoon Pardon wrote:
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "vslice.py", line 48, in ?
class iterslice(slice):
TypeError: Error when calling the metaclass bases
type 'slice' is not an acceptable base type
Searching for "not an acceptable base type" in the Python source reveals
that this exception is produced when the proposed base type doesn't have
Py_TPFLAGS_BASETYPE set.
So what is going on. I thought the class vs type
distinction was eliminated in order to be able
to subclass base types. So why doesn't this work?


slice.__base__ == object. It's the basetype flag issue. You could
propose a patch to make it subclassable.
--
Michael Hoffman
Dec 21 '05 #2
Op 2005-12-21, Michael Hoffman schreef <ca*******@mh391.invalid>:
Antoon Pardon wrote:
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "vslice.py", line 48, in ?
class iterslice(slice):
TypeError: Error when calling the metaclass bases
type 'slice' is not an acceptable base type


Searching for "not an acceptable base type" in the Python source reveals
that this exception is produced when the proposed base type doesn't have
Py_TPFLAGS_BASETYPE set.
So what is going on. I thought the class vs type
distinction was eliminated in order to be able
to subclass base types. So why doesn't this work?


slice.__base__ == object. It's the basetype flag issue. You could
propose a patch to make it subclassable.


I'll keep this is mind. It'll have to wait for after the holidays
though.

--
Antoon Pardon
Dec 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Roberto A. F. De Almeida | last post by:
I found that when using negative indices, the slice object passed to __getitem__ depends on the number of slices. An example to clarify: class a: def __getitem__(self, index): return index ...
0
by: Sebastien de Menten | last post by:
Hi, I wonder why the slice object is not pickable via pickle or cPickle. E.g.: import pickle pickle.dumps(slice(0,4)) leads to
108
by: Bryan Olson | last post by:
The Python slice type has one method 'indices', and reportedly: This method takes a single integer argument /length/ and computes information about the extended slice that the slice object would...
40
by: Ron Adam | last post by:
After considering several alternatives and trying out a few ideas with a modified list object Bengt Richter posted, (Thank You), I think I've found a way to make slice operation (especially far end...
2
by: smichr | last post by:
It seems to me that the indices() method for slices is could be improved. Right now it gives back concrete indices for a range of length n. That is, it does not return any None values. Using an...
1
by: Ronald S. Cook | last post by:
So we'll have a SelectPens function and associated proc to bring back all pens to the client. Now think about all the variations that might be needed (many). For example, to show the pen feed...
3
by: Julie | last post by:
Here's the scenario (public attributes, etc. omitted for brevity): class Base { } class Derived : Base { }
1
by: =?Utf-8?B?U2NvdHQ=?= | last post by:
Hello, Using VS2008 in a C# web service application, a class has been created that inherits from the ConfigurationSelection. This class file has been placed in the App_Code folder. The...
18
by: Stephan Beal | last post by:
Hi, all! Before i ask my question, i want to clarify that my question is not about the code i will show, but about what the C Standard says should happen. A week or so ago it occurred to me...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.