2004年08月10日 星期二 11:48
实现树和链表不需要指针,只要引用就可以了.所谓Python,Java一类的语言中没有指针是指你不能得到一个数据的确切的地址,不能做指针运算等等. 不是说你不能引用另外一个对象. class LinkedListNode: def __init__(self, nextNode): self.nextNode = nextNode ----- Original Message ----- From: "limodou" <chatme at 263.net> To: <python-chinese at lists.python.cn> Sent: Tuesday, August 10, 2004 11:38 AM Subject: Re: [python-chinese] Python没有指针,怎么实现树和链表的结构? > guochen,您好! > > 使用对象啊。对象可以是任意的东西啊。 > > a = [1,2,[3,4,[5,6]]] > > 这样不就和链表一样吗?树也可以这样表示啊。 > > ======= 2004-08-10 11:15:39 您在来信中写道:======= > > >python-chinese,您好! > > > > > > > > 致 > >礼! > > > > > > guochen > > guochen at 1218.com.cn > > 2004-08-10 > > > > > >_______________________________________________ > >python-chinese list > >python-chinese at lists.python.cn > >http://python.cn/mailman/listinfo/python-chinese > > = = = = = = = = = = = = = = = = = = = = > > > 致 > 礼! > > > limodou > chatme at 263.net > 2004-08-10 > > -------------------------------------------------------------------------------- > _______________________________________________ > python-chinese list > python-chinese at lists.python.cn > http://python.cn/mailman/listinfo/python-chinese >
2004年08月10日 星期二 11:53
杨元杰,您好! 不会。你可以在google.com里面搜索一下线程的定义。 ======= 2004-08-09 16:00:54 您在来信中写道:======= >大家好! >这是《programming python》10。4中的一个例子。这例子运行在服务器端,响应客户端的请求 >Example 10-7. PP2E\Internet\Sockets\thread-server.py >######################################################### ># Server side: open a socket on a port, listen for ># a message from a client, and send an echo reply; ># echos lines until eof when client closes socket; ># spawns a thread to handle each client connection; ># threads share global memory space with main thread; ># this is more portable than fork--not yet on Windows; >######################################################### > >import thread, time >from socket import * # get socket constructor and constants >myHost = '' # server machine, '' means local host >myPort = 50007 # listen on a non-reserved port number > >sockobj = socket(AF_INET, SOCK_STREAM) # make a TCP socket object >sockobj.bind((myHost, myPort)) # bind it to server port number >sockobj.listen(5) # allow up to 5 pending connects > >def now(): > return time.ctime(time.time()) # current time on the server > >def handleClient(connection): # in spawned thread: reply > time.sleep(5) # simulate a blocking activity > while 1: # read, write a client socket > data = connection.recv(1024) > if not data: break > connection.send('Echo=>%s at %s' % (data, now())) > connection.close() > >def dispatcher(): # listen until process killd > while 1: # wait for next connection, > connection, address = sockobj.accept() # pass to thread for service > print 'Server connected by', address, > print 'at', now() > thread.start_new(handleClient, (connection,)) > >dispatcher() > >我不明白的是: > 在函数dispatcher()中,当服务器接到一个请求,启动了一个线程A,在线程A运行过程中,服务器又街道另个client的请求,执行connection, address = sockobj.accept(),那么线程A中的connecion不是就会被覆盖了吗? > > > > > >------------------------------------------------------------------------------------- >15寸液晶双子星,震天雷II--D451¥2466/D353¥2399 http://design.163.com/aocmonitor/index.html >_______________________________________________ >python-chinese list >python-chinese at lists.python.cn >http://python.cn/mailman/listinfo/python-chinese > = = = = = = = = = = = = = = = = = = = = 致 礼! info info at xichen.com 2004-08-10
2004年08月10日 星期二 11:55
RGVhZG1hbizE+rrDo6ENCg0KCbTz0ae9zLLEwO/D5tPQsb6hts34wue7+bG+1K3A7aG3o6zA78Pm 09C9ssr2oaMNCiAgICDB7c3izfjJz9PQtPPBv7XE18rBz6GjvajS6cTjz8jFqsfls/50Y3C6zXVk cLXEx/ix8KGjDQoNCj09PT09PT0gMjAwNC0wOC0wOSAxOTo0NzoyOSDE+tTawLTQxdbQ0LS1wKO6 PT09PT09PQ0KDQo+1+69/LP2rEbSu9CpVURQIEJUIFRyYWNrZXIsztLV/c/r3mu3qNans9bL+6Os tavO0oymVURQsrvK7M+kDQo+DQo+LS0gDQo+VGhlIERlYWRtYW4gV2Fsa2luZy4uLi4uLg0KPl9f X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fDQo+cHl0aG9uLWNo aW5lc2UgbGlzdA0KPnB5dGhvbi1jaGluZXNlQGxpc3RzLnB5dGhvbi5jbg0KPmh0dHA6Ly9weXRo b24uY24vbWFpbG1hbi9saXN0aW5mby9weXRob24tY2hpbmVzZQ0KPg0KDQo9ID0gPSA9ID0gPSA9 ID0gPSA9ID0gPSA9ID0gPSA9ID0gPSA9ID0NCgkJCQ0KDQqhoaGhoaGhoaGhoaGhoaGh1sINCsDx o6ENCiANCgkJCQkgDQqhoaGhoaGhoaGhoaGhoaGhaW5mbw0KoaGhoaGhoaGhoaGhoaGhoWluZm9A eGljaGVuLmNvbQ0KoaGhoaGhoaGhoaGhoaGhoaGhoaEyMDA0LTA4LTEwDQoNCg==
2004年08月10日 星期二 11:56
gentoo.cn,您好! 在python中确定一个对象所占的内存数好像没有意义阿,列表占多少内存? 是放列表中元素的引用所用的内存大小?还是连元素所占内存一起算? python中所有对象继承自Object类(在python的c实现中就是struct Object),列表放的只是一个元素为 指向Object的指针数组(当然也包含Object类的数据,和其它一些类型相关的信息),具体一个元素占多少空间,真的很难说清楚,这和python的实现有关,和对象所含的内容有关. 在python中不用去关心内存的具体使用情况. 至于指针,谁说实现数据结构一定要指针? 用指针只是在c++和c中的方法,python根本用不到. ======= 2004-08-10 11:58:12 您在来信中写道:======= >C++不用指针没法实现树吗? >同理,Python中使用C++中不用指针的树的算法不就可以了吗 >提示:使用数组的树 > >Jacob Fan wrote: > >>实现树和链表不需要指针,只要引用就可以了.所谓Python,Java一类的语言中没有指针是指你不能得到一个数据的确切的地址,不能做指针运算等等. 不是说你不能引用另外一个对象. >> >>class LinkedListNode: >> def __init__(self, nextNode): >> self.nextNode = nextNode >> >>----- Original Message ----- >>From: "limodou" <chatme at 263.net> >>To: <python-chinese at lists.python.cn> >>Sent: Tuesday, August 10, 2004 11:38 AM >>Subject: Re: [python-chinese] Python没有指针,怎么实现树和链表的结构? >> >> >> >> >>>guochen,您好! >>> >>>使用对象啊。对象可以是任意的东西啊。 >>> >>>a = [1,2,[3,4,[5,6]]] >>> >>>这样不就和链表一样吗?树也可以这样表示啊。 >>> >>>======= 2004-08-10 11:15:39 您在来信中写道:======= >>> >>> >>> >>>>python-chinese,您好! >>>> >>>> >>>> >>>> 致 >>>>礼! >>>> >>>> >>>> guochen >>>> guochen at 1218.com.cn >>>> 2004-08-10 >>>> >>>> >>>>_______________________________________________ >>>>python-chinese list >>>>python-chinese at lists.python.cn >>>>http://python.cn/mailman/listinfo/python-chinese >>>> >>>> >>>= = = = = = = = = = = = = = = = = = = = >>> >>> >>> 致 >>>礼! >>> >>> >>> limodou >>> chatme at 263.net >>> 2004-08-10 >>> >>> >>> >>> >> >> >>-------------------------------------------------------------------------------- >> >> >> >> >>>_______________________________________________ >>>python-chinese list >>>python-chinese at lists.python.cn >>>http://python.cn/mailman/listinfo/python-chinese >>> >>> >>>------------------------------------------------------------------------ >>> >>>_______________________________________________ >>>python-chinese list >>>python-chinese at lists.python.cn >>>http://python.cn/mailman/listinfo/python-chinese >>> >>> > >_______________________________________________ >python-chinese list >python-chinese at lists.python.cn >http://python.cn/mailman/listinfo/python-chinese = = = = = = = = = = = = = = = = = = = = 致 礼! hoxide hoxide_dirac at yahoo.com.cn 2004-08-10
2004年08月10日 星期二 11:58
C++不用指针没法实现树吗? 同理,Python中使用C++中不用指针的树的算法不就可以了吗 提示:使用数组的树 Jacob Fan wrote: >实现树和链表不需要指针,只要引用就可以了.所谓Python,Java一类的语言中没有指针是指你不能得到一个数据的确切的地址,不能做指针运算等等. 不是说你不能引用另外一个对象. > >class LinkedListNode: > def __init__(self, nextNode): > self.nextNode = nextNode > >----- Original Message ----- >From: "limodou" <chatme at 263.net> >To: <python-chinese at lists.python.cn> >Sent: Tuesday, August 10, 2004 11:38 AM >Subject: Re: [python-chinese] Python没有指针,怎么实现树和链表的结构? > > > > >>guochen,您好! >> >>使用对象啊。对象可以是任意的东西啊。 >> >>a = [1,2,[3,4,[5,6]]] >> >>这样不就和链表一样吗?树也可以这样表示啊。 >> >>======= 2004-08-10 11:15:39 您在来信中写道:======= >> >> >> >>>python-chinese,您好! >>> >>> >>> >>> 致 >>>礼! >>> >>> >>> guochen >>> guochen at 1218.com.cn >>> 2004-08-10 >>> >>> >>>_______________________________________________ >>>python-chinese list >>>python-chinese at lists.python.cn >>>http://python.cn/mailman/listinfo/python-chinese >>> >>> >>= = = = = = = = = = = = = = = = = = = = >> >> >> 致 >>礼! >> >> >> limodou >> chatme at 263.net >> 2004-08-10 >> >> >> >> > > >-------------------------------------------------------------------------------- > > > > >>_______________________________________________ >>python-chinese list >>python-chinese at lists.python.cn >>http://python.cn/mailman/listinfo/python-chinese >> >> >>------------------------------------------------------------------------ >> >>_______________________________________________ >>python-chinese list >>python-chinese at lists.python.cn >>http://python.cn/mailman/listinfo/python-chinese >> >>
2004年08月10日 星期二 11:58
提问的兄弟, 思维不要被c++僵化啊. 没c++的很多繁杂概念,世界一样很好. ======= 2004-08-10 11:58:12 您在来信中写道:======= >C++不用指针没法实现树吗? >同理,Python中使用C++中不用指针的树的算法不就可以了吗 >提示:使用数组的树 > >Jacob Fan wrote: > >>实现树和链表不需要指针,只要引用就可以了.所谓Python,Java一类的语言中没有指针是指你不能得到一个数据的确切的地址,不能做指针运算等等. 不是说你不能引用另外一个对象. >> >>class LinkedListNode: >> def __init__(self, nextNode): >> self.nextNode = nextNode >> >>----- Original Message ----- >>From: "limodou" <chatme at 263.net> >>To: <python-chinese at lists.python.cn> >>Sent: Tuesday, August 10, 2004 11:38 AM >>Subject: Re: [python-chinese] Python没有指针,怎么实现树和链表的结构? >> >> >> >> >>>guochen,您好! >>> >>>使用对象啊。对象可以是任意的东西啊。 >>> >>>a = [1,2,[3,4,[5,6]]] >>> >>>这样不就和链表一样吗?树也可以这样表示啊。 >>> >>>======= 2004-08-10 11:15:39 您在来信中写道:======= >>> >>> >>> >>>>python-chinese,您好! >>>> >>>> >>>> >>>> 致 >>>>礼! >>>> >>>> >>>> guochen >>>> guochen at 1218.com.cn >>>> 2004-08-10 >>>> >>>> >>>>_______________________________________________ >>>>python-chinese list >>>>python-chinese at lists.python.cn >>>>http://python.cn/mailman/listinfo/python-chinese >>>> >>>> >>>= = = = = = = = = = = = = = = = = = = = >>> >>> >>> 致 >>>礼! >>> >>> >>> limodou >>> chatme at 263.net >>> 2004-08-10 >>> >>> >>> >>> >> >> >>-------------------------------------------------------------------------------- >> >> >> >> >>>_______________________________________________ >>>python-chinese list >>>python-chinese at lists.python.cn >>>http://python.cn/mailman/listinfo/python-chinese >>> >>> >>>------------------------------------------------------------------------ >>> >>>_______________________________________________ >>>python-chinese list >>>python-chinese at lists.python.cn >>>http://python.cn/mailman/listinfo/python-chinese >>> >>> > >_______________________________________________ >python-chinese list >python-chinese at lists.python.cn >http://python.cn/mailman/listinfo/python-chinese
2004年08月10日 星期二 14:18
既然有更直接的方法,你干吗那样做呢? ;) ----- Original Message ----- From: "gentoo.cn" <gentoo.cn at 126.com> To: <python-chinese at lists.python.cn> Sent: Tuesday, August 10, 2004 11:58 AM Subject: Re: [python-chinese] Python没有指针,怎么实现树和链表的结构? > C++不用指针没法实现树吗? > 同理,Python中使用C++中不用指针的树的算法不就可以了吗 > 提示:使用数组的树 > > Jacob Fan wrote: > > >实现树和链表不需要指针,只要引用就可以了.所谓Python,Java一类的语言中没有指针是指你不能得到一个数据的确切的地址,不能做指针运算等等. 不是说你不能引用另外一个对象. > > > >class LinkedListNode: > > def __init__(self, nextNode): > > self.nextNode = nextNode > > > >----- Original Message ----- > >From: "limodou" <chatme at 263.net> > >To: <python-chinese at lists.python.cn> > >Sent: Tuesday, August 10, 2004 11:38 AM > >Subject: Re: [python-chinese] Python没有指针,怎么实现树和链表的结构? > > > > > > > > > >>guochen,您好! > >> > >>使用对象啊。对象可以是任意的东西啊。 > >> > >>a = [1,2,[3,4,[5,6]]] > >> > >>这样不就和链表一样吗?树也可以这样表示啊。 > >> > >>======= 2004-08-10 11:15:39 您在来信中写道:======= > >> > >> > >> > >>>python-chinese,您好! > >>> > >>> > >>> > >>> 致 > >>>礼! > >>> > >>> > >>> guochen > >>> guochen at 1218.com.cn > >>> 2004-08-10 > >>> > >>> > >>>_______________________________________________ > >>>python-chinese list > >>>python-chinese at lists.python.cn > >>>http://python.cn/mailman/listinfo/python-chinese > >>> > >>> > >>= = = = = = = = = = = = = = = = = = = = > >> > >> > >> 致 > >>礼! > >> > >> > >> limodou > >> chatme at 263.net > >> 2004-08-10 > >> > >> > >> > >> > > > > > >-------------------------------------------------------------------------------- > > > > > > > > > >>_______________________________________________ > >>python-chinese list > >>python-chinese at lists.python.cn > >>http://python.cn/mailman/listinfo/python-chinese > >> > >> > >>------------------------------------------------------------------------ > >> > >>_______________________________________________ > >>python-chinese list > >>python-chinese at lists.python.cn > >>http://python.cn/mailman/listinfo/python-chinese > >> > >> > > _______________________________________________ > python-chinese list > python-chinese at lists.python.cn > http://python.cn/mailman/listinfo/python-chinese > >
2004年08月10日 星期二 14:25
用一颗树对应的完全树来按照层次编号就可以使用联系存储空间(比如数组)来表示树 啦。 -----邮件原件----- 发件人: python-chinese-bounces at lists.python.cn [mailto:python-chinese-bounces at lists.python.cn] 代表 gentoo.cn 发送时间: 2004年8月10日 11:58 收件人: python-chinese at lists.python.cn 主题: Re: [python-chinese] Python没有指针,怎么实现树和链表的结构? C++不用指针没法实现树吗? 同理,Python中使用C++中不用指针的树的算法不就可以了吗 提示:使用数组的树 Jacob Fan wrote: >实现树和链表不需要指针,只要引用就可以了.所谓Python,Java一类的语言中没有指针 是指你不能得到一个数据的确切的地址,不能做指针运算等等. 不是说你不能引用另外 一个对象. > >class LinkedListNode: > def __init__(self, nextNode): > self.nextNode = nextNode > >----- Original Message ----- >From: "limodou" <chatme at 263.net> >To: <python-chinese at lists.python.cn> >Sent: Tuesday, August 10, 2004 11:38 AM >Subject: Re: [python-chinese] Python没有指针,怎么实现树和链表的结构? > > > > >>guochen,您好! >> >>使用对象啊。对象可以是任意的东西啊。 >> >>a = [1,2,[3,4,[5,6]]] >> >>这样不就和链表一样吗?树也可以这样表示啊。 >> >>======= 2004-08-10 11:15:39 您在来信中写道:======= >> >> >> >>>python-chinese,您好! >>> >>> >>> >>> 致 >>>礼! >>> >>> >>> guochen >>> guochen at 1218.com.cn >>> 2004-08-10 >>> >>> >>>_______________________________________________ >>>python-chinese list >>>python-chinese at lists.python.cn >>>http://python.cn/mailman/listinfo/python-chinese >>> >>> >>= = = = = = = = = = = = = = = = = = = = >> >> >> 致 >>礼! >> >> >> limodou >> chatme at 263.net >> 2004-08-10 >> >> >> >> > > >----------------------------------------------------------------------- >--------- > > > > >>_______________________________________________ >>python-chinese list >>python-chinese at lists.python.cn >>http://python.cn/mailman/listinfo/python-chinese >> >> >>---------------------------------------------------------------------- >>-- >> >>_______________________________________________ >>python-chinese list >>python-chinese at lists.python.cn >>http://python.cn/mailman/listinfo/python-chinese >> >> _______________________________________________ python-chinese list python-chinese at lists.python.cn http://python.cn/mailman/listinfo/python-chinese
Zeuux © 2024
京ICP备05028076号