473,387 Members | 1,520 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

python's OOP question

There's a program, it's result is "unexpected aaa", i want it to be
"expected aaa". how to make it work?

Expand|Select|Wrap|Line Numbers
  1.  
  2. class C1(object):
  3. def v(self, o):
  4. return "expected "+o
  5.  
  6. class C2(object):
  7. def v(self, o):
  8. return "unexpected "+o
  9. def m(self):
  10. print self.v("aaa")
  11.  
  12. class C3(object):
  13. def nothing(self):
  14. pass
  15.  
  16. def test1():
  17. o = C3()
  18. setattr(o,"m",C2().m)
  19. setattr(o,"v",C1().v)
  20. o.m()
  21.  
  22. test1()
  23.  
  24.  
Oct 16 '06 #1
23 1484
neoedmund wrote:
There's a program, it's result is "unexpected aaa", i want it to be
"expected aaa". how to make it work?

Expand|Select|Wrap|Line Numbers
  1. class C1(object):
  2.     def v(self, o):
  3.         return "expected "+o
  4. class C2(object):
  5.     def v(self, o):
  6.         return "unexpected "+o
  7.     def m(self):
  8.         print self.v("aaa")
  9. class C3(object):
  10.     def nothing(self):
  11.         pass
  12. def test1():
  13.     o = C3()
  14.     setattr(o,"m",C2().m)
  15.     setattr(o,"v",C1().v)
  16.     o.m()
  17. test1()
  18.  
class C3(C1, C2):pass
>>C3.mro() # shows method resolution order
[<class '__main__.C3'>, <class '__main__.C1'>, <class '__main__.C2'>,
<type 'object'>]
>>o = C3()
o.m()
expected aaa

Oct 16 '06 #2
"neoedmund" <ne*******@gmail.comwrites:
There's a program, it's result is "unexpected aaa", i want it to be
"expected aaa". how to make it work?

[code]

class C1(object):
def v(self, o):
return "expected "+o

class C2(object):
def v(self, o):
return "unexpected "+o
def m(self):
print self.v("aaa")

class C3(object):
def nothing(self):
pass

def test1():
o = C3()
setattr(o,"m",C2().m)
setattr(o,"v",C1().v)
o.m()
Setting attributes on an object externally isn't the same thing as
making bound methods of that object.

In this case, 'o.m' is a bound method of a C2 instance, and has no
knowledge of C1. 'o.v' is a bound method of a C1 instance, and has no
knowledge of C2. Neither of them has any knowledge of C3.

What is it you're trying to achieve?

--
\ "Unix is an operating system, OS/2 is half an operating system, |
`\ Windows is a shell, and DOS is a boot partition virus." -- |
_o__) Peter H. Coffin |
Ben Finney

Oct 16 '06 #3
thank you, Kay.

But i need a "dynamic" way. Say i have a existing class, and add some
method from other class into it.
Kay Schluehr wrote:
neoedmund wrote:
There's a program, it's result is "unexpected aaa", i want it to be
"expected aaa". how to make it work?

Expand|Select|Wrap|Line Numbers
  1.  
  2.  class C1(object):
  3.      def v(self, o):
  4.          return "expected "+o
  5.  
  6.  class C2(object):
  7.      def v(self, o):
  8.          return "unexpected "+o
  9.      def m(self):
  10.          print self.v("aaa")
  11.  
  12.  class C3(object):
  13.      def nothing(self):
  14.          pass
  15.  
  16.  def test1():
  17.      o = C3()
  18.      setattr(o,"m",C2().m)
  19.      setattr(o,"v",C1().v)
  20.      o.m()
  21.  
  22.  test1()
  23.  
  24.  

class C3(C1, C2):pass
>C3.mro() # shows method resolution order
[<class '__main__.C3'>, <class '__main__.C1'>, <class '__main__.C2'>,
<type 'object'>]
>o = C3()
o.m()
expected aaa
Oct 16 '06 #4
I'm trying to achieve a higher level of "reusability". Maybe it cannot
be done in python? Can anybody help me?
Ben Finney wrote:
"neoedmund" <ne*******@gmail.comwrites:
There's a program, it's result is "unexpected aaa", i want it to be
"expected aaa". how to make it work?

[code]

class C1(object):
def v(self, o):
return "expected "+o

class C2(object):
def v(self, o):
return "unexpected "+o
def m(self):
print self.v("aaa")

class C3(object):
def nothing(self):
pass

def test1():
o = C3()
setattr(o,"m",C2().m)
setattr(o,"v",C1().v)
o.m()

Setting attributes on an object externally isn't the same thing as
making bound methods of that object.

In this case, 'o.m' is a bound method of a C2 instance, and has no
knowledge of C1. 'o.v' is a bound method of a C1 instance, and has no
knowledge of C2. Neither of them has any knowledge of C3.

What is it you're trying to achieve?

--
\ "Unix is an operating system, OS/2 is half an operating system, |
`\ Windows is a shell, and DOS is a boot partition virus." -- |
_o__) Peter H. Coffin |
Ben Finney
Oct 16 '06 #5
[Please don't top-post above the text to which you're replying.]

"neoedmund" <ne*******@gmail.comwrites:
I'm trying to achieve a higher level of "reusability". Maybe it
cannot be done in python? Can anybody help me?
What, specifically, are you trying to achieve? What problem needs
solving?

--
\ "If you're a horse, and someone gets on you, and falls off, and |
`\ then gets right back on you, I think you should buck him off |
_o__) right away." -- Jack Handey |
Ben Finney

Oct 16 '06 #6
python use multiple inheritance.
but "inheritance" means you must inherite all methods from super type.
now i just need "some" methods from one type and "some" methods from
other types,
to build the new type.
Do you think this way is more flexible than tranditional inheritance?
Ben Finney wrote:
[Please don't top-post above the text to which you're replying.]

"neoedmund" <ne*******@gmail.comwrites:
I'm trying to achieve a higher level of "reusability". Maybe it
cannot be done in python? Can anybody help me?

What, specifically, are you trying to achieve? What problem needs
solving?

--
\ "If you're a horse, and someone gets on you, and falls off, and |
`\ then gets right back on you, I think you should buck him off |
_o__) right away." -- Jack Handey |
Ben Finney
Oct 16 '06 #7
neoedmund schrieb:
python use multiple inheritance.
but "inheritance" means you must inherite all methods from super type.
now i just need "some" methods from one type and "some" methods from
other types,
to build the new type.
Do you think this way is more flexible than tranditional inheritance?
Probably your problem is better solved with delegation instead of
inheritance.

--
Servus, Gregor
Oct 16 '06 #8
neoedmund wrote:
python use multiple inheritance.
but "inheritance" means you must inherite all methods from super type.
now i just need "some" methods from one type and "some" methods from
other types,
to build the new type.
Do you think this way is more flexible than tranditional inheritance?
The following does the trick:

from types import MethodType

def addMethod(meth, obj):
f = meth.im_func
setattr(obj, f.__name__, MethodType(f,obj))

def test1():
addMethod(C2.m, C3)
addMethod(C1.v, C3)
o = C3()
o.m()

The same works as is on modifying individual instances, rather than
their class:

def test2():
o = C3()
addMethod(C2.m, o)
addMethod(C1.v, o)
o.m()
# raises AttributeError
# C3().m()
George

Oct 16 '06 #9
I found a dynamic way to inherite classes:

def MixIn(pyClass, mixInClass):
if mixInClass not in pyClass.__bases__:
pyClass.__bases__ += (mixInClass,)

def test1():
o = C3()
MixIn(C3,C1)
MixIn(C3,C2)
o.m()

"expected aaa"

neoedmund wrote:
thank you, Kay.

But i need a "dynamic" way. Say i have a existing class, and add some
method from other class into it.
Kay Schluehr wrote:
neoedmund wrote:
There's a program, it's result is "unexpected aaa", i want it to be
"expected aaa". how to make it work?
>
Expand|Select|Wrap|Line Numbers
  1.  >
  2.  class C1(object):
  3.      def v(self, o):
  4.          return "expected "+o
  5.  >
  6.  class C2(object):
  7.      def v(self, o):
  8.          return "unexpected "+o
  9.      def m(self):
  10.          print self.v("aaa")
  11.  >
  12.  class C3(object):
  13.      def nothing(self):
  14.          pass
  15.  >
  16.  def test1():
  17.      o = C3()
  18.      setattr(o,"m",C2().m)
  19.      setattr(o,"v",C1().v)
  20.      o.m()
  21.  >
  22.  test1()
  23.  >
  24.  
class C3(C1, C2):pass
>>C3.mro() # shows method resolution order
[<class '__main__.C3'>, <class '__main__.C1'>, <class '__main__.C2'>,
<type 'object'>]
>>o = C3()
>>o.m()
expected aaa
Oct 16 '06 #10
Oh, How great is the solution! ( though i don't know how it works. )
Thank you George.

George Sakkis wrote:
neoedmund wrote:
python use multiple inheritance.
but "inheritance" means you must inherite all methods from super type.
now i just need "some" methods from one type and "some" methods from
other types,
to build the new type.
Do you think this way is more flexible than tranditional inheritance?

The following does the trick:

from types import MethodType

def addMethod(meth, obj):
f = meth.im_func
setattr(obj, f.__name__, MethodType(f,obj))

def test1():
addMethod(C2.m, C3)
addMethod(C1.v, C3)
o = C3()
o.m()

The same works as is on modifying individual instances, rather than
their class:

def test2():
o = C3()
addMethod(C2.m, o)
addMethod(C1.v, o)
o.m()
# raises AttributeError
# C3().m()
George
Oct 16 '06 #11
neoedmund wrote:
(*PLEASE* stop top-posting - corrected)
>
Ben Finney wrote:
>[Please don't top-post above the text to which you're replying.]

"neoedmund" <ne*******@gmail.comwrites:
>>I'm trying to achieve a higher level of "reusability". Maybe it
cannot be done in python? Can anybody help me?
What, specifically, are you trying to achieve? What problem needs
solving?
python use multiple inheritance.
but "inheritance" means you must inherite all methods from super type.
now i just need "some" methods from one type and "some" methods from
other types, to build the new type.
Do you think this way is more flexible than tranditional inheritance?
While dynamically adding attributes (and methods - which are attributes
too) is not a problem, I'd second Gregor's anwser : it might be better
to use composition/delegation here.

--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'o****@xiludom.gro'.split('@')])"
Oct 16 '06 #12

Bruno Desthuilliers wrote:
neoedmund wrote:
(*PLEASE* stop top-posting - corrected)

Ben Finney wrote:
[Please don't top-post above the text to which you're replying.]

"neoedmund" <ne*******@gmail.comwrites:

I'm trying to achieve a higher level of "reusability". Maybe it
cannot be done in python? Can anybody help me?
What, specifically, are you trying to achieve? What problem needs
solving?
python use multiple inheritance.
but "inheritance" means you must inherite all methods from super type.
now i just need "some" methods from one type and "some" methods from
other types, to build the new type.
Do you think this way is more flexible than tranditional inheritance?

While dynamically adding attributes (and methods - which are attributes
too) is not a problem, I'd second Gregor's anwser : it might be better
to use composition/delegation here.
Could you show some code to help me know how composition/delegation can
be done here? Thanks.

Oct 16 '06 #13
neoedmund wrote:
Could you show some code to help me know how composition/delegation can
be done here? Thanks.
Starting with your example C2 might just derive from C1 and perform a
supercall:

class C1(object):
def v(self, o):
return "expected "+o
class C2(C1):
def v(self, o):
return "unexpected "+o
def m(self):
print super(C2,self).v("aaa")
>>c2 = C2()
c2.m()
expected aaa

But in general there is no single pattern to deal with object
composition.

Oct 16 '06 #14
neoedmund wrote:
Bruno Desthuilliers wrote:
>neoedmund wrote:
(*PLEASE* stop top-posting - corrected)
>>Ben Finney wrote:
[Please don't top-post above the text to which you're replying.]

"neoedmund" <ne*******@gmail.comwrites:

I'm trying to achieve a higher level of "reusability". Maybe it
cannot be done in python? Can anybody help me?
What, specifically, are you trying to achieve? What problem needs
solving?
python use multiple inheritance.
but "inheritance" means you must inherite all methods from super type.
now i just need "some" methods from one type and "some" methods from
other types, to build the new type.
Do you think this way is more flexible than tranditional inheritance?
While dynamically adding attributes (and methods - which are attributes
too) is not a problem, I'd second Gregor's anwser : it might be better
to use composition/delegation here.
Could you show some code to help me know how composition/delegation can
be done here? Thanks.
About composition/delegation, there's no "one-size-fits-all" answer, but
the main idea is to use the magic '__getattr__(self, name)' method.

Now back to your specific case : after a better reading of your original
question, straight composition/delegation wouldn't work here - at least
not without modifications to both C1 and C2 (sorry, should have read
better the first time).

Given the context (ie : "create a new type with methods from type X and
methods from type Y"), a very simple solution could be:

class C3(object):
m = C2.m.im_func
v = C1.v.im_func

FWIW, if you have full control over C1, C2 and C3, you could also just
'externalize' the functions definitions:

def v1(self, o):
return "expected "+o

def v2(self, o):
return "unexpected "+o

def m2(self):
""" requires that 'self' has a v(self, somestring) method """
print self.v("aaa")

class C1(object):
v = v1

class C2(object):
v = v2
m = m2

class C3(object):
v = v1
m = m2
The problem (with the whole approach, whatever the choosen technical
solution) is that if one of theses methods depends on another one (or on
any other attribute) that is not defined in your new class, you're in
trouble. This is not such a big deal in the above example, but might
become much more brittle in real life.

Now we can look at the problem from a different perspective. You wrote:
"""
but "inheritance" means you must inherite all methods from super type.
now i just need "some" methods from one type and "some" methods from
other types, to build the new type.
"""

What is your problem with having the other extra methods too ?

--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'o****@xiludom.gro'.split('@')])"
Oct 16 '06 #15


On Oct 16, 9:01 pm, Bruno Desthuilliers <o...@xiludom.growrote:
neoedmund wrote:
Bruno Desthuilliers wrote:
neoedmund wrote:
(*PLEASE* stop top-posting - corrected)
Ben Finney wrote:
[Please don't top-post above the text to which you're replying.]
>>"neoedmund" <neoedm...@gmail.comwrites:
>>>I'm trying to achieve a higher level of "reusability". Maybe it
cannot be done in python? Can anybody help me?
What, specifically, are you trying to achieve? What problem needs
solving?
python use multiple inheritance.
but "inheritance" means you must inherite all methods from super type.
now i just need "some" methods from one type and "some" methods from
other types, to build the new type.
Do you think this way is more flexible than tranditional inheritance?
While dynamically adding attributes (and methods - which are attributes
too) is not a problem, I'd second Gregor's anwser : it might be better
to use composition/delegation here.
Could you show some code to help me know how composition/delegation can
be done here? Thanks.About composition/delegation, there's no "one-size-fits-all" answer, but
the main idea is to use the magic '__getattr__(self, name)' method.

Now back to your specific case : after a better reading of your original
question, straight composition/delegation wouldn't work here - at least
not without modifications to both C1 and C2 (sorry, should have read
better the first time).

Given the context (ie : "create a new type with methods from type X and
methods from type Y"), a very simple solution could be:

class C3(object):
m = C2.m.im_func
v = C1.v.im_func

FWIW, if you have full control over C1, C2 and C3, you could also just
'externalize' the functions definitions:

def v1(self, o):
return "expected "+o

def v2(self, o):
return "unexpected "+o

def m2(self):
""" requires that 'self' has a v(self, somestring) method """
print self.v("aaa")

class C1(object):
v = v1

class C2(object):
v = v2
m = m2

class C3(object):
v = v1
m = m2

The problem (with the whole approach, whatever the choosen technical
solution) is that if one of theses methods depends on another one (or on
any other attribute) that is not defined in your new class, you're in
trouble. This is not such a big deal in the above example, but might
become much more brittle in real life.

Now we can look at the problem from a different perspective. You wrote:
"""
but "inheritance" means you must inherite all methods from super type.
now i just need "some" methods from one type and "some" methods from
other types, to build the new type.
"""

What is your problem with having the other extra methods too ?

--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'on...@xiludom.gro'.split('@')])"
Bruno , your 2 great and clear samples revealed what method is in
python, which is also I really want to ask. thank you.
So I can reuse a method freely only if it's worth reusing.
For the word "inheritance", in some aspect, meanings reuse the super
class, with the condition: must reuse everything from super class.
It's lack of a option to select which methods are to be reused.
this is something should be improved for general OOP i think.
So to answer " What is your problem with having the other extra methods
too ?",
in real life, a class is not defined so well that any method is needed
by sub-class. so contains a method never to be used is meaningless and
i think something should forbidden.
also, any handy methods in a class can be grabbed out for our reuse. so
we can forgotting the bundering inheritance tree and order.

Oct 17 '06 #16
neoedmund wrote:
(snip)
So I can reuse a method freely only if it's worth reusing.
For the word "inheritance", in some aspect, meanings reuse the super
class, with the condition: must reuse everything from super class.
Not really. In fact, inheritance *is* a special case of
composition/delegation. A 'child' class is a class that has references
to other classes - it's 'parents' -, and then attributes that are not
found in the instance or child class are looked up in the parents
(according to mro rules in case of multiple inheritance). And that's all
there is.
It's lack of a option to select which methods are to be reused.
Methods not redefined in the 'child' class or it's instance are
'reusable'. Now they are only effectively 'reused' if and when called by
client code. So the 'option to select which methods are to be reused' is
mostly up to both the 'child' class and code using it.
this is something should be improved for general OOP i think.
So to answer " What is your problem with having the other extra methods
too ?",
in real life, a class is not defined so well that any method is needed
by sub-class.
Then perhaps is it time to refactor. A class should be a highly cohesive
unit. If you find yourself needing only a specific subset of a class, it
may be time to extract this subset in it's own class. Given Python's
support for both multiple inheritance and composition/delegation, it's
usually a trivial task (unless you already mixed up too many orthogonal
concerns in your base class...).

--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'o****@xiludom.gro'.split('@')])"
Oct 17 '06 #17

Bruno Desthuilliers wrote:
neoedmund wrote:
(snip)
So I can reuse a method freely only if it's worth reusing.
For the word "inheritance", in some aspect, meanings reuse the super
class, with the condition: must reuse everything from super class.

Not really. In fact, inheritance *is* a special case of
composition/delegation. A 'child' class is a class that has references
to other classes - it's 'parents' -, and then attributes that are not
found in the instance or child class are looked up in the parents
(according to mro rules in case of multiple inheritance). And that's all
there is.
It's lack of a option to select which methods are to be reused.

Methods not redefined in the 'child' class or it's instance are
'reusable'. Now they are only effectively 'reused' if and when called by
client code. So the 'option to select which methods are to be reused' is
mostly up to both the 'child' class and code using it.
this is something should be improved for general OOP i think.
So to answer " What is your problem with having the other extra methods
too ?",
in real life, a class is not defined so well that any method is needed
by sub-class.

Then perhaps is it time to refactor. A class should be a highly cohesive
unit. If you find yourself needing only a specific subset of a class, it
may be time to extract this subset in it's own class. Given Python's
support for both multiple inheritance and composition/delegation, it's
usually a trivial task (unless you already mixed up too many orthogonal
concerns in your base class...).

--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'o****@xiludom.gro'.split('@')])"
ivestgating the web, i found something similiar with my approch:
http://en.wikipedia.org/wiki/Duck_typing
"Duck-typing avoids tests using type() or isinstance(). Instead, it
typically employs hasattr() tests"

Oct 18 '06 #18

Bruno Desthuilliers wrote:
neoedmund wrote:
(snip)
So I can reuse a method freely only if it's worth reusing.
For the word "inheritance", in some aspect, meanings reuse the super
class, with the condition: must reuse everything from super class.

Not really. In fact, inheritance *is* a special case of
composition/delegation. A 'child' class is a class that has references
to other classes - it's 'parents' -, and then attributes that are not
found in the instance or child class are looked up in the parents
(according to mro rules in case of multiple inheritance). And that's all
there is.
It's lack of a option to select which methods are to be reused.

Methods not redefined in the 'child' class or it's instance are
'reusable'. Now they are only effectively 'reused' if and when called by
client code. So the 'option to select which methods are to be reused' is
mostly up to both the 'child' class and code using it.
this is something should be improved for general OOP i think.
So to answer " What is your problem with having the other extra methods
too ?",
in real life, a class is not defined so well that any method is needed
by sub-class.

Then perhaps is it time to refactor. A class should be a highly cohesive
unit. If you find yourself needing only a specific subset of a class, it
may be time to extract this subset in it's own class. Given Python's
support for both multiple inheritance and composition/delegation, it's
usually a trivial task (unless you already mixed up too many orthogonal
concerns in your base class...).

--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'o****@xiludom.gro'.split('@')])"
I donnot agree with your "it's time to refactory" very much, man has
probly never has time to do such things. suppose a system is working
soundly, you maybe has no time or motivation to do refactory instead of
having a vocation to a island. it's easy to say, at lease myself has
not the experience to do such things, :-)

Oct 18 '06 #19
neoedmund wrote:
ivestgating the web, i found something similiar with my approch:
http://en.wikipedia.org/wiki/Duck_typing
"Duck-typing avoids tests using type() or isinstance(). Instead, it
typically employs hasattr() tests"
that's not entirely correct, though: in Python, duck-typing typically
uses "Easier to Ask Forgiveness than Permission" (EAFP), aka "Just Do
It", rather than "Look Before You Leap" (LBYL).

</F>

Oct 18 '06 #20
"neoedmund" <ne*******@gmail.comwrites:
Bruno Desthuilliers wrote:
neoedmund wrote:
in real life, a class is not defined so well that any method is
needed by sub-class.
Then perhaps is it time to refactor. A class should be a highly
cohesive unit. If you find yourself needing only a specific subset
of a class, it may be time to extract this subset in it's own
class.

I donnot agree with your "it's time to refactory" very much, man has
probly never has time to do such things.
I respectfully suggest that the *reason* you find yourself with little
time to refactor is probably related to the fact that you *need* to
refactor. If your code is crufty and poorly-designed, it is costing
you every time you need to maintain it.

Would it help if we called it "preventative maintenance"?

--
\ "I bought a dog the other day. I named him Stay. It's fun to |
`\ call him. 'Come here, Stay! Come here, Stay!' He went insane. |
_o__) Now he just ignores me and keeps typing." -- Steven Wright |
Ben Finney

Oct 18 '06 #21
On 2006-10-18, neoedmund <ne*******@gmail.comwrote:
ivestgating the web, i found something similiar with my approch:
http://en.wikipedia.org/wiki/Duck_typing
"Duck-typing avoids tests using type() or isinstance(). Instead, it
typically employs hasattr() tests"
It's pity it didn't get called quack typing. One ckecks if
some unknown noun can quack, not if a duck can do something
unknown.

--
Neil Cerutti
Oct 18 '06 #22
Neil Cerutti wrote:
On 2006-10-18, neoedmund <ne*******@gmail.comwrote:
>ivestgating the web, i found something similiar with my approch:
http://en.wikipedia.org/wiki/Duck_typing
"Duck-typing avoids tests using type() or isinstance(). Instead, it
typically employs hasattr() tests"

It's pity it didn't get called quack typing.
That's because the quacks recommend static typing.

Peter

Oct 18 '06 #23
Neil Cerutti wrote:
On 2006-10-18, neoedmund <ne*******@gmail.comwrote:
>ivestgating the web, i found something similiar with my approch:
http://en.wikipedia.org/wiki/Duck_typing
"Duck-typing avoids tests using type() or isinstance(). Instead, it
typically employs hasattr() tests"

It's pity it didn't get called quack typing.
That's because the quacks prescribe static typing.

Peter

Oct 18 '06 #24

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

44
by: Carl | last post by:
"Nine Language Performance Round-up: Benchmarking Math & File I/O" http://www.osnews.com/story.php?news_id=5602 I think this is an unfair comparison! I wouldn't dream of developing a numerical...
114
by: Maurice LING | last post by:
This may be a dumb thing to ask, but besides the penalty for dynamic typing, is there any other real reasons that Python is slower than Java? maurice
68
by: Lad | last post by:
Is anyone capable of providing Python advantages over PHP if there are any? Cheers, L.
50
by: diffuser78 | last post by:
I have just started to learn python. Some said that its slow. Can somebody pin point the issue. Thans
112
by: mystilleef | last post by:
Hello, What is the Pythonic way of implementing getters and setters. I've heard people say the use of accessors is not Pythonic. But why? And what is the alternative? I refrain from using them...
158
by: Giovanni Bajo | last post by:
Hello, I just read this mail by Brett Cannon: http://mail.python.org/pipermail/python-dev/2006-October/069139.html where the "PSF infrastracture committee", after weeks of evaluation, recommends...
4
by: Martitza | last post by:
Hi. I work for a small company (actually in process of forming) interested in embedding or extending python as part of our commercial non-open-source product. We have legal counsel, but are...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.