Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > type checking

Reply
Thread Tools

type checking

 
 
Alex Martelli
Guest
Posts: n/a
 
      10-13-2003
Stephen Horne wrote:

> On Mon, 13 Oct 2003 11:52:31 GMT, Alex Martelli <(E-Mail Removed)>
> wrote:
>
>>The "immediate destruction when last reference gone" is an implementation
>>specific detail of CPython -- handy, but there's quite a price paid for
>>it, so the _language_ makes no guarantees. So you have try/finally for
>>those cases where you NEED guarantees (not as handy, admittedly).

>
> Ah - I think I've just had one of those subtle but important paradigm
> shifts. Resource management (for resources other than memory) simply
> rests on slightly different language mechanisms in Python and Java
> than it does in C++.


Yes, this is a good way to put it, I think.


> Oddly enough, I think my Python code has reflected this for some time
> without me noticing the issue.


Interesting indeed! This kind of "you're smarter than you know" effect
IS observed time and again, admittedly...


Alex

 
Reply With Quote
 
 
 
 
Cameron Laird
Guest
Posts: n/a
 
      10-13-2003
In article <Dnyib.275941$(E-Mail Removed)>,
Alex Martelli <(E-Mail Removed)> wrote:
>Stephen Horne wrote:

.
.
.
>> Oddly enough, I think my Python code has reflected this for some time
>> without me noticing the issue.

>
>Interesting indeed! This kind of "you're smarter than you know" effect
>IS observed time and again, admittedly...
>
>
>Alex
>


The aptness of jokes about Guido's time-machine hints at
real quality in the language. More often than not, or
more often than with other languages, Python seems to
treat ignorance gently. This is a dimension of craftsman-
ship: to do the right thing, degrees of freedom remain.

Python Does It Right. No, better than that, Python makes
it easy to do it right.
--

Cameron Laird <(E-Mail Removed)>
Business: http://www.Phaseit.net
 
Reply With Quote
 
 
 
 
Anand Pillai
Guest
Posts: n/a
 
      10-13-2003
I was not exagerrating when I wrote it. I find python one of the
most 'expressive' languages out there among the crop of higher-level
languages like Perl, Tcl, Ruby etc. It kind of tends to be very
intuitive and the code follows your brain pretty well. Recently
in the wing IDE mailing list there was a suggestion of the slogan
"Python - Fits Your Brain" with many threads. It really does fit
the brain, and I find no exaggeration in the slogan, not even a bit.

For someone who is still coding C++ for a living, I find the hobby
stuff I do in python to be pretty soothing for my brain. I dont
use any debugger, never once so far, and I find the occasional
'print' statements sprinkled here and there is more than enough.

I am not trying to impress anyone. Give me a problem and I can
lay a wager I can do it in python and deliver you the beta code in
two weeks. Let that be a fresh problem btw. Give me another two
weeks and I can deliver you commercial quality code without using
a debugger.

Try me.

-Anand

Stephen Horne <$$$$$$$$$$$$$$$$$@$$$$$$$$$$$$$$$$$$$$.co.uk> wrote in message news:<(E-Mail Removed)>. ..
> On 13 Oct 2003 00:50:18 -0700, http://www.velocityreviews.com/forums/(E-Mail Removed) (Anand Pillai)
> wrote:
>
> >I consider Python as high-level psuedo-code. It helps me in
> >programming, since you dont make mistakes while writing
> >psuedo-code. So it follows by induction that you dont make
> >these mistakes like static type errors while programming python.
> >
> >It is a different approach, by altering your thinking, rather
> >than relying on tools. Works for me

>
> While I agree that most likely sashan needs a change of mindset rather
> than a language with static typing, this is an unrealistically
> impressive claim.
>
> There is no context where I do not sometimes make mistakes, including
> pseudocode.
>
> Of course errors do tend to be much rarer in Python, mainly because I
> am concentrating on the program logic, rather than being distracted by
> the overheads of the language.

 
Reply With Quote
 
Stephen Horne
Guest
Posts: n/a
 
      10-13-2003
On 13 Oct 2003 10:04:21 -0700, (E-Mail Removed) (Anand Pillai)
wrote:

>I am not trying to impress anyone. Give me a problem and I can
>lay a wager I can do it in python and deliver you the beta code in
>two weeks. Let that be a fresh problem btw. Give me another two
>weeks and I can deliver you commercial quality code without using
>a debugger.
>
>Try me.


OK - how about the Turing test?

Ah - I see - that's not a fresh problem, having been proposed some 50
years ago


Some problems are complex in any language.


--
Steve Horne

steve at ninereeds dot fsnet dot co dot uk
 
Reply With Quote
 
Alexander Schmolck
Guest
Posts: n/a
 
      10-15-2003
sashan <(E-Mail Removed)> writes:

> I'm a Python newbie. I have been using c++ for 5 years and before that I was
> programming in Pascal. The one thing that annoys me about python is dynamic
> typing because I find myself making typographical errors of the sort that
> would under C++ be picked up by the compiler at compiler time. With Python I
> have to wait for the error to appear at runtime in order for me to correct
> it. I find this inefficient. Any advice about how to get around this would
> be appreciated.
>


Try C-cC-w in emacs.

'as
 
Reply With Quote
 
Carlo v. Dango
Guest
Posts: n/a
 
      10-16-2003
> I am not trying to impress anyone. Give me a problem and I can
> lay a wager I can do it in python and deliver you the beta code in
> two weeks. Let that be a fresh problem btw. Give me another two
> weeks and I can deliver you commercial quality code without using
> a debugger.
> Try me.
>
> -Anand


please show me a solution where pythons inner class instances has an
'outer scope' where it can access the fields and methods of its outer
class instance. Similar to inner classes in java, and similarly to methods
inside methods in python..


-carlo


--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
 
Reply With Quote
 
Alex Martelli
Guest
Posts: n/a
 
      10-16-2003
Carlo v. Dango wrote:

>> I am not trying to impress anyone. Give me a problem and I can
>> lay a wager I can do it in python and deliver you the beta code in
>> two weeks. Let that be a fresh problem btw. Give me another two
>> weeks and I can deliver you commercial quality code without using
>> a debugger.
>> Try me.
>>
>> -Anand

>
> please show me a solution where pythons inner class instances has an
> 'outer scope' where it can access the fields and methods of its outer
> class instance. Similar to inner classes in java, and similarly to methods
> inside methods in python..


It seems to me you keep confusing ACCESS with RE-BIND.

"methods inside methods", in Python, cannot re-bind variables in the
outer scope. If you really want to be similar to THAT, it's trivial:
having just __getattr__ and no __setattr__ at all should suffice.

If what you want is something extremely intricate and non-obvious
such as:

in the inner classe, self.x = y means self.outer.x = y IF it
so happens that self.outer had an attribute x already defined
at that specific point in time; but it changes meaning to a
normal self.x = y if self.outer did NOT have that attribute
at that precise instant

(which may be a caricature of how somebody, who just doesn't get
the _dynamic_ nature of binding and attributes in Python, and is
dead set on kludging up something that would only make sense if
that nature was static instead, might "reason"), that' easy:

def __setattr__(self, name, value):
if hasattr(self.outer, name): setattr(self.outer, name, value)
else: object.__setattr__(self, name, value)

(and use object.__setattr__(self, 'outer', outer) in __init__ --
also inherit your inner class from object, obviously).

The problem is not how to implement ANY precise specification:
it's coming up with a specification of what exactly you want to
happen, that makes sense and provides SOME usefulness within the
rest of how Python works. I can't see the above spec and its
implementation meeting this common-sense test (but then, I cannot
see any spec that vaguely resembles any of your several descriptions
of what you want that does it, either).

E.g., say the two objects are outer and inner, with inner delegating
to outer as above. With the above specs:

inner.x = 23 # say outer has no x attribute at this instant
outer.x = 45 # but now of course it has acquired it
inner.x = 67 # and so THIS assignment delegates

now a "print inner.x, outer.x" would print 23, 67 -- the inner.x
remains "stuck" at the last value you assigned for it BEFORE
outer.x sprung into existence, any further assignment to inner.x
affects outer.x instead. A "del outer.x" would suddenly make
further assignments to inner.x sensible again (until something
else assigns to outer.x, when assignments to inner.x become crazy
again, as per specs).

There may be application usefulness in this behavior, maybe, but
if so I'm definitely failing to SEE it...


Alex

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Type Hinting vs Type Checking and Preconditions Tom Bradford Python 4 03-10-2006 06:25 PM
Re: Type Hinting vs Type Checking and Preconditions Tom Bradford Python 3 03-09-2006 07:37 AM
RE: Type Hinting vs Type Checking and Preconditions Delaney, Timothy (Tim) Python 7 03-08-2006 05:32 PM
Checking a form input tag type works only for type text... not others...why? Randell D. Javascript 12 07-06-2005 07:51 PM
Re: Type casting- a larger type to a smaller type heyo C Programming 3 04-01-2004 06:35 PM



Advertisments