Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #27634 > unrolled thread

Objects in Python

Started byshaun <shaun.wiseman91@gmail.com>
First post2012-08-22 07:13 -0700
Last post2012-08-22 11:29 -0600
Articles 20 on this page of 106 — 26 participants

Back to article view | Back to comp.lang.python


Contents

  Objects in Python shaun <shaun.wiseman91@gmail.com> - 2012-08-22 07:13 -0700
    Re: Objects in Python Joel Goldstick <joel.goldstick@gmail.com> - 2012-08-22 10:31 -0400
    Re: Objects in Python Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2012-08-22 17:31 +0300
    Re: Objects in Python Peter Otten <__peter__@web.de> - 2012-08-22 16:36 +0200
    Re: Objects in Python lipska the kat <lipskathekat@yahoo.co.uk> - 2012-08-22 15:59 +0100
      Re: Objects in Python MRAB <python@mrabarnett.plus.com> - 2012-08-22 16:58 +0100
        Re: Objects in Python lipska the kat <lipskathekat@yahoo.co.uk> - 2012-08-22 17:10 +0100
          Re: Objects in Python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-08-22 17:30 +0100
            Re: Objects in Python lipska the kat <lipskathekat@yahoo.co.uk> - 2012-08-22 18:06 +0100
              Re: Objects in Python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-08-22 19:07 +0100
                Re: Objects in Python lipska the kat <lipskathekat@yahoo.co.uk> - 2012-08-22 20:13 +0100
      Re: Objects in Python Terry Reedy <tjreedy@udel.edu> - 2012-08-22 13:01 -0400
        Re: Objects in Python lipska the kat <lipskathekat@yahoo.co.uk> - 2012-08-22 18:46 +0100
          Re: Objects in Python Ian Kelly <ian.g.kelly@gmail.com> - 2012-08-22 12:15 -0600
            Re: Objects in Python lipska the kat <lipskathekat@yahoo.co.uk> - 2012-08-22 20:03 +0100
              Re: Objects in Python Chris Angelico <rosuav@gmail.com> - 2012-08-23 12:02 +1000
                Re: Objects in Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-23 04:11 +0000
                  Re: Objects in Python Chris Angelico <rosuav@gmail.com> - 2012-08-23 15:26 +1000
                  Re: Objects in Python Jan Kuiken <jan.kuiken@quicknet.nl> - 2012-08-23 20:02 +0200
                    Re: Objects in Python Ian Kelly <ian.g.kelly@gmail.com> - 2012-08-23 12:17 -0600
                      Re: Objects in Python Jan Kuiken <jan.kuiken@quicknet.nl> - 2012-08-23 22:43 +0200
                    Re: Objects in Python 88888 Dihedral <dihedral88888@googlemail.com> - 2012-08-25 23:14 -0700
          Re: Objects in Python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-08-22 19:23 +0100
          Re: Re: Objects in Python Evan Driscoll <driscoll@cs.wisc.edu> - 2012-08-22 14:03 -0500
            Re: Objects in Python lipska the kat <lipskathekat@yahoo.co.uk> - 2012-08-22 20:45 +0100
              Re: Objects in Python MRAB <python@mrabarnett.plus.com> - 2012-08-22 21:31 +0100
              Re: Objects in Python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-08-22 21:46 +0100
                Methods versus functions [was Re: Objects in Python] Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-23 04:07 +0000
              Re: Re: Objects in Python Evan Driscoll <driscoll@cs.wisc.edu> - 2012-08-22 16:31 -0500
                Re: Objects in Python lipska the kat <lipskathekat@yahoo.co.uk> - 2012-08-23 10:19 +0100
                  Re: Re: Objects in Python Evan Driscoll <driscoll@cs.wisc.edu> - 2012-08-23 11:44 -0500
                    Re: Objects in Python lipska the kat <lipskathekat@yahoo.co.uk> - 2012-08-23 18:56 +0100
          Re: Objects in Python Ben Finney <ben+python@benfinney.id.au> - 2012-08-23 09:58 +1000
            Re: Objects in Python Ian Kelly <ian.g.kelly@gmail.com> - 2012-08-22 18:10 -0600
            Re: Re: Objects in Python Evan Driscoll <driscoll@cs.wisc.edu> - 2012-08-22 23:49 -0500
              Re: Objects in Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-23 06:55 +0000
                Re: Objects in Python Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2012-08-23 11:59 +0300
                  Re: Objects in Python MRAB <python@mrabarnett.plus.com> - 2012-08-23 12:28 +0100
                  Re: Objects in Python Jerry Hill <malaclypse2@gmail.com> - 2012-08-23 10:43 -0400
                  Re: Objects in Python Evan Driscoll <driscoll@cs.wisc.edu> - 2012-08-23 12:17 -0500
                    Re: Objects in Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-23 17:56 +0000
                      Variables vs names [was: Objects in Python] Evan Driscoll <driscoll@cs.wisc.edu> - 2012-08-23 14:22 -0500
                        Re: Variables vs names Ben Finney <ben+python@benfinney.id.au> - 2012-08-24 10:02 +1000
                        Re: Variables vs names [was: Objects in Python] Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-25 02:05 +0000
                          Re: Variables vs names Ben Finney <ben+python@benfinney.id.au> - 2012-08-25 15:24 +1000
                      Re: Objects in Python Chris Angelico <rosuav@gmail.com> - 2012-08-24 08:00 +1000
                        Re: Objects in Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-25 03:04 +0000
                          Re: Objects in Python Chris Angelico <rosuav@gmail.com> - 2012-08-25 16:34 +1000
                          Re: Objects in Python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-08-25 09:55 +0100
                          Re: Objects in Python Chris Angelico <rosuav@gmail.com> - 2012-08-25 20:23 +1000
                          Re: Objects in Python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-08-25 12:01 +0100
                          Re: Objects in Python Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-08-25 15:56 -0400
                          Re: Objects in Python Chris Angelico <rosuav@gmail.com> - 2012-08-26 09:27 +1000
                          Re: Objects in Python Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-08-25 20:43 -0400
                          Re: Re: Objects in Python Evan Driscoll <driscoll@cs.wisc.edu> - 2012-08-26 00:25 -0500
                      Re: Variables vs names [was: Objects in Python] Chris Angelico <rosuav@gmail.com> - 2012-08-24 09:34 +1000
                      Re: Objects in Python Ben Finney <ben+python@benfinney.id.au> - 2012-08-24 09:49 +1000
                      Re: Variables vs names [was: Objects in Python] Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-08-23 19:52 -0400
                      Re: Objects in Python Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-08-23 19:54 -0400
                      Re: Objects in Python Chris Angelico <rosuav@gmail.com> - 2012-08-24 10:01 +1000
                  Re: Objects in Python Terry Reedy <tjreedy@udel.edu> - 2012-08-23 13:17 -0400
              Re: Objects in Python Ben Finney <ben+python@benfinney.id.au> - 2012-08-24 00:16 +1000
              Re: Objects in Python Roy Smith <roy@panix.com> - 2012-08-23 20:36 -0400
                Re: Objects in Python Chris Angelico <rosuav@gmail.com> - 2012-08-24 11:34 +1000
                  Re: Objects in Python alex23 <wuwei23@gmail.com> - 2012-08-23 20:17 -0700
                    Re: Re: Objects in Python Evan Driscoll <driscoll@cs.wisc.edu> - 2012-08-24 04:14 -0500
                      Re: Objects in Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-24 10:00 +0000
                        Re: Objects in Python Grant Edwards <invalid@invalid.invalid> - 2012-08-24 13:27 +0000
                          Re: Objects in Python Chris Angelico <rosuav@gmail.com> - 2012-08-25 05:18 +1000
                        Re: Re: Objects in Python Evan Driscoll <driscoll@cs.wisc.edu> - 2012-08-26 00:45 -0500
                          Re: Objects in Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-26 13:43 +0000
                            Re: Objects in Python Chris Angelico <rosuav@gmail.com> - 2012-08-26 23:58 +1000
                              Re: Objects in Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-26 14:18 +0000
                                Re: Objects in Python Chris Angelico <rosuav@gmail.com> - 2012-08-27 00:54 +1000
                                  Re: Objects in Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-26 22:47 +0000
                            Re: Objects in Python Roy Smith <roy@panix.com> - 2012-08-26 10:02 -0400
                              Re: Objects in Python Chris Angelico <rosuav@gmail.com> - 2012-08-27 00:14 +1000
                            Re: Objects in Python Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-08-26 16:12 -0400
                              Re: Objects in Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-26 23:29 +0000
                        Re: Re: Objects in Python Chris Angelico <rosuav@gmail.com> - 2012-08-26 16:22 +1000
                          Re: Objects in Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-26 12:02 +0000
                            Re: Objects in Python Chris Angelico <rosuav@gmail.com> - 2012-08-26 23:34 +1000
                            Re: Objects in Python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-08-26 15:02 +0100
                            Re: Objects in Python Chris Angelico <rosuav@gmail.com> - 2012-08-27 00:05 +1000
                          Re: Objects in Python Roy Smith <roy@panix.com> - 2012-08-26 09:41 -0400
                Identity function id() [was Re: Objects in Python] Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-24 10:06 +0000
            Re: Re: Objects in Python Chris Angelico <rosuav@gmail.com> - 2012-08-23 15:33 +1000
            Re: Objects in Python Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-08-23 14:30 -0400
              Re: Objects in Python Alexander Blinne <news@blinne.net> - 2012-08-24 15:23 +0200
            Re: Objects in Python Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2012-08-24 09:38 +0200
            Re: Objects in Python Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2012-08-24 10:03 +0200
          Re: Objects in Python Walter Hurry <walterhurry@lavabit.com> - 2012-08-23 01:19 +0000
            Re: Objects in Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-23 04:14 +0000
              Re: Objects in Python lipska the kat <lipskathekat@yahoo.co.uk> - 2012-08-23 09:10 +0100
                Re: Objects in Python Ben Finney <ben+python@benfinney.id.au> - 2012-08-23 23:59 +1000
                  Re: Objects in Python lipska the kat <lipskathekat@yahoo.co.uk> - 2012-08-23 15:20 +0100
                    Re: Objects in Python Ben Finney <ben+python@benfinney.id.au> - 2012-08-24 00:24 +1000
            Re: Objects in Python lipska the kat <lipskathekat@yahoo.co.uk> - 2012-08-23 09:03 +0100
          Re: Objects in Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-23 04:34 +0000
            Re: Objects in Python rusi <rustompmody@gmail.com> - 2012-08-23 10:04 -0700
    Re: Objects in Python John Gordon <gordon@panix.com> - 2012-08-22 15:03 +0000
    Re: Objects in Python shaun <shaun.wiseman91@gmail.com> - 2012-08-22 08:25 -0700
      Re: Objects in Python Chris Angelico <rosuav@gmail.com> - 2012-08-23 01:47 +1000
      Re: Objects in Python Dave Angel <d@davea.name> - 2012-08-22 11:51 -0400
      Re: Objects in Python Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-08-22 17:13 +0100
      Re: Objects in Python Ian Kelly <ian.g.kelly@gmail.com> - 2012-08-22 11:29 -0600

Page 1 of 6  [1] 2 3 4 5 6  Next page →


#27634 — Objects in Python

Fromshaun <shaun.wiseman91@gmail.com>
Date2012-08-22 07:13 -0700
SubjectObjects in Python
Message-ID<18409992-1e28-4721-8e64-60c69668da4e@googlegroups.com>
I'm having an issue its my first time using python and i set up a class one of the methods is supposed to return a string but instead returns:

<bound method Param.returnString of <Param.Param instance at 0x00C
389E0>>

Im very new to python and the object orientated feature doesnt seem to be as well put together as Java. Can anyone help with this problem?

[toc] | [next] | [standalone]


#27636

FromJoel Goldstick <joel.goldstick@gmail.com>
Date2012-08-22 10:31 -0400
Message-ID<mailman.3650.1345645874.4697.python-list@python.org>
In reply to#27634
On Wed, Aug 22, 2012 at 10:13 AM, shaun <shaun.wiseman91@gmail.com> wrote:
> I'm having an issue its my first time using python and i set up a class one of the methods is supposed to return a string but instead returns:
>
> <bound method Param.returnString of <Param.Param instance at 0x00C
> 389E0>>
>
> Im very new to python and the object orientated feature doesnt seem to be as well put together as Java. Can anyone help with this problem?
> --
> http://mail.python.org/mailman/listinfo/python-list

It looks like you didn't add parens to the end of your call.  Show us
your code. with the traceback

-- 
Joel Goldstick

[toc] | [prev] | [next] | [standalone]


#27637

FromJussi Piitulainen <jpiitula@ling.helsinki.fi>
Date2012-08-22 17:31 +0300
Message-ID<qotpq6juhev.fsf@ruuvi.it.helsinki.fi>
In reply to#27634
shaun writes:

> I'm having an issue its my first time using python and i set up a
> class one of the methods is supposed to return a string but instead
> returns:
> 
> <bound method Param.returnString of <Param.Param instance at 0x00C
> 389E0>>
> 
> Im very new to python and the object orientated feature doesnt seem
> to be as well put together as Java. Can anyone help with this
> problem?

I bet you are trying to call the method, returnString, without the
parentheses that enclose the parameters (and without any @property
stuff in the class).

>>> Para('dox').myWev
<bound method Para.myWev of <Para.Para object at 0xb7191dac>>
>>> Para('dox').myWev()
'dox'

[toc] | [prev] | [next] | [standalone]


#27639

FromPeter Otten <__peter__@web.de>
Date2012-08-22 16:36 +0200
Message-ID<mailman.3652.1345646167.4697.python-list@python.org>
In reply to#27634
shaun wrote:

> I'm having an issue its my first time using python and i set up a class
> one of the methods is supposed to return a string but instead returns:
> 
> <bound method Param.returnString of <Param.Param instance at 0x00C
> 389E0>>
> 
> Im very new to python and the object orientated feature doesnt seem to be
> as well put together as Java. 

It's definitely too early for you to draw conclusions ;)

> Can anyone help with this problem?

You have successfully created a bound method, now you need to invoke it:

>>> class Param(object):
...     def returnString(self):
...             return "hello"
... 
>>> p = Param()
>>> p.returnString
<bound method Param.returnString of <__main__.Param object at 
0x7facb3a16a50>>
>>> p.returnString()
'hello'

Unlike some other langages Python does not implicitly invoke functions or 
methods. That makes it easy to pass them around like any other object.



[toc] | [prev] | [next] | [standalone]


#27642

Fromlipska the kat <lipskathekat@yahoo.co.uk>
Date2012-08-22 15:59 +0100
Message-ID<w7adnXiWqoJSbqnNnZ2dnUVZ7o2dnZ2d@bt.com>
In reply to#27634
On 22/08/12 15:13, shaun wrote:

[snip]

> Im very new to python and the object orientated feature doesnt seem to be as well put together as Java. Can anyone help with this problem?

 From one Java head to another I suggest you park what you know about 
Java and approach Python with a clear mind.

Python is not Java and Java is not Python, that much has become clear.
Python has actually been around longer than Java and contains many 
features you will be familiar with, serialization and introspection to 
name but two. The whole 'everything is an object' thing is a bit strange 
at first but actually it just means that everything you write is wrapped 
up in a component that exposes various standard methods and attributes, 
you treat functions as Objects and modules as Objects and even your 
classes will automagically sprout new attributes and properties, at 
least that's what I've discovered so far.

There is no real enforced concept of information hiding, no binding of 
type to variable in fact no concept of typing at all as far as I can 
see. No interfaces and no subtype polymorphism (Python has 'Duck Type' 
polymorphism and I haven't really explored all the ramifications of this 
yet). It does however have multiple inheritance.

In trying to get a handle on the language it has helped me to think of 
Python as a friendly interface onto the C programming language, it may 
or may not help you

There are some very experienced pythonistas here and I'm sure you will 
get the help you need. There is a tutor mailing list and a great first 
starter is Dive into Python (google it)

I can't say that Python will replace Java for me, I've been using Java 
since version 1, but it's got a good standard library and good support 
here and on the mailing list ... and it supports Unicode :-)

I like it, give it a chance and you will probably like it too.

lipska

-- 
Lipska the Kat©: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun

[toc] | [prev] | [next] | [standalone]


#27649

FromMRAB <python@mrabarnett.plus.com>
Date2012-08-22 16:58 +0100
Message-ID<mailman.3661.1345651107.4697.python-list@python.org>
In reply to#27642
On 22/08/2012 15:59, lipska the kat wrote:
> On 22/08/12 15:13, shaun wrote:
>
> [snip]
>
>> Im very new to python and the object orientated feature doesnt seem to be as well put together as Java. Can anyone help with this problem?
>
>   From one Java head to another I suggest you park what you know about
> Java and approach Python with a clear mind.
>
> Python is not Java and Java is not Python, that much has become clear.
> Python has actually been around longer than Java and contains many
> features you will be familiar with, serialization and introspection to
> name but two. The whole 'everything is an object' thing is a bit strange
> at first but actually it just means that everything you write is wrapped
> up in a component that exposes various standard methods and attributes,
> you treat functions as Objects and modules as Objects and even your
> classes will automagically sprout new attributes and properties, at
> least that's what I've discovered so far.
>
> There is no real enforced concept of information hiding, no binding of
> type to variable in fact no concept of typing at all as far as I can
> see.

strong typing != static typing

Python is strongly typed, but not statically typed.

 > No interfaces and no subtype polymorphism (Python has 'Duck Type'
> polymorphism and I haven't really explored all the ramifications of this
> yet). It does however have multiple inheritance.
>
[snip]
Python doesn't have interfaces as in Java because it isn't statically
typed.

The idea behind Duck Typing is that the actual type doesn't matter; if
it supports the required method(s) and returns the expected type, then
that's good enough!

http://en.wikipedia.org/wiki/Duck_typing

[toc] | [prev] | [next] | [standalone]


#27650

Fromlipska the kat <lipskathekat@yahoo.co.uk>
Date2012-08-22 17:10 +0100
Message-ID<npWdnYUopoATmajNnZ2dnUVZ7qWdnZ2d@bt.com>
In reply to#27649
On 22/08/12 16:58, MRAB wrote:
> On 22/08/2012 15:59, lipska the kat wrote:
>> On 22/08/12 15:13, shaun wrote:
>>
>> [snip]
>>
>>> Im very new to python and the object orientated feature doesnt seem
>>> to be as well put together as Java. Can anyone help with this problem?
>>
>> From one Java head to another I suggest you park what you know about
>> Java and approach Python with a clear mind.
[snip]
>
> strong typing != static typing
>
> Python is strongly typed, but not statically typed.
>
>  > No interfaces and no subtype polymorphism (Python has 'Duck Type'
>> polymorphism and I haven't really explored all the ramifications of this
>> yet). It does however have multiple inheritance.
>>

[snip]

The residents can be pretty defensive as well :-)

Once again, no criticism intended.

lipska

-- 
Lipska the Kat©: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun

[toc] | [prev] | [next] | [standalone]


#27652

FromMark Lawrence <breamoreboy@yahoo.co.uk>
Date2012-08-22 17:30 +0100
Message-ID<mailman.3663.1345652894.4697.python-list@python.org>
In reply to#27650
On 22/08/2012 17:10, lipska the kat wrote:
> On 22/08/12 16:58, MRAB wrote:
>> On 22/08/2012 15:59, lipska the kat wrote:
>>> On 22/08/12 15:13, shaun wrote:
>>>
>>> [snip]
>>>
>>>> Im very new to python and the object orientated feature doesnt seem
>>>> to be as well put together as Java. Can anyone help with this problem?
>>>
>>> From one Java head to another I suggest you park what you know about
>>> Java and approach Python with a clear mind.
> [snip]
>>
>> strong typing != static typing
>>
>> Python is strongly typed, but not statically typed.
>>
>>  > No interfaces and no subtype polymorphism (Python has 'Duck Type'
>>> polymorphism and I haven't really explored all the ramifications of this
>>> yet). It does however have multiple inheritance.
>>>
>
> [snip]
>
> The residents can be pretty defensive as well :-)
>
> Once again, no criticism intended.
>
> lipska
>

I'm lost.  I see nothing defensive at all.  I see a statement of fact.

-- 
Cheers.

Mark Lawrence.

[toc] | [prev] | [next] | [standalone]


#27658

Fromlipska the kat <lipskathekat@yahoo.co.uk>
Date2012-08-22 18:06 +0100
Message-ID<JPCdncgdapItjKjNnZ2dnUVZ8kGdnZ2d@bt.com>
In reply to#27652
On 22/08/12 17:30, Mark Lawrence wrote:
> On 22/08/2012 17:10, lipska the kat wrote:
>> On 22/08/12 16:58, MRAB wrote:
>>> On 22/08/2012 15:59, lipska the kat wrote:
>>>> On 22/08/12 15:13, shaun wrote:
>>>>
>>>> [snip]
>>>>
>>>>> Im very new to python and the object orientated feature doesnt seem
>>>>> to be as well put together as Java. Can anyone help with this problem?

>>
>> The residents can be pretty defensive as well :-)
>>
>> Once again, no criticism intended.
>>
>> lipska
>>
>
> I'm lost. I see nothing defensive at all. I see a statement of fact.


You seem to be perpetually lost Mark ...


lipska

-- 
Lipska the Kat©: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun

[toc] | [prev] | [next] | [standalone]


#27666

FromMark Lawrence <breamoreboy@yahoo.co.uk>
Date2012-08-22 19:07 +0100
Message-ID<mailman.3674.1345658839.4697.python-list@python.org>
In reply to#27658
On 22/08/2012 18:06, lipska the kat wrote:
> On 22/08/12 17:30, Mark Lawrence wrote:
>> On 22/08/2012 17:10, lipska the kat wrote:
>>> On 22/08/12 16:58, MRAB wrote:
>>>> On 22/08/2012 15:59, lipska the kat wrote:
>>>>> On 22/08/12 15:13, shaun wrote:
>>>>>
>>>>> [snip]
>>>>>
>>>>>> Im very new to python and the object orientated feature doesnt seem
>>>>>> to be as well put together as Java. Can anyone help with this
>>>>>> problem?
>
>>>
>>> The residents can be pretty defensive as well :-)
>>>
>>> Once again, no criticism intended.
>>>
>>> lipska
>>>
>>
>> I'm lost. I see nothing defensive at all. I see a statement of fact.
>
>
> You seem to be perpetually lost Mark ...
>
>
> lipska
>

Maybe but I seem to understand Python rather better than some people :)

Once again, no criticism intended.



-- 
Cheers.

Mark Lawrence.

[toc] | [prev] | [next] | [standalone]


#27674

Fromlipska the kat <lipskathekat@yahoo.co.uk>
Date2012-08-22 20:13 +0100
Message-ID<RZOdnQboVvXnsqjNnZ2dnUVZ8g2dnZ2d@bt.com>
In reply to#27666
On 22/08/12 19:07, Mark Lawrence wrote:
> On 22/08/2012 18:06, lipska the kat wrote:
>> On 22/08/12 17:30, Mark Lawrence wrote:
>>> On 22/08/2012 17:10, lipska the kat wrote:
>>>> On 22/08/12 16:58, MRAB wrote:
>>>>> On 22/08/2012 15:59, lipska the kat wrote:
>>>>>> On 22/08/12 15:13, shaun wrote:
>>>>>>

[snip]

>
> Maybe but I seem to understand Python rather better than some people :)

Well I should certainly hope so after '10 years of using Python'
I freely admit I don't fully understand Python yet but I will and 
hopefully it won't take 10 years ;-)

Never give up, never surrender !!!

> Once again, no criticism intended.

None taken

lipska

-- 
Lipska the Kat©: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun

[toc] | [prev] | [next] | [standalone]


#27657

FromTerry Reedy <tjreedy@udel.edu>
Date2012-08-22 13:01 -0400
Message-ID<mailman.3668.1345654939.4697.python-list@python.org>
In reply to#27642
On 8/22/2012 10:59 AM, lipska the kat wrote:

> There is no real enforced concept of information hiding, no binding of
> type to variable in fact no concept of typing at all as far as I can
> see.

Given that type(valid_name) always returns a type(class), that is a 
slightly strange statement. What is true is that there is no concept of 
static type for names. In Python (and similar languages) type or class 
is a property of objects, not names. This goes alone with names being 
bound to objects rather than linear memory blocks. (Memory block is a 
machine implementation of the abstraction 'information object'.) And 
Python objects are more stfongly typed than in some other languages. 
Names are only dynamically and indirectly typed when they are bound to 
an object. Except for the few keyword names like None, True, etc, names 
can be rebound to another object of another type.

-- 
Terry Jan Reedy

[toc] | [prev] | [next] | [standalone]


#27664

Fromlipska the kat <lipskathekat@yahoo.co.uk>
Date2012-08-22 18:46 +0100
Message-ID<gsSdnaYuqqabhqjNnZ2dnUVZ8jmdnZ2d@bt.com>
In reply to#27657
On 22/08/12 18:01, Terry Reedy wrote:
> On 8/22/2012 10:59 AM, lipska the kat wrote:
>
>> There is no real enforced concept of information hiding, no binding of
>> type to variable in fact no concept of typing at all as far as I can
>> see.
>
> Given that type(valid_name) always returns a type(class), that is a
> slightly strange statement.

[snip]

Well I'm a beginner so I'm allowed to make strange statements.
However I don't think it's that strange and here's why.

If, in a language, I find I am able to say

a = 1

then later, in the same scope I can say

a = "foo"

then later again in the same scope I can say

a = ([1,2,3], "xyz", True)

then, and I may be missing something here, to me, that doesn't say 
'strongly typed' that says 'no typing constraints whatsoever'

If you can show me a 'type' that cannot be assigned to

a

in the same scope then I would be most interested to know, I haven't 
found one yet.

We need to separate out the 'view' from the 'implementation' here.
Most developers I know, if looking at the code and without the possibly 
dubious benefit of knowing that in Python 'everything is an object' 
would not call this 'strong typing'

Once again, this is not a criticism, it's an observation

It is OK to to make (possibly erroneous) observations isn't it?

Thanks for taking the time to reply.

lipska

-- 
Lipska the Kat©: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun

[toc] | [prev] | [next] | [standalone]


#27667

FromIan Kelly <ian.g.kelly@gmail.com>
Date2012-08-22 12:15 -0600
Message-ID<mailman.3675.1345659675.4697.python-list@python.org>
In reply to#27664
On Wed, Aug 22, 2012 at 11:46 AM, lipska the kat
<lipskathekat@yahoo.co.uk> wrote:
> If, in a language, I find I am able to say
>
> a = 1
>
> then later, in the same scope I can say
>
> a = "foo"
>
> then later again in the same scope I can say
>
> a = ([1,2,3], "xyz", True)
>
> then, and I may be missing something here, to me, that doesn't say 'strongly
> typed' that says 'no typing constraints whatsoever'

You're conflating "strong typing" with "static typing".  Strong typing
does not refer to restrictions on what type of data can be stored
where, but to restrictions on how operations on that data can be
intermixed.

The classic example of weak typing is concatenation of strings and
numbers, e.g. ("abc" + 123).  Weakly typed languages like JavaScript
will implicitly coerce the number to a string and perform the
concatenation.  Strongly typed languages like Python will raise a
TypeError instead.

Note that statically typed languages can be weakly typed as well.  For
instance, C is commonly considered to be weakly typed because the
casting rules of that language allow you to treat any piece of data as
being of any type, even though the variables themselves are all
statically typed.

[toc] | [prev] | [next] | [standalone]


#27673

Fromlipska the kat <lipskathekat@yahoo.co.uk>
Date2012-08-22 20:03 +0100
Message-ID<1pidnX71rLNrsajNnZ2dnUVZ8jCdnZ2d@bt.com>
In reply to#27667
On 22/08/12 19:15, Ian Kelly wrote:
> On Wed, Aug 22, 2012 at 11:46 AM, lipska the kat
> <lipskathekat@yahoo.co.uk>  wrote:
>> If, in a language, I find I am able to say
>>
>> a = 1

[snip]

>
> You're conflating "strong typing" with "static typing".  Strong typing
> does not refer to restrictions on what type of data can be stored
> where, but to restrictions on how operations on that data can be
> intermixed.

Yes of course I am, thank you for pointing that out.
I don't know why I have this overwhelming need to see variables 
explicitly defined ... years of 'same old same old' I suppose.

I do seem to remember reading something about Python moving towards 
static typing and there are tools out there to help avoid run time 
disasters ... anyway, this has latched now so thanks for taking the time 
to reply.

lipska

-- 
Lipska the Kat©: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun

[toc] | [prev] | [next] | [standalone]


#27690

FromChris Angelico <rosuav@gmail.com>
Date2012-08-23 12:02 +1000
Message-ID<mailman.3691.1345687339.4697.python-list@python.org>
In reply to#27673
On Thu, Aug 23, 2012 at 5:03 AM, lipska the kat
<lipskathekat@yahoo.co.uk> wrote:
> On 22/08/12 19:15, Ian Kelly wrote:
>>
>> You're conflating "strong typing" with "static typing".  Strong typing
>> does not refer to restrictions on what type of data can be stored
>> where, but to restrictions on how operations on that data can be
>> intermixed.
>
> Yes of course I am, thank you for pointing that out.
> I don't know why I have this overwhelming need to see variables explicitly
> defined ... years of 'same old same old' I suppose.

Python's object model is not fundamentally incompatible with a system
of declared variables. I, too, like declaring my variables explicitly.
There are quite a few advantages to it:

1) Scoping is extremely clear. (Leaving aside anomalous behaviour like
Javascript's "var" declarations applying to a whole function.) You see
a declaration, you know that variable exists there and further inside
only. In a C-style language, that means it disappears at the
corresponding close brace.

2) Related to the above, you can infinitely nest scopes. There's
nothing wrong with having six variables called 'q'; you always use the
innermost one. Yes, this can hurt readability, especially taken to
this sort of stupid extreme, but that's a question for a style guide
and not a language design.

3) Variable-name typos can be caught at parse time. In Python, if you
misspell a variable, you've just made a new local variable.

It has its downsides, too, of course; mainly that it's (in some
people's opinion) syntactic salt. Why should I have to tell the
interpreter/compiler what it can figure out by itself? It's
duplicating information, and that's inefficient. It's like forcing all
your integer constants to be given in both decimal and hex, to catch
errors.

I'm of the opinion that the benefits are worth the effort. Others
disagree. It's hugely a matter of taste, and I'm just glad that there
are enough languages around that we can all have what we want :)

If you like the Python object model but want to add variable
declarations, grab me off list and I'll tell you about my personal
favorite language...

ChrisA

[toc] | [prev] | [next] | [standalone]


#27694

FromSteven D'Aprano <steve+comp.lang.python@pearwood.info>
Date2012-08-23 04:11 +0000
Message-ID<5035ad87$0$1645$c3e8da3$76491128@news.astraweb.com>
In reply to#27690
On Thu, 23 Aug 2012 12:02:16 +1000, Chris Angelico wrote:

> 2) Related to the above, you can infinitely nest scopes. There's nothing
> wrong with having six variables called 'q'; you always use the innermost
> one. Yes, this can hurt readability

Well, there you go. There *is* something wrong with having six variables 
called 'q'.

Namespaces and scopes are work-arounds for the fact that, while there are 
an infinite number of possible names, most of the good ones are already 
taken.

Namespaces and scopes mean that I can use a name "q" even though I've 
already used it for something else, but there is still cost to re-using 
names (even if that cost is sometimes trivial).


-- 
Steven

[toc] | [prev] | [next] | [standalone]


#27698

FromChris Angelico <rosuav@gmail.com>
Date2012-08-23 15:26 +1000
Message-ID<mailman.3694.1345699573.4697.python-list@python.org>
In reply to#27694
On Thu, Aug 23, 2012 at 2:11 PM, Steven D'Aprano
<steve+comp.lang.python@pearwood.info> wrote:
> On Thu, 23 Aug 2012 12:02:16 +1000, Chris Angelico wrote:
>
>> 2) Related to the above, you can infinitely nest scopes. There's nothing
>> wrong with having six variables called 'q'; you always use the innermost
>> one. Yes, this can hurt readability
>
> Well, there you go. There *is* something wrong with having six variables
> called 'q'.

But it's the same thing that's wrong with having one variable called
'q', when that variable would be better called 'invoice' because it's
iterating over your invoices, or 'item' when it's iterating over the
lines of one invoice. Python doesn't stop you from doing that; it's
not the language's job to enforce useful variable names.

ChrisA

[toc] | [prev] | [next] | [standalone]


#27753

FromJan Kuiken <jan.kuiken@quicknet.nl>
Date2012-08-23 20:02 +0200
Message-ID<ae6b2$50367017$546bb230$30002@cache100.multikabel.net>
In reply to#27694
On 8/23/12 06:11 , Steven D'Aprano wrote:

>> 2) Related to the above, you can infinitely nest scopes. There's nothing
>> wrong with having six variables called 'q'; you always use the innermost
>> one. Yes, this can hurt readability
>
> Well, there you go. There *is* something wrong with having six variables
> called 'q'.

Sometimes you don't want only six variables called 'q' but a hundred
of them :-)

   def fac(q):
       if q < 1 :
           return 1
       else:
           return q * fac(q-1)

   print(fac(100))


Jan Kuiken

[toc] | [prev] | [next] | [standalone]


#27755

FromIan Kelly <ian.g.kelly@gmail.com>
Date2012-08-23 12:17 -0600
Message-ID<mailman.3725.1345745889.4697.python-list@python.org>
In reply to#27753
On Thu, Aug 23, 2012 at 12:02 PM, Jan Kuiken <jan.kuiken@quicknet.nl> wrote:
> On 8/23/12 06:11 , Steven D'Aprano wrote:
>
>>> 2) Related to the above, you can infinitely nest scopes. There's nothing
>>> wrong with having six variables called 'q'; you always use the innermost
>>> one. Yes, this can hurt readability
>>
>>
>> Well, there you go. There *is* something wrong with having six variables
>> called 'q'.
>
>
> Sometimes you don't want only six variables called 'q' but a hundred
> of them :-)
>
>   def fac(q):
>       if q < 1 :
>           return 1
>       else:
>           return q * fac(q-1)
>
>   print(fac(100))

That's only one variable called 'q', instantiated 100 times simultaneously.

[toc] | [prev] | [next] | [standalone]


Page 1 of 6  [1] 2 3 4 5 6  Next page →

Back to top | Article view | comp.lang.python


csiph-web