Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #36328
| References | <1357513931.54941.YahooMailNeo@web125504.mail.ne1.yahoo.com> <kcd5sg$dtq$1@ger.gmane.org> |
|---|---|
| Date | 2013-01-07 00:53 -0800 |
| From | chaouche yacine <yacinechaouche@yahoo.com> |
| Subject | Re: Over 30 types of variables available in python ? |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.209.1357548954.2939.python-list@python.org> (permalink) |
[Multipart message — attachments visible in raw view] - view raw
Thanks for all your comments. It appears to me that there is a slight confusion between types and classes then, plus other entities (protocols ?) So my question is : is there a notion of "type" in python, like in other languages (integers, booleans, floats, strings, characters (in c)) ? if so, can you give a list of the available "types" ? The documentation (http://docs.python.org/2/library/stdtypes.html) states "The principal built-in types are numerics, sequences, mappings, files, classes, instances and exceptions." ________________________________ From: Terry Reedy <tjreedy@udel.edu> To: python-list@python.org Sent: Monday, January 7, 2013 1:45 AM Subject: Re: Over 30 types of variables available in python ? On 1/6/2013 6:12 PM, chaouche yacine wrote: > > booleans > ints, floats, longs, complexes > strings, unicode strings > lists, tuples, dictionaries, dictionary views, sets, frozensets, > buffers, bytearrays, slices > functions, methods, code objects,modules,classes, instances, types, > nulls (there is exactly one object of type Null which is None), > tracebacks, frames > generators, iterators, xranges, > files, > memoryviews, > context managers, > > These are all listed in this page > http://docs.python.org/2/library/stdtypes.html as built-in types. They would better be called classes. Every thing is Python is an instance of a class. 'Iterator' and 'context manager' are protocols that multiple classes can follow, not classes themselves. > Am I > getting anything wrong here ? I'm a bit confused about it. I have never > seen so many types in the few programming languages I saw. C has up to 8 integer types, Python 3 just 1. Most of the above are structures in C, which may or may not by typedef-ed, or classes in C++. If you counted all the structures and classes that come with C or C++, you would find a comparable number. C stdlib has a pointer to file structure type, which is equivalent to Python's file class. It is true that C does not come with hashed arrays (sets) and hashed associative arrays (dicts), but they are often needed. So C programmers either reinvent the wheel or include a third-party library. C also has frame structure, but they are normally hidden. C programmers do not have easy direct access. However, virus writers learn to work with them ;-(. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Re: Over 30 types of variables available in python ? chaouche yacine <yacinechaouche@yahoo.com> - 2013-01-07 00:53 -0800
Re: Over 30 types of variables available in python ? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-01-07 09:52 +0000
Re: Over 30 types of variables available in python ? marduk <marduk@python.net> - 2013-01-07 09:32 -0500
Re: Over 30 types of variables available in python ? Dave Angel <d@davea.name> - 2013-01-07 09:45 -0500
Re: Over 30 types of variables available in python ? Chris Angelico <rosuav@gmail.com> - 2013-01-08 01:59 +1100
Re: Over 30 types of variables available in python ? Rick Johnson <rantingrickjohnson@gmail.com> - 2013-01-10 21:20 -0800
Re: Over 30 types of variables available in python ? Rick Johnson <rantingrickjohnson@gmail.com> - 2013-01-10 21:20 -0800
csiph-web