New to Python: Features
Richard Blackwood
richardblackwood at cloudthunder.com
Tue Oct 5 02:40:16 EDT 2004
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 at dalkescientific.com
Because Python is...well...more Pythonic. I much prefer it (esp.
whitespace).
More information about the Python-list
mailing list