On Fri, 01 Mar 2013 17:24:05 +0800, Honghe Wu wrote:
> Thanks! Cause I need sorted returnd list, and the arbitrary list makes the
> other procedure go wrong. Maybe the I/O speed is more important in other
> cases.
You can sort the lists of files and subdirectories with e.g.:
for root, di
Thanks! Cause I need sorted returnd list, and the arbitrary list makes the
other procedure go wrong. Maybe the I/O speed is more important in other
cases.
On Mar 1, 2013 4:55 PM, "Chris Rebert" wrote:
> On Fri, Mar 1, 2013 at 12:43 AM, Honghe Wu wrote:
> > env: python 2.7.3
> >
> > 6 test files'
On Fri, Mar 1, 2013 at 12:43 AM, Honghe Wu wrote:
> env: python 2.7.3
>
> 6 test files' name in a directory as below:
> 12ab Abc Eab a1bc acd bc
>
> the following is test code:
> for root, dirs, files in os.walk(os.getcwd()):
> print files
>
> the output in win32 platform is:
> ['12ab', '
On Fri, Mar 1, 2013 at 12:43 AM, Honghe Wu wrote:
> env: python 2.7.3
>
> 6 test files' name in a directory as below:
> 12ab Abc Eab a1bc acd bc
>
> the following is test code:
> for root, dirs, files in os.walk(os.getcwd()):
> print files
>
> the output in win32 platform is:
> ['12ab', '
env: python 2.7.3
6 test files' name in a directory as below:
12ab Abc Eab a1bc acd bc
the following is test code:
for root, dirs, files in os.walk(os.getcwd()):
print files
the output in win32 platform is:
['12ab', 'a1bc', 'Abc', 'acd', 'bc', 'Eab']
but in linux is:
['Eab', 'acd', 'a1
I see now. Thank you so much.
I think namespace is really a confusing part in Python.
On Friday, January 21, 2011 11:00:32 AM UTC-6, Peter Otten wrote:
> There are only two cases that matter: identical local/global namespaces and
> distinct local/global namespaces:
>
> >>> code = """\
> ... x =
longqian9...@gmail.com wrote:
> In pyhton 3.1, I found the following code will succeed with argument 1
> to 4 and fail with argument 5 to 9. It is really strange to me. I
> suspect it may be a buy in exec() function. Does anyone have some idea
> about it? Thanks.
>
>
> t1="""
> class foo:
> def
Of cause your code runs well. But if you remove the "global foo" in
main(), it will fail. And it will succeed again if you call exec(t1)
directly. I think this behavior is strange. Even I pass a shadow copy
of globals and locals to exec, it still fails. So perhaps there is a
basic difference betwee
On Thu, 20 Jan 2011 20:52:15 -0800, longqian9...@gmail.com wrote:
> In pyhton 3.1, I found the following code will succeed with argument 1
> to 4 and fail with argument 5 to 9. It is really strange to me. I
> suspect it may be a buy in exec() function. Does anyone have some idea
> about it? Thanks
In pyhton 3.1, I found the following code will succeed with argument 1
to 4 and fail with argument 5 to 9. It is really strange to me. I
suspect it may be a buy in exec() function. Does anyone have some idea
about it? Thanks.
t1="""
class foo:
def fun():
print('foo')
def m
Oops, missed out that... thanks
On Sun, Aug 30, 2009 at 2:25 PM, Jan Kaliszewski wrote:
> 30-08-2009 o 06:10:46 Abhishek Mishra wrote:
>
>> The single quote \' is the culprit.
>> When you say words = ["Hi", "Whats up", "Bye"] and try print words,
>> you get this -
>> ['Hi', 'Whats up', 'Bye']
>>
25-08-2009 o 22:51:14 Gleb Belov wrote:
I have two questions:
1) Is it possible and if so, how do I access each individual element?
Are there any indexes and what is the syntax?
It's a 'Read-The-Friendly-Manual' question.
(hint: library reference - Built-in Types - ...)
--
Jan Kaliszewski (
gt; 1) Is it possible and if so, how do I access each individual element?
> > Are there any indexes and what is the syntax?
>
> For the first element:
>
> >>> words[0]
> > 2) I just noticed that the first and the last words in the output are
> > enclosed in single qu
dexes and what is the syntax?
For the first element:
>>> words[0]
> 2) I just noticed that the first and the last words in the output are
> enclosed in single quotes, and the middle one is enclosed in double
> quotes. Is it a bug? If not, why does the output work that way?
The
quot;, "Bye!"]
>>> print words
['Hi!', "What's up?", 'Bye!']
I have two questions:
1) Is it possible and if so, how do I access each individual element?
Are there any indexes and what is the syntax?
2) I just noticed that the first and the last word
yoma wrote:
python version 2.5 in module copy
we all know that copy have two method: copy() and deepcopy().
and the explain is
- A shallow copy constructs a new compound object and then (to the
extent possible) inserts *the same objects* into it that the
original contains.
- A deep copy con
On Thu, 06 Nov 2008 23:59:51 -0800, yoma wrote:
> import copy
>
> class A:
> i = 1
>
> class B:
> a = A()
>
>
> b = B()
>
> x=copy.copy(b)
>
> y=copy.deepcopy(b)
>
> print id(x.a), id(b.a)
>
> print id(y.a), id(y.a)
>
> the result:
> 14505264 14505264
> 14505264 14505264
>
> So m
On Thu, Nov 6, 2008 at 11:59 PM, yoma <[EMAIL PROTECTED]> wrote:
> python version 2.5 in module copy
>
> we all know that copy have two method: copy() and deepcopy().
> and the explain is
> - A shallow copy constructs a new compound object and then (to the
> extent possible) inserts *the same obje
python version 2.5 in module copy
we all know that copy have two method: copy() and deepcopy().
and the explain is
- A shallow copy constructs a new compound object and then (to the
extent possible) inserts *the same objects* into it that the
original contains.
- A deep copy constructs a new
En Sun, 27 Jan 2008 14:21:20 -0200, Mr Shore <[EMAIL PROTECTED]>
escribi�:
> import threading
> import time
> class timer(threading.Thread):
> def __init__(self,no,interval):
> threading.Thread.__init__(self)
> self.no=no
> self.interval=interval
>
> def run(self)
import threading
import time
class timer(threading.Thread):
def __init__(self,no,interval):
threading.Thread.__init__(self)
self.no=no
self.interval=interval
def run(self):
while True:
print 'Thread Object (%d), Time:%s'%(self.no,time.ctime())
Sylvain Ferriol wrote:
>class Toto(float):
>>
>> eq = float.__eq__
>>
>>
>Toto().eq(42)
>>
>> False
>>
> i can not use it because:
> class toto(float):
> def __init__(self,a=None):pass
>
> t=toto(a=3)
> TypeError: 'a' is an invalid keyword argument for this function
Ove
Sylvain Ferriol wrote:
> i just want a class variable named 'eq'
so why are you assigning another class' descriptor to it? descriptors
are bound to types, and only works properly if used with the type they
were created for.
> why i can not create some class variables like this ?
>
> class to
Peter Otten a écrit :
> Sylvain Ferriol wrote:
>
>
>>can you explain to me what happened:
>>
>>class toto(object):
>> eq = float.__eq__
>>
>>t = toto()
>>
>>getattr(t,'eq')
>>TypeError: descriptor '__eq__' for 'float' objects doesn't apply to
>>'toto' object
>
>
> float.__eq__ is probably imp
Fredrik Lundh a écrit :
> Sylvain Ferriol wrote:
>
>> can you explain to me what happened:
>>
>> class toto(object):
>>eq = float.__eq__
>>
>> t = toto()
>>
>> getattr(t,'eq')
>> TypeError: descriptor '__eq__' for 'float' objects doesn't apply to
>> 'toto' object
>
>
> I'd say the error mes
Sylvain Ferriol wrote:
> can you explain to me what happened:
>
> class toto(object):
>eq = float.__eq__
>
> t = toto()
>
> getattr(t,'eq')
> TypeError: descriptor '__eq__' for 'float' objects doesn't apply to
> 'toto' object
I'd say the error message explains it pretty well. what did yo
Sylvain Ferriol wrote:
> can you explain to me what happened:
>
> class toto(object):
>eq = float.__eq__
>
> t = toto()
>
> getattr(t,'eq')
> TypeError: descriptor '__eq__' for 'float' objects doesn't apply to
> 'toto' object
float.__eq__ is probably implemented in C and its operation will
hello
can you explain to me what happened:
class toto(object):
eq = float.__eq__
t = toto()
getattr(t,'eq')
TypeError: descriptor '__eq__' for 'float' objects doesn't apply to
'toto' object
--
http://mail.python.org/mailman/listinfo/python-list
Darren Cui Liang wrote:
> Hi, there!
>
> Now I am working around with the "logging" module. Here is the code:
>
>
> >>> import logging
> >>> log1=logging.getLogger("a")
> >>> log1.critical("msg")
> No handlers could be found for logger "a"
> >>> logging.critical("msg")
> CRITICAL:root:msg
>
Hi, there!
Now I am working around with the "logging" module. Here is the code:
>>> import logging
>>> log1=logging.getLogger("a")
>>> log1.critical("msg")
No handlers could be found for logger "a"
>>> logging.critical("msg")
CRITICAL:root:msg
Since every "logger" is under the "root logger"
30 matches
Mail list logo