Re: Ways to make a free variable local to a function?

2018-04-15 Thread Yubin Ruan
On 2018-04-15 13:31, Kirill Balunov wrote: > > > 2018-04-15 10:58 GMT+03:00 Yubin Ruan : > > [this is a bit late...] > > Did you really have any benchmark for it? I know what you are doing but it > seems to be a pre-mature optimization. If this really is the

Re: Download

2017-06-06 Thread Yubin Ruan
On Mon, Jun 05, 2017 at 05:16:55PM +0200, Maria Alonso-Martirena wrote: > Good morning, > > > > You asked me to subscribe before writing to you and i've already done so. I > need your help: I’ve just downloaded Python for Windows (versión 3.6.1.). > However, when I try to open it, it just says “

python3: why writing to socket require bytes type while writing to a file require str ?

2016-07-22 Thread Yubin Ruan
ython write to file using unicode(type 'str')? Does python encode 'str'(Unicode) automatically before writing things to file? If it's true, then why can't it do that automatic encoding when I trying to write a 'str' to socket ? Regards, Ruan -- https://mail.python.org/mailman/listinfo/python-list

Multiline parsing of python compiler demistification needed

2016-06-16 Thread Yubin Ruan
g to make it a **online** string. You don't have to show code in that respect. Thanks in advance! Ruan. -- https://mail.python.org/mailman/listinfo/python-list

Re: python regex: variable length of positive lookbehind assertion

2016-06-14 Thread Yubin Ruan
On Wednesday, June 15, 2016 at 12:18:31 PM UTC+8, Lawrence D’Oliveiro wrote: > On Wednesday, June 15, 2016 at 3:28:37 PM UTC+12, Yubin Ruan wrote: > > > I want to match the all the text surrounded by those " ", > > You are trying to use regex (type 3 grammar) t

python regex: variable length of positive lookbehind assertion

2016-06-14 Thread Yubin Ruan
;ccc","ddd","eee"] How can I write a regex to match that? I have try to use the **positive lookbehind assertion** in python regex, but it does not allowed variable length of lookbehind. Thanks in advance, Ruan -- https://mail.python.org/mailman/listinfo/python-list

Re: Why doesn't my heapify work?

2007-02-07 Thread Ruan
I found out what is wrong. You must give it a negative step, like range(10,1,-1) But my code is not good enought for heapify. I will try again. "Ruan" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Can't range go from larger to smaller? > >

Re: Why doesn't my heapify work?

2007-02-07 Thread Ruan
Can't range go from larger to smaller? "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Dongsheng Ruan wrote: > >> I want to turn an Array into a heap, but my code just doesn't work: no >> change after ex

Why doesn't my heapify work?

2007-02-07 Thread Dongsheng Ruan
I want to turn an Array into a heap, but my code just doesn't work: no change after execution. A=[3,5,4,9,6,7] m=len(A)-1 for i in range(m,1): t=(i-1)/2 if A[i]>A[t]: A[i],A[t]=A[t],A[i] -- http://mail.python.org/mailman/listinfo/python-list

what is wrong with my python code?

2007-02-07 Thread Dongsheng Ruan
I got feed back saying" list object is not callable". But I can't figure out what is wrong with my code. A=[3,5,4,9,6,7] l=len(A)-1 for i in range(l): print A(i) -- http://mail.python.org/mailman/listinfo/python-list

Re: confused about resizing array in Python

2007-02-03 Thread Dongsheng Ruan
This seems to be clever to use reference for list. Is it unique to Python? How about the traditional programming languages like C, Pascal or C++? "Roel Schroeven" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Dongsheng Ruan schreef: >> "Roe

Re: confused about resizing array in Python

2007-02-03 Thread Dongsheng Ruan
TED]> wrote in message news:[EMAIL PROTECTED] > Ruan schreef: >> "Roel Schroeven" <[EMAIL PROTECTED]> wrote: >>> Ruan schreef: >>>> My confusion comes from the following piece of code: >>>> >>>> memo = {1:1, 2:1} >

Re: confused about resizing array in Python

2007-02-03 Thread Ruan
n message news:[EMAIL PROTECTED] > Ruan schreef: > > My confusion comes from the following piece of code: > > > > memo = {1:1, 2:1} > > def fib_memo(n): > > global memo > > if not n in memo: > > memo[n] = fib_memo(n-1) + fib_memo(n-2) > > return memo[n] &g

confused about resizing array in Python

2007-02-03 Thread Ruan
My confusion comes from the following piece of code: memo = {1:1, 2:1} def fib_memo(n): global memo if not n in memo: memo[n] = fib_memo(n-1) + fib_memo(n-2) return memo[n] I used to think that the time complexity for this code is O(n) due to its use of memoization. However, I was told recently

need help on a data structure problem

2007-02-01 Thread Dongsheng Ruan
Not quite related with Python. But my Data Structure course is experiemented on python and there is no data structure group, So I have to post here: Write a procedure (in pseudocode!) to increase the number of buckets in a (closed) hash table. Analyze its time and space complexity. -- http:/

Re: What is the dummy statement that do nothing in Python?

2007-01-31 Thread Dongsheng Ruan
Yes, that's just what I want. Thanks! - Original Message - From: Analog Kid To: Dongsheng Ruan Cc: python-list@python.org Sent: Wednesday, January 31, 2007 12:04 PM Subject: Re: What is the dummy statement that do nothing in Python? hey dongsheng: not too sure

What is the dummy statement that do nothing in Python?

2007-01-31 Thread Dongsheng Ruan
I remember that in python there is some kind of dummy statement that just holds space and does nothing. I want it to hold the place after a something like if a>b: do nothing I can't just leave the space blank after if statement because there will be error message. Does anybody know what to ins

How to pass arguments to the function embedded in the timeit.Timer()

2007-01-18 Thread Dongsheng Ruan
Hi Does anybody know how to pass multiple arguments to the function tested in timeit.timer() in python? I googled and found how to pass one argument: x=1 mytime = timeit.Timer( setup="from Createlst import createlst", stmt= "createlst(%s)"%(x) ) But how can I extend it to two or more

Re: How can I create a linked list in Python?

2007-01-16 Thread Dongsheng Ruan
list in Python. "Gary Herron" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Dongsheng Ruan wrote: >> with a cell class like this: >> >> #!/usr/bin/python >> >> import sys >> >> class Cell: >> >> def

How can I create a linked list in Python?

2007-01-16 Thread Dongsheng Ruan
with a cell class like this: #!/usr/bin/python import sys class Cell: def __init__( self, data, next=None ): self.data = data self.next = next def __str__( self ): return str( self.data ) def echo( self ): print self.__str__() -- http://mail.python.org/mailman/listinfo/python-l