interfacing with x86_64 assembler

2012-08-31 Thread lipska the kat

Worryingly

I was hacking away at some x86_64 assembler today
when I found myself obsessively indenting my code
by EXACTLY 4 spaces or (multiples thereof)

Who'd have thought it.

lipska

--
Lipska the Kat©: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
--
http://mail.python.org/mailman/listinfo/python-list


Re: Is Python a commercial proposition ?

2012-08-24 Thread lipska the kat

On 23/08/12 22:46, Chris Withers wrote:

On 30/07/2012 03:31, Rodrick Brown wrote:

Hence the reason why no one will seriously look at Python for none
glue work or simple web apps. When it comes to designing complex
applications that need to exploit large multicore systems Python just
isn't an option.

Its still not possible to be a pure Python developer and find gainful
employment today.


Oh come on, are you *actually* serious?

Pretty much everything you've said is nothing but inept bullshit.
Please stop.


OK, well excuse me for butting in but it's obvious from your website 
that you have some experience with Python in the 'real world' I'd be 
most interested to hear if you have experience of or have heard of 
Python being used in any of the following circumstances.


Critical Systems:

wikipedia does a better job than I on the definition of a critical 
system although I'm not suggesting that everything in this article 
refers to a potential software system but it's a good illustration.


http://en.wikipedia.org/wiki/Life-critical_system

Real time systems:

An example of a real time system in this context is
an odds arbitrage back end publishing to the WWW via a
collection of web services, of course this is just one possible 
interface, it could publish to another computer system or another HCI
This requirement of course implies a complete decoupling of view and 
implementation. For more on odds arbitrage


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

It's 'real time' because publishing incorrect odds could cost someone a 
great deal of money, the odds need to be available for manipulation by 
the arbitrage engine as soon as they appear on the relevant bookies 
website (in fact I've had them appearing _before_ this as I managed to 
process them before the bookies web site did :-).


http://www.python.org/about/success/#real-time has a few examples
but I'd be interested to hear 'from the horses mouth'

Again, wikipedia is your friend
http://en.wikipedia.org/wiki/Real-time_computing

What is the largest Python project you have experience of, you can use 
any metric you want, a simple KLOC, function point or cost analysis will 
be fine.


This is a genuine enquiry and not designed to 'diss' Python in any way.


Many thanks

lipska
--
Lipska the Kat©: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
--
http://mail.python.org/mailman/listinfo/python-list


Re: Objects in Python

2012-08-23 Thread lipska the kat

On 23/08/12 02:19, Walter Hurry wrote:

On Wed, 22 Aug 2012 18:46:43 +0100, lipska the kat wrote:


Well I'm a beginner


Then maybe you should read more and write less.


Really ? I read all the responses to my posts and learn more from them 
in less time than I ever have from reading the 'documentation'


If you don't like it then don't read it.

lipska

--
Lipska the Kat©: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
--
http://mail.python.org/mailman/listinfo/python-list


Re: Objects in Python

2012-08-23 Thread lipska the kat

On 23/08/12 05:14, Steven D'Aprano wrote:

On Thu, 23 Aug 2012 01:19:49 +, Walter Hurry wrote:


On Wed, 22 Aug 2012 18:46:43 +0100, lipska the kat wrote:


Well I'm a beginner


Then maybe you should read more and write less.


I think that's uncalled for. Lipska isn't trolling. He's making
observations as he sees them. The fact that they're sometimes wrong is
not a reason to effectively tell him to STFU.

Better the misconception which is spoken allowed and corrected, then the
one which is kept quiet and festers.


Excellent advice as usual, but I'm more than capable of looking after 
myself thank you.


Nobody has ever succeeded in making me STFU yet :-)

When that day comes I'll retire to the garden

lipska

--
Lipska the Kat©: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
--
http://mail.python.org/mailman/listinfo/python-list


Re: Objects in Python

2012-08-23 Thread lipska the kat

On 22/08/12 22:31, Evan Driscoll wrote:

On 08/22/2012 02:45 PM, lipska the kat wrote:

On 22/08/12 20:03, Evan Driscoll wrote:

Second, this concept isn't *so* unfamiliar to you. If I give you the
following Java code:

void foo(Object o) { ... }


looking at this method declaration I can see that the method takes an
argument of type Object (and just FYI class Object is not abstract and
you can do Object o = new Object()) and does not return a value.
I know that for the lifetime of this JVM, whatever o turns out to be it
will always be an Object. I can't assign a primitive to o as ints chars
floats etc are certainly not Objects. There are certain invariants that
give me a warm and comfortable feeling inside.


I'm not saying it's nothing, but can't assign a primitive isn't much
of an invariant in the broad scheme of things


Well we don't want to turn this into a language comparison thread do we, 
that might upset too many people but I can't remember ever writing a 
method that took an Object as argument, you just can't do that much with 
an Object. I do however often write methods that take an interface as 
argument knowing that in future, any classes I write that implement this 
interface would just work thanks to subtype polymorphism


A method 'declaration' such as this in an interface

Product getProductByBarcode(Barcode b) throws CrappyProductException;

tells me a whole lot about what the 'definition' in an implementing 
class might do, in fact I might well get away with just reading the 
interface and using the method without having to delve into the code.


And I think this is the nub of the problem at the moment. I'm in a 
particular mindset, almost 'locked in' you might say and when I see a 
Python function that doesn't give me what I need straight away I get 
annoyed.


I will get over it.


when you can pass items as
diverse as lists, GUI buttons, files, etc. I would say it's more like if
you see 'int x' then *that* imposes a pretty big invariant, but passing
'Object' imposes almost nothing.


Well you may be able to pass them in but you couldn't really do anything 
meaningful with them as you are restricted to operations on Object, I 
suppose you could pepper your code with tests to check the runtime type 
of a reference but it all gets a bit messy.


[snip]


Thus *all*
Python variables are essentially references.)


That makes sense

Thanks for taking the time to reply. It really is most valuable to me.

lipska

--
Lipska the Kat©: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
--
http://mail.python.org/mailman/listinfo/python-list


Re: Objects in Python

2012-08-23 Thread lipska the kat

On 23/08/12 14:59, Ben Finney wrote:

lipska the katlipskathe...@yahoo.co.uk  writes:


On 23/08/12 05:14, Steven D'Aprano wrote:

I think that's uncalled for.

[…]


Excellent advice as usual, but I'm more than capable of looking after
myself thank you.


As is usual, it's not all about you; Steven is demonstrating that we
require civil behaviour here, for anyone who may be watching but not
saying anything.


You 'require civil behaviour here' do you. Well so far I have been very 
civil.


This is a USENET newsgroup, it's a public forum, not your personal 
domain. Please stop all this 'it's not all about you' meaningless 
nonsense. It's pointless and wastes mine and no doubt others time.


If you want to carry this on please contact me off list.

lipska

--
Lipska the Kat©: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
--
http://mail.python.org/mailman/listinfo/python-list


Re: Objects in Python

2012-08-23 Thread lipska the kat

On 23/08/12 17:44, Evan Driscoll wrote:

On 08/23/2012 04:19 AM, lipska the kat wrote:

Well we don't want to turn this into a language comparison thread do we,
that might upset too many people but I can't remember ever writing a
method that took an Object as argument, you just can't do that much with
an Object.


In the pre-Java-1.5 days, functions that took Objects were *very*
common;


Well the Collections framework does expose methods that take Objects but 
generally you override certain methods in class Object when you want to 
compare Objects, in fact String comparison is a really interesting area 
due to the way Java internalizes Strings at compile time... but that is 
way to off topic for here.


regards

lipska

--
Lipska the Kat©: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
--
http://mail.python.org/mailman/listinfo/python-list


Re: Objects in Python

2012-08-22 Thread lipska the kat

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
--
http://mail.python.org/mailman/listinfo/python-list


Re: Objects in Python

2012-08-22 Thread lipska the kat

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
--
http://mail.python.org/mailman/listinfo/python-list


Re: Objects in Python

2012-08-22 Thread lipska the kat

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
--
http://mail.python.org/mailman/listinfo/python-list


Re: Objects in Python

2012-08-22 Thread lipska the kat

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
--
http://mail.python.org/mailman/listinfo/python-list


Re: Objects in Python

2012-08-22 Thread lipska the kat

On 22/08/12 19:15, Ian Kelly wrote:

On Wed, Aug 22, 2012 at 11:46 AM, lipska the kat
lipskathe...@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
--
http://mail.python.org/mailman/listinfo/python-list


Re: Objects in Python

2012-08-22 Thread lipska the kat

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
--
http://mail.python.org/mailman/listinfo/python-list


Re: Objects in Python

2012-08-22 Thread lipska the kat

On 22/08/12 20:03, Evan Driscoll wrote:

On 08/22/2012 12:46 PM, lipska the kat wrote:

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.



[snip]



Second, this concept isn't *so* unfamiliar to you. If I give you the
following Java code:

   void foo(Object o) { ... }

and ask what type 'o' is, there are kind of two answers. The first is
that 'o' is an 'Object'. But you can't make an Object -- that's an
abstract class. (IIRC. If it's not then just bear with me; you get the
idea. :-)) So from a strictly static type-theory point of view, 'foo' is
unusable because it takes a type which you can never create. But of
course that's not the case, because in actual Java 'o' has some dynamic
type which is a subclass of 'Object'.


Well I think this is where I'm struggling a bit.

looking at this method declaration I can see that the method takes an 
argument of type Object (and just FYI class Object is not abstract and 
you can do Object o = new Object()) and does not return a value.
I know that for the lifetime of this JVM, whatever o turns out to be it 
will always be an Object. I can't assign a primitive to o as ints chars 
floats etc are certainly not Objects. There are certain invariants that 
give me a warm and comfortable feeling inside.


compare this to a function declaration in Python

def foo(self):

... I can learn nothing about this function by looking at the first line

If I see

def foo(self, someVar=1):

I can determine that foo takes an argument that, at some time or other 
is or has been a number of some description but I can't rely on it and I 
have no idea what is returned and that's where I think I'm having trouble.


But I will get over it and I will learn the language and I may look back 
on these exchanges and say ... I was wrong, this is so much better that 
what I was used to, or maybe I won't. I'll let you know


Thank you for your calm and reasoned response.

Disclaimer:
None of my comments above should be construed as criticisms
they are just observations.

lipska

--
Lipska the Kat©: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
--
http://mail.python.org/mailman/listinfo/python-list


Re: How to convert base 10 to base 2?

2012-08-20 Thread lipska the kat

On 20/08/12 08:50, gianpy...@gmail.com wrote:

Hi,
as you can argue from the subject, i'm really,really new to python.
What is the best way to achieve that with python? Because the syntax 
int('30',2) doesn't seem to work


 x = bin(30)[2:]
 x
'0'
 int(x, 2)
30


lipska

--
Lipska the Kat©: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
--
http://mail.python.org/mailman/listinfo/python-list


Re: How do I display unicode value stored in a string variable using ord()

2012-08-19 Thread lipska the kat

On 19/08/12 07:09, Steven D'Aprano wrote:

This is a long post. If you don't feel like reading an essay, skip to the
very bottom and read my last few paragraphs, starting with To recap.


Thank you for this excellent post,
it has certainly cleared up a few things for me

[snip]

incidentally

 But in UTF-16, ...

[snip]

 py  s = chr(0x + 1)
 py  a, b = s
 py  a
 '\ud800'
 py  b
 '\udc00'

in IDLE

Python 3.2.3 (default, May  3 2012, 15:51:42)
[GCC 4.6.3] on linux2
Type copyright, credits or license() for more information.
 No Subprocess 
 s = chr(0x + 1)
 a, b = s
Traceback (most recent call last):
  File pyshell#1, line 1, in module
a, b = s
ValueError: need more than 1 value to unpack

At a terminal prompt

[lipska@ubuntu ~]$ python3.2
Python 3.2.3 (default, Jul 17 2012, 14:23:10)
[GCC 4.6.3] on linux2
Type help, copyright, credits or license for more information.
 s = chr(0x + 1)
 a, b = s
 a
'\ud800'
 b
'\udc00'


The date stamp is different but the Python version is the same

No idea why this is happening, I just thought it was interesting

lipska

--
Lipska the Kat©: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
--
http://mail.python.org/mailman/listinfo/python-list


Re: How do I display unicode value stored in a string variable using ord()

2012-08-19 Thread lipska the kat

On 19/08/12 11:19, Chris Angelico wrote:

On Sun, Aug 19, 2012 at 8:13 PM, lipska the kat
lipskathe...@yahoo.co.uk  wrote:

The date stamp is different but the Python version is the same


Check out what 'sys.maxunicode' is in each of those Pythons. It's
possible that one is a wide build and the other narrow.


Ah ...

I built my local version from source
and no, I didn't read the makefile so I didn't configure for a wide 
build :-( not that I would have known the difference at that time.


[lipska@ubuntu ~]$ python3.2
Python 3.2.3 (default, Jul 17 2012, 14:23:10)
[GCC 4.6.3] on linux2
Type help, copyright, credits or license for more information.
 import sys
 sys.maxunicode
65535


Later, I did an apt-get install idle3 which pulled
down a precompiled IDLE from the Ubuntu repos
This was obviously compiled 'wide'

Python 3.2.3 (default, May  3 2012, 15:51:42)
[GCC 4.6.3] on linux2
Type copyright, credits or license() for more information.
 No Subprocess 
 import sys
 sys.maxunicode
1114111


All very interesting and enlightening

Thanks

lipska

--
Lipska the Kat©: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
--
http://mail.python.org/mailman/listinfo/python-list


Re: Encapsulation, inheritance and polymorphism

2012-08-19 Thread lipska the kat

On 19/08/12 09:55, Mark Lawrence wrote:

On 19/08/2012 06:21, Robert Miles wrote:

On 7/23/2012 11:18 AM, Albert van der Horst wrote:

In article 5006b48a$0$29978$c3e8da3$54964...@news.astraweb.com,
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote:


[snip]


that functions must only have one exit?


[snip[



Surely the first check is your filing system to make sure that you've
paid the utilties bills so you've got gas and or electricity to apply
the heat. Either that or you hire Ray Mears to produce the spark needed
to light the fire :)


I was wondering how long it would be ...

lipska

--
Lipska the Kat©: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
--
http://mail.python.org/mailman/listinfo/python-list


Re: socketserver.BaseRequestHandler and socketserver.StreamRequestServer docs

2012-08-10 Thread lipska the kat

On 09/08/12 20:45, Terry Reedy wrote:

On 8/9/2012 1:39 PM, Dennis Lee Bieber wrote:

On Thu, 09 Aug 2012 16:15:33 +0100, lipska the kat
lipskathe...@yahoo.co.uk declaimed the following in
gmane.comp.python.general:



in the examples in this chapter we see usage examples for
socketserver.BaseRequestHandler


[snip]



I think the doc can be improved a bit and opened an issue to Improve
socketserver doc
http://bugs.python.org/issue15608


Thank you for your reasonable responses
I have sent an email to d...@python.org
politely suggesting a couple of improvements to
the socketserver documentation

lipska

--
Lipska the Kat: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
--
http://mail.python.org/mailman/listinfo/python-list


Re: Looking for a good introduction to object oriented programming with Python

2012-08-09 Thread lipska the kat

On 09/08/12 03:59, Dennis Lee Bieber wrote:

On Wed, 08 Aug 2012 20:31:57 +0100, lipska the kat
lipskathe...@yahoo.co.uk  declaimed the following in
gmane.comp.python.general:



[snip]



If a node is a father or mother, and it takes one of each to
produce a leaf, your tree has just collapsed.


This would come out in the iterative wash and I'm sure it could be 
resolved without resorting to a Person class


People are starting to get annoyed by this thread now (I'm surprised it 
has taken so long) so it's probably best to move on.


lipska

--
Lipska the Kat: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
--
http://mail.python.org/mailman/listinfo/python-list


socketserver.BaseRequestHandler and socketserver.StreamRequestServer docs

2012-08-09 Thread lipska the kat
First of all sincere apologies if this is blindingly obvious and I just 
missed it


In the documentation at

http://docs.python.org/py3k/library/socketserver.html

mention is made more than once of a class
socketserver.StreamRequestHandler

in the examples in this chapter we see usage examples for
socketserver.BaseRequestHandler

I am trying to find documentation for these two classes as I would like 
to use the former and, well I'd just like to learn more aout the latter.
I've looked in the general index and used Google. The problem is that 
however hard I look I just cannot find it !!!


In Eclipse I have the entire standard library mounted on an explorer 
node. When I find socketserver.py I can navigate to the 
BaseRequestHandler and StreamRequestHandler classes
but I can't find the (documented) class [socketserver].RequestHandler 
class in socketserver.py nor can I find any explicit documentation for 
the classes socketserver.StreamRequestHandler

and socketserver.BaseRequestHandler.

I'm probably being INCREDIBLY dense here but what am I missing ?

Incidently if I read the code for these two classes I CAN understand 
what they do but this is not always the case and anyway, how many other 
potentially useful classes are lurking undocumented in the library


This is NOT intended as a criticism but it is frustrating.

many thanks

lipska
--
Lipska the Kat: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
--
http://mail.python.org/mailman/listinfo/python-list


Re: socketserver.BaseRequestHandler and socketserver.StreamRequestServer docs

2012-08-09 Thread lipska the kat

On 09/08/12 18:39, Dennis Lee Bieber wrote:

On Thu, 09 Aug 2012 16:15:33 +0100, lipska the kat
lipskathe...@yahoo.co.uk  declaimed the following in
gmane.comp.python.general:



in the examples in this chapter we see usage examples for
socketserver.BaseRequestHandler


So far as I can tell, all RequestHandler objects are covered in
section 20.19.3 RequestHandler Objects



In Eclipse I have the entire standard library mounted on an explorer
node. When I find socketserver.py I can navigate to the
BaseRequestHandler and StreamRequestHandler classes
but I can't find the (documented) class [socketserver].RequestHandler
class in socketserver.py nor can I find any explicit documentation for
the classes socketserver.StreamRequestHandler
and socketserver.BaseRequestHandler.



There is no RequestHandler class. The section is general to all
RequestHandler OBJECTS (Base, Stream, and Datagram).

Stream and Datagram request handlers are subclasses of Base, in
which the setup/finish methods handle the creation/destruction of
file-like attributes -- allowing one to just do read/write operations
within the core handle() method, instead of having to be concerned with
the type of connection and performing actual socket recv()/send()
operations. They are documented in the second paragraph of the .handle()
method in sectin 20.19.3

In all cases, you are responsible for providing the contents of the
handle() method.






--
Lipska the Kat: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
--
http://mail.python.org/mailman/listinfo/python-list


Re: socketserver.BaseRequestHandler and socketserver.StreamRequestServer docs

2012-08-09 Thread lipska the kat

On 09/08/12 18:39, Dennis Lee Bieber wrote:

On Thu, 09 Aug 2012 16:15:33 +0100, lipska the kat
lipskathe...@yahoo.co.uk  declaimed the following in
gmane.comp.python.general:



in the examples in this chapter we see usage examples for
socketserver.BaseRequestHandler


So far as I can tell, all RequestHandler objects are covered in
section 20.19.3 RequestHandler Objects


Yes, I know, I've read it. Thank you.


There is no RequestHandler class. The section is general to all
RequestHandler OBJECTS (Base, Stream, and Datagram).


Yes I know, I've read socketserver.py. Thank you.
Why do I find myself getting annoyed here ?

This is hard work but I'll try again.

socketserver.RequestHandler is EXPLICITLY documented in section 20.19.3 
RequestHandler Objects yet does not exist in socketserver.py
Does this not strike you as odd. I certainly strikes me as odd. Maybe it 
should be socketserver.BaseRequestHandler that is documented here.


The CLASSES socketserver.StreamRequestHandler and 
socketserver.DatagramRequestHandler are DEFINED in socketserver.py
They are NOT Objects, they are CLASSES yet they are NOT EXPLICITLY 
documented in section 20.19.3 or any other section as far as I can tell.


This is the question I was asking. I am quite capable of extracting the 
slightly obtuse documentation in the section and confirming my 
assumptions by reading the code.


So, I'll try again.

Is there anywhere that documents EXPLICITLY all the publicly visible 
classes in the standard library.


If there is I'd be most grateful if you could point me to it as I can't 
find it


If there isn't how does one go about
contributing to the documentation.

Thank you for taking the time to reply

lipska

--
Lipska the Kat: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
--
http://mail.python.org/mailman/listinfo/python-list


Re: socketserver.BaseRequestHandler and socketserver.StreamRequestServer docs

2012-08-09 Thread lipska the kat

On 09/08/12 19:55, Mark Lawrence wrote:

On 09/08/2012 19:37, lipska the kat wrote:

On 09/08/12 18:39, Dennis Lee Bieber wrote:

On Thu, 09 Aug 2012 16:15:33 +0100, lipska the kat
lipskathe...@yahoo.co.uk declaimed the following in
gmane.comp.python.general:



in the examples in this chapter we see usage examples for
socketserver.BaseRequestHandler


So far as I can tell, all RequestHandler objects are covered in
section 20.19.3 RequestHandler Objects


Yes, I know, I've read it. Thank you.


Dennis was only trying to help so please don't shout, thanks.


I appreciate that he was trying to help but quoting entire sections of 
text that I have already stated that I have read is pointless and wastes 
everybody's time.


I asked a specific question which he failed to answer.
I also thanked him for his time

lipska

--
Lipska the Kat: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
--
http://mail.python.org/mailman/listinfo/python-list


Re: socketserver.BaseRequestHandler and socketserver.StreamRequestServer docs

2012-08-09 Thread lipska the kat

On 09/08/12 20:07, Peter Otten wrote:

lipska the kat wrote:


If there isn't how does one go about
contributing to the documentation.


http://docs.python.org/dev/py3k/bugs.html

A similar link should be right there in the footer of the socketserver
documentation.


It is indeed, thank you.

lipska.

--
Lipska the Kat: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
--
http://mail.python.org/mailman/listinfo/python-list


Re: Looking for a good introduction to object oriented programming with Python

2012-08-08 Thread lipska the kat

On 07/08/12 22:57, Chris Angelico wrote:

On Wed, Aug 8, 2012 at 3:00 AM, lipska the katlipskathe...@yahoo.co.uk  wrote:

I'm still undecided over the whole 'User' thing actually,


[snip]


This makes little sense to my mind. If you can have a class User:,
why can you not have a class Person: ?


User and Person are entirely different concepts, surely you can see that.
A User can be anything that interacts with our system, not necessarily a 
Person.



Now, that said, I can't remember the last time I actually had a class
called Person in anything other than a demo. But that's merely
because of terminology; I've had classes representing human beings,
but named according to what part these people play in the system
(Customer, Employee (haven't done that one, actually, but there's no
reason not to),


Customer is a 'business Class'. Businesses without Customers don't 
exist, at least I don't know of any. A Customer however can be many 
things, Organisations can be customers of other organisations. Is a 
LampPost a Customer of the Electricity company that supplies it with 
power ? possibly, it depends on your business model. A LampPost sure 
isn't a Person though. Limiting the Customer class to representing human 
beings is exactly that, limiting.


[snip]


The Person class details what data you store about a person,
a Person instance stores that data about one particular person. This
works for other things;
a QueueEntry isn't actually standing in queue,


Ah but it is, that's exactly what we are doing when we encapsulate a 
Human concept, where do you think the idea comes from, why is it called 
a queue, because it's analogous to what we do when we go to the cinema, 
go to the bank, do queuing type things. In fact it's a very precise, 
well defined encapsulation, First in, First out. We enforce our ideas of 
what it means to stand in a queue by writing the code in such a way that 
is impossible for anything other than thing at the head of the queue to 
get out first. If we change the concept we change the name, 
PriorityQueue ? Highest priority out first regardless of position. This 
is an extension of the original concept that exists in the real world, 
the casualty department for example, triage sorts the urgent cases from 
the non urgent, you get seen depending on the urgency of your case not 
depending on when you arrived at the hospital.


The point I'm obviously struggling to make is that words convey concepts
The word Person conveys a whole lifetime of experience of People and as 
imperfect human beings many of us are unable to tease out 'bits of being 
a person' that are relevant to the system we are developing. Inevitably 
other seemingly irreversibly entwined bits keep popping up to cloud our 
thinking. This is my experience, not an isolated case but one that has 
popped up again and again.



but it holds the data you store about the thing that is.

Or maybe that doesn't help, in which case just ignore it.


I don't need any help with this but thank you for contributing

lipska

--
Lipska the Kat: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
--
http://mail.python.org/mailman/listinfo/python-list


Re: Pickle file and send via socket

2012-08-08 Thread lipska the kat

On 06/08/12 14:32, S.B wrote:

Hello friends

Does anyone know if it's possible to pickle and un-pickle a file across a 
network socket. i.e:
First host pickles a file object and writes the pickled file object to a client 
socket.
Second host reads the pickled file object from the server socket and un-pickles 
it.

Can anyone provide a simple code example of the client and server sides?

Thanks



Hi

Firstly I am a raw beginner at Python and I don't publish this code
as a good example of anything. It works for me on Ubuntu Linux 12.04 and 
Python3.2


As usual I welcome constructive comments but I will be working on this 
more to help me understand exactly what is going on


http://pastebin.com/iFzK7fuk SpaceTravellers.py
http://pastebin.com/TdqPwMGi NetworkPickler.py
http://pastebin.com/DF5DtYRZ NetworkUnpickler.py

lipska

--
Lipska the Kat: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
--
http://mail.python.org/mailman/listinfo/python-list


Re: Pickle file and send via socket

2012-08-08 Thread lipska the kat

On 08/08/12 14:50, S.B wrote:

On Wednesday, August 8, 2012 3:48:43 PM UTC+3, lipska the kat wrote:

On 06/08/12 14:32, S.B wrote:



[snip]


Thank you so much !
The examples are very helpful.
What happens if I have a regular text file I want to send via the network.
Do I need to read the file and then dump it into the stargate file object?


Well according to the documentation at

http://docs.python.org/py3k/tutorial/inputoutput.html#reading-and-writing-files

it should be straightforward to read and write pickled files
Not sure why you want to pickle a text file over the network when you 
could just stream it between ports !


however ...

I'm currently getting a Unicode decode error on the first byte in the 
stream when it gets to the other end, no idea why so I guess I have to 
continue searching, read the documentation above and see if you can 
figure it out, that's what I'm doing.


lipska

--
Lipska the Kat: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
--
http://mail.python.org/mailman/listinfo/python-list


Re: Looking for a good introduction to object oriented programming with Python

2012-08-08 Thread lipska the kat

On 08/08/12 17:42, Dennis Lee Bieber wrote:

On Wed, 08 Aug 2012 10:51:45 +0100, lipska the kat
lipskathe...@yahoo.co.uk  declaimed the following in
gmane.comp.python.general:



The point I'm obviously struggling to make is that words convey concepts
The word Person conveys a whole lifetime of experience of People and as
imperfect human beings many of us are unable to tease out 'bits of being
a person' that are relevant to the system we are developing. Inevitably
other seemingly irreversibly entwined bits keep popping up to cloud our
thinking. This is my experience, not an isolated case but one that has
popped up again and again.


You've never considered writing a genealogy program, have you? One
that never acknowledges Person?

Before I start let me say that this thread really has been the most 
enormous fun and I can take any amount of ridicule so don't hold back.


Normally when I have a bath I think of the best way to stop the mice 
from feasting on my herb patch without killing them. This evening I lay 
there thinking about this outwardly tricky problem when I realised that 
what we have here, at it's most basic, is a Tree.


I am not a genealogy expert, the nearest I've been to a family tree is 
the ones my old mum thrusts under my nose at Christmas, Sunday lunch, 
birthdays,funerals etc etc . They are increasing large, beautifully hand 
drawn and most definitely a Tree


So here is my off the cuff, in the bath design for a genealogy system

A Tree consists of Node(s) and Leaf(s), relationships are modelled by 
following the Line(s) in the Tree diagram and that is it. Line may be a 
class as in 'the patriarchal line' I'm not sure, it would come out in 
the iterative wash.


We can infer whatever we want from this simple model. A Leaf is a child, 
until it becomes a parent when it becomes a Node. To anthropomorphize a 
bit more (I love that word) and introduce non species specific words and 
concepts, a Node can be a father or mother (simple to implement by 
virtue of an enumeration e.g enum Gender{MALE, FEMALE, HERMAPHRODITE, 
NON_GENDER_SPECIFIC_CHIMERA, ...}) A male sibling of a parent is an 
uncle, a female an aunt and a cousin is ...I  have no idea but hopefully 
you can see where I'm going with this. Furthermore our system can work 
for Horses and Dogs and Zoomorphs and Epiphytes, Parasites and 
Zygomorphs and Fungi and Parrots and anything else you can possibly 
think of ...


But what of all the ephemeral data that goes with a sentient existance 
on this planet such as birth certificates, newspaper articles, 
christenings, death certificates, photographs etc etc, what about 
pegigree certificates, innoculation records and any other trivia, 
information and flotsam that goes with a pedigree Dog or Horse or indeed 
Parrot.


Well you don't need me to answer this one do you, we could have a class 
called Ephemera ... but then I prefer the Just In Time concept to 
loading data, I'd store the gubbins in a 'database' (don't get me 
started on databases) or I may decide to pickle the data out to disk and 
pull it out when someone requests it and probably charge them a small 
fortune for the privilige of looking at their own families historical 
information.


And not a 'Person' in sight

Of course you may be a genealogy expert and just waiting to shoot me 
down in flames, go ahead, I'll have a good smile about it next time I'm 
in the bath.


lipska

--
Lipska the Kat: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
--
http://mail.python.org/mailman/listinfo/python-list


Re: [newbie] Looking for a good introduction to object oriented programming with Python

2012-08-07 Thread lipska the kat

On 07/08/12 06:35, Steven D'Aprano wrote:

On Mon, 06 Aug 2012 10:24:10 +0100, lipska the kat wrote:


er, the point I was trying to make is that when you say 'interface' it
could mean so many things. If you say 'facade' everyone knows exactly
what you are talking about. And that is EXACTLY the point.


The whole point of design patterns is to avoid getting stuck in
incidental implementation details of a particular library or class and
look for higher-level design patterns.

The same applies to facade -- it's just a special case of the interface
pattern.


So you AGREE with me, fantastic, what are we arguing about then (it's 
great fun though isn't it) facade is a SPECIAL case of interface.

You seem to be missing this point.

I may not be as smart or experienced as you but in my fairly wide 
experience of software projects of all sizes the biggest problem is one 
of communication. Design patterns, in my experience help with communication.


I have designed and implemented many facades, I have also designed many 
interfaces. I do not think Java is the be all and end all of programming 
languages but it has paid off my mortgage and provided me with a good 
living. Python interests me because it is different. As far as I can see 
if I'm talking with a Pythonista or a Java developer or a hardware 
engineer (possibly) or a C++ guru or a university lecturer or an Eiffel 
developer and I say 'interface' they will all visualise something 
slightly different, if I say 'facade' they will all (hopefully) know 
EXACTLY what I am talking about.


lipska

--
Lipska the Kat: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
--
http://mail.python.org/mailman/listinfo/python-list


Re: [newbie] Looking for a good introduction to object oriented programming with Python

2012-08-07 Thread lipska the kat

On 07/08/12 06:19, Steven D'Aprano wrote:

On Mon, 06 Aug 2012 09:55:24 +0100, lipska the kat wrote:


On 06/08/12 01:22, Steven D'Aprano wrote:

On Sun, 05 Aug 2012 20:46:23 +0100, lipska the kat wrote:



[snip]



The clue is in the name 'Object Oriented' ... anything else is (or
should be) implementation detail.


So your argument is that any programming which is oriented (meaning
what?) towards objects (which are...?) is OOP, and everything else is
implementation detail.

Well now I'm enlightened. That certainly clears that up for me.


Glad I could help :-)

[snip]



As you go on to explain:


A class variable is static and can be
accessed without instantiation an instance variable is accessed via an
instance


which are semantic differences, differences in meaning and function.


Yes but when we TALK about these things a String variable is a String 
variable is a String variable. The words 'Class variable' and 'instance 
variable' are 'abstractions'. It saves us saying,


'this is a variable that can only be accessed from an instance and may 
hold values of the type Integer or String or Weak Reference ... (and so 
on ad nauseum) ... but only of one type unless you count runtime 
polymorphism in which case the runtime type may be different from the 
compile time type ... etc etc'


or 'this is a variable that can be accessed without instantiating a 
class (see above)'


If you don't like the term abstraction then perhaps we can agree on 
something else.



Since a string variable is a variable holding a string, and a float
variable is a variable holding a float, an instance variable should be
a variable holding an instance, and a class variable should be a
variable holding a class.


See above


Class variable and instance variable are higher level abstractions.


Of what? Of variables?


Exactly, now you're getting the hang of it

[snip]


Simply put, the choice of terminology is crap --


possibly but it's the best we've got.


But what *really* gets me is not the existence of poor terminology. I
couldn't care less what terminology Java programmers use among
themselves.


I'd be most grateful if you could park the whole 'This person is a 'Java 
developer so must be a moron thing' it's getting a bit wearing.
As I said in a previous post, Java has indeed been good to me but my 
brain IS capable of dealing with more than one language.



What gets me is that the ubiquity of them means that
substandard terminology spreads into other languages, like dryrot.


Yea well welcome to the world of spin, if you can't fight it then learn 
to roll with it.



The ONLY concept that you should never try to encapsulate is/are human
beings or their aliases.


snip


Is this some sort of mystical humans aren't objects, they're
SPECIAL!!! rubbish? Because it sure sounds like it.


[snip]

Well now this is a personal thing born of bitter experience. In my 
experience, when you have an entity called 'Person' or some such in your 
Class model it soon becomes what we 'in the trade' call a 'God Object' 
The name should be self explanatory but hold tight, here comes some more 
jargon.


Objects can have a 'has a' relationship with other Objects or an 'is a' 
relationship with other objects


The 'has a' relationship means that an Object 'owns' another object, the 
'is a' relationship means that an Object 'is of a particular type'
Of course in an 'Object Oriented' language such as Java an Object 
reference can have a different type at runtime than it does at compile 
time. In Python too.


Anyway, this Person thing soon ends up with a 'has a' relationship with 
everything in sight. a Person 'has a[n]' Address, a Person 'has a[n]' 
account, a Person 'has a' Doughnut etc etc etc


Also, inevitably a Person 'is a' Customer, a Person 'is a' Contact, a 
Person 'is a' security risk, well you get the idea.


Of course this is a problem with the actual design process itself and 
yes, the identification of the 'nouns in the language of the domain' is 
an important part of the process. Sorry, but it just works when it's 
done properly, I know it works as I used this technique to turn around 
this 'Person as God' design from a failing money pit into a working 
system that delivered (almost) on time. The very first thing I did was 
to exorcise Person from the design.



I've already managed to write meaningful code but I haven't invented a
single class yet.


And why do you think this is a problem?


A problem? I wasn't ware that I'd stated it was a problem it just


You said BUT [emphasis added] I haven't invented a single class yet,
which implies that this is a bad thing


[snip]

No it implies that I noticed it was possible to do meaningful work in 
Python without writing a class.



Well this HAS been fun, I look forward to your reply but at the moment I 
have to go and pick some runner beans as it's been a fantastic year for 
beans and the freezer awaits.


lipska

--
Lipska the Kat: Troll hunter, sandbox destroyer
and farscape

Re: OT probably but still relevant (was Re: Looking for a good introduction to object oriented programming with Python)

2012-08-07 Thread lipska the kat

On 07/08/12 10:44, Steven D'Aprano wrote:

On Mon, 06 Aug 2012 17:23:19 +0100, lipska the kat wrote:


On 06/08/12 13:19, rusi wrote:



I suggest this
http://steve-yegge.blogspot.in/2006/03/execution-in-kingdom-of-

nouns.html


http://bpfurtado.livejournal.com/2006/10/21/


Unfortunately the author (Bruno Furtado) has missed the point. He seems


Steve, chill out, you seem to have this whole Javahate thing going at 
the moment. It's just a language, like Python. You can write crap code 
in Java just like you can write crap code in any language. Just for the 
record 'Time' is way too complex a concept to encapsulate in a single 
class (we can debate that if you like although it all gets a bit 
philosophical) If you MUST have a Time Object in Java you can 
instantiate java.sql.Time, not really that complicated is it ?


I do enjoy debating with you but really, lighten up a bit, it really 
isn't that important, mankind existed for millenia before computers and 
programming languages. If we want to exist for millenia after their 
invention then we need to get off this planet. If you want to get 
excited about something then get excited about our apparent inability to 
exceed the speed of light. Until we solve that one we are doomed.


waits for rant about how Java has destroyed the space program

I'm thinking of adding a line to my sig for this group that says

I don't hate Python, I like it for it's differences

;-)

lipska

--
Lipska the Kat: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
--
http://mail.python.org/mailman/listinfo/python-list


Re: Pickle file and send via socket

2012-08-07 Thread lipska the kat

On 07/08/12 12:21, S.B wrote:




 Can anyone provide a simple code example of the client and server sides?


Working on it

lipska

--
Lipska the Kat: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
--
http://mail.python.org/mailman/listinfo/python-list


Re: [newbie] Looking for a good introduction to object oriented programming with Python

2012-08-07 Thread lipska the kat

On 07/08/12 14:12, Ben Finney wrote:

lipska the katlipskathe...@yahoo.co.uk  writes:


The ONLY concept that you should never try to encapsulate is/are
human beings or their aliases.


You stated this in absolute, dogmatic terms. I thought at first you were
being hyperbolic for effect, but the situation that you present to
support this dogma is one where I can't see anyone rationally concluding
the dogma applies.


Ah, you mean you don't agree.


Well now this is a personal thing born of bitter experience.


[snip]


Also, inevitably a Person 'is a' Customer, a Person 'is a' Contact, a
Person 'is a' security risk, well you get the idea.


This accurately reflects the reality that “person” is a real-world
entity very frequently involved in just about anything a typical system
needs to model.


No, you are wrong. Having a Person class is profoundly and fundamentally 
wrong. If we follow this argument then every system ever modelled would 
have a Person at it's heart.


I think you are missing the point here. You say.

 This accurately reflects the reality that “person” is a real-world
 entity very frequently involved in just about anything a typical stem
 needs to model. that a person is a real-world entity very frequently

Have asserted that you are profoundly wrong I now have to say that I 
couldn't agree more BUT with the crucial modifier that a person is an 
actor I don't care if you like or dislike the terminology, you get the 
general idea. An actor exists outside the system. Having a Person in the 
Class model tends to blur the boundaries between system and users. I 
know it does, I've seen it happen so many times.


It's all about how we think about a system in the early stages of design
The moment we introduce a Person (or alias for a Person) we confuse our 
thinking, are we thinking about Person as actor or are we thinking about 
Person as entity in our system. This is not some nebulous flight of 
fancy, this is born of real world, stand at the whiteboard and thrash 
out a design experience. I have been ridiculed before, strangely enough, 
once the Person has been expunged from the system mind things go a whole 
lot more smoothly.



Of course this is a problem with the actual design process itself


What problem? If the real-world entity really exists and the “has-a” and
“is-a” relationships really exist, then it's *good* design to model
whatever ones of those are significant to the operation of the program.

Indeed, it would be *bad* design to avoid modelling the real world
merely because of dogma against modelling persons and their
relationships to other entities.


Dogma is an emotive word that you are using to belittle the idea. That's 
fine, you asked me to explain myself and I have done so.


[snip]


And when the real domain to be modelled almost certainly has people as a
central entity in complex interactions, removing Person from the design
entirely is poor work grounded in irrationality.


Well I say it's sound judgment grounded in experience and most if not 
all my employers seem to agree. I have thousands of lines of code 'in 
the wild' operating without fault day after week after year and not one 
single line refers to, implies or otherwise represents a Person in any 
way whatsoever.


Just one tiny point, I NEVER have to 'remove' a Person from my designs 
as they never get through the door in the first place.


The only time I have ever had to agree that a Person belongs in a 
computer is when I saw Tron.


lipska

--
Lipska the Kat: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
--
http://mail.python.org/mailman/listinfo/python-list


Re: [newbie] Looking for a good introduction to object oriented programming with Python

2012-08-07 Thread lipska the kat

On 07/08/12 15:14, Steven D'Aprano wrote:

On Tue, 07 Aug 2012 10:19:31 +0100, lipska the kat wrote:


On 07/08/12 06:19, Steven D'Aprano wrote:

[...]

But what *really* gets me is not the existence of poor terminology. I
couldn't care less what terminology Java programmers use among
themselves.


I'd be most grateful if you could park the whole 'This person is a 'Java
developer so must be a moron thing' it's getting a bit wearing.


Lipska, it's not always about you.


Never thought so for a moment, good to know you can be reasonable as 
well as misguided ;-)


lipska

--
Lipska the Kat: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
--
http://mail.python.org/mailman/listinfo/python-list


Re: Looking for a good introduction to object oriented programming with Python

2012-08-07 Thread lipska the kat

On 07/08/12 16:04, rusi wrote:

On Aug 7, 7:34 pm, lipska the katlipskathe...@yahoo.co.uk  wrote:


Never thought so for a moment, good to know you can be reasonable as
well as misguided ;-)


Well Lipska I must say that I find something resonant about the 'no-
person' thing, though I am not sure what.

You also said something about 'user' being more acceptable.  From a
different (opposite?) angle Dijkstra seems to be saying the same
thing, here:
http://www.cs.utexas.edu/~EWD/transcriptions/EWD06xx/EWD618.html

Wonder what you make of it?


This text is often quoted in discussions I have had on this subject on 
Usenet and other forums.


Professor Dijkstra is far more eloquent that I could ever hope to be.
I don't profess to be an academic nor do I have the rhetorical ability 
of some of the people in this group, having said that I think the 
professor may be equally as indignant about the word elbowing it's way 
into his native language as he is about the way the word is used in the 
computing industry but here is my rationale for thinking that there is a 
case for a class called User.


A 'User' of a computer system can be another computer system, equally a 
Person can be a user of a computer system. Denying the use of the 
concept User may inhibit certain thought processes. At the very least 
'User' can be used as a place holder indicating that we are aware that 
we are dealing with something that will eventually need to communicate 
outside of it's boundaries. Abstracting away an entire 'class' of 
concepts into a single 4 letter word can be wonderfully liberating. When 
you tell a group of struggling software developers to ignore external 
influences but be aware that there is this thing called 'User' that will 
eventually have to communicate with the thing we are inventing they 
breath a huge sigh of relief and start to focus on what is important, 
namely the business logic of the entity that is employing them. Once a 
basic design has been thrashed out we can start thinking about how 
external systems (and 'People') interface with the representation of the 
business we have invented. We then iterate and re-iterate as external 
influences invariably affect our design, however the core design remains 
and acts as an anchor to our thinking. In the past, when we have got 
confused and frustrated with these external influences we have gone back 
to our original design to ground ourselves again.


Having said all this it has never been my experience that we actually 
end up with a User Class in any design I have been involved in. 
Eventually we just find ourselves in a place where the 'User' has 
transmogrified into a collection of facades and interfaces that present 
a view of the system to the outside world.


I'm still undecided over the whole 'User' thing actually, I don't think 
I can see a time when I will have a User Class in one of my systems but 
as I don't want to get 'dogmatic' about this I remain open to any ideas 
that might include such a Class.


Person however is an entirely different matter and will never appear in 
my systems in any way shape or form ...this is not dogma, it's a fact.


lipska

--
Lipska the Kat: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
--
http://mail.python.org/mailman/listinfo/python-list


Re: Looking for a good introduction to object oriented programming with Python

2012-08-06 Thread lipska the kat

On 05/08/12 23:51, Steven D'Aprano wrote:

On Sun, 05 Aug 2012 18:45:47 -0400, Dennis Lee Bieber wrote:


Don't look for Object-Oriented Programming -- since the first widely
popular OOP language was C++ (Smalltalk was earlier, but rather
specialized, whereas C++ started as a preprocessor for C).
Rather look for Object-Oriented Analysis and Design (OOAD). An OOAD
textbook /should/ be language neutral and, these days, likely using the
constructs/notation of UML [which derived from a merger of two or three
separate proposals for OOAD tools]


Good lord. I'd rather read C++ than UML.  And I can't read C++.


This reminds me of a consultant I once worked with.
He had worked on government projects for a decade or more and was a 
staunch supporter of the 'big bang' approach to software development.

I asked him how many of these had been a success ... deafening silence.

His attitude to UML was 'I'd rather cut my right arm off than waste time 
with that new fangled nonsense'


UML works, non technical 'stakeholders' (yuk) can understand it at a 
high level and in my HUMBLE opinion the sequence diagram is the single 
most important piece of documentation in the entire software project


jeez

lipska

--
Lipska the Kat: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
--
http://mail.python.org/mailman/listinfo/python-list


Re: Looking for a good introduction to object oriented programming with Python

2012-08-06 Thread lipska the kat

On 06/08/12 01:27, Steven D'Aprano wrote:

On Sun, 05 Aug 2012 19:12:35 -0400, Roy Smith wrote:


Good lord. I'd rather read C++ than UML.  And I can't read C++.


UML is under-rated.  I certainly don't have any love of the 47 different
flavors of diagram, but the basic idea of having a common graphical
language for describing how objects and classes interact is pretty
useful.  Just don't ask me to remember which kind of arrowhead I'm
supposed to use in which situation.



I frequently draw diagrams to understand the relationships between my
classes and the problem I am trying to solve. I almost invariably use one
type of box and one type of arrowhead. Sometimes if I'm bored I draw
doodles on the diagram. If only I could remember to be consistent about
what doodle I draw where, I too could be an UML guru.



Yea, it can be tricky. But if you persevere you will gain enlightenment.
It does take a bit of application though.

lipska

--
Lipska the Kat: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
--
http://mail.python.org/mailman/listinfo/python-list


Re: [newbie] Looking for a good introduction to object oriented programming with Python

2012-08-06 Thread lipska the kat

On 06/08/12 01:22, Steven D'Aprano wrote:

On Sun, 05 Aug 2012 20:46:23 +0100, lipska the kat wrote:


rant
Object Oriented programming is a mindset, a way of looking at that
particular part of our world that you are trying to encapsulate in
computer language. The language you use is (should be) irrelevant.


That depends on how you define OOP, and in particular, which aspects of
OOP your language supports.


The clue is in the name 'Object Oriented' ... anything else is (or 
should be) implementation detail.


[large snip]



In particularly, terminology varies -- I personally despise with the heat
of a thousand suns the terms instance variable and class variable for
attributes or members.


This is an implementation detail and describes the difference between 
certain types of attributes. A class variable is static and can be 
accessed without instantiation an instance variable is accessed via an 
instance ... again the clue is in the name.



Since a string variable is a variable holding a
string, and a float variable is a variable holding a float, an instance
variable should be a variable holding an instance, and a class variable
should be a variable holding a class.


Class variable and instance variable are higher level abstractions.


The ONLY concept that you should never try to encapsulate is/are human
beings or their aliases.


snip


Is this some sort of mystical humans aren't objects, they're SPECIAL!!!
rubbish? Because it sure sounds like it.

Can you give some non-religious reasons why you should not implement
human beings or aliases as objects?


You have answered your own question I would be glad to debate my 
assertion at length with you however the 'moderators' are listening.



If not, let me just say that I reject your prohibition and leave it at
that.



Actually it should really be called Class Oriented programming as
classes are the units of encapsulation.


Incorrect. You don't even need classes to have objects. You can have
class-based OOP, and prototype-based OOP, as in Javascript, Actionscript,
Io, and the language which invented the term, Self.



http://en.wikipedia.org/wiki/Prototype-based_programming


Interesting article, I withdraw my 'classed based' assertion however the 
concept of a unit of encapsulation still exists. Where unit of 
encapsulation is different from a unit of function or method.



I really don't think python is a
good language to learn OO programming, the problem is that Python
doesn't enforce OO so you are never going to learn what is 'OO' and what
isn't.


I think that's exactly why Python *is* a good language to learn OOP,
because you can be productive even while learning. You can start off by
just adding a little bit of OOP syntax to your programs:


Well I'm afraid I can't agree with this. OO is a state if mind (again) 
you can't successfully be a 'little bit OO' IMHO



response = raw_input(What do you want to do? )
response = response.lower()  # Look ma, I'm using OOP!


Infantile but funny

snip


I've already managed to write meaningful code but I haven't
invented a single class yet.


And why do you think this is a problem?


A problem? I wasn't aware that I'd stated it was a problem it just 
underlines my belief that Python, however useful it is, is not the ideal 
language to learn about Object Oriented software development.



Classes are one possible solution to problems that actually matter. What
matters is the solution, not the mechanism of the solution. Writing
classes is just a means to an end (the solution), not the end itself.


I couldn't agree more, the point is that they are a good solution. I 
learned very early on that there is more than one way to skin a cat. I 
have never said that Python is a bad language, I LIKE Python. I 
certainly prefer it to Java for on the fly development and it sure is 
more fun at times.



There is a book you could try, it's a bit dry and I read it when I can't
sleep, about 30 mins usually does it :-) It's called Design Patterns


snippety snip



In my not-so-humble opinion, the popularity of Design Patterns has a lot
to do with the fact that they are so abstract and jargon-ridden that they
have become a badge of membership into an elite.


Hmm, I feel a rant coming on about elitism ...

snip

and a Facade is just an interface layer.

Well as you seem to be so concerned with terminology I'd have to 
disagree with you here. An interface (in computing) has any number of 
meanings, hardware interfaces, software interfaces the HCI etc etc. In 
some languages an interface is a non functional unit of compilation that 
describes the methods an implementing class must provide. A facade on 
the other hand aggregates a number of fine grained operations that often 
implement the business logic of an application into coarser grained 
methods that can be called further up the implementation stack.
More importantly, what goes on behind a facade can be completely changed 
without affecting anything that uses

Re: [newbie] Looking for a good introduction to object oriented programming with Python

2012-08-06 Thread lipska the kat

On 06/08/12 09:55, lipska the kat wrote:

On 06/08/12 01:22, Steven D'Aprano wrote:

On Sun, 05 Aug 2012 20:46:23 +0100, lipska the kat wrote:


rant


snip


Well as you seem to be so concerned with terminology I'd have to
disagree with you here. An interface (in computing) has any number of
meanings, hardware interfaces, software interfaces the HCI etc etc. In
some languages an interface is a non functional unit of compilation that
describes the methods an implementing class must provide. A facade on
the other hand aggregates a number of fine grained operations that often
implement the business logic of an application into coarser grained
methods that can be called further up the implementation stack.
More importantly, what goes on behind a facade can be completely changed
without affecting anything that uses the facade thereby enhancing
maintainability. (I'm trying really hard not to use buzzwords here).


er, the point I was trying to make is that when you say 'interface' it 
could mean so many things. If you say 'facade' everyone knows exactly 
what you are talking about. And that is EXACTLY the point.


lipska

--
Lipska the Kat: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
--
http://mail.python.org/mailman/listinfo/python-list


Re: Looking for a good introduction to object oriented programming with Python

2012-08-06 Thread lipska the kat

On 06/08/12 13:19, rusi wrote:

On Aug 6, 12:46 am, lipska the katlipskathe...@yahoo.co.uk  wrote:

On 04/08/12 16:49, Jean Dubois wrote:


I'm looking for a good introduction to object oriented programming
with Python.





Object Oriented programming is a mindset, a way of looking at that
particular part of our world that you are trying to encapsulate
in computer language. The language you use is (should be) irrelevant.


snip


Learn Python by all means, the interactive mode is particularly fun,just
try and get a good idea of what OO is all about before you start.


I suggest this
http://steve-yegge.blogspot.in/2006/03/execution-in-kingdom-of-nouns.html

Particularly useful if you are a bit drunk on snake-oil


You take out the garbage.
I've got automatic garbage collection

lipska

--
Lipska the Kat: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
--
http://mail.python.org/mailman/listinfo/python-list


OT probably but still relevant (was Re: Looking for a good introduction to object oriented programming with Python)

2012-08-06 Thread lipska the kat

On 06/08/12 13:19, rusi wrote:

On Aug 6, 12:46 am, lipska the katlipskathe...@yahoo.co.uk  wrote:

On 04/08/12 16:49, Jean Dubois wrote:


I'm looking for a good introduction to object oriented programming
with Python.




snip



I suggest this
http://steve-yegge.blogspot.in/2006/03/execution-in-kingdom-of-nouns.html


http://bpfurtado.livejournal.com/2006/10/21/

lipska

--
Lipska the Kat: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
--
http://mail.python.org/mailman/listinfo/python-list


Re: [newbie] Looking for a good introduction to object oriented programming with Python

2012-08-05 Thread lipska the kat

On 04/08/12 16:49, Jean Dubois wrote:

I'm looking for a good introduction to object oriented programming
with Python.


rant
Object Oriented programming is a mindset, a way of looking at that
particular part of our world that you are trying to encapsulate
in computer language. The language you use is (should be) irrelevant.

The ONLY concept that you should never try to encapsulate is/are human
beings or their aliases. So Person, User, Human etc should not exist in 
any way shape or form in your design. There is an argument that User is

ok but I don't subscribe to that.

If you want to represent human interaction in your software design use
Account or Session or some other non human noun.
/rant

Actually it should really be called Class Oriented programming as
classes are the units of encapsulation.
I really don't think python is a good language to learn OO programming,
the problem is that Python doesn't enforce OO so you are never going to
learn what is 'OO' and what isn't.

Before I get told off/flamed/shouted at I've just started learning
Python and I think it is a great language with a fantastic standard 
library. I've already managed to write meaningful code but I haven't 
invented a single class yet.


Apologies if this sound negative, it's not meant to be it's meant to be
constructive.

There is a book you could try, it's a bit dry and I read it when I can't
sleep, about 30 mins usually does it :-)
It's called Design Patterns by Gamma, Helm, Johnson and Vlissides
ISBN 0-201-63361-2.
They do use C++ code in examples but as they say, this is just a
convenience and shouldn't colour your view of the subject
I still read the introduction and get something out of it after several
years. You should be able to implement the patterns in Python
although I must admit I haven't tried that yet

Learn Python by all means, the interactive mode is particularly fun,just 
try and get a good idea of what OO is all about before you start.


Just my opinion

lipska



--
Lipska the Kat: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
--
http://mail.python.org/mailman/listinfo/python-list


Re: Eclipse and the Python plugin

2012-08-04 Thread lipska the kat

On 04/08/12 00:29, Cousin Stanley wrote:

lipska the kat wrote:



I can now create, debug and test a simple IRC server
written in Java and an IRC Bot that I am attempting
to build in Python



   For a bit of inspiration python-irc-bot-wise
   you might look at supybot 



Yep, it's there (here). Thanks for the heads up

lipska

--
Lipska the Kat: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
--
http://mail.python.org/mailman/listinfo/python-list


Eclipse and the Python plugin

2012-08-03 Thread lipska the kat
A while ago someone asked me what I thought of the Eclipse plugin for 
python, well I just downloaded and installed the latest version of 
Eclipse for Java (Juno) followed by the Python plugin. After a while 
messing about with it I can only say ... phew, what a relief. The plugin 
looks like it automates a whole bunch of tasks such as packaging and you 
can configure it to use Jython, Iron Python (neither of which I have 
used) and some other stuff I have never heard of


I installed all this on Ubuntu Linux 12.04 with no problems whatsoever.

There's a debugger (which I haven't tried), code completion, error 
highlighting and much more.


Installing the plugin is documented here
http://www.rose-hulman.edu/class/csse/resources/Eclipse/eclipse-python-configuration.htm

And the most amazing thing of all is it's all completely free.

I can now create, debug and test a simple IRC server written in Java
and an IRC Bot that I am attempting to build in Python side by side in 
the same IDE simply by switching profiles (click one button). Astonishing.


You might like to try it

Just FYI so please don't tell me off (again).

lipska

--
Lipska the Kat: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
--
http://mail.python.org/mailman/listinfo/python-list


Re: Eclipse and the Python plugin

2012-08-03 Thread lipska the kat

On 03/08/12 13:10, Mark Lawrence wrote:

On 03/08/2012 12:34, lipska the kat wrote:

A while ago someone asked me what I thought of the Eclipse plugin for
python,


snip





My opinion of Eclipse is unchanged by your words, it's like trying to
run a legless carthorse in the Grand National or the Derby.


:-)) There's this image in my mind ... jeez, get a grip.

I'm sorry to hear that, what would you recommend.

lipska

--
Lipska the Kat: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
--
http://mail.python.org/mailman/listinfo/python-list


Re: Eclipse and the Python plugin

2012-08-03 Thread lipska the kat

On 03/08/12 13:40, Mark Lawrence wrote:

On 03/08/2012 13:23, lipska the kat wrote:

On 03/08/12 13:10, Mark Lawrence wrote:

On 03/08/2012 12:34, lipska the kat wrote:

A while ago someone asked me what I thought of the Eclipse plugin for
python,


snip


it's like trying to
run a legless carthorse in the Grand National or the Derby.


:-)) There's this image in my mind ... jeez, get a grip.

I'm sorry to hear that, what would you recommend.


Sorry I can't recommend anything as I use Python for small personal
projects, so I find a combination of Notepad++ and PythonWin totally
adequate for my needs. Eclipse is also popular, so simply because I
don't like it speed wise doesn't mean that it's not for you.


I've been using it for years for Java, I just recently found the Python 
plugin.



Picking an IDE often gets down to your own preferences and perhaps budget.


It's free ... good enough reason for me. I'm Always interested to hear 
of alternatives though.


lipska

--
Lipska the Kat: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
--
http://mail.python.org/mailman/listinfo/python-list


Re: Eclipse and the Python plugin

2012-08-03 Thread lipska the kat

On 03/08/12 14:54, rusi wrote:

On Aug 3, 4:34 pm, lipska the katlipskathe...@yahoo.co.uk  wrote:

A while ago someone asked me what I thought of the Eclipse plugin for
python, well I just downloaded and installed the latest version of
Eclipse for Java (Juno) followed by the Python plugin.


Thanks Lipska for reporting back.
I personally find the eclipse UI frightening but I am unwilling to
conclude that its eclipse and not me.


snip.

I have no vested interest in Eclipse but I don't believe that you would 
feel the same once you got your head around the basics. I don't pretend 
to be an expert, far from it, but I have taught myself enough to go into 
a contract and hit the ground running, loading the source tree into 
Eclipse is a great way to start to understand the code and the libraries 
it uses. Well it works for me anyway.



More to the point, it seems to me that eclipse was today what emacs
was then -- seemingly too large but in time I expect it will not seem
so large.


It can be bewildering I agree but the basics are not too intimidating.
I remember early versions of IBMs VisualAge for Java ... guaranteed to 
give you brain damage.



So one more request from me:

Can you try the refactoring support and tell us how it fares?


Well, I don't really have enough Python code to refactor anything at the 
moment however I did try something that may or may not prove to be 
informative.


If I create a Java class and right click in the code window and select 
refactor from the context menu there is a HUGE list of things I can do. 
Why I might want to do some of them I have no idea, but there they are. 
In contrast if I create a Python class and select refactor I get a 
significantly smaller list of things I can do. Inline local variable, 
Extract local variable, Extract method, Rename, Generate constructors, 
Generate properties and Override/Implement methods. I think this may be 
a result of Pythons different (from Java) grammar rules. I can write a 
Python class and call it Foo and save it in a file called Bar and it's 
no big deal (at least Eclipse doesn't get excited) If I try that in Java 
the sky falls in. Of course I'm about as far away from being a Python 
expert as it's possible to be.


Anyway, if and when I find out more I'll let you know. It will be a 
while though.


lipska

--
Lipska the Kat: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
--
http://mail.python.org/mailman/listinfo/python-list


Re: Eclipse and the Python plugin

2012-08-03 Thread lipska the kat

On 03/08/12 17:40, Steven D'Aprano wrote:

On Fri, 03 Aug 2012 16:51:26 +0100, lipska the kat wrote:


I can write a
Python class and call it Foo and save it in a file called Bar and it's
no big deal (at least Eclipse doesn't get excited) If I try that in Java
the sky falls in.


:)

Correct. Python does not require, or even encourage, the one-class-per-
file rule of Java.


snip

Well it's actually one public class per file, you can have as many 
package visible classes as you like not to mention inner classes and 
anonymous classes, but I know what you mean.


I used to know a developer who though that any file (class) that 
contained more lines of code than could fit on an A4 sheet of paper at 
10 points was too large ... a little extreme perhaps.



Mind you, both of those are seriously large, Decimal has 117 methods and
Context around 70-80 (I stopped counting). So as I said, that's about the
upper limit for what I consider reasonable in a single module.


117 methods seems a lot doesn't it. I'm still trying to get my head 
around Python packages, I think Eclipse will help me with this and the 
whole module mix of functions and classes is taking a while to get used 
to. The standard included libraries are pretty impressive though and it 
is certainly easier to write quick throwaway prototypes in Python. I 
guess this will become even quicker once I understand the language better.


lipska

--
Lipska the Kat: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
--
http://mail.python.org/mailman/listinfo/python-list


Re: Is Python a commercial proposition ?

2012-08-02 Thread lipska the kat

On 02/08/12 04:10, David wrote:

On 01/08/2012, Stefan Behnelstefan...@behnel.de  wrote:


Would you mind taking this slightly off-topic discussion off the list?


I always strive to stay on-topic. In fact immediately this thread went
off topic, 4 messages back, I did try to go off list, but got this
result from the OP:

Delivery to the following recipient failed permanently:
  lip...@yahoo.co.uk


snip

This is my fault, I set the reply to address incorrectly. You HAVE 
corresponded successfully with me in the past however... I apologise for 
the inconvenience.


JFTR I did not call you an ignoramus (it's a funny word though isn't it, 
makes me smile anyway).


lipska

--
Lipska the Kat: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
--
http://mail.python.org/mailman/listinfo/python-list


Re: Is Python a commercial proposition ?

2012-08-01 Thread lipska the kat

On 01/08/12 09:06, Mark Lawrence wrote:

On 01/08/2012 00:31, David wrote:

On 01/08/2012, lipska the kat lip...@yahoo.co.uk wrote:

On 31/07/12 14:52, David wrote:


[1] as in beer
[2] for research purposes


There's one (as in 1 above) in the pump for you.


Great, more beer = better research = \o/\o/\o/
But, pump sounds a bit extreme .. I usually sip contentedly from a
glass :p



You complete ignoramus, if it gets poured in advance that's no good to
anybody as it'll go flat. Has to stay in the pump until you're ready to
drink it from the glass. Don't you know anything about the importance of
process and timing? :)



Heh heh, obviously never got drunk ... er I mean served behind the bar 
at uni/college/pub %-}


lipska

--
Lipska the Kat: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
--
http://mail.python.org/mailman/listinfo/python-list


Re: Is Python a commercial proposition ?

2012-07-31 Thread lipska the kat

On 31/07/12 14:52, David wrote:

On 30/07/2012, lipska the katlip...@yahoo.co.uk  wrote:

On 30/07/12 14:06, Roy Smith wrote:


These days, I'm working on a fairly large web application (songza.com).


We are very sorry to say that due to licensing constraints we cannot
allow access to Songza for listeners located outside of the United States.

Arse :-(


A free[1] US proxy could bypass[2] that page ... eg something like
http://www.airproxy.ca/

[1] as in beer
[2] for research purposes


Oh that's a bit good isn't it, just for research purposes of course.

There's one (as in 1 above) in the pump for you.

lipska

--
Lipska the Kat: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
--
http://mail.python.org/mailman/listinfo/python-list


Re: Is Python a commercial proposition ?

2012-07-30 Thread lipska the kat

On 30/07/12 14:06, Roy Smith wrote:

In articlemailman.2717.1343634778.4697.python-l...@python.org,
  Chris Angelicoros...@gmail.com  wrote:


Python's an excellent glue language, but it's also fine for huge
applications. Yes, it can't multithread across cores if you use
CPython and are CPU-bound. That's actually a pretty specific
limitation, and taking out any component of that eliminates the GIL as
a serious problem.


These days, I'm working on a fairly large web application (songza.com).
The business/application logic is written entirely in Python (mostly as
two django apps).  That's what we spend 80% of our developer time
writing.



snip

We are very sorry to say that due to licensing constraints we cannot 
allow access to Songza for listeners located outside of the United States.


Arse :-(

Lipska

--
Lipska the Kat: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
--
http://mail.python.org/mailman/listinfo/python-list


Is Python a commercial proposition ?

2012-07-29 Thread lipska the kat

Pythoners

Firstly, thanks to those on the tutor list who answered my questions.

I'm trying to understand where Python fits into the set of commonly 
available, commercially used languages of the moment.


My most recent experience is with Java. The last project I was involved 
with included 6775 java source files containing 1,145,785 lines of code. 
How do I know this? because I managed to cobble together a python script 
that walks the source tree and counts the lines of code. It ignores 
block and line comments and whitespace lines so I'm fairly confident 
it's an accurate total. It doesn't include web interface files (mainly 
.jsp and HTML) or configuration files (XML, properties files and what 
have you). In fact it was remarkably easy to do this in python which got 
me thinking about how I could use the language in a commercial environment.


I was first attracted to python by it's apparent 'Object Orientedness' I 
soon realised however that by looking at it in terms of the language I 
know best I wasn't comparing like with like. Once I had 'rebooted the 
bioware' I tried to approach python with an open mind and I have to say 
it's growing on me.


The questions I have are ...

How is python used in the real world.
What sized projects are people involved with
Are applications generally written entirely in python or is it more 
often used for a subset of functionality.


I hope this is an acceptable question for this group

Many thanks

Lipska

--
Lipska the Kat: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun
--
http://mail.python.org/mailman/listinfo/python-list


Re: My first ever Python program, comments welcome

2012-07-24 Thread Lipska the Kat

On 24/07/12 06:13, rusi wrote:

On Jul 22, 10:23 pm, Lipska the Katlip...@lipskathekat.com  wrote:


Heh heh, Nothing to do with Eclipse, just another thing to get my head
around. For work and Java IMHO you can't beat eclipse...
at the moment I'm getting my head around git,


Bumped into this yesterday. Seems like a good aid to git-comprehension
https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh


eek ... now that's a shell script to be proud of isn't it .. and it 
works [lipska@ubuntu fileio (master)]$ impressive. Good find, thanks.



reminding myself of C, learning Python
and re-learning make. Enough already; but if there's a python plugin I
guess I'll get around to it eventually


Seems like a strange combo. It should be
(Cmake)|(pythonX)|(JavaAnt)
where X could range from


%-}


Setup http://docs.python.org/distutils/setupscript.html
to distribute http://guide.python-distribute.org/
to scons http://www.scons.org/


Well that's the joy of life in semi-retirement. I can do as I please
I read something somewhere the other day about living longer if you 
retire early, well I retired early but if I live another 50 years it 
won't be long enough to learn everything I want to.


JavaAnt everyday
Cmake   a while back

python well I sort of got sidetracked by python
... and then I got sidetracked by git !!!

Lipska

--
Lipska the Kat: Troll hunter, Sandbox destroyer
and Farscape dreamer of Aeryn Sun.
--
http://mail.python.org/mailman/listinfo/python-list


python package confusion

2012-07-23 Thread Lipska the Kat

Hello again pythoners

I'm trying to understand the python package stuff

I have the following directory

/home/lipska/python/dev/mods

In this directory I have two files, both executable

--

#! /usr/bin/env python3.2

# fibo.py Fibonacci numbers module

def fib(n):# write Fibonacci series up to n
a, b = 0, 1
while b  n:
print(b, end=' ')
a, b = b, a+b
print()

--

#! /usr/bin/env python3.2

# test.py fibo module test program

import fibo

fibo.fib(1000)

---

The PYTHONPATH ev is set to /home/lipska/python/dev/mods:.
in .bashrc

The following interactive session works thusly

lipska@ubuntu:~/python/dev/mods$ python3.2
Python 3.2.3 (default, Jul 17 2012, 14:23:10)
[GCC 4.6.3] on linux2
Type help, copyright, credits or license for more information.
 import fibo
 fibo.fib(1000)
1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987


However if I try and run test.py as an executable I get the following error

lipska@ubuntu:~/python/dev/mods$ test.py
Traceback (most recent call last):
  File ./test.py, line 5, in module
fib(1000)
NameError: name 'fib' is not defined

if I print sys.path I get the following

 print(sys.path)
['', '/usr/local/lib/python32.zip', '/usr/local/lib/python3.2', 
'/usr/local/lib/python3.2/plat-linux2', 
'/usr/local/lib/python3.2/lib-dynload', 
'/home/lipska/.local/lib/python3.2/site-packages', 
'/usr/local/lib/python3.2/site-packages']


The documentation states that ...

sys.path is initialized from these locations:

the directory containing the input script (or the current directory).
PYTHONPATH (a list of directory names, with the same syntax as the 
shell variable PATH).


But apparently the additional locations I specify in .bashrc are not 
being added to sys.path


I also have an empty file __init__.py in the mods directory

Not sure what I'm doing wrong here

Any help much appreciated.

Lipska


--
Lipska the Kat: Troll hunter, Sandbox destroyer
and Farscape dreamer of Aeryn Sun.
--
http://mail.python.org/mailman/listinfo/python-list


Re: python package confusion

2012-07-23 Thread Lipska the Kat

On 23/07/12 11:19, Dave Angel wrote:

On 07/23/2012 06:02 AM, Lipska the Kat wrote:

Hello again pythoners


snip


That line isn't the way you showed it in the source.  You showed us
source as  fibo.fib(1000), and the error message shows it as fib(1000)

So you're either cutting  pasting wrong, or you have two test.py files.


jeez, you are right. I must be getting old. embarrased

Apologies for wasting your time.

Lipska

--
Lipska the Kat: Troll hunter, Sandbox destroyer
and Farscape dreamer of Aeryn Sun.
--
http://mail.python.org/mailman/listinfo/python-list


Re: python package confusion

2012-07-23 Thread Lipska the Kat

On 23/07/12 11:22, Devin Jeanpierre wrote:

On Mon, Jul 23, 2012 at 6:02 AM, Lipska the Katlip...@lipskathekat.com  wrote:

The PYTHONPATH ev is set to /home/lipska/python/dev/mods:.
in .bashrc


Did you export it? Show us your .bashrc, or the relevant line in it
exactly. (And make sure that it isn't defined multiple times).


forgot to export it stupid stupid stupid


Also adding . to the import search path is probably a bad diea.


I removed it


lipska@ubuntu:~/python/dev/mods$ test.py
Traceback (most recent call last):
   File ./test.py, line 5, inmodule
 fib(1000)
NameError: name 'fib' is not defined

Neither of the files you described in your email message contain the
line fib(1000), so you pasted the wrong files.


See grovelling apology in other reply




I also have an empty file __init__.py in the mods directory


This only matters if you want to import mods.


huh .. OK, I'll read again

Thanks for taking the time to reply
It all works now

Lipska slinks away to hide

--
Lipska the Kat: Troll hunter, Sandbox destroyer
and Farscape dreamer of Aeryn Sun.
--
http://mail.python.org/mailman/listinfo/python-list


Re: python package confusion

2012-07-23 Thread Lipska the Kat

On 23/07/12 12:16, David wrote:

On 23/07/2012, Lipska the Katlip...@lipskathekat.com  wrote:


Hello again pythoners

  [snip]
Any help much appreciated.

Hi Lipska

Glad you got it sorted.

In case you are not aware of this:
   Tutor maillist  -  tu...@python.org
   http://mail.python.org/mailman/listinfo/tutor


I'll certainly look into it, thanks. It was more a problem of trying to 
do too many things at once and doing none of them well. Pathetic excuse 
I know but it's the best I've got. :-(



So if you are interested in that, feel free to email me directly, or
not as you wish.


I've sent you  message

Lipska

--
Lipska the Kat: Troll hunter, Sandbox destroyer
and Farscape dreamer of Aeryn Sun.
--
http://mail.python.org/mailman/listinfo/python-list


Re: My first ever Python program, comments welcome

2012-07-22 Thread Lipska the Kat

On 21/07/12 21:10, Dave Angel wrote:

On 07/21/2012 03:08 PM, Lipska the Kat wrote:

Greetings Pythoners

A short while back I posted a message that described a task I had set
myself. I wanted to implement the following bash shell script in Python



snip






A totally off-the-wall query.  Are you using a source control system,
such as git ?  It can make you much braver about refactoring a working
program.


Thanks for your comments, I've taken them on board,
I'm most familiar with with cvs and svn for source control. I've also 
used Microsoft source safe. I generally just use what's given to me by 
whoever is paying me and don't worry too much about the details. Many in 
the Linux world seem to use git. Seeing as I've been using Linux at home 
since the early days of slackware I suppose I'd better look into it. 
Strangely enough I've never had a paid job using Linux. I've worked on 
multiuser UNIX systems and Sun Workstations but never Linux so I guess 
the need has never arisen.


The Java world seems to largely use Maven to manage their code. It's a 
bit of a headbanger and I've never used it. Ant and FTP are my current 
faves at home. Primitive but good enough for my personal and business sites.


Lipska



--
Lipska the Kat: Troll hunter, Sandbox destroyer
and Farscape dreamer of Aeryn Sun.
--
http://mail.python.org/mailman/listinfo/python-list


Re: My first ever Python program, comments welcome

2012-07-22 Thread Lipska the Kat

On 22/07/12 03:55, rusi wrote:

On Jul 22, 1:10 am, Dave Angeld...@davea.name  wrote:


A totally off-the-wall query.  Are you using a source control system,
such as git ?  It can make you much braver about refactoring a working
program.


Question in a similar vein: What development environment do you use?
My impression is that the majority of pythonistas use a non-ide editor
like vi or emacs
Ive been using emacs for 20 years and python-mode of emacs is very
useful but I am increasingly concerned that emacs is refusing to move
with the times.


My current 'Python development environment' is gedit with line numbering 
turned on and a terminal window to run chmodded scripts :-)




Which is why I am particularly curious how an ol Java-head finds
eclipse+python (http://pydev.org/ )


Python and eclipse ... Noo ;-)

Well I have to say that I've used Eclipse with the myEclipse plugin for 
a number of years now and although it has it's moments it has earned me 
LOADS of MONEY so I can't really criticise it. I have Eclipse installed 
on a Windows box so I may try the plugin ... but actually I'm really 
enjoying doing things the 'old fashioned way' again.


I'm going to do 'proper OO' version of the shell script to learn about 
wiring different modules together ... I find the official documentation 
hard to navigate though.


Lipska


--
Lipska the Kat: Troll hunter, Sandbox destroyer
and Farscape dreamer of Aeryn Sun.
--
http://mail.python.org/mailman/listinfo/python-list


Re: My first ever Python program, comments welcome

2012-07-22 Thread Lipska the Kat

On 22/07/12 11:17, Chris Angelico wrote:

On Sun, Jul 22, 2012 at 6:49 PM, Andrew Bergbahamutzero8...@gmail.com  wrote:

On 7/22/2012 3:37 AM, Lipska the Kat wrote:

Many in
the Linux world seem to use git.


snip


Use source control now; you'll reap the benefits later!



from sudo apt-get install git to git add *.py was about 5 minutes
and that included reading the basic documentation. POSITIVELY the 
fastest install and the least trouble from any source control app ever


Lipska

--
Lipska the Kat: Troll hunter, Sandbox destroyer
and Farscape dreamer of Aeryn Sun.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Looking for good tutorials after reading Byte of Python

2012-07-22 Thread Lipska the Kat

On 22/07/12 15:48, Paulo wrote:

My main goal is to do web development with Django/flask or another framework 
that suits me best. But I think that I should learn a bit more of  Python 
before diving  into a framework. I would like to know if anyone has some good 
tutorials like building a to-do list app or any other type of programs so I can 
learn by doing and also as a guiding kinda thing.

Thanks in advance.

P.S. excuse my poor english


You may have already seen this but there is a tutorial on
the python site http://docs.python.org/py3k/ (python3.2.3)

There is also one at http://www.tutorialspoint.com/python/index.htm
that looks like it could be worth reading

Lipska

--
Lipska the Kat: Troll hunter, Sandbox destroyer
and Farscape dreamer of Aeryn Sun.
--
http://mail.python.org/mailman/listinfo/python-list


Re: My first ever Python program, comments welcome

2012-07-22 Thread Lipska the Kat

On 22/07/12 17:18, rusi wrote:

On Jul 22, 2:20 pm, Lipska the Katlip...@lipskathekat.com  wrote:


Well I have to say that I've used Eclipse with the myEclipse plugin for
a number of years now and although it has it's moments it has earned me
LOADS of MONEY so I can't really criticise it.


Ive probably tried to use eclipse about 4 times in the last 8 years.
Always run away in terror.
Still I'm never sure whether eclipse is stupid or I am...

First time I'm hearing of myEclipse. Thanks. What does it have/do that
standard eclipse (JDT?) does not?


Eclipse for Java supports development of 'standard' Java applications
that is applications that use the standard Java Distributions (JDK). 
MyEclipse adds support for J2EE and a bunch of other stuff. I used it 
mainly for jsp syntax highlighting, HTML syntax highlighting and Servlet 
development. It's marketed as a J2EE and web development IDE. It comes 
with an embedded Tomcat server and some versions support common 
frameworks such as Spring and Hibernate. Struts is supported by default 
I think although I always stayed away from frameworks when I could. I 
preferred to write Java rather than XML :-) Check out 
http://www.myeclipseide.com/ for an example of marketing bling.



Python and eclipse ... Noo ;-)



Very curious about this.  You made 'Loads of money' with eclipse but
want to stay away from it?
Simply cannot make out this thing called 'java-programmer-culture'...


How dare you sir, I'm not a Java programmer I am a 'retired' software 
engineer ;-)


Heh heh, Nothing to do with Eclipse, just another thing to get my head 
around. For work and Java IMHO you can't beat eclipse... at the moment 
I'm getting my head around git, reminding myself of C, learning Python 
and re-learning make. Enough already; but if there's a python plugin I 
guess I'll get around to it eventually


Lipska

--
Lipska the Kat: Troll hunter, Sandbox destroyer
and Farscape dreamer of Aeryn Sun.
--
http://mail.python.org/mailman/listinfo/python-list


My first ever Python program, comments welcome

2012-07-21 Thread Lipska the Kat

Greetings Pythoners

A short while back I posted a message that described a task I had set 
myself. I wanted to implement the following bash shell script in Python


Here's the script

sort -nr $1 | head -${2:-10}

this script takes a filename and an optional number of lines to display
and sorts the lines in numerical order, printing them to standard out.
if no optional number of lines are input the script prints 10 lines

Here's the file.

50  Parrots
12  Storage Jars
6   Lemon Currys
2   Pythons
14  Spam Fritters
23  Flying Circuses
1   Meaning Of Life
123 Holy Grails
76  Secret Policemans Balls
8   Something Completely Differents
12  Lives of Brian
49  Spatulas


... and here's my very first attempt at a Python program
I'd be interested to know what you think, you can't hurt my feelings
just be brutal (but fair). There is very little error checking as you 
can see and I'm sure you can crash the program easily.

'Better' implementations most welcome

#! /usr/bin/env python3.2

import fileinput
from sys import argv
from operator import itemgetter

l=[]
t = tuple
filename=argv[1]
lineCount=10

with fileinput.input(files=(filename)) as f:
for line in f:
t=(line.split('\t'))
t[0]=int(t[0])
l.append(t)
l=sorted(l, key=itemgetter(0))

try:
inCount = int(argv[2])
lineCount = inCount
except IndexError:
#just catch the error and continue  
None

for c in range(lineCount):
t=l[c]
print(t[0], t[1], sep='\t', end='')

Thanks

Lipska


--
Lipska the Kat: Troll hunter, Sandbox destroyer
and Farscape dreamer of Aeryn Sun.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Encapsulation, inheritance and polymorphism

2012-07-19 Thread Lipska the Kat

On 19/07/12 07:09, rusi wrote:

On Jul 19, 6:34 am, Steven D'Apranosteve
+comp.lang.pyt...@pearwood.info  wrote:

On Wed, 18 Jul 2012 15:40:00 +0100, Lipska the Kat wrote:

Object Oriented programming is all about encapsulating human concepts in
a way that makes sense to human beings. Make no mistake, it is NEVER the
case that a software system is written for any other reason than to
serve human beings. OO is more than just the mechanics of writing code,
it's a state of mind.


Um, yes?



Its not so much a question of language as in programming as language
as in layman-speak.
One characteristic with our field is that we take ordinary words and
then distort them so much the original meaning is completely lost.

Take 'computer' for example.  For Turing a computer was a
mathematician doing a computation with a pen and paper.  He then
showed how to de-skill the mathematician so much that a machine could
do what he was doing.  In trying that he also hit upon the limits of
such 'de-skilling' -- human-computers routinely detect infinite loops,
whereas machine-computers can never do so (in full generality).

Ironically the important lesson is lost and today 'computer' is
synonymous with machine.

Here is Dijkstra on similar distortions with 'user' and
'intelligent':
http://www.cs.utexas.edu/~EWD/transcriptions/EWD06xx/EWD618.html

'Object' (and OO) are similar messes.


Well this is all very interesting.

The terminology is quite concise if you allow it to be
Take An Object is an instance of a Class

A Class describes a human concept (be it concrete like a 'Parrot' or 
more abstract like a 'Session') an Object is an actual representation of 
that concept that exists in the memory of a computer (what else should 
we call it). Objects don't exist in the mind of a human, concepts do. A 
class is a way of representing that concept so that other humans can 
understand it. That's it, really, there is no more, anything else is 
implementation.



In layman-speak and object is well, a thing.


But we are not talking in 'layman-speak' we are discussing concepts that 
are familiar to us in the 'language of the domain' at least I though we 
were. Academic twiddling with the distorted meaning of words spun by 
vested interests is all very interesting I'm sure but doesn't really 
advance the discussion does it?



- subject to space-laws like can only exist at one place at a time,
there cannot be two objects at the same place and time etc.
- subject to time-laws like coming into existence at some time and
going out at some other
- connotes inanimateness unlike other 'creatures' or 'beings'.


Well here I have to agree with you. Anyone who invents a 'Person' Class 
should be dismissed forthwith. Parrots are OK though.



When this metaphor works (for example as in guis and simulation) then
we have success-stories like smalltalk and simula.

When it doesn't the success is poorer. eg a programmer writing math
software in/on a OO system may for example 'clone' a matrix.  This may
be good science-fiction; its bad math.

And one of the most pervasive (and stupidist) metaphors is the parent-
child relation of classes.
Just for the record, in the normal world 'creatures/beings' reproduce
and therefore inherit.


But we are not talking about the 'real world' are we, we are talking 
about representing complex interacting human concepts in a way that can 
be understood by humans and translated into a form that can be executed 
on a binary machine


 Objects dont.

Well they do, it's a fact, you can call a method on a sub class that 
only exists in the super class. What else would you call it.


Well it's been fun but I have bills to pay so I suppose I'd better do 
some work. TTFN



--
Lipska the Kat: Troll hunter, Sandbox destroyer
and Farscape dreamer of Aeryn Sun.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Encapsulation, inheritance and polymorphism

2012-07-18 Thread Lipska the Kat

On 18/07/12 01:46, Andrew Cooper wrote:

On 17/07/2012 19:36, Lipska the Kat wrote:

On 17/07/12 19:18, Mark Lawrence wrote:

On 17/07/2012 18:29, Ethan Furman wrote:

Terry Reedy wrote:

On 7/17/2012 10:23 AM, Lipska the Kat wrote:



snip



Take for example a Linux system call handler.  The general form looks a
little like (substituting C for python style pseudocode)

if not (you are permitted to do this):
 return -EPERM
if not (you've given me some valid data):
 return -EFAULT
if not (you've given me some sensible data):
 return -EINVAL
return actually_try_to_do_something_with(data)

How would you program this sort of logic with a single return statement?
  This is very common logic for all routines for which there is even the
remotest possibility that some data has come from an untrusted source.


Eeek! well if you insist (type bound)

someType -EPERM
someType -EFAULT
sometype -EINVAL
someType -EDOSOMETHING

//method
someType checkSomething(data){

someType result = -EINVAL //or your most likely or 'safest' result

if not (you are permitted to do this):
  result = -EPERM
if not (you've given me some valid data):
  result = -EFAULT
if not (you've given me some sensible data):
  result = -EINVAL
else
  result = -EDSOMETHING

  return result
}
//cohesive, encapsulated, reusable and easy to read

//later

if(checkSomething(data) == EDOSOMETHING){

actually_try_to_do_something_with(data)
}
else{
//who knows
}

What do you think ?



~Andrew

P.S. like the sig.


thanks


--
Lipska the Kat: Troll hunter, Sandbox destroyer
and Farscape dreamer of Aeryn Sun.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Encapsulation, inheritance and polymorphism

2012-07-18 Thread Lipska the Kat

On 18/07/12 14:05, Steven D'Aprano wrote:

On Wed, 18 Jul 2012 01:46:31 +0100, Andrew Cooper wrote:


Take for example a Linux system call handler.  The general form looks a
little like (substituting C for python style pseudocode)

if not (you are permitted to do this):
 return -EPERM
if not (you've given me some valid data):
 return -EFAULT
if not (you've given me some sensible data):
 return -EINVAL
return actually_try_to_do_something_with(data)
I’m feeling a bit fed uI’m feeling a bit fed uI’m feeling a bit fed u
How would you program this sort of logic with a single return statement?


That's not terribly hard.

if not (you are permitted to do this):
 result = -EPERM
elif not (you've given me some valid data):
 result = -EFAULT
elif not (you've given me some sensible data):
 result = -EINVAL
else:
 result = actually_try_to_do_something_with(data)
return result


A better example would involve loops. I used to hate programming in some
versions of Pascal without a break statement: I needed a guard variable
to decide whether or not to do anything in the loop!

# pseudo-code
for i in 1 to 100:
 if not condition:
 do_something_useful()


Even with a break, why bother continuing through the body of the function
when you already have the result? When your calculation is done, it's
done, just return for goodness sake. You wouldn't write a search that
keeps going after you've found the value that you want, out of some
misplaced sense that you have to look at every value. Why write code with
unnecessary guard values and temporary variables out of a misplaced sense
that functions must only have one exit?


Object Oriented programming is all about encapsulating human concepts in 
a way that makes sense to human beings. Make no mistake, it is NEVER the 
case that a software system is written for any other reason than to 
serve human beings. OO is more than just the mechanics of writing code, 
it's a state of mind.


OO was 'invented' to address the many problems that beset increasingly 
complex software systems. The main problem was maintainability. 
Encapsulating a concept in a clear and concise way makes the code easier 
to understand. Sometimes this means writing code that is not 'optimal' 
for the machine. Good code should be readable as well as efficient but I 
contend that it is better to write something that is clear, concise and 
well encapsulated than always go for the 'meanest dog in the scrapyard' 
approach where a developer is determined to write unreadable code that 
shows how jolly clever he is. More often than not he is forced to admit 
six months down the line that he has no idea what his code does as he 
'forgot' to comment it.


I speak from bitter experience. This approach works for me. I have 
thousands of lines of code operating every day 'in the wild', everything 
from flight booking systems to real time odds arbitrage. Any developer 
who 'gets' OO can read and modify my code and I am very proud of this 
fact ... and I have never been forced to admit that I don't know what I 
wrote six months ago.


If you are writing embedded systems that must have a very limited memory 
footprint then there is a case for conciseness over readability but even 
then it has to be maintainable


Python looks like an interesting language and I will certainly spend 
time getting to know it but at the moment it seems to me that calling it 
an Object Oriented language is just plain misleading.


There, I've said it, trolls and flamers beware, I take no prisoners.

Lipska

--
Lipska the Kat: Troll hunter, Sandbox destroyer
and Farscape dreamer of Aeryn Sun.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Encapsulation, inheritance and polymorphism

2012-07-18 Thread Lipska the Kat

On 18/07/12 15:34, Grant Edwards wrote:

On 2012-07-17, Lipska the Katlip...@lipskathekat.com  wrote:


and what's this obsession with 'correct' indentation of code ???


If you can explain to us Java's obsession with 'correct' placemnt of
curly-braces, then you've explained indentation in python.


I'm not getting into the curly braces wars. Life is just too short.


Unless you're asking about the tabs vs. spaces argument.  In that
case, people who use 4 spaces per level are 'correct'; people who use
a different number of spaces are a bit less correct; people who use
tabs are wrong;


hmm, I've been using tabs ... still, why use one key press when you can 
use 4 ;-).  Actually I quite like this aspect of Python, it's rapidly 
growing on me. Wonder if I could introduce this in a future release of 
Java ... nah, I'd be dead within a week %-(



and people who mix spaces and tabs -- well, we don't
talk about them in polite company.




--
Lipska the Kat: Troll hunter, Sandbox destroyer
and Farscape dreamer of Aeryn Sun.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Encapsulation, inheritance and polymorphism

2012-07-18 Thread Lipska the Kat

On 18/07/12 16:09, Chris Angelico wrote:

On Thu, Jul 19, 2012 at 12:48 AM, Lipska the Kat
lip...@lipskathekat.com  wrote:

hmm, I've been using tabs ...


snip


We must meet half way, you know.


Seems reasonable to me, I'll let you suggest it ;-)


As to tab vs spaces: I'm a fan of tabs, myself. There was an argument
over the matter last year at work, and we settled on tabs because the
one guy who reckons 1-2 space indent is plenty was then able to just
set his editor to two-space tabs, and the rest of us could use a more
reasonable width. Using tab characters in the file gives this
flexibility. It separates the lexical structure (this is three blocks
in) from the visual display (draw these glyphs 35mm from the left
margin).


OK, I'll set my tab to 4 spaces ...

Lipska

--
Lipska the Kat: Troll hunter, Sandbox destroyer
and Farscape dreamer of Aeryn Sun.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Encapsulation, inheritance and polymorphism

2012-07-18 Thread Lipska the Kat

On 18/07/12 16:32, Ethan Furman wrote:

Lipska the Kat wrote:

On 18/07/12 14:05, Steven D'Aprano wrote:

Even with a break, why bother continuing through the body of the
function
when you already have the result? When your calculation is done, it's
done, just return for goodness sake. You wouldn't write a search that
keeps going after you've found the value that you want, out of some
misplaced sense that you have to look at every value. Why write code
with
unnecessary guard values and temporary variables out of a misplaced
sense
that functions must only have one exit?


Object Oriented programming is all about encapsulating human concepts
in a way that makes sense to human beings. Make no mistake, it is
NEVER the case that a software system is written for any other reason
than to serve human beings. OO is more than just the mechanics of
writing code, it's a state of mind.


I must admit I have no idea how we went from discussing Single Exit
functions to the One True Purpose of Object Oriented Programming; are
you saying that SE is one of the basic tenets of OO?


It's my fault, I get carried away sometimes. Maintainable code is one of 
the basic tenets of OO, it all seems so clear to me and I get frustrated 
when I think that others don't see the 'beauty' ... but then I come to 
my senses and realise that there is always another way to do things.



Python looks like an interesting language and I will certainly spend
time getting to know it but at the moment it seems to me that calling
it an Object Oriented language is just plain misleading.


Since *everything* in Python is an object, how can you /not/ call it an
OO language?


Obviously I can't. I can't make a call as I haven't studied the language 
yet. I just can't get my head around duck typing at the moment as it is 
just so ... different.



Sure, you don't have to use everything as an object --
plain functions exist -- kinda ;) Even functions live in some namespace:
len() lives in __builtin__, any top level function lives in its module,
etc. Oh, and namespaces are objects.

It seems to me that Python is more about providing tools, and then
staying out of your way.

That works for me. Maybe it will work for you, too.


I hope so and thank you for being so calm and reasonable in your response.



~Ethan~


Lipska


--
Lipska the Kat: Troll hunter, Sandbox destroyer
and Farscape dreamer of Aeryn Sun.
--
http://mail.python.org/mailman/listinfo/python-list


Encapsulation, inheritance and polymorphism

2012-07-17 Thread Lipska the Kat

Pythoners

Python 2.7.3
Ubuntu Linux 12.04 LTS

I've been taking a brief look at Python.

From the tutorial documentation I get the following

'Python is an easy to learn, powerful programming language. It has 
efficient high-level data structures and a simple but effective approach 
to object-oriented programming'.


I was expecting (hoping) to see in depth documentation relating to Class 
construction, extension mechanisms and runtime polymorphism.


What I actually get is a confusion of Classes, modules, scripts and 
whatever else.


Is Python truly OO or is it just one way to use the language. I see some 
documentation relating to classes but nothing on instantiation .. in 
fact the documentation appears to say that classes are used in a static 
way e.g ClassName.method(), and command line scripting is really outside 
the scope of other OO languages I have experienced.


Is there a previous discussion in the group that I could read.

Many thanks

Lipska

--
Lipska the Kat: Troll hunter, Sandbox destroyer
and Farscape dreamer.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Encapsulation, inheritance and polymorphism

2012-07-17 Thread Lipska the Kat

On 17/07/12 10:30, Ulrich Eckhardt wrote:

Welcome!

Am 17.07.2012 10:45, schrieb Lipska the Kat:

I was expecting (hoping) to see in depth documentation relating to Class
construction, extension mechanisms and runtime polymorphism.


In addition to this forum for direct help and discussion, two
suggestions: Firstly, it could help if you mentioned what programming
languages you are fluent in


For the past 9 years I have been developing in Java, everything from 
device drivers (well firmware interfaces would be a better description)
to serverside business logic implemented using POJOs and database 
interfaces along with some in depth work with earlier versions of J2EE 
including EJBs and of course the obligatory frameworks. There's more but 
you get the idea.


My speciality if you like is the design of high availability real time 
business systems right from high level natural language specifications 
to detailed use cases and associated models in UML. I also do some 
implementation work although not so much these days. phew! my resume in 
a nutshell I suppose


Earlier on in my career I did some fairly low level stuff in C and C++ 
although the mists of time and all that ...


Anyway, I'm looking at Python as a rapid prototyping language.
I have an idea and just want to get it down in basic outline code as 
quickly as possible before it departs my aging brain... I'm not used to 
using variables without declaring their type ... (well I used to do 
Visual Basic many years ago) It just seems so weird, and what's this 
obsession with 'correct' indentation of code ???



in order to help traditional misconceptions
and to draw parallels. Secondly, http://docs.python.org is the central
hub to tutorials and documentation.



What I actually get is a confusion of Classes, modules, scripts and
whatever else.


Due to the very dynamic nature of Python, types (classes), modules and
functions are themselves objects that can be manipulated.




snip




I see some documentation relating to classes but nothing on
instantiation .. in fact the documentation appears to say that classes

  are used in a static way e.g ClassName.method(), and command line
  scripting is really outside the scope of other OO languages I have
  experienced.

I think you are confused.


Highly likely


For the documentation, it would help to know
which documentation exactly seems to make such claims. For the thing
about commandline scripting, I'm afraid you will have to adjust your
expectations.


I'll try to find it again



BTW: In general, you instantiate a class by just calling the class' name
like a function. If e.g. ClassName is a class, ClassName() instantiates
this class.


Good luck!


Thank you, and thank you for your kind response

Lipska


--
Lipska the Kat: Troll hunter, Sandbox destroyer
and Farscape dreamer of Aeryn Sun.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Encapsulation, inheritance and polymorphism

2012-07-17 Thread Lipska the Kat

On 17/07/12 11:03, Devin Jeanpierre wrote:

On Tue, Jul 17, 2012 at 4:45 AM, Lipska the Katlip...@lipskathekat.com  wrote:

Is Python truly OO or is it just one way to use the language. I see some
documentation relating to classes but nothing on instantiation .. in fact
the documentation appears to say that classes are used in a static way e.g
ClassName.method(), and command line scripting is really outside the scope
of other OO languages I have experienced.


It doesn't look like you're reading the section on classes:

http://docs.python.org/tutorial/classes.html


Thanks, I wasn't, there is too much to do and not enough time to do it.
So now I just need to chill out a bit and get into 'documentation 
reading mode' again




Polymorphism is duck typed --


Yes, I've been reading the wikipedia entry on this ... this type of 
polymorphism is not familiar to me ... I come from a Java background. 
more reading I guess.


snip


-- Devin


Thanks for your time and I'll try to do a bit better with the reading 
thing before asking more questions... not sure about this obsession with 
code indentation though :-|



--
Lipska the Kat: Troll hunter, Sandbox destroyer
and Farscape dreamer of Aeryn Sun.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Encapsulation, inheritance and polymorphism

2012-07-17 Thread Lipska the Kat

On 17/07/12 12:37, Andrew Berg wrote:

On 7/17/2012 6:01 AM, Lipska the Kat wrote:

Anyway, I'm looking at Python as a rapid prototyping language.


snip


Pythonic is (or at least should be) a word you encounter frequently in
discussions of Python code. Learn what is considered Pythonic and then
write Python code that way if you want to work with the language rather
than fight it. Duck-typing is very Pythonic


You're not kidding, the 'duck' example at 
http://en.wikipedia.org/wiki/Duck_typing made me check I hadn't overdone 
the medication this morning. That is just plain ...weird. It will take 
me a while to form non knee jerk opinions of this for sure.


snip


On a side note, I would highly recommend learning Python 3 (3.2 is the
latest stable version) unless you have an explicit need for Python 2
(some major 3rd-party libraries have not been ported yet). Python 2
won't get any new features; it will simply get bug fixes until its EOL
in 2014 (15?).


I'll check it out, thanks.

Lipska


--
Lipska the Kat: Troll hunter, Sandbox destroyer
and Farscape dreamer of Aeryn Sun.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Encapsulation, inheritance and polymorphism

2012-07-17 Thread Lipska the Kat

On 17/07/12 09:45, Lipska the Kat wrote:

Pythoners

Python 2.7.3
Ubuntu Linux 12.04 LTS

I've been taking a brief look at Python.



snip

Well I've set myself a task.
I have a text file containing a list of stock items
each line contains the number in stock followed by a tab followed by the 
name of the item. I need to implement something that reads in the text 
file and outputs the stock list in ascending or descending order of 
quantity.


Please note I am NOT asking for solutions.

In bash this is laughably trivial

sort -nr $1 | head -${2:-10}

Java is easy but long winded and takes a while to set up

C is ... well it's been a while but I'll get there

Python, well that's my current task. It will be interesting to compare 
the solutions for speed and ease of development and more importantly

re-usability.



Lipska




--
Lipska the Kat: Troll hunter, Sandbox destroyer
and Farscape dreamer of Aeryn Sun.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Encapsulation, inheritance and polymorphism

2012-07-17 Thread Lipska the Kat

On 17/07/12 12:37, Andrew Berg wrote:

On 7/17/2012 6:01 AM, Lipska the Kat wrote:


snip


On a side note, I would highly recommend learning Python 3 (3.2 is the
latest stable version) unless you have an explicit need for Python 2
(some major 3rd-party libraries have not been ported yet). Python 2
won't get any new features; it will simply get bug fixes until its EOL
in 2014 (15?).


Wow, that was a blast from the past
Just downloaded, unzipped, untarred, configured, made and installed 
python 3.2.3 ... it's YEARS since I've done this, makes me feel young again.


Lispka


--
Lipska the Kat: Troll hunter, Sandbox destroyer
and Farscape dreamer of Aeryn Sun.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Encapsulation, inheritance and polymorphism

2012-07-17 Thread Lipska the Kat

On 17/07/12 14:52, Roy Smith wrote:

In article-8sdnvrxgqie25jnnz2dnuvz7qkdn...@bt.com,
  Lipska the Katlip...@lipskathekat.com  wrote:


I'm not used to using variables without declaring their type


If you truly wanted to recreate this type-bondage style of programming
in Python, it's easy enough to do.


snip

Well 'type-bondage' is a strange way of thinking about compile time type 
checking and making code easier to read (and therefor debug) but
I'm not about to get into some religious war about declaring a variables 
type. I'll just say that I prefer to devote testing efforts to the real 
danger area which in my experience is 'user' input.
Clients look dimly on runtime errors however they occur and if I can 
leave it to the compiler to check as much as possible then I'll take that.


I do understand however that compiling an intepreted language doesn't 
really make sense however i'm sure there are interpreted languages that 
allow pre-execution type checking ... aren't there ? Oh yes, there's one 
called Java :-)


Still, I'm sure you're only kidding around with me :-)

Lipska

--
Lipska the Kat: Troll hunter, Sandbox destroyer
and Farscape dreamer of Aeryn Sun.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Encapsulation, inheritance and polymorphism

2012-07-17 Thread Lipska the Kat

On 17/07/12 15:16, Andrew Berg wrote:

On 7/17/2012 9:01 AM, Lipska the Kat wrote:

Wow, that was a blast from the past
Just downloaded, unzipped, untarred, configured, made and installed
python 3.2.3 ... it's YEARS since I've done this, makes me feel young again.

Most Linux distributions should have a premade package for stable Python
versions - apt-get install python3 or something like that.


Not as much fun though is it :-)

Lipska

--
Lipska the Kat: Troll hunter, Sandbox destroyer
and Farscape dreamer of Aeryn Sun.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Encapsulation, inheritance and polymorphism

2012-07-17 Thread Lipska the Kat

On 17/07/12 17:26, Mark Lawrence wrote:

On 17/07/2012 15:23, Lipska the Kat wrote:

On 17/07/12 14:52, Roy Smith wrote:


snip



Still, I'm sure you're only kidding around with me :-)


Kidding around on a Python mailing list, never, how dare you Sir, simply
wouldn't be cricket :-)


As in The batsman of the Kalahari no doubt :-)

--
Lipska the Kat: Troll hunter, Sandbox destroyer
and Farscape dreamer of Aeryn Sun.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Encapsulation, inheritance and polymorphism

2012-07-17 Thread Lipska the Kat

On 17/07/12 18:24, Terry Reedy wrote:

On 7/17/2012 8:01 AM, Lipska the Kat wrote:

On 17/07/12 09:45, Lipska the Kat wrote:

Pythoners

Python 2.7.3
Ubuntu Linux 12.04 LTS

I've been taking a brief look at Python.



snip



Well I've set myself a task.
I have a text file containing a list of stock items
each line contains the number in stock followed by a tab followed by the
name of the item. I need to implement something that reads in the text
file and outputs the stock list in ascending or descending order of
quantity.



snip




In bash this is laughably trivial

sort -nr $1 | head -${2:-10}


Won't sort work alphabetically and leave the following as is?

1\talpha
11\tbeta
2\tgamma


The -n option tells sort to interpret the first word on a line as a 
number r means sort in descending order. It works fine. I also added 
another feature not in the specification that allows the input of a 
number of lines to print ...

well on the way to being bloatware I guess ;-)

Lipska

--
Lipska the Kat: Troll hunter, Sandbox destroyer
and Farscape dreamer of Aeryn Sun.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Encapsulation, inheritance and polymorphism

2012-07-17 Thread Lipska the Kat

On 17/07/12 19:18, Mark Lawrence wrote:

On 17/07/2012 18:29, Ethan Furman wrote:

Terry Reedy wrote:

On 7/17/2012 10:23 AM, Lipska the Kat wrote:


Well 'type-bondage' is a strange way of thinking about compile time
type
checking and making code easier to read (and therefor debug


'type-bondage' is the requirement to restrict function inputs and
output to one declared type, where the type declaration mechanisms are
usually quite limited.

 def max(a, b):
if a = b: return a
return b



Surely you meant 'if a = b: . . .'

No worries, I'm sure your unittests would have caught it. ;)

~Ethan~


Wouldn't the compiler have caught it before the unittests? :-)



Not unless the compiler could read your mind!
The syntax looks fine it's the semantics that are suspect. Wrong is a 
word that I try not to use as it tends to upset people, let's call them 
differently right ;-)


BTW having more than one return statement in a block is a little thing I 
know but it drives me nuts ... another Pythonic thing I'll have to get 
used to I suppose.


--
Lipska the Kat: Troll hunter, Sandbox destroyer
and Farscape dreamer of Aeryn Sun.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Encapsulation, inheritance and polymorphism

2012-07-17 Thread Lipska the Kat

On 17/07/12 18:07, Terry Reedy wrote:

On 7/17/2012 10:23 AM, Lipska the Kat wrote:


Well 'type-bondage' is a strange way of thinking about compile time type
checking and making code easier to read (and therefor debug




snip



How easy was it to write max, or a universal sort in Java?

Well java.lang.Math.max() (or min() depending on what you want) might do 
it and as for sorting ... java.utils.Collections.sort will sort anything 
that implements the java.util.Comparable interface. All the standard 
numerical classes implement Comparable by default so there is nothing to 
do really.


Lipska

--
Lipska the Kat: Troll hunter, Sandbox destroyer
and Farscape dreamer of Aeryn Sun.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Encapsulation, inheritance and polymorphism

2012-07-17 Thread Lipska the Kat

On 17/07/12 20:39, Mark Lawrence wrote:

On 17/07/2012 20:29, Lipska the Kat wrote:

On 17/07/12 18:07, Terry Reedy wrote:

On 7/17/2012 10:23 AM, Lipska the Kat wrote:



snip


How easy was it to write max, or a universal sort in Java?


Well java.lang.Math.max() (or min() depending on what you want) might do
it and as for sorting ... java.utils.Collections.sort will sort anything
that implements the java.util.Comparable interface. All the standard
numerical classes implement Comparable by default so there is nothing to
do really.

Lipska



I would like to spend more time on this thread, but unfortunately the 44
ton artic carrying Java in a Nutshell Volume 1 Part 1 Chapter 1
Paragraph 1 Sentence 1 has just arrived outside my abode and needs
unloading :-)


:-)))

LOL (and I did) but the pay is FANTASTIC, particularly if you 'get' OO.


--
Lipska the Kat: Troll hunter, Sandbox destroyer
and Farscape dreamer of Aeryn Sun.
--
http://mail.python.org/mailman/listinfo/python-list