up with PyGUI!

  • Thread starter Zooko O'Whielacronx
  • Start date
G

Greg Ewing

Hans said:
I'm not sure if the construct described above is all
that great...

For a while now I've been wondering whether Python could
benefit from an "instance" statement that works similarly
to a class statement but creates instances instead of
classes.

e.g.

class MainFrame(FrameDescription):

instance b1(ButtonDescription):
size = (40, 40)
text = "b1"

Haven't figured out all the details of how it would
work, though...
 
P

Peter Hansen

Greg said:
For a while now I've been wondering whether Python could
benefit from an "instance" statement that works similarly
to a class statement but creates instances instead of
classes.

e.g.

class MainFrame(FrameDescription):

instance b1(ButtonDescription):
size = (40, 40)
text = "b1"

Haven't figured out all the details of how it would
work, though...

I think you can probably force the current implementation to
work this way, with a little work. You'd need to *slightly*
change the above spelling though, and make sure you were
using one of the standard Python implementations and not,
say, something that didn't follow the language reference:

class MainFrame(FrameDescription):
b1 = ButtonDescription(
size = (40, 40),
text = "b1",
)

That's pretty close to what you asked for. You're welcome,
in advance. <wink>

(Actually, I suspect you wanted slightly different behaviour,
but I'm not clear on what.)

-Peter
 
P

Piet van Oostrum

GE> For a while now I've been wondering whether Python could
GE> benefit from an "instance" statement that works similarly
GE> to a class statement but creates instances instead of
GE> classes.

GE> e.g.

GE> class MainFrame(FrameDescription):

GE> instance b1(ButtonDescription):
GE> size = (40, 40)
GE> text = "b1"

How would this be different from:

b1 = ButtonDescription():
b1.size = (40, 40)
b1.text = "b1"

or from this:

def instance(klass, **kw):
inst = klass()
for k in kw:
# could add a check for __getattr__ here
inst.__dict__[k] = kw[k]
return inst

b1 = instance(ButtonDescription,
size = (40,40),
text = "b1")
 
V

Ville Vainio

Luis> Now you see China, India, Brazil and other countries that
Luis> are doing well, improving the condition of their
Luis> inhabitants, getting them out of missery and incorporating
Luis> them to the global market. Those foreigners buy american
Luis> products, now more than before because they have more money,
Lkuis> thus improving the profit of the monsters mentioned above.

What are these American products they are buying? Coca Cola and Big
Macs (which are probably locally produced)? MSFT Windows?

I don't really see a need for any American products when much cheaper
alternatives are available, from Asia and elsewhere.

However, that's all irrelevant. Corporations are going to move jobs
away from the US anyway, because it makes sense financially. If they
can save a buck, it doesn't matter if that puts 1000 (perceivedly)
overpaid americans out of their jobs. It's not like those specific
laid-off workers were using their salaries to buy the company products
in the first place.

Luis> This is the internet age. I hope that it contributes to make
Luis> the poor less poor and the rich not so rich, and maybe, in a
Luis> distant future we will have a better world for all of us.

Well, at least it contributes to making the rich (people, not
countries) much richer, while reducing the overall wealth of rich
countries. I guess it won't be the end of the world if the first world
countries can bear the burden of the resulting unemployment - it's
much more comfortable to be poor in a country that doesn't routinely
hit -20C on winters ;-).

Personally, I don't care much either way because Finland is one of
those countries with low salaries for engineers, with the unfortunate
twist of the cost of living being high as well.
 
C

Carlos Ribeiro

For a while now I've been wondering whether Python could
benefit from an "instance" statement that works similarly
to a class statement but creates instances instead of
classes.

I've done something like you want using metaclasses. I've posted it as
another thread, it was a "Call for suggestions". As you may see, I'm
still looking for more people to work with me on this solution :)
Basically what it does is to process declarations like this:

class MainFrame(FrameDescription):

class b1(ButtonDescription):
size = (40, 40)
text = "b1"

.... where FrameDescription and ButtonDescription are both derived from
a base Container class. When constructed, the MainFrame will contain
an **instance** called b1 from the class b1 (that's right, the same
name; the temporary class definition is gone). The metaclass creation
engine also respects the order of the declaration. The orderd list is
stored as a _fields member; in the case above, _fields[0] is size, and
_fields[1] is text. Note that the hash used to store attributes that
is passed to the metaclass can't work this magic alone.



--
Carlos Ribeiro
Consultoria em Projetos
blog: http://rascunhosrotos.blogspot.com
blog: http://pythonnotes.blogspot.com
mail: (e-mail address removed)
mail: (e-mail address removed)
 
C

Carlos Ribeiro

I've recently been working on a system that lets you do that kind
of thing. It's a set of metaclasses that wrap the wxPython classes so
you define your GUI with nested class structures. Certain things are
hard here because of the way class definitions are handled in Python,
but I am making progress.

I think I have solved the first half of your problem. Please check my
"Call for suggestions" post from yesterday. I implemented a Container
metaclass that can take nested class declarations and generate a
representation with a few important features:

-- it's ordered (in the same order as the original declarations in the
source code)
-- all nested classes are converted to instances

Please check it, and let me know if you're interested. I'm focusing my
work on this part now, I'm purposefully not dealing with the GUI; I
have my own ideas regarding the GUI part, but let us solve one problem
at a time, right?
If anyone's interested, you can see an example of what the GUI code
looks like at http://www.brenbarn.net/misc/idealgui.txt . This is code
that actually produces a working program with my current setup. It
won't work for anyone else, of course, because I haven't made my library
available yet. My main goal here, though, is to get it so the code
LOOKS nice, so just seeing how the code looks will give you an idea of
the style.

It seems like we're looking for similar solutions. I'm looking for
more people to start a separate discussion to avoid spamming c.l.py.
Please drop me a note if you're interested.

--
Carlos Ribeiro
Consultoria em Projetos
blog: http://rascunhosrotos.blogspot.com
blog: http://pythonnotes.blogspot.com
mail: (e-mail address removed)
mail: (e-mail address removed)
 
E

Ed Leafe

Basically what it does is to process declarations like this:

class MainFrame(FrameDescription):

class b1(ButtonDescription):
size = (40, 40)
text = "b1"

... where FrameDescription and ButtonDescription are both derived from
a base Container class. When constructed, the MainFrame will contain
an **instance** called b1 from the class b1 (that's right, the same
name; the temporary class definition is gone). The metaclass creation
engine also respects the order of the declaration.

How is this more powerful/flexible/robust than something like:

class MainForm(dabo.ui.dForm):
def __init__(self, parent=None):
self.addObject(ButtonDescription, "b1")
self.b1.Size = (40,40)
self.b1.Caption = "b1"

....which is the standard syntax in Dabo for adding objects to a form
(frame)?

___/
/
__/
/
____/
Ed Leafe
http://leafe.com/
http://dabodev.com/
 
C

Carlos Ribeiro

[...my sample...]
class MainFrame(FrameDescription):

class b1(ButtonDescription):
size = (40, 40)
text = "b1"

[...your question...]
How is this more powerful/flexible/robust than something like:

class MainForm(dabo.ui.dForm):
def __init__(self, parent=None):
self.addObject(ButtonDescription, "b1")
self.b1.Size = (40,40)
self.b1.Caption = "b1"

Ok. I'll try to answer your questions, but first some background is
needed to focus the discussion.

We can broadly define three ways to implement GUI description: (a)
Imperative, (b) Data-driven and (c) Declarative. Dabo uses a
imperative approach (as do wxPython and almost all other GUI packages
for Python). Some packages are available which take a description of
the UI and build it, using XML or some other intermediary data
representation. Glade (for GTk) works this way. I'm using a
declarative approach -- using Python native class declarations to
build the UI definition.

Why do it this way? First of all, it's an *experiment*. It's something
I'm doing because I feel that it has potential to be better than other
approaches. It's also based on my experience with other tools. Delphi
forms are stored in a intermediate format that is read by the
application; it's really data driven, but the language "reads" for the
programmer as a declarative language. It's much more readable than,
for example, a XML file or a Python dict storing the UI definition. I
also remember the old days of dBase 2 and FoxPro (for DOS), where it
was easy to build data entry screens with just a few lines of
declarations embedded in the same program, with no need to create
separate data files, etc.

What I'm trying to do is to bridge the last gap here: having a
readable declaration of the interface, written in pure Python code, in
such a way as to allow the programmer to work with a single language
all the time. As I said, there's nothing wrong with other approaches,
but I *think* that my approach will show its value once we start to
use it for day-to-day coding. I may be wrong, but why can't we try it?

DESIGN GOALS

The system is being designed for readability and flexibility. It's not
being designed to be powerful, in the sense of fine control over the
UI, but to be as simple to use as possible, and both things (power vs.
simplicity) are at odds sometimes. I'm yet to see how big a compromise
must be made.

The first part is the metacontainer engine. It's a metaclass that
handles creation of nested classes in such way as to preserve some
information that is lost when Python parses the code; namely, the
ordering of the declarations. It also converts nested classes into
instances, which is needed for later use.

This engine is totally independent of its use. You can use the engine
anytime a declarative language is useful: form design, reports,
database declarations, etc.. (In fact, the design was inspired by Ian
Bicking's sqlobject way to declare object entities; I just wanted a
way to generalize it for other stuff).

Over this engine (that is already working and is nicely encapsulated),
I'm building a generic Form class. I could be doing the same for
databases, or for reports. Everything will share the same engine and
the same way to write declarations. What will change is the base
classes used for this purpose, and the way the resulting class
definition will be used.

The class description works together with a renderer object. They
collaborate to convert the declaration of the UI into a real
representation -- for example, a wxFrame filled with all controls
needed. It's probably slower than executing code written by hand. But
it's easier to write, because the engine can handle a lot of the stuff
that has to be done manually by the programmer.

This approach is not being design for speed, but nothing prevents it
from being fast. A good part of the "black magic" is done by the
metaclass when the class declaration is first read, parsed and
byte-compiele by Python. The result of the rendering can also be
cached for later use, so it's not really needed to render it everytime
it's needed.

--
Carlos Ribeiro
Consultoria em Projetos
blog: http://rascunhosrotos.blogspot.com
blog: http://pythonnotes.blogspot.com
mail: (e-mail address removed)
mail: (e-mail address removed)
 
A

A. Lloyd Flanagan

people, with knowledge of two or more languages and with high tech
skills can aspire to pay the rent and make a living, making 4 or 5x
less than an american counterpart.
These people worked their ass off to have what they're getting now.

So did we. I certainly respect the accomplishments of programmers the
world over. However...

I think the real problem is not so much that foreign programmers are
paid less than US programmers. Instead I suspect the problem (from
our point of view) is that their cost of living is so much lower. If
I worked for the salary of an Indian programmer I would have no place
to live, no insurance, and would have a hard time buying food to take
back to my family living under a bridge.

Meanwhile the Indian programmer is living like a king (more or less).

This issue will impact a lot more professions than programming. It's
getting hard to find a function that can't be performed from the other
side of the world anymore. What the American economy can do to
respond to this I have no idea.

On the other hand maybe we should all just move to India. We could
teach them how to play football (the real kind, not that soccer
stuff).
 
J

Jorge Godoy

I think the real problem is not so much that foreign programmers are
paid less than US programmers. Instead I suspect the problem (from
our point of view) is that their cost of living is so much lower. If
I worked for the salary of an Indian programmer I would have no place
to live, no insurance, and would have a hard time buying food to take
back to my family living under a bridge.

Meanwhile the Indian programmer is living like a king (more or less).

This issue will impact a lot more professions than programming. It's
getting hard to find a function that can't be performed from the other
side of the world anymore. What the American economy can do to
respond to this I have no idea.

Do you really think that the price of the things is really what it is
worth in the US or that it is like that to keep these high salaries? ;-)

I think that this is a cyclic thing: things are expensive because they
cost more due to salaries and salaries are higher because things cost
more.

Here we had experience with several *thousands* of percents of inflation
per year (something along the lines of 800% per month, prices went up
every day). Now things are more stable. I don't know for how long...
I hope forever :)
On the other hand maybe we should all just move to India. We could
teach them how to play football (the real kind, not that soccer
stuff).

You mean the one that has the 'foot' on the name but is played with the
hands? ;-) It seems to me like there's a contradiction somewhere :)


Be seeing you,
 
N

Neuruss

What are these American products they are buying? Coca Cola and Big
Macs (which are probably locally produced)? MSFT Windows?

I don't really see a need for any American products when much cheaper
alternatives are available, from Asia and elsewhere.

Of course you are right, and I didn't say that as an absolute
statement, I just
wanted to pinpoint a trend that you can see as positive, from another
point of view.
For example, you can buy american (or european, or japanese) products
that are locally produced, but the profit goes for the corporations
(as usual).
The good news here is that at least a little part of this value goes
for the workers who made them.
When I buy a pair of Nike snickers made in Vietnam, I'm buying
american products. I'm improving the chances that those who work in
marketing, design, accountancy, or whatever sector of the company keep
on living well, and at the same time I'm sure that a few vietnamese
who work producing them will at least feed their family, which is much
better than starving.

Personally, I don't care much either way because Finland is one of
those countries with low salaries for engineers, with the unfortunate
twist of the cost of living being high as well.

You don't have to be affraid because Finland has everything to be rich
and prosperous: a transparent political system, highly educated
people, respect for law and a honest society.
 
A

Arthur

I'd just like to add a comment, not to start an endless debate on U.S
economic or trade policy...
IMHO what you are experiencing in the U.S is just another sign of the
globalization process, which is bad from an american perspective, but
good from a global one.

For too long, the industrialized countries have enjoy the power of
their competitiveness and technical inovation while, at the same time,
they have been protecting their less competitive sectors such as
agriculture and labor intensive jobs. But this situation led to a club
of rich nations isolated from a mass of third world countries, whose
primary products weren't allowed to enter the rich markets due to very
rigid policy of subsidies and trade barriers.

But how can IBM, Microsoft, HP, and all those monsters keep on growing
without selling to the so called "emerging markets"? By trading with
Mars?
If the rich want to get richer, sooner or later they will have to even
the field, allowing others to rise from missery in order to
incorporate them to the consumption society.

That's true. And generally understood. Which is perhaps why the IBMs
and Microsofts tend to play an important and productive role in
accomplishing just that. Enlightened self interest at work.

OK. So this all sounds, big picture, like win/win developments, though
with some inevitable displacement effecting some real human beings.

But what I haven't been quite able to grasp is the basis for the
sentiment of "Globalization" as a dirty word, with the U.S. (and its
evil corporations - as if corporations were something other than an
organizational structure for goal oriented human endeavor) assigned
the role of the heavy. In the more extreme forms of this viewpoint,
"the heavy" being a considerable understatement for the role assigned
the U.S. and its evil lackey corporations.

I don't think, for example, the U.S. is aggressive at all in
protecting its markets with subsidies or trade barriers. If anything
there is the argument that the U.S. should perhaps be doing more in
protecting its markets from goods being produced overseas at
artificially low costs as a result of implicit or explicit subsidies
being provided in the originating country. But being generally
liberal on these kinds of issues seems, at this time, to set the right
leadership tone, and seems to be working - so there is generally a
let-it-be attitude.

The U.S. in anything but the heavy in *my* story.

Is it just that I am a neo-Dadaist PolyAnna?

Art
 
C

Cameron Laird

.
.
.
You don't have to be affraid because Finland has everything to be rich
and prosperous: a transparent political system, highly educated
people, respect for law and a honest society.

And smoked herring. Why, someday Finland will be the kind
of place where programmers will have the talent to produce
even, say, operating systems.

Disculpeme, Luis; it's hard to stay serious as we wander so
far from the topic of Python (although I think I can, in a
pinch, related smoked herring to Python). You are right,
of course, that Finns can justly have pride and high expec-
tations for their nation.
 
O

OKB (not okblacke)

Ed said:
How is this more powerful/flexible/robust than something like:

class MainForm(dabo.ui.dForm):
def __init__(self, parent=None):
self.addObject(ButtonDescription, "b1")
self.b1.Size = (40,40)
self.b1.Caption = "b1"

...which is the standard syntax in Dabo for adding objects to a
form (frame)?

I would say that the former is a great deal more readable. In
particular, this is one case where having to use an explicit "self"
really hurts. You've already had to retype "self.b1" twice just to
specify the size and caption. What if you wanted to specify a color? A
background color? To say nothing of an event handler.

In the same vein as what Carlos Ribeiro said in another post: it's
my opinion that defining the GUI layout is a fundamentally declarative
task, and forcing the programmer to perform it in a procedural fashion
is working against the grain of the problem.

--
--OKB (not okblacke)
Brendan Barnwell
"Do not follow where the path may lead. Go, instead, where there is
no path, and leave a trail."
--author unknown
 
B

Brendan Barnwell

I think I have solved the first half of your problem. Please check my
"Call for suggestions" post from yesterday. I implemented a Container
metaclass that can take nested class declarations and generate a
representation with a few important features:

-- it's ordered (in the same order as the original declarations in the
source code)
-- all nested classes are converted to instances

My implementation essentially does this as well. However, I
have devised a metaclass (called ClassObj) that does not actually
replace the class with an instance. Instead, each class keeps a reference
to singleton instance. All attributes are stored on the class object, but
methods are forwarded to the instance (since Python won't allow you
to call methods on a class). The advantage of this is that the classes
can even be subclassed. This metaclass largely eliminates the
distinction between classes and objects; a ClassObj can effectively
function as either.
Please check it, and let me know if you're interested. I'm focusing my
work on this part now, I'm purposefully not dealing with the GUI; I
have my own ideas regarding the GUI part, but let us solve one problem
at a time, right?
It seems like we're looking for similar solutions. I'm looking for
more people to start a separate discussion to avoid spamming c.l.py.
Please drop me a note if you're interested.

I'm definitely interested. I have put my work-in-progress code up
if you want to look at it. It is at http://www.brenbarn.net/misc/gui/
(You may have to change the import statements in the files slightly; I
haven't bothered to make sure the directory structure there is the same
as on my local system.) This is obviously incomplete, but it gives an
idea of the kind of thing I am doing. Let me know what you think!
 
C

Carlos Ribeiro

My implementation essentially does this as well. However, I
have devised a metaclass (called ClassObj) that does not actually
replace the class with an instance. Instead, each class keeps a reference
to singleton instance. All attributes are stored on the class object, but
methods are forwarded to the instance (since Python won't allow you
to call methods on a class). The advantage of this is that the classes
can even be subclassed. This metaclass largely eliminates the
distinction between classes and objects; a ClassObj can effectively
function as either.

Well, it took me sometime to figure out if I should leave inner
classes as classes or instantiate them. It's funny because my approach
ends up being similar to yours -- the class is instantiated by the
metaclass, and in the process the original class declaration is lost,
which means that it turns into a singleton for all practical purposes.

The reasons why I decided to instantiate inner classes were:

1) It's easier to process the resultin class declaration, because all
attributes are instances. Before doing it I had to put some "isclass"
checks to take different actions depending on the type of the
attribute. It's not needed anymore (not to the same extent, at least).

2) The original class is not needed really for subclassing. It's not
convenient anyway, because you'ld need dot notation to find the inner
class declaration. My suggestion is that all classes that are supposed
to be subclassed can be safely declared at the top level, as in:

class i_am_a_baseclass(Container):
attr0 = "zzz"

class outer_class(Container):
class inner_class_1(Container):
attr1 = "a"
attr2 = "b"
class inner_class_1(i_am_a_baseclass):
attr3 = "r"
attr4 = "s"

As of now, I really don't know for sure which approach is better. More
experimentation is needed to check what makes more sense in the long
run not only for me (and you), but for other users having a first try
at this concept.
I'm definitely interested. I have put my work-in-progress code up
if you want to look at it. It is at http://www.brenbarn.net/misc/gui/
(You may have to change the import statements in the files slightly; I
haven't bothered to make sure the directory structure there is the same
as on my local system.) This is obviously incomplete, but it gives an
idea of the kind of thing I am doing. Let me know what you think!

Thanks for the code -- now it's really late (2:30am), and I need to
sleep... I'll try to check it tomorrow with a fresh mind.

As for my code, I've changed heavily the code that I've posted
yesterday. I've tested some alternatives and dropped parts of the
code. It's simpler and easier to reuse now. I'm debuggin some advanced
stuff now -- weird bugs pop up sometimes :p

--
Carlos Ribeiro
Consultoria em Projetos
blog: http://rascunhosrotos.blogspot.com
blog: http://pythonnotes.blogspot.com
mail: (e-mail address removed)
mail: (e-mail address removed)
 
A

Alex Martelli

Arthur said:
But what I haven't been quite able to grasp is the basis for the
sentiment of "Globalization" as a dirty word, with the U.S. (and its
evil corporations - as if corporations were something other than an
organizational structure for goal oriented human endeavor) assigned

Try Stiglitz's bestseller, "Globalization and Its Discontents" -- the
author's towering stature helps. The book focuses more on the role of
institutions such as the IMF, US-dominated though technically
international, rather than on private corporations or US's
protectionism, though (the aspects are connected, of course, but not as
directly and immediately as an oversimplification might suggest).
I don't think, for example, the U.S. is aggressive at all in
protecting its markets with subsidies or trade barriers. If anything

I do, and it appears to me that such bodies as NAFTA and WTO agree. The
US's so-called "antidumping" policies are a particular bone of
contention.

NAFTA's panel recently decreed, after a fight that lasted years, that
there is no subsidy of Canada's soft wood exports to the US, so the US
long-standing antidumping duties were illegal. The US Dept of Commerce
basically agreed (they won't appeal, they say) -- but the duties remain.

I'm surely not the only observer to see this as the behavior of a
playground bully: what's Canada gonna do about it, take a clue from the
South Park movie?! In such a case the US is basically stating, "we're
the 500-pounds gorilla, rules apply to lesser countries, not us, so
there". And that's wrt their closest neighbor and friend -- AND for
incredibly myopic reasons too. Canada's cheap wood obviously HELPS
crucial US industries such as construction (US house construction uses
MUCH more wood than we do in Europe)... but the wood-loggers' lobby is
strong enough in a key swing state, Oregon (and to some extent
Washington, too, I believe), to perhaps swing the next presidental
election, if it's as close as many think... so, forget the rules and all
the nice words, might makes right.

_Some_ US observers are clear-sighted enough to see how much hate this
kind of behavior builds up in the world over the years. But obviously
not enough.

The cases of cotton and sugar, with subsidies and help from tariffs
amounting to over 100,000 dollars per each of the few thousands of lucky
US cotton and sugar growers who benefit from it, are other good
examples. They're likely to end up in front of the WTO, but it doesn't
really matter because there, for once, the US isn't even _claiming_ an
antidumping issue. Similarly for the huge hidden subsidy to growers of
fruit and even rice (!) in the parched fields of Southern California in
terms of essentially free water in ridiculous quantities (that's
unlikely to become a trade/subsidy issue, but with good water growing
scarcer in the region it's been causing tension with Mexico for a while,
and the tension is growing) - and at a time when millions of Californian
in cities have had problems with water scarcity, too.

In each case, the US does damage to its international "public relation",
to the cause of free trade, AND to a large number of its citizens, in
order to lavish largesse on small, lucky, politically powerful lobbies.

The pattern keeps repeating. Consider the "steel antidumping tariffs"
that your President imposed, then removed -- they damaged your ailing
manufacturing sector (cars and other machinery foremost) and a part of
the construction industry (for those buildings that use substantial
amounts of steel) much more than they helped steel smelters who were in
any case being revived by such strokes of luck as China's insatiable
appetite for steel (which raises worldwide steel prices). The WTO had
little trouble in decreeing that there was absolutely no dumping
involved, i.e., as usual, the US was brandishing "anti-dumping" as an
excuse to play internal electoral politics -- what distinguished this
case was that the political calculations were wrong (the votes to be won
by sucking up to steel producers are in fact fewer than those to be lost
by seriously enraging the manufacturing sector -- both constituencies
being concentrated in the mid-west, more or less).

there is the argument that the U.S. should perhaps be doing more in
protecting its markets from goods being produced overseas at
artificially low costs as a result of implicit or explicit subsidies
being provided in the originating country.

Yeah, right. Tell that to the WTO and NAFTA panels which keep finding
out (over and over and OVER again) that US "antidumping" is invariably
barely veiled protectionism.
But being generally
liberal on these kinds of issues seems, at this time, to set the right
leadership tone, and seems to be working - so there is generally a
let-it-be attitude.

You appear to be unaware of the ill-will and even hate that such issues
as your protectionist attacks against, e.g., Canadian wood, etc,
generate in the countries you thus attack.
The U.S. in anything but the heavy in *my* story.

The US's glaring faults do not mean that other countries are blameless,
far from it. Agricultural subsidies and barriers in Japan and Europe
are horrid, and, again, they damage their own citizens as well as
international trade, all to help a few favourites. And all sorts of
barriers are highest (and most damaging to their own citizens) in poor
countries, mostly against primary goods produced in other poor
countries. But, e.g., Kenya's absurd tariffs against maize didn't tend
to raise international alarm, even though they starved poor children
(even worse than adults) in Turkana or Baringo -- apart from a few of us
crazies who READ the FAO reports, most people around the world didn't
even _hear_ about the whole issue. And the trend in Japan and Europe
appears to be improving (in fits and starts, admittedly, and there may
be regression now that the EU has been joined by one large country with
MANY agricultural-based voters, Poland), while the US trend with the
present administration seems definitely negative. (The Clinton
administration _spoke_ with a lot of bluster and rhetoric that often
sounded anti-free-trade, which may have helped it in internal politics
but surely damaged international perception of the US, but its actual
_actions_ overall were more favourable than damaging to free trade).

Is it just that I am a neo-Dadaist PolyAnna?

Your perception appears to be congruent with that of the mass of US
voters. But try reading, e.g., the Economist magazine for a few years:
it's one source which you definitely can't suspect of a-priori
anti-americanism or anti-capitalism, but DOES wave an unfailing banner
for free trade (the magazine was founded to champion free trade in the
19th century, and on that one aspect it has never wavered). The news
and analyses you will read there may help you see the different
perspectives from which others see US behavior -- particularly
interesting, I hope, as being based on actual facts and sound economic
analysis, as opposed to the instinctive anti-Americanism that one can
observe in so many places.


Alex
 
C

Cameron Laird

.
.
.
South Park movie?! In such a case the US is basically stating, "we're
the 500-pounds gorilla, rules apply to lesser countries, not us, so
there". And that's wrt their closest neighbor and friend -- AND for
incredibly myopic reasons too. Canada's cheap wood obviously HELPS
crucial US industries such as construction (US house construction uses
MUCH more wood than we do in Europe)... but the wood-loggers' lobby is
strong enough in a key swing state, Oregon (and to some extent
Washington, too, I believe), to perhaps swing the next presidental
election, if it's as close as many think... so, forget the rules and all
the nice words, might makes right.

_Some_ US observers are clear-sighted enough to see how much hate this
kind of behavior builds up in the world over the years. But obviously
not enough.

The cases of cotton and sugar, with subsidies and help from tariffs
amounting to over 100,000 dollars per each of the few thousands of lucky
US cotton and sugar growers who benefit from it, are other good
examples. They're likely to end up in front of the WTO, but it doesn't
really matter because there, for once, the US isn't even _claiming_ an
antidumping issue. Similarly for the huge hidden subsidy to growers of
fruit and even rice (!) in the parched fields of Southern California in
terms of essentially free water in ridiculous quantities (that's
unlikely to become a trade/subsidy issue, but with good water growing
scarcer in the region it's been causing tension with Mexico for a while,
and the tension is growing) - and at a time when millions of Californian
in cities have had problems with water scarcity, too.
.
.
.
While we're piling on, Alex, let's review the political message
this conveys to third-world citizens: involve yourself in
terrorism and/or drug trafficking, and the US pays attention,
and spreads money around; but clean up your economy, promote
civic improvement, hold just elections, institute the rule of
law, and (as has more or less happened throughout the Caribbean,
Egypt, Chile, Sri Lanka, various African countries, ...) the US
will be sure to slap you down for threatening its sugar or
textile or produce or programming or ... protectorates. Is
"Globalization" just advertising for a refinement of imperialism?
Of course not, to those of us fundamentally aligned with the
progressivism on display in, to echo your example, *The Econo-
mist*. At the same time, US external political policies could
hardly do more to convince the world *the US believes this
reactionary claptrap*. It makes one weep.

I struggle to bring this all back on-topic. Mention of <URL:
http://www.pbs.org/cringely/pulpit/pulpit20040923.html > is my
current attempt.
 
A

Alex Martelli

Cameron Laird said:
"Globalization" just advertising for a refinement of imperialism?
Of course not, to those of us fundamentally aligned with the
progressivism on display in, to echo your example, *The Econo-

Amartya Sen's book is another excellent display of that "of course not".

Some people have taken Stiglitz's and Sen's books as "warring
Nobel-laureate economists con vs pro globalisation", but that's silly.
Rather, Stiglitz focuses more on some ugly aspects of what parts of the
globalisation process have actually BEEN; Sen, more on the sunny parts
and on what they COULD and SHOULD be.

I'm sure Sen and Stiglitz actually agree on FAR more than what they
disagree on -- unfortunately, it's likely to be stuff the average
street-demonstration participant, laid-off worker, or elected politician
can't possibly understand, unless they take a few years off to get the
needed background, starting with differential equations and moving up
from there;-).
I struggle to bring this all back on-topic. Mention of <URL:
http://www.pbs.org/cringely/pulpit/pulpit20040923.html > is my
current attempt.

Tx for the pointer. DMCA _is_ truly scary. OTOH, one _can_ devotely
pray that MS is overplaying their hand, just like IBM did not all THAT
long ago with their proprietary "token rings", OS/2, and
"microchannels"... IBM almost managed to destroy _itself_ that way,
though Gerstner was there to save it from the brink...

And yes, if emerging third-world nations aren't making sure there's Open
Source for everything they can possibly need, the only explanation must
be the high level of corruption in their polities. It's the only
sensible strategy on any political and economic plane, after all.


Alex
 
E

Ed Leafe

You've already had to retype "self.b1" twice just to
specify the size and caption. What if you wanted to specify a color?
A
background color? To say nothing of an event handler.

Obviously, if things were that complex, you could set a reference to
the button and use that reference instead of the 'self' construct.

class MainForm(dabo.ui.dForm):
def __init__(self, parent=None):
self.addObject(ButtonDescription, "b1")
btn = self.b1
btn.Size = (40,40)
btn.Caption = "b1"


There is also nothing to prevent you from writing that button as a
class definition (although I have a personal dislike of a 'class' being
used for an instance). Something like:

class MainForm(dabo.ui.dForm):
def __init__(self, parent=None):
class btn1(ButtonDescription):
Size = (40, 40)
Caption = "b1"
self.addObject(btn1, "b1")

To my eye, that's a lot uglier than writing it as it is: instance
coding. Dressing it up as a class in order to save typing 'self' isn't
justified, IMO.

___/
/
__/
/
____/
Ed Leafe
http://leafe.com/
http://dabodev.com/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top