python vs javascript

2009-03-27  来源:本站原创  分类:AJAX  人气:1042 

python structural body (including class, function and class instances) and the javascript of the structure (Object and function) to achieve somewhat similar, but also somewhat different.

python the class of data and functions around the store are Victoria __dict__.
Object property and method exist inside.
The javascript object (Object or function) should have two hash stored data, a prototype, one is xxx (now do not know what, storage object's own methods and data). Data and methods is also of mixed storage.

Examples of methods for target search, the two, is almost the same.
python Medium:
class Dog ():
def spark (self):
print "spark"

dog = Dog ()
dog.spark () # output spark

Medium dog.__dict__ nothing, when dog.spark called, python first dog__dict__ find spark, if not, from the class Dog Medium __dict__ search.
class dict not copy the function to the instance in the go.

The javascript:
function Dog () ()
Dog.prototype.spark = function () (alert ( 'spark');)

dog = new Dog ();

dog.spark (); # output spark

If the modified method of class Dog dog will affect the solution?
Dog.prototype.spark = function () (alert ( 'spark2');)

dog.spark () # output spark2
Changed.
So javascript methods like retrieval and python.

python and javascript feel like,
From the python's class and function definitions, key: value, can be seen, python is the core of dict.
The javascript is the prototype of a dict.
Their methods and data are stored mixed. Without "()" is the method itself, added a "()" method is called.

This way of implementation of the ruby is not the same.
Since ruby is a pure OO husband, a distinction between the internal member variables and methods, so the storage is separate from the iv_table and m_table.
And class instantiation process, and also a bit like javascript.
javascript defined in the prototype is equivalent to ruby in the Ways instance_methods. There are things that can be retrieved at function scope. The difference is, js is a function of the copy. Medium ruby in the class is only preserved example of a class of indicators point to k_class.
js and ruby are the function of the class divided into two parts, instance_methods (prototype) and class methods (Object-private methods)

相关文章
  • python vs javascript 2009-03-27

    python structural body (including class, function and class instances) and the javascript of the structure (Object and function) to achieve somewhat similar, but also somewhat different. python the class of data and functions around the store are Vic

  • pyv8学习python和javascript变量进行交互 2015-02-21

    这篇文章主要介绍了pyv8学习python和javascript变量进行交互,python取得javascript里面的值.javascript取得python里面的值.python和javascript里面的函数交互 python取得javascript里面的值 import PyV8 with PyV8.JSContext() as env1: env1.eval(""" var_i = 1; var_f = 1.0; var_s = "test";

  • PHP.Python和Javascript的装饰器模式对比 2015-05-04

    这篇文章主要介绍了PHP.Python和Javascript的装饰器模式对比,修饰模式(Decorator Pattern),又叫装饰者模式,是面向对象编程领域中,一种动态地往一个类中添加新的行为的设计模式,需要的朋友可以参考下 修饰模式(Decorator Pattern),又叫装饰者模式,是面向对象编程领域中,一种动态地往一个类中添加新的行为的设计模式.就功能而言,修饰模式相比生成子类更为灵活,这样可以给某个对象而不是整个类添加一些功能.装饰模式非常适用于灵活扩展对象的功能,下面是装饰模式的

  • Python替换JavaScript Brython 2012-12-15

    Brython 网站 : http://www.brython.info/ Brython 设计用于替换网页上的 JavaScript 脚本语言,它使用 Python 来编写脚本,并直接在网页上执行. 使用方法: 授权协议: BSD 开发语言: Python JavaScript 操作系统: 跨平台 收录时间: 2012年12月15日

  • Python 转 JavaScript PythonJS 2014-06-09

    PythonJS 网站 : https://github.com/PythonJS/PythonJS PythonJS 是一个用 Python 写的转换器,用来将 Python 代码转成快速的 JavaScript,可运行于 Node.js 平台上.PythonJS 的设计思路的快速和易于集成现有的 JavaScript 代码. 使用方法: var pythonjs = require('python-js'); var pycode = "a = []; a.append('hello');

  • 谁是速度之王(Python vs JavaScript)? 2012-03-20

    Python 是个比较成熟的语言,运行速度在几年前是快于 JavaScript 的.但这些年 JavaScript 的解释器发展很快,特别是 Google 的 V8 和 Mozilla 的 SpiderMonkey, 将 JavaScript 的运行速度提升了一大块,以致 JavaScript 的运行速度大有反超 Python 之势,但 Python 也不甘示弱,PyPy 项目经过几年的开发之后,最近也在频频发布版本, 将 JIT 带到 Python 之中,所以谁比谁牛,还很难说.这里做个简单的

  • python和javascript共用的base64加解密代码 2015-03-09

    最近在OpenEDX中开发了个新的组件,其中需要支持上传功能.由于全都是异步操作,而一些现有的文件上传的库都失效不可用.所以想自己将文件编码成base64,扔到服务端,服务端接收解码保存,以此来实现文件上传的功能.之前在javascript中加解密部分一直喜欢用CryptoJS库.结果发现此库对数据Base64编码后,python的base64库解密不出来.后来更换了js-base64 这个库,还是不行,于是自己用coffeescript写了一个.这里存档,以备后用. class CSTBase

  • Python.Javascript中的闭包比较 2014-10-05

    这篇文章主要介绍了Python.Javascript中的闭包比较,本文分别讲解了Python和Javascript中的闭包,分对它们的不同做了一个简单的比较,需要的朋友可以参考下 同为脚本语言,python和Javascript具有相似的变量作用域,不像php,函数的内部的所有变量和外部都是隔绝的,也就是说,函数要想处理其外部的数据,必须使用参数把需要处理的数据传递进来(使用global关键词这里不讨论),而python和Javascript不同,如果在函数声明变量,它会逐级网上查找,直到返回着

  • Python中还原JavaScript的escape函数编码后字符串的方法 2015-04-05

    这篇文章主要介绍了Python中解析JavaScript的escape函数编码后字符串的方法,即Python中如何还原JavaScript escape函数编码后的字符串,需要的朋友可以参考下 遇到一个问题需要用Python把JavaScript中escape的中文给还原,但找了大半天,也没有找到答案,只好自己深入研究解决方案. 我们先来看在js中escape一段文字的编码 a = escape('这是一串文字'); alert(a); 输出: 复制代码 代码如下: %u8FD9%u662F%u

  • Python的RIA框架 Pyjs 2012-05-17

    Pyjs 网站 : http://pyjs.org/ Pyjs 是用于Web和桌面的 RIA 开发平台,包含一个 Python 到 JavaScript 的编译器,一个 Ajax 框架和一组 Widget API.Pyjs 相当于是谷歌的 GWT 的 Python 移植版本,同时也支持桌面应用开发 -- Pyjs Desktop,可直接使用独立桌面应用程序的方式来运行相同代码的 Web 项目,而无需打开浏览器. 一段简单的 Pyjs 代码: import pyjd # this is dummy

  • 孩子们为什么要学Python编程? 2014-06-28

    这个问题,即使你说出许多理由也无济于事,需要依靠实际统计数字来说话. 4月6日,Black Duck Software, Inc. 发布一项内容十分周详的调查报告,题为"Open Source By The Numbers"(报告人是Rich Sands ),读后有感. 该调查发现,当今最活跃的编程语言是C/C++,跟随其后的是Java,Python,JavaScript等编程语言,如下图所示: 从上图可见,圆饼图左下方的淡蓝色扇形区域代表的就是Python编程语言.那么,我们为什么要

  • Ian Bicking:跟Python说再见 2014-12-25

    这篇文章有点长,这并非声明观点,只是对我一路走来的反思.我很久以前就离开了Python世界,但我从没机会说个再见. 在我多年前离开Python的时候,无限感慨,不太承认我不会再回来.当我对PyCon2013的提议被拒绝时,我非常泄气并且感觉到我不再是Python社区的一员了. Python社区是我第一个也是唯一一个参与的开源社区.参与到Python里是经过深思熟虑的决定.在大学里我对Scheme和Smalltalk感兴趣.这些语言很高端大气很有意思,但是很难找到实际用户.Scheme的库一直不太

  • 5分钟入门Python ---- django前夕 2012-11-04

    Python作为一门高级语言 拥有简单高效的数据结构 有区别于传统语言C C++ Java 在Python 里编程变得极其简单让人上瘾的切片(slide sequences)表达式会让C程序员感到震撼 让我们花5分钟来熟悉一下如何使用切片进行简单的Python编码 花费宝贵的5分钟 进入Python的世界 可以向这样操作一个数组 Array[index] $ >>> foo="hello world" $ >>> print foo[1] $ e 也

  • python学习手册:学习笔记5--String Fundamentals 2015-02-18

    1. 字符串简述 目前对于程序员来说,Unicode是一个非常重要的知识点.对于Python3.X以上的版本,字符串就是Unicode(用str函数来操作),但是对于Python2.7X以上的版本,str函数处理的是ASCII字符.(ASCII只是Unicode的一个子集),以下是不同版本的Python对字符串的处理: 1. 在Python3.X中有三种字符串类型:str用于Unicode(包含ASCII),bytes用于二进制数据(包含编码的文本),bytearray是可改变的bytes类型.

  • Hot forum JavaEye recommended in March the year -2009 2009-07-14

    Hot forum JavaEye recommended in March the year -2009 JavaEye article JavaEye forum is to discuss the highest quality one of the most active space, we've summed up the March 2009 forum for Java, AJAX, Ruby, integrated technical and project management

  • Father of Java: Oracle Management Java reassuring 2010-03-20

    Quote [Change] U.S. time on March 17, after the Oracle acquisition of Sun Microsystems, Java father James Gosling first appeared in public, he always maintained a high degree of concern on Java and Java in the Oracle's charge that under the reassurin

  • perl ide integrated development environment for consolidation Daquan [Reserved] 2010-03-07

    [Comment: Perl language is similar to Ruby, Python as a language. But it is mainly used to write at home WEB program. He can be considered a long history. Here are some of the integrated development environment, as a reference tool for learning and w

  • Faramita draft language design 0.1 - truly mobile code (mobile code) 2010-04-19

    Faramita draft language design 0.1 Advertising language (not really): The real mobile code (mobile code), a real distributed computing Abbreviation explanation: RPC: Remote Procedure Call Remote Call DSL: Domain Specific Language Domain Specific Lang

  • Those things cloud computing 2010-05-29

    Cloud Computing (Cloud computing), is a new method of sharing infrastructure, the system can be a huge pool of connected together to provide various IT services. Many factors drive the demand for this type of environment, including connected devices,

  • Build your own regular expressions assistant program (transfer) 2010-07-01

    Original link: http://iregex.org/blog/diy-regexbuddy.html In fact, RegexBuddy very good use, I have been using it. Its use, benefits, can write a lot of text, this site did the introduction;, however, also have reason to not using it, while this is a