in reply to Re^2: [OT] Python vs R
in thread [OT] Python vs R

Given that Python is 100% class/object based inherently, I'd say it's far closer to Perl 6 than it is Perl 5, while enforcing specific indentation.

Replies are listed 'Best First'.
Re^4: [OT] Python vs R
by Anonymous Monk on May 30, 2017 at 16:09 UTC

    That might be true. Perl6 deliberately borrowed a number of features from Python. But I don't think either Python or Perl6 is "100% class/object based inherently." I mean, they don't force you to put your code in a formal class definition like Java does. You can say that "every object has a class" in those languages, or equivalently "every value has a type," but that's trivially true of any language. Even a monotyped language like Perl1 where every value is a string.

    The forced indentation thing is another manifestation of Python's "there's one way to do it" attitude.

Re^4: [OT] Python vs R
by LanX (Saint) on May 30, 2017 at 17:41 UTC
    > Given that Python is 100% class/object based inherently,

    Really? I remember reading a comparison to Py vs Ruby and it was Ruby where everything was an object.

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!

      Everything is an object in Python too, but they aren't as useful as their Ruby counterparts e.g.
      % python Python 2.7.13 (default, Mar 20 2017, 13:35:32) [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> x = 2 >>> type(x) <type 'int'> >>> dir(x) ['__abs__', '__add__', '__and__', '__class__', '__cmp__', '__coerce__' +, '__delattr__', '__div__', '__divmod__', '__doc__', '__float__', '__ +floordiv__', '__format__', '__getattribute__', '__getnewargs__', '__h +ash__', '__hex__', '__index__', '__init__', '__int__', '__invert__', +'__long__', '__lshift__', '__mod__', '__mul__', '__neg__', '__new__', + '__nonzero__', '__oct__', '__or__', '__pos__', '__pow__', '__radd__' +, '__rand__', '__rdiv__', '__rdivmod__', '__reduce__', '__reduce_ex__ +', '__repr__', '__rfloordiv__', '__rlshift__', '__rmod__', '__rmul__' +, '__ror__', '__rpow__', '__rrshift__', '__rshift__', '__rsub__', '__ +rtruediv__', '__rxor__', '__setattr__', '__sizeof__', '__str__', '__s +ub__', '__subclasshook__', '__truediv__', '__trunc__', '__xor__', 'bi +t_length', 'conjugate', 'denominator', 'imag', 'numerator', 'real'] >>> x.bit_length() 2 >>> x.denominator() Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: 'int' object is not callable >>> >>> y = 'hello' >>> type(y) <type 'str'> >>> dir(y) ['__add__', '__class__', '__contains__', '__delattr__', '__doc__', '__ +eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__ +getnewargs__', '__getslice__', '__gt__', '__hash__', '__init__', '__l +e__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__', '__new__', + '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', ' +__setattr__', '__sizeof__', '__str__', '__subclasshook__', '_formatte +r_field_name_split', '_formatter_parser', 'capitalize', 'center', 'co +unt', 'decode', 'encode', 'endswith', 'expandtabs', 'find', 'format', + 'index', 'isalnum', 'isalpha', 'isdigit', 'islower', 'isspace', 'ist +itle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'partition', 'r +eplace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip' +, 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', +'translate', 'upper', 'zfill'] >>> >>> y.capitalize() 'Hello' >>> y.__len__() 5 >>> len(y) 5 >>>
      vs
      % irb irb(main):001:0> x = 2 => 2 irb(main):002:0> x.methods => [:%, :&, :*, :+, :-, :/, :<, :>, :^, :|, :~, :-@, :**, :<=>, :<<, : +>>, :<=, :>=, :==, :===, :[], :inspect, :size, :succ, :to_int, :to_s, + :to_i, :to_f, :next, :div, :upto, :chr, :ord, :coerce, :divmod, :fdi +v, :modulo, :remainder, :abs, :magnitude, :integer?, :floor, :ceil, : +round, :truncate, :odd?, :even?, :downto, :times, :pred, :bit_length, + :digits, :to_r, :numerator, :denominator, :rationalize, :gcd, :lcm, +:gcdlcm, :+@, :eql?, :singleton_method_added, :i, :real?, :zero?, :no +nzero?, :finite?, :infinite?, :step, :positive?, :negative?, :quo, :a +rg, :rectangular, :rect, :polar, :real, :imaginary, :imag, :abs2, :an +gle, :phase, :conjugate, :conj, :to_c, :between?, :clamp, :instance_o +f?, :kind_of?, :is_a?, :tap, :public_send, :remove_instance_variable, + :singleton_method, :instance_variable_set, :define_singleton_method, + :method, :public_method, :extend, :to_enum, :enum_for, :=~, :!~, :re +spond_to?, :freeze, :object_id, :send, :display, :nil?, :hash, :class +, :singleton_class, :clone, :dup, :itself, :taint, :tainted?, :untain +t, :untrust, :untrusted?, :trust, :frozen?, :methods, :singleton_meth +ods, :protected_methods, :private_methods, :public_methods, :instance +_variable_get, :instance_variables, :instance_variable_defined?, :!, +:!=, :__send__, :equal?, :instance_eval, :instance_exec, :__id__] irb(main):003:0> irb(main):004:0* x.denominator => 1 irb(main):005:0> y = 'hello' => "hello" irb(main):006:0> y.methods => [:include?, :%, :*, :+, :to_c, :unicode_normalize, :unicode_normali +ze!, :unicode_normalized?, :count, :partition, :unpack, :unpack1, :su +m, :next, :casecmp, :casecmp?, :insert, :bytesize, :match, :match?, : +succ!, :+@, :-@, :index, :rindex, :<=>, :replace, :clear, :upto, :get +byte, :==, :===, :setbyte, :=~, :scrub, :[], :[]=, :chr, :scrub!, :du +mp, :byteslice, :upcase, :next!, :empty?, :eql?, :downcase, :capitali +ze, :swapcase, :upcase!, :downcase!, :capitalize!, :swapcase!, :hex, +:oct, :split, :lines, :reverse, :chars, :codepoints, :prepend, :bytes +, :concat, :<<, :freeze, :inspect, :intern, :end_with?, :crypt, :ljus +t, :reverse!, :chop, :scan, :gsub, :ord, :start_with?, :length, :size +, :rstrip, :succ, :center, :sub, :chomp!, :sub!, :chomp, :rjust, :lst +rip!, :gsub!, :chop!, :strip, :to_str, :to_sym, :rstrip!, :tr, :tr_s, + :delete, :to_s, :to_i, :tr_s!, :delete!, :squeeze!, :each_line, :squ +eeze, :strip!, :each_codepoint, :lstrip, :slice!, :rpartition, :each_ +byte, :each_char, :to_f, :slice, :ascii_only?, :encoding, :force_enco +ding, :b, :valid_encoding?, :tr!, :encode, :encode!, :hash, :to_r, :< +, :>, :<=, :>=, :between?, :clamp, :instance_of?, :kind_of?, :is_a?, +:tap, :public_send, :remove_instance_variable, :singleton_method, :in +stance_variable_set, :define_singleton_method, :method, :public_metho +d, :extend, :to_enum, :enum_for, :!~, :respond_to?, :object_id, :send +, :display, :nil?, :class, :singleton_class, :clone, :dup, :itself, : +taint, :tainted?, :untaint, :untrust, :untrusted?, :trust, :frozen?, +:methods, :singleton_methods, :protected_methods, :private_methods, : +public_methods, :instance_variable_get, :instance_variables, :instanc +e_variable_defined?, :!, :!=, :__send__, :equal?, :instance_eval, :in +stance_exec, :__id__] irb(main):007:0> irb(main):008:0* y.length => 5 irb(main):009:0>