why cannot assign to function call

2008-12-28 Thread scsoce
I have a function return a reference, and want to assign to the 
reference, simply like this:

>>def f(a)
 return a
b = 0
   * f( b ) = 1*
but the last line will be refused as "can't assign to function call".
In my thought , the assignment is very nature,  but  why the interpreter 
refused to do that ?


thks


--
http://mail.python.org/mailman/listinfo/python-list


Re: Re: how to get all repeated group with regular expression

2008-11-21 Thread scsoce

MRAB wrote:
Steve 
Holden wrote:

Please keep this on the list.

scsoce wrote:

Steve Holden wrote:

scsoce wrote:
 

say, when I try to search and match every char  from variable length
string, such as string '123456',  i tried re.findall( r'(\d)*, 
'12346' )


I think you will find you missed a quote out there. Always better to
copy and paste ...

 
, but only get '6' and Python doc indeed say: "If a group is 
contained
in a part of the pattern that matched multiple times, the last 
match is

returned."


So use

r'(\d*)'

instead and then the group includes all the digits you match.

 
cause the regx engine cannot remember all the past history then ?  
is it

nature to all regx engine or only to Python ?

Different regex engines have different capabilities, so I can't 
speak to
them all. If you wanted *all* the matches of *all* groups, how 
would you
have them returned? As a list? That would make the case where there 
was

only one match  much tricker to handle. And what would you do with

  r'((\w)*\d)*)'

Also, what about named groups? I can see enough potential 
implementation
issues that I can perfectly understand why Python works the way it 
does,
so I'd be interested to know why it doesn't makes sense to you, and 
what

you would prefer it to do.

regards
 Steve
  
maybe my expression was not clear. I  want to capture every matched 
part

in a repeated pattern, not only the last,  say, for string '123456',  I
want to back reference any one char, not only the '6'. and i know the
example is very simple, so we can got the whole string using regx and
get every char using other python statements, but if the pattern in
group is complex?
and I test in VIM, it can do the 'back reference':
==you text in vim:
123456
== pattern:
:%s/\(\d\)*/$2
text will turn to be:
2


'Fraid the Python re implementers just decided not to do it that way.


Nor Perl.

Probably what you want is re.findall(r"(\d)", "123456"), which returns 
a list of what it captured.




Yes, you are right, but this way findall() capture only the 'top' group. 
What I really need to do is to capture nested and repated patterns, say, 
 tag in html contains many ,contains many ,   
the  data in   is i need, so I write the regx like this:

   regx ='''
 \n|\n)*
   \s*\n
  |\n)*
  )
  \s*
   '''
Steve Holden wrote:

I can see enough potential implementation
issues that I can perfectly understand why Python works the way it does,
so I'd be interested to know why it doesn't makes sense to you, and what
you would prefer it to do.
  


As Steve said, if re really cannot do this kind of work , so I have to 
split the one line regx down, and  capture  first, and then loop 
to catpure , and then , and so on ... . I donnot like this way 
compared with the above one clean regx line.


--
http://mail.python.org/mailman/listinfo/python-list


how to get all repeated group with regular expression

2008-11-21 Thread scsoce
say, when I try to search and match every char  from variable length 
string, such as string '123456',  i tried re.findall( r'(\d)*, '12346' ) 
, but only get '6' and Python doc indeed say: "If a group is contained 
in a part of the pattern that matched multiple times, the last match is 
returned."
cause the regx engine cannot remember all the past history then ?  is it 
nature to all regx engine or only to Python ? 


--
http://mail.python.org/mailman/listinfo/python-list


need to suspend/resume a child thread

2008-11-12 Thread scsoce
A child thread has a long-time executions, how to suspend it and resume 
back the orignial place ? 
I know it' nature to use singal, but  child thread cannot get signal as 
Python Manual say.  And i dnt like to  check status variable  as the 
long-time executions can not or be dirty to stop to do check.

--
http://mail.python.org/mailman/listinfo/python-list


cannot pickle object returned by urllib2.urlopen()

2008-11-11 Thread scsoce
got a exception:  "a class that defines __slots__ without defining 
__getstate__ cannot be pickled "
why? 
and is there any other dump method but for pickle to store the kind of 
object ?


--
http://mail.python.org/mailman/listinfo/python-list


how can i profile every line of code

2008-02-21 Thread scsoce
I want to profile a function which has some lines of statement. It seem 
that profile module only report function's stats instead of every  line 
of code, how can i profile every line of code?
thanks.
scsoce
-- 
http://mail.python.org/mailman/listinfo/python-list


where to join a open project in Python

2008-01-21 Thread scsoce sc
hi,all:
 as a newbie, i found that finding a suitable open project in Python seems
hard, well, i has tried sourceforge and google code, python project is just
rare or not fit for me. so i want to get any suggestion or experience from
you dear pythonmates.
thank you
scsoce
-- 
http://mail.python.org/mailman/listinfo/python-list