Re: New to Python: Features

From: Richard Blackwood (richardblackwood_at_cloudthunder.com)
Date: 10/05/04


Date: Tue, 05 Oct 2004 02:40:16 -0400
To: dalke@dalkescientific.com, python-list@python.org

Andrew Dalke wrote:

> Richard Blackwood wrote:
>
>>> exec code, glbls, lcls
>>>
>>
>>
>> This is a cool language, I love code chunks!!
>
>
> Like I said with eval, DO NOT USE THIS! It almost certainly
> means you're doing the wrong thing. It's full of security
> holes and there are nearly always better ways to solve
> the underlying problem.
>

Why are you so fervently against eval, exec? What sort of security
holes? Don't tell me, I'll look it up.

>> How come Python always complains when I don't include the self
>> parameter in an object method? Your code doesn't work on my
>> interpreter.
>
>
> Remember that pointer to asking smart questions? Remember
> that part about reading the documentation? Doing those
> would seriously help your understanding and help us know
> what you mean with "always complains" and "doesn't work."
>
>
It tells me I passed in two arguments when I only passed in one.

>> I know but that's a real bummer. No way around that?
>
>
> Python is not a functional programming language.
>
> Do you want it because it's cool or because it's useful?
>
Cool = useful

>> So is the print statement ironed into the language and not a function?
>
>
> Documentation.
>
> Does it look like a function?
>
Yes it does. Other language have them as functions (just funny looking
one's like in this case). Take Lua for example. "require" is a method
but it import the same way "import" does in Python (syntactically).

>
>>>> 22. Is the self parameter hidden from me as a programmer? Can I
>>>> hide/unhide it as I wish?
>>>
>>>
>>> It is not hidden, in fact, you get to name it...
>>>
>>> class foo:
>>> def goo(I_AM_SELF, arg):
>>> pass
>>>
>> Cool!
>
>
>
> DO NOT DO THAT EVER!
>
> Seriously not cool.
>

Would you like to explain why not? Josiah didn't seem to have any
qualms with it.

>> Not fully implemented, but I guess that will have to suffice.
>
>
> Is there any non-trivial language which is fully implemented
> for C#?
>
Sure, why don't you utilize Google? LOL No, seriously, there are a few.

>>> Python has no static typing.
>>>
>>
>> Argg!
>
>
> This is precisely why my first reply said this question
> was way too hard to answer briefly. You claim experience with
> Smalltalk. Smalltalk has no static typing either. There
> are many essays available (and books no doubt) on all the
> nuances here. You've used Ruby -- it's the same there too.
>
I use ObjC too, grief.

>
>> I'd like to be able to use a string as an integer without an explicit
>> coerion on my part for example.
>
>
> NO! Don't do that. Bad code. Subtle errors.
>
> Try Perl or Ruby instead.
>
Now your encouraging me not to use Python?

>
>> That is quite a shame, no modules for this either huh?
>
>
> It quite depends on your expectations of what design by
> contract, protocols, etc. means. Do some research. Hint:
> Google for 'python "design by contract"' and related topics.
>
Cameron provided me a link, most excellent.

> That's why I say it's easier to just read the docs rather
> than have people give you short answers that aren't useful
> without the entire context of how Python works.
>
>
>> What I actually meant was are there any facilities (built-in or
>> modules) which allow for automatic compilation to C/C++/C#/D. For
>> example, particular Smalltalk distros compile to C as does ObjC.
>
>
> Yes. But you'll never use them. The problem you'll want
> to solve is "how do I call Python code from a ... library"
> or "how do I package Python as an executable" and not
> "how do I convert Python code into C".
>
> You are asking the wrong question. You are asking about
> technique, not goal.
>
No, no, I want the C speed.

>>>> 43. Embedding variables in strings like: print "Hello, World. Time:
>>>> #{Time.now}"
>>>
>>>
>>> t = time.asctime()
>>> print "Hello World %(t)s"%{'t':t}
>>> print "Hello World %(t)s"%locals()
>>>
>>
>> That is messy, exactly why I wanted the kind of clear embedding I
>> gave an example for. Oh well.
>
>
> You asked for "embedding variables" not embedding expressions.
> You got what you asked for, not what you wanted. That's part
> of being able to ask the right question. Remember that essay
> people suggested you read?
>
I gave a goddamn code example, grief. How much more explicit do I need be?

>> Really? Hmmmm, does anyone know of a bridge between Python and Ruby?
>
>
> Why not just use Ruby? It seems to fit your search criteria
> much better.
>
> Andrew
> dalke@dalkescientific.com

Because Python is...well...more Pythonic. I much prefer it (esp.
whitespace).



Relevant Pages

  • Re: isa keyword
    ... When the line of code above is executed, the Python virtual machine decides whether is a member of A or B, and then executed one of A.selectoror B.selectordepending on which it is. ... And now let's consider the Smalltalk example. ... Some people are still under the misapprehension that message-passing is a fundamental of object-oriented programming because of Smalltalk, ... Of course Python can create code blocks with compiler.compile, but this is not mainstream, and Python has so many more-useful mechanisms to implement program control that using code objects as data is correctly regarded as being ion the boundaries of language voodoo. ...
    (comp.lang.python)
  • Re: Python for Fortran programmers
    ... proposition for Python in the Fortran community", ... compiled language such as Fortran or C++, but I would still prefer to ... greater number of programming errors that are typically detected by a ...
    (comp.lang.fortran)
  • Re: Basic inheritance question
    ... used 'this' in C++ and Java. ... but in Python it doesn't. ... language, they would write a lot of ten liners that is changed a LOT ... Add three levels of inheritence and a couple globals and you'll find out ...
    (comp.lang.python)
  • Re: Pythons simplicity philosophy
    ... the correct Python idiom, ''.join. ... However, if you agree with Paul Graham's theories on language design, ... 'sum' itself lost substantial generality between my original ...
    (comp.lang.python)
  • Re: Is there a "Large Scale Python Software Design" ?
    ... around 20 developers, assuming colocation... ... situation with Python, yet, only with Fortran, C, C++. ... It sure beats "retrofitting" unit tests post facto. ... Jones' estimates for Java's language level; ...
    (comp.lang.python)