Python Forum
Question about primitive variables.
Thread Rating:
  • 2 Vote(s) - 2.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Question about primitive variables.
#4
(Apr-01-2017, 05:58 PM)micseydel Wrote: What's the source? What different, other than semantics, are they claiming? The difference can be important in other languages.

I wouldn't say Python has primitives. Even ints are referenced, and there's even an optimization for small ints where this can be observed in CPython (the standard Python implementation)
Output:
>>> 2**2 is 2**2 True >>> 2**32 is 2**32 False
OK, firstly I must say your example gave me a new question lol.
why "2**32 is 2**32" gives us output of "False"?
I mean, it is not only the same value but it is also the same type, shouldn't it be True? like the first example?

regarding the primitives I can give you for example someone which answer a question online:
http://stackoverflow.com/questions/63916...-primitive
stating "there are no primitive types in Python"

on the other hand there is this link:
https://en.wikiversity.org/wiki/Python_C...data_types
where they stated:
"In Python there are four primitive variable types, which are listed below.
Integers
Floats
Strings
Characters"

which made me not understand why some say this way and some the other way,
but by your answer and ichabod801 answer I guess they did a mistake on this site?


(Apr-01-2017, 05:59 PM)ichabod801 Wrote: In Python the distinction is generally made between mutable and immutable objects. Mutable objects can be changed in place, and are stored by reference. Immutable objects must be replaced, and are stored by value. (There are exceptions to this, but they're not that big a deal). So, the immutable types (what you would call primitive) include ints, floats, complex, strs, tuples, bytes, and frozensets.

OK, so I think I understand what you are saying.
You are basically saying that everything in python is an object, therefore we distinct between mutable and immutable objects.
Reply


Messages In This Thread
Question about primitive variables. - by Nirelg - Apr-01-2017, 05:06 PM
RE: Question about primitive variables. - by Nirelg - Apr-01-2017, 08:25 PM
RE: Question about primitive variables. - by wavic - Apr-01-2017, 09:04 PM
RE: Question about primitive variables. - by Nirelg - Apr-01-2017, 10:27 PM
RE: Question about primitive variables. - by wavic - Apr-01-2017, 09:52 PM
RE: Question about primitive variables. - by Nirelg - Apr-02-2017, 10:11 PM
RE: Question about primitive variables. - by Ofnuts - Apr-02-2017, 08:37 PM
RE: Question about primitive variables. - by wavic - Apr-03-2017, 12:13 AM
RE: Question about primitive variables. - by Nirelg - Apr-03-2017, 01:01 AM
RE: Question about primitive variables. - by casevh - Apr-03-2017, 02:59 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Very Beginner question on simple variables Harvy 1 235 Apr-12-2024, 12:03 AM
Last Post: deanhystad
  Question regarding local and global variables donmerch 12 5,190 Apr-12-2020, 03:58 PM
Last Post: TomToad
  Question about naming variables in class methods sShadowSerpent 1 2,037 Mar-25-2020, 04:51 PM
Last Post: ndc85430
  Basic Pyhton for Rhino 6 question about variables SaeedSH 1 2,169 Jan-28-2020, 04:33 AM
Last Post: Larz60+
  A question about global variables Goldberg291 3 4,039 Feb-02-2017, 10:50 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020