Quote: Onoitsu2 wrote:
I stopped using VB, and learned Lua as fast as possible.
That's understandable :D Lua > VBScript for everything that doesn't involve COM. (Afaik VBScript doesn't even have a native associative array type? Relying on a COM object to get that functionality.)
Quote: David Haley wrote:
Set behavior:
Make a table. An object is in the set if the table keyed to that object is non-nil. An object is not in the set if the table keyed to that object is nil. Pretty simple.
Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> c = set(['red', 'green', 'blue', 'blue'])
>>> c
set(['blue', 'green', 'red'])
>>> c.add('red')
>>> c.add('yellow')
>>> c
set(['blue', 'green', 'yellow', 'red'])
>>> c & set(['red', 'blue'])
set(['blue', 'red'])
>>> c | set(['red', 'black', 'white'])
set(['blue', 'green', 'yellow', 'black', 'white', 'red'])
>>> 'blue' in c
True
>>> 'mauve' in c
False
>>> len(c)
4
>>> c.issuperset(['red', 'yellow', 'blue'])
True
>>> c.issubset(['red', 'yellow', 'blue', 'green', 'purple', 'orange',])
True
>>>
Quote: David Haley wrote:
Generators:
Well, I've seen this word used to mean several things, so I'm not exactly sure what you mean. Lua has closures, and so you can return functions with 'state', e.g. a function that returns a number that grows by one every time you call it. In fact this is trivial to do.
(Example taken from the Python manual.)
Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> def counter(ul = 0):
i = 0
while ul < 1 or i < ul:
v = (yield i)
if v is not None:
i = v
else:
i += 1
>>> for i in counter(10):
print i,
0 1 2 3 4 5 6 7 8 9
>>> c = counter(10)
>>> c.next()
0
>>> c.send(5)
5
>>> for i in c:
print i,
6 7 8 9
>>>
The PEP (Python Enhancement Proposal) that described generators also includes a how-to for turning them into coroutines.
Quote: David Haley wrote:
Registry access:
Deliberately absent from standard libraries; whether or not that is a good thing depends on your needs. You would have to provide this functionality yourself (or from somebody who wrote a registry extension). But, if you had such a thing written (and I'm sure it has been already) it would be a one-liner to include it.
The _winreg library is part of Python's standard library, but then so is pwd and fcntl on *nix and Carbon on Mac OS X.
What I'd miss most of Python is the interactive mode that allows on-the-fly debugging
Quote: David Haley wrote:Syntax is one thing (I think it's a subjective preference issue, really) but you make it sound like Lua is only good for the simplest of scripting needs.
Syntax: yes and no. Most people think of syntax as a preference, but there are syntaces(?) that are objectively better than others. I haven't seen a comparison between Lua and Python. (I have seen Python vs C, C++, C#, Java, Ada and VB. Python pwnz0red. :D )
I won't say that Lua is only good for the simplest of scripting needs.
I will say that the most complicated (function points) script I could maintain in Lua would be much less complex than the most complicated script I could maintain in Python.
Quote: Shadowfyr wrote:
This also means, ironically, that half the stuff in something like the wx extensions for Python are *redundant*, in that they already exist in some fashion, if sometimes limited, in the main Python.
Tkinter requires knowing Tk. (And it is a full implementation of Tk not just "some GUI stuff".) Tkinter however produces Tk-looking components. wx produces native-looking components.
Quote: Shadowfyr wrote:
Yes, that is moderately annoying if you don't already have the library to do it. So what? It also means that you can, or someone else can, design one that does what "you" want, not what some person you never met thought it should do.
If you use "crippling" instead of "moderately annoying", I'd agree with you :P
In terms of programmer (me) effort, the difference between: (1) importing the necessary library (which is well documented); (2) finding a library that does what I want it to do (AND has adequate documentation) somewhere on the web, downloading it, getting it to work in my environment and then importing (and possibly converting between data types) and (3) hacking something together from scratch is something like (1) five minutes, (2) an hour, (3) upwards of six hours depending on complexity.
Trying to reimplement Python's _winreg in Lua (where "in Lua" may mean "in C, but with Lua bindings") could take weeks to months :P
Quote: Shadowfyr wrote:
I am sure there are .ini style configuration libraries around, since that is more cross-platform than using the registry, so unless you are doing something dangerous (and imho potentially stupid, not to mention possibly restricted under things like XP or Vista), you shouldn't need to screw with the registry anyway.
Python has ConfigParser in the standard library for reading and writing .ini files.
Though, I am wondering why you say "use an external library" (which may or may not have working cross-platform implementations) in the previous paragraph and then complaining about the portability of anything built on the registry in this paragraph.
Quote: Shadowfyr wrote:
Oh, and then there is the fact that under 95/98, the registry is buggier than a termite mound.
The Official Microsoft-Enforced Jargon for HKCU/HKLM/HKCC/HKU/HKCR is "hive(s)". Draw what conclusions you may :D |