On Sep 27, 6:15 am, wxjmfa...@gmail.com wrote:
> The interesting point or my question.
> Why a Python beginner arrives here and should ask about this?
Would you prefer that they'd instead make some kind of false
assumption and then post endless screeds condemning it?
--
http://mail.python.org/mai
Le mardi 25 septembre 2012 16:44:05 UTC+2, Jayden a écrit :
> In learning Python, I found there are two types of classes? Which one are
> widely used in new Python code? Is the new-style much better than old-style?
> Thanks!!
Use Python 3 and classes.
---
The interesting point or my ques
ween the two.
On the third hand, all it takes to create a new-style class is to have
it inherit from object. It's no big deal to write
>>> class Foo(object):
instead of just
>>> class Foo:
so you might as well use new-style classes :-)
--
http://mail.python.org/mailman/listinfo/python-list
On Tuesday, 25 September 2012 20:14:05 UTC+5:30, Jayden wrote:
> In learning Python, I found there are two types of classes? Which one are
> widely used in new Python code? Is the new-style much better than old-style?
> Thanks!!
Next time just Google your questions.
:-)
Good luck with Python
--
On 25/09/2012 17:20, Steven D'Aprano wrote:
On Tue, 25 Sep 2012 07:44:04 -0700, Jayden wrote:
In learning Python, I found there are two types of classes? Which one
are widely used in new Python code?
New-style classes.
Is the new-style much better than old-style?
Yes.
Always use new-styl
On Tue, 25 Sep 2012 07:44:04 -0700, Jayden wrote:
> In learning Python, I found there are two types of classes? Which one
> are widely used in new Python code?
New-style classes.
> Is the new-style much better than old-style?
Yes.
Always use new-style classes, unless you have some specific re
27;t
supported, and the syntax that would create an old-style class in
Python 2 will implicitly create a new-style class. (Explicitly
subclassing object still works in Py3, so you can happily use that
syntax for both.)
ChrisA
--
http://mail.python.org/mailman/listinfo/python-list
On 9/25/2012 8:44 AM, Jayden wrote:
In learning Python, I found there are two types of classes? Which one are
widely used in new Python code? Is the new-style much better than old-style?
Thanks!!
Perhaps this is useful:
http://docs.python.org/reference/datamodel.html
It's 3.3 I think.
--
Ta
In learning Python, I found there are two types of classes? Which one are
widely used in new Python code? Is the new-style much better than old-style?
Thanks!!
--
http://mail.python.org/mailman/listinfo/python-list
Hi, I'm trying to execute the following code:
d = {}
exec('import cPickle') in d
desc = """
class A(object):
pass
"""
exec(desc) in d
exec('a = A()') in d
exec('cPickle.dump(a, open("tmp.txt","wb"))')in d
for some reason it fails with the following traceback:
Traceback (most recent call la
On Sep 16, 8:05 pm, Hrvoje Niksic <[EMAIL PROTECTED]> wrote:
> "Gabriel Genellina" <[EMAIL PROTECTED]> writes:
> > In Python you would write isinstance(x, object).
>
> It will return True for all Python objects (except perhaps those that
> fiddle with metaclasses), not only for instances of new-sty
On 30 dic, 06:24, Riccardo Murri <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] writes:
>
> >> (Pydb) p graph == self.base[27]
> >> True
> >> (Pydb) p graph in self.base
> >> True
> >> (Pydb) self.base.index(graph)
> >> *** ValueError: list.index(x): x not in list
> > Looking at the
>
>> (Pydb) self.base.index(graph)
>> *** ValueError: list.index(x): x not in list
>>
>> All graphs are instances of a `Graph` new-style class that implements
>> comparison operators `__eq__` and `__ne__`, but no other rich-compare
>> stuff.
>>
>> I
gt; True
>
> (Pydb) p graph in self.base
> True
>
> However, I cannot directly get the index of the canonical graph (the
> number "27" above was found by manual inspection)::
>
> (Pydb) self.base.index(graph)
> *** ValueError: list.index(x): x not in list
&g
ue
(Pydb) p graph in self.base
True
However, I cannot directly get the index of the canonical graph (the
number "27" above was found by manual inspection)::
(Pydb) self.base.index(graph)
*** ValueError: list.index(x): x not in list
All graphs are instances of a `Graph
Steven
Regrettably I have to reply to your post because it misses the point of
my initial post completely. I suggested that Eric Raymond's advice
provided cover for people who were rude, hostile or arrogant. There are
two obvious responses: his advice does not provide such cover or it
does
On Sat, 08 Dec 2007 23:14:44 +, Bruce Coram wrote:
>> http://www.catb.org/~esr/faqs/smart-questions.html
>>
> Eric Raymond's advice on how to ask questions the smart way would seem
> to provide an excuse for people with ego control problems to indulge
> themselves at the expense of others.
Aahz wrote:
> In article <[EMAIL PROTECTED]>,
> Nigel Rantor <[EMAIL PROTECTED]> wrote:
>
>> I think what Boris was being exceedingly unhelpful in saying was "why
>> should it work when you're calling methods that do not exist"
>>
>
> http://www.catb.org/~esr/faqs/smart-questions.html
>
En Fri, 02 Nov 2007 08:58:32 -0300, gert <[EMAIL PROTECTED]> escribió:
> Could not one of you just say "@staticmethod" for once damnit :)
Do we have to read your mind now? You miss-typed the method names the
first time. You could equally have forgotten to type the 'self' parameter.
Don't you
In article <[EMAIL PROTECTED]>,
Nigel Rantor <[EMAIL PROTECTED]> wrote:
>
>I think what Boris was being exceedingly unhelpful in saying was "why
>should it work when you're calling methods that do not exist"
http://www.catb.org/~esr/faqs/smart-questions.html
--
Aahz ([EMAIL PROTECTED])
On Nov 2, 4:04 pm, Boris Borcic <[EMAIL PROTECTED]> wrote:
> gert wrote:
> > Could not one of you just say "@staticmethod" for once damnit :)
>
> I did, did I not ?
i am sorry, yes you did :)
--
http://mail.python.org/mailman/listinfo/python-list
gert wrote:
> Could not one of you just say "@staticmethod" for once damnit :)
>
why were you asking if you knew the answer?
yeesh
--
http://mail.python.org/mailman/listinfo/python-list
gert wrote:
> Could not one of you just say "@staticmethod" for once damnit :)
>
I did, did I not ?
--
http://mail.python.org/mailman/listinfo/python-list
Wildemar Wildenburger wrote:
> Bjoern Schliessmann wrote:
>> No, since everyone's crystal balls are in repair.
>
> I don't even have crystal balls!
Not many are rich *and* impotent. :)
Regards,
Björn
--
BOFH excuse #14:
sounds like a Windows problem, try calling Microsoft support
--
http
On Nov 2, 2:10 pm, Wildemar Wildenburger
<[EMAIL PROTECTED]> wrote:
> Bjoern Schliessmann wrote:
> > gert wrote:
> >> Could not one of you just say "@staticmethod" for once damnit :)
>
> > No, since everyone's crystal balls are in repair.
>
> I don't even have crystal balls!
>
> /W
lol
--
http:/
Bjoern Schliessmann wrote:
> gert wrote:
>> Could not one of you just say "@staticmethod" for once damnit :)
>
> No, since everyone's crystal balls are in repair.
>
I don't even have crystal balls!
/W
--
http://mail.python.org/mailman/listinfo/python-list
gert wrote:
> oops the code is like this but doesn't work
For sake of the god of your choice, please always provide runnable
code as well as hints to
- what you think it should do
- what you want it to do
- what exact error message(s) you get
NOT just "it doesn't work".
Regards,
Björn
--
gert wrote:
> Could not one of you just say "@staticmethod" for once damnit :)
No, since everyone's crystal balls are in repair.
Regards,
Björn
--
BOFH excuse #256:
You need to install an RTFM interface.
--
http://mail.python.org/mailman/listinfo/python-list
Could not one of you just say "@staticmethod" for once damnit :)
--
http://mail.python.org/mailman/listinfo/python-list
_name__ == '__main__':
>>> gert = Test()
>>> print gert.m1('1')
>>> print Test.m2('2')
>>> Why doesn't this new style class work in python 2.5.1 ?
>> why should it ?
>
> I don't know I thought it was supported fr
gert wrote:
[...]
>>>> Why doesn't this new style class work in python 2.5.1 ?
>>> why should it ?
>> I don't know I thought it was supported from 2.2?
>
> oops the code is like this but doesn't work
>
> class Test(object):
>
&
gert wrote:
> oops the code is like this but doesn't work
>
> class Test(object):
>
> def m1(self,v):
> return v
>
> def m2(v):
> return v
>
> if __name__ == '__main__':
> gert = Test()
> print gert.m1('1')
> print Test.m2('2')
>
Well, what do you think:
>>>>> "gert" == gert <[EMAIL PROTECTED]> writes:
gert> Why doesn't this new style class work in python 2.5.1 ?
Whether you declare your class as a new style class or an old style
class, your code is completely and utterly broken. Calling non-existing
metho
_name__ == '__main__':
>>> gert = Test()
>>> print gert.m1('1')
>>> print Test.m2('2')
>>> Why doesn't this new style class work in python 2.5.1 ?
>> why should it ?
>
> I don't know I thought it was supported fr
_name__ == '__main__':
>>> gert = Test()
>>> print gert.m1('1')
>>> print Test.m2('2')
>>> Why doesn't this new style class work in python 2.5.1 ?
>> why should it ?
>
> I don't know I thought it was supported
> > def escape(v):
> > > return v
>
> > > if __name__ == '__main__':
> > > gert = Test()
> > > print gert.m1('1')
> > > print Test.m2('2')
>
> > > Why doesn't this new style c
:
> > gert = Test()
> > print gert.m1('1')
> > print Test.m2('2')
>
> > Why doesn't this new style class work in python 2.5.1 ?
>
> why should it ?
I don't know I thought it was supported from 2.2?
--
http://mail.python.org/mailman/listinfo/python-list
gert wrote:
> class Test(object):
>
> def execute(self,v):
> return v
>
> def escape(v):
> return v
>
> if __name__ == '__main__':
> gert = Test()
> print gert.m1('1')
> print Test.m2('2')
&g
class Test(object):
def execute(self,v):
return v
def escape(v):
return v
if __name__ == '__main__':
gert = Test()
print gert.m1('1')
print Test.m2('2')
Why doesn't this new style class work in python 2.5.1 ?
--
http
> import zipfile
> class walkZip(zipfile):
> pass
>
> if __name__ == "__main__":
> print "Hello World"
`zipfile' is the name of the module, not a class. What you probably
want is this:
[code]
import zipfile
class WalkZip(zipfile.ZipFile):
pass
if __name__ == "__main__":
print
Larry Bates wrote:
> import zipfile
> class walkZip(zipfile):
> pass
>
>
> if __name__ == "__main__":
> print "Hello World"
>
> Traceback (most recent call last):
> File "", line 192, in run_nodebug
> File "", line 2, in
> TypeError: Error when calling the metaclass bases
> modu
On Thursday 06 September 2007 16:15, Larry Bates wrote:
> I'm trying to learn about subclassing new style classes and the first
> project I went to do needs to subclass zipfile to add some methods.
>
>
> Why does this:
>
> import zipfile
> class walkZip(zipfile):
> pass
>
>
> if __name__ == "_
I'm trying to learn about subclassing new style classes and the first project I
went to do needs to subclass zipfile to add some methods.
Why does this:
import zipfile
class walkZip(zipfile):
pass
if __name__ == "__main__":
print "Hello World"
Traceback (most recent call last):
43 matches
Mail list logo