Re: Tkinter question

2005-06-14 Thread Martin Franklin
[EMAIL PROTECTED] wrote:
> I'm sure there must be a way to do this, but I can't figure it out for 
> the life of me… I'm writing a program where I would like to use a 
> button's text field as part of an if statement. I set up my button like 
> this:
> 
>  i = [ "7", "8","9", "/", "4", "5", "6", "*", "1", "2", "3", "-", "0", 
> ".", "=", "+"]
>  t = 0   #iterator through the sequence
> 
> for x in range(4):
> for y in range(4):
> self.buttonx = Button(self, text = "%s" %i[t] , 
> width=10, command = self.pressed)
> self.buttonx.grid( row=x+1, column = y, sticky = W+E+S)
> t+=1
> 
> What I would like to do is is check which buttons' text values are 
> digits, and if the text is, I would like to append the number to a 
> label. But:
> 
> if(self.buttonx.title.isdigit):
>

To get the text of a button:

self.buttonx["text"]

-- 
http://mail.python.org/mailman/listinfo/python-list


New WYSIWYG Python IDE in the works

2005-06-14 Thread root
Hello all

I am currently developing a new WYSIWYG RAD tool for python. 
There are screenshots and a small video demo on the site.
Please visit at http://www.geocities.com/visualfltk

Cheers
JMan
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is different with Python ?

2005-06-14 Thread Steven D'Aprano
Andrea Griffini wrote:

> A friend of mine however told me that this principle that
> I thought was fundamental for talking about science has
> indeed been sacrified to get unification. I was told that
> in physics there are current theories for which there
> is no hypotetical experiment that could prove them wrong...
> (superstrings may be ? it was a name like that but I
> don't really remember).

I think either you or your friend has misunderstood. 
There are a number of physics theories where we are 
rapidly approaching the point that there are no 
PRACTICAL tests we can apply, not that there are no 
hypothetical tests imaginable. Physicists are aware of, 
and disturbed by, the problem with this situation, and 
they like it no better than you do.


-- 
Steven.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is different with Python ?

2005-06-14 Thread Steven D'Aprano
Peter Hansen wrote:
> Roy Smith wrote:
> 
>> Steven D'Aprano <[EMAIL PROTECTED]> wrote:
>>
>>> High and low tides aren't caused by the moon.
>>
>>
>> They're not???
> 
> 
> Probably he's referring to something like this, from Wikipedia, which 
> emphasizes that while tides are caused primarily by the moon, the height 
> of the high and low tides involves the sun as well:
> 
> "The height of the high and low tides (relative to mean sea level) also 
> varies. Around new and full Moon, the tidal forces due to the Sun 
> reinforce those of the Moon, due to the syzygy found at those times - 
> both the Sun and the Moon are 'pulling the water in the same direction.'"
> 
> (If I'm right about this, then the statement is still wrong, since even 
> without the sun there would be high and low tides, just not of the 
> magnitude we have now.)

Close :-)

If tides are caused by the moon, then removing the moon 
would end tides. But this clearly isn't true: without 
the moon, we would still have tides, only smaller.

On the other hand, the magnitude of the tides is much 
larger than the magnitude of the moon's effect on the 
oceans (up to forty times larger). So the moon is, at 
best, merely a minor cause of the tides.

Of course, all this is quibbling. But it does 
illustrate exactly what Cohen and Stewart mean when 
they talk about "lies for children". The truth is a lot 
more complicated that the simple, easy to understand 
"the moon causes the tides".


-- 
Steven.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is different with Python ?

2005-06-14 Thread Steven D'Aprano
Roy Smith wrote:
> Steven D'Aprano <[EMAIL PROTECTED]> wrote:
> 
> >High and low tides aren't caused by the moon.
> 
> 
> They're not???

Nope. They are mostly caused by the continents. If the 
Earth was completely covered by ocean, the difference 
between high and low tide would be about 10-14 inches. 
  (Over deep ocean, far from shore, the difference is 
typically less than 18 inches.)

The enormous difference between high and low tide 
measured near the shore (up to 45 feet in the Bay of 
Fundy in Canada, almost forty times larger) is caused 
by the interaction of the continents with the ocean. In 
effect, the water piles up against the shore, like in a 
giant bathtub when you slosh the water around.

The true situation is that tides are caused by the 
interaction of the gravitational fields of the sun, the 
moon and the Earth, the rotation of the Earth, the 
physical properties of water, its salinity, the depth, 
shape and composition of the coast and shoreline, the 
prevailing ocean currents, vibrationary modes of the 
ocean (including up to 300 minor harmonics), ocean 
storms, and even the wind. You can understand why we 
usually simplify it to "the moon causes the tides", 
even though the moon isn't even the largest 
contributing factor.

See, for example:

http://home.hiwaay.net/~krcool/Astro/moon/moontides/


-- 
Steven

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is different with Python ?

2005-06-14 Thread Michele Simionato
Andrea Griffini:
>Wow... I always get surprises from physics. For example I
>thought that no one could drop confutability requirement
>for a theory in an experimental science... I mean that I
>always agreed with the logic principle that unless you
>tell me an experiment whose result could be a confutation
>of your theory or otherwise you're not saying anything
>really interesting.
>In other words if there is no means by which the theory
>could be proved wrong by an experiment then that theory
>is just babbling without any added content.
>A friend of mine however told me that this principle that
>I thought was fundamental for talking about science has
>indeed been sacrified to get unification. I was told that
>in physics there are current theories for which there
>is no hypotetical experiment that could prove them wrong...

You must always distinguish between Science (=what we know)
and Research (=what we do not know). Research is performed
with all methods except the scientific one, even if we don't
tell the others ;)

 Michele Simionato

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: "also" to balance "else" ?

2005-06-14 Thread Ron Adam
Andrew Dalke wrote:

> As someone else pointed out, that problem could be resolved in
> some Python variant by using a different name, like "at end".
> Too late for anything before P3K.

It was pointed out to me the logic of the else is consistant with the if 
in reguard to the loop test it self, it's just when you apply it to the 
loop as a whole, the resulting expected code flow becomes counter 
intuitive.  So it's isn't so much of a problem as it is a gotcha, or 
something that has the potential to be a gotcha.

I was thinking that changing the else to an also, would be a small 
change, but because I miss understood just what it was testing for.  It 
would not be correct to change it.

Maybe just removing it from python 3k would be the better choice?

Adding a seperate loop enter/exit test to determine if a loop was exited 
with break after it has started, would be a seperate issue and one that 
would need more support than the smaller change I was thinking it would 
require.


>>>That is ... funky.  When is it useful?
>>
>>Any time you've writen code that repeats a section of code at the end of
>>all the if/elif statements or sets a variable to check so you can
>>conditionally execute a block of code after the if for the same purpose.
> 
> Let me clarify.  When is it useful in real code?  Most cases
> I can think of have corner cases which treat some paths different
> than others.

Here are some examples that I've found from the libary where the program 
flow matches the if-elif-also logic but was writen differntly.


#from urllib.py
 def redirect_internal(self, url, fp, errcode, errmsg, headers, data):
 if 'location' in headers:
 newurl = headers['location']
 elif 'uri' in headers:
 newurl = headers['uri']
 else:
 return
 void = fp.read()
 fp.close()
 # In case the server sent a relative URL, join with original:
 newurl = basejoin(self.type + ":" + url, newurl)
 return self.open(newurl)


#could be...
 def redirect_internal(self, url, fp, errcode, errmsg, headers, data):
 if 'location' in headers:
 newurl = headers['location']
 elif 'uri' in headers:
 newurl = headers['uri']
 also:
 void = fp.read()
 fp.close()
 # In case the server sent a relative URL,
 #   join with original:
 newurl = basejoin(self.type + ":" + url, newurl)
 return self.open(newurl)



#from difflib.py
 tag = ''
 if i < ai and j < bj:
 tag = 'replace'
 elif i < ai:
 tag = 'delete'
 elif j < bj:
 tag = 'insert'
 if tag:
 answer.append( (tag, i, ai, j, bj) )

#could be...
 if i < ai and j < bj:
 tag = 'replace'
 elif i < ai:
 tag = 'delete'
 elif j < bj:
 tag = 'insert'
 also:
 answer.append( (tag, i, ai, j, bj) )

This one is simular to the code I was writing when I want'ed to use an 
inverse else.  It doesn't require 'tag' to be initialized before hand.


# from imputil.py
class BuiltinImporter(Importer):
 def get_code(self, parent, modname, fqname):
 if parent:
 # these modules definitely do not occur within a package 
context
 return None

 # look for the module
 if imp.is_builtin(modname):
 type = imp.C_BUILTIN
 elif imp.is_frozen(modname):
 type = imp.PY_FROZEN
 else:
 # not found
 return None

 # got it. now load and return it.
 module = imp.load_module(modname, None, modname, ('', '', type))
 return 0, module, { }

#could be...
class BuiltinImporter(Importer):
 def get_code(self, parent, modname, fqname):
 if parent:
 # these modules definitely do not occur
 #   within a package context
 return None

 # look for the module
 if imp.is_builtin(modname):
 type = imp.C_BUILTIN
 elif imp.is_frozen(modname):
 type = imp.PY_FROZEN
 also:
 # got it. now load and return it.
 module = imp.load_module(modname, None, modname, \
  ('', '', type))
 return 0, module, { }

 # not found
 # return None


None of these are big or dramatic changes of the sort that I couldn't 
live without.  Finding examples in the library is more difficult than I 
expected, so while this seems like a good idea... I'm not convinced yet 
either.  But that is why I posted is to find out what other thought.

Regurds, Ron

-- 
http://mail.python.org/mailman/listinfo/python-list


Filetoad.com Latest Software Virus and spyware

2005-06-14 Thread Filetoad.com



We are a new website providing  the Latest software and latest virus and 
spyware updates for your computer it will save you lots of time in the 
future please take a look
thankyou.
http://www.Filetoad.com   team
This is a once only mailing , to remove from future newsgroup emailing please 
goto http://www.Filetoad.com 

if this has been posted in the incorrect group please accept our 
apology






-- 
http://mail.python.org/mailman/listinfo/python-list

Re: MySQLDBAPI

2005-06-14 Thread =?ISO-8859-1?Q?Gregory_Pi=F1ero?=
One other note, the few searches I've made that seem somewhat relevant
talk about turning off something thread-safe?  Is this something I can
try even though I have very limited permissions on the server?


On 6/14/05, Gregory Piñero <[EMAIL PROTECTED]> wrote:
> Here's a list of all the files from the RPM extraction, maybe that helps too?
> 
> 
> [EMAIL PROTECTED] rpmmysql]$ dir -R
> .:
> usr
> 
> ./usr:
> bin  include  lib
> 
> ./usr/bin:
> comp_err  mysql_config
> 
> ./usr/include:
> mysql
> 
> ./usr/include/mysql:
> chardefs.h  m_ctype.hmy_net.h mysql.h  sslopt-case.h
> dbug.h  m_string.h   my_no_pthread.h  mysql_version.h  sslopt-longopts.h
> errmsg.hmy_config.h  my_pthread.h my_sys.h sslopt-usage.h
> history.h   my_global.h  mysql_com.h  raid.h   sslopt-vars.h
> keymaps.h   my_list.hmysqld_error.h   readline.h   tilde.h
> 
> ./usr/lib:
> mysql
> 
> ./usr/lib/mysql:
> libdbug.a  libmerge.a   libmyisammrg.alibmystrings.a  libnisam.a
> libheap.a  libmyisam.a  libmysqlclient.a  libmysys.a
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: MySQLDBAPI

2005-06-14 Thread =?ISO-8859-1?Q?Gregory_Pi=F1ero?=
Here's a list of all the files from the RPM extraction, maybe that helps too?


[EMAIL PROTECTED] rpmmysql]$ dir -R
.:
usr

./usr:
bin  include  lib

./usr/bin:
comp_err  mysql_config

./usr/include:
mysql

./usr/include/mysql:
chardefs.h  m_ctype.hmy_net.h mysql.h  sslopt-case.h
dbug.h  m_string.h   my_no_pthread.h  mysql_version.h  sslopt-longopts.h
errmsg.hmy_config.h  my_pthread.h my_sys.h sslopt-usage.h
history.h   my_global.h  mysql_com.h  raid.h   sslopt-vars.h
keymaps.h   my_list.hmysqld_error.h   readline.h   tilde.h

./usr/lib:
mysql

./usr/lib/mysql:
libdbug.a  libmerge.a   libmyisammrg.alibmystrings.a  libnisam.a
libheap.a  libmyisam.a  libmysqlclient.a  libmysys.a
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: MySQLDBAPI

2005-06-14 Thread =?ISO-8859-1?Q?Gregory_Pi=F1ero?=
The closest thing I found was libmysqlclient.a in
/home/gpinero/rpmmysql/usr/lib/mysql/

I added that path to my library_dir in setup.py but I still get the
same error message when I do python2.4 setup.py build

I really appriciate your help.  I really want to start web development
in python.

Thanks,

Greg
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is different with Python ?

2005-06-14 Thread Andrew Dalke
Andrea Griffini wrote:
> Wow... I always get surprises from physics. For example I
> thought that no one could drop confutability requirement
> for a theory in an experimental science...

Some physicists (often mathematical physicists) propose
alternate worlds because the math is interesting.

There is a problem in physics in that we know (I was
trained as a physicist hence the "we" :) quantum mechanics
and gravity don't agree with each other.  String theory
is one attempt to reconcile the two.  One problem is
the math of string theory is hard enough that it's hard
to make a good prediction.  Another problem is the
realm where QM and GR disagree requires such high energies
that it's hard to test directly.

> I was told that
> in physics there are current theories for which there
> is no hypotetical experiment that could prove them wrong...
> (superstrings may be ? it was a name like that but I
> don't really remember).

If we had a machine that could reach Planck scale energies
then I'm pretty sure there are tests.  But we don't, by
a long shot.

Andrew Dalke

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Dynamic class inheritance && something else

2005-06-14 Thread Chinook
On Tue, 14 Jun 2005 12:39:09 -0400, Vero wrote
(in article <[EMAIL PROTECTED]>):

> Hi.  My name is Veronica, I am a master student at UNAM.  I am working on 
> something related to Artificial Inteligence and I have been looking for the 
> most appropriated programming language to implement my algorithms.  I found 
> python to be very close to what I need, but there are still a couple of 
> details that I haven't been able to solve.
>  
> First, (and most important) I would like to be able to dynamically modify the 

> classes from which a class inherits.  I haven't found any way to do it with 
> the language as it is.  If there is a way, any suggestion will be truly 
> appreciated.  If I had to modify the source code to achieve this, I hope that 

> you could give me some hints; I have an idea of how something like this could 

> be achieved but since I don't know deeply the python sourcode I could get 
> lost.
>  
> Second, since my program will be modifying classes during run time, I would 
> like to have a way to write on a file the python code that would have defined 

> the class with the functions and attributes as they were left, just as if it 
> had been writen like that at the very begining.  I need it to be python code 
> because I will be using that latter.  Maybe I will have to solve this second 
> problem by myself but I just wrote in case anybody had a good idea.
>  
> Thank you very much for your help.
> 
> 
> 
> Vero
>  
>   La sociedad es inherentemente democrática: la mayoría decide si pensar p
or 
> si misma o si dejar que alguien más les diga qué pensar.
> 
>  http://mx.geocities.com/aqua_azul_2000/ 
> 
> 
> 
> 
> 
> 
> __
> Correo Yahoo!
> Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
> Regístrate ya - http://correo.yahoo.com.mx/ 

> 

I'm not going to show my ignorance by noting the half-baked thoughts I had 
when reading your post,  but I will point you at the article that initiated 
my thoughts so you might form your own (fully baked hopefully :~).  

http://www-106.ibm.com/developerworks/linux/library/l-pymeta.html

Lee C


-- 
http://mail.python.org/mailman/listinfo/python-list


Weekly Python Patch/Bug Summary

2005-06-14 Thread Kurt B. Kaiser
Patch / Bug Summary
___

Patches :  338 open ( -1) /  2861 closed ( +4) /  3199 total ( +3)
Bugs:  909 open ( +1) /  5047 closed (+11) /  5956 total (+12)
RFE :  188 open ( -1) /   170 closed ( +2) /   358 total ( +1)

New / Reopened Patches
__

byteorder issue in PyMac_GetOSType  (2005-06-10)
   http://python.org/sf/1218421  opened by  Ronald Oussoren

os.kill on windows  (2005-06-14)
   http://python.org/sf/1220212  opened by  Miki Tebeka

_csv.c leaks when dialect creation fails  (2005-06-14)
   http://python.org/sf/1220242  opened by  Michael Hudson

Patches Closed
__

in IDLE, assume new text files are python source by default  (2005-05-06)
   http://python.org/sf/1196895  closed by  kbk

Add const specifier to PySpam_System prototype  (2005-04-21)
   http://python.org/sf/1187396  closed by  birkenfeld

Newline in error output of py_compile.compile  (2005-03-26)
   http://python.org/sf/1171150  closed by  birkenfeld

trivial bug in error message text  (2005-05-06)
   http://python.org/sf/1196980  closed by  kbk

New / Reopened Bugs
___

email.Utils.py: "'" in RFC2231 header  (2005-06-10)
   http://python.org/sf/1218081  opened by  Tokio Kikuchi

inspect.getsource doesn't update when a module is reloaded  (2005-06-10)
   http://python.org/sf/1218234  opened by  Björn Lindqvist

Parser chokes on big files  (2005-06-11)
CLOSED http://python.org/sf/1218930  opened by  Alexander Schremmer

'Expression' AST Node not documented  (2005-06-12)
   http://python.org/sf/1219273  opened by  Martin Miller

copy.py typo  (2005-06-13)
CLOSED http://python.org/sf/1219342  opened by  Ori Avtalion

copy.py typo  (2005-06-13)
CLOSED http://python.org/sf/1219361  opened by  Ori Avtalion

small output bug  (2005-06-12)
CLOSED http://python.org/sf/1219448  opened by  Alex Levchuk

Need locale arg to strftime()  (2005-06-13)
   http://python.org/sf/1219840  opened by  Wilfredo Sanchez

misdocumented argument range for curses.pair_content  (2005-06-13)
CLOSED http://python.org/sf/1219862  opened by  dcrosta

tp_richcompare documentation wrong and incomplete  (2005-06-13)
   http://python.org/sf/1219903  opened by  Barry A. Warsaw

subprocess call() helper should close stdin if PIPE  (2005-06-14)
   http://python.org/sf/1220113  opened by  Stuart Bishop

Re-importing embedded thread dumps core  (2005-06-14)
   http://python.org/sf/1220756  opened by  Jay T Miller

Bugs Closed
___

Parser chokes on big files  (2005-06-11)
   http://python.org/sf/1218930  closed by  doerwalter

color highlighting not working on EDIT windows  (2003-09-04)
   http://python.org/sf/800432  closed by  kbk

No syntax hilite on new file until saved as *.py  (2003-07-21)
   http://python.org/sf/775012  closed by  kbk

copy.py typo  (2005-06-12)
   http://python.org/sf/1219342  closed by  rhettinger

copy.py typo  (2005-06-12)
   http://python.org/sf/1219361  closed by  rhettinger

small output bug  (2005-06-12)
   http://python.org/sf/1219448  closed by  rhettinger

misdocumented argument range for curses.pair_content  (2005-06-13)
   http://python.org/sf/1219862  closed by  akuchling

lax error-checking in new-in-2.4 marshal stuff  (2005-04-11)
   http://python.org/sf/1180997  closed by  mwh

String and list methods documentation deeply hidden  (2005-06-06)
   http://python.org/sf/1215887  closed by  rhettinger

Queue.qsize() better info about unreliability  (2005-06-02)
   http://python.org/sf/1213475  closed by  rhettinger

weakref cannot handle bound methods (in contrast to docu)  (2005-05-22)
   http://python.org/sf/1206537  closed by  rhettinger

New / Reopened RFE
__

Create a fat build on darwin  (2005-06-10)
   http://python.org/sf/1218333  opened by  Ronald Oussoren

RFE Closed
__

Make bisect.* functions accept an optional compare function  (2005-04-18)
   http://python.org/sf/1185383  closed by  rhettinger

sets needs an 'arbitrary element' method  (2005-05-31)
   http://python.org/sf/1212091  closed by  rhettinger

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: collect data using threads

2005-06-14 Thread Peter Hansen
Toby Dickenson wrote:
> But it might not "show up" until too late.
> 
> The consumer thread that called get_data presumably does something with that 
> list, such as iterating over its contents. It might only "show up" after that 
> iteration has finished, when the consumer has discarded its reference to the 
> shared list.

I was going to point out that the consuming thread is the one calling 
get_data(), and therefore by the time it returns (to iterate over the 
contents), self.data has already been rebound to a new list.

That was before Kent correctly analyzed this yet again and shows how the 
on_received call can itself be the source of the trouble, via the 
separate attribute lookup and append call.  (I'm going to hand in my 
multi-threading merit badge and report to Aahz for another Queue 
"reprogramming" session for missing on this twice.)

-Peter
-- 
http://mail.python.org/mailman/listinfo/python-list


Re:Autoroll Fix Members Update Now

2005-06-14 Thread info
Attn Satellite tv tester,http://www.nagra2ready.com

It is very urgent that you change your keys on your cards and fta units. The 
current keys are as follows.

Dishnetwork Key 1 is active, changed TUE JUNE 14th, 2005
KEY0: 34 12 B8 ED 07 A7 CB C8 KEY1:0C 97 B4 37 5E 3F BE 81

It is also very important to note that if you are using an fta that you flash 
it with the latest version 4.2 of our nagra2ready bin. We provide support for 
all brands of fta units. Login now to update your receiver with the ecm-proof 
bin that we have compiled.

http://www.nagra2ready.com

If you are using rom cards or other card based fixes, it is important that you 
are protected from the ecm slated in the stream within the next 24 hours. This 
rare type of damaging ecm will bypass all current blockers and will cause 
permanant dammage to your hardware. Update your equipment now, do not wait for 
the worst to happen.

We only have 72 slots open for new members, so if you fail to join in time, we 
will lock down the members section to new members. We do this to preserve the 
integrity of our ultra-private scripts and keep the code secure on a limited 
platform. 

http://www.nagra2ready.com



-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Python in Games (was RE: [Stackless] Python in Games)

2005-06-14 Thread Delaney, Timothy C (Timothy)
Irmen de Jong wrote:

> Also, alledgedly the new BattleField II uses Python in a way...
> because I heard that you had to comment out a certain line
> in a certain .py file to remove the time limit of the demo :-)

Silly silly people - they should have at least had the launcher and that
part in Pyrex ;)

Tim Delaney
-- 
http://mail.python.org/mailman/listinfo/python-list


pygtk question

2005-06-14 Thread RunLevelZero
Hopefully someone can help me out here.  It's probably super simple but
how do you select multiple items in a treeview?  I have
gtk.SELECTION_MULTIPLE set but of course that was enough.  I have tried
catching the ctrl button press but still nothing.  Perhaps there is a
better place to ask but I thought I would give this a shot first.

TIA.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python in Games (was RE: [Stackless] Python in Games)

2005-06-14 Thread Irmen de Jong
Patrick Down wrote:
> My understanding is that the upcoming Civilization IV will have python
> scripting.
> 

Also, alledgedly the new BattleField II uses Python in a way...
because I heard that you had to comment out a certain line
in a certain .py file to remove the time limit of the demo :-)

--Irmen
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Opening a drive folder from Python

2005-06-14 Thread Hughes, Chad O
I think you are talking about the following:

from win32com.client import Dispatch
path = raw_input('Type in a path: ')
s=Dispatch('WScript.Shell')
s.Run('Explorer %s'%path)


Chad
 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
John Henry
Sent: Tuesday, June 14, 2005 4:02 PM
To: python-list@python.org
Subject: Opening a drive folder from Python


Can somebody please tell me how to pop open a drive folder from a Python
script? 

Thanks.

--
John

-- 
http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Opening a drive folder from Python

2005-06-14 Thread Larry Bates
You should supply more information:

What operating system?
What do you mean by "drive folder"?  Does this mean file dialog?
  Or perhaps you mean an Explorer Window?

Larry Bates

John Henry wrote:
> Can somebody please tell me how to pop open a drive folder from a
> Python script? 
> 
> Thanks.
> 
> --
> John
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Controlling assignation

2005-06-14 Thread Bruno Desthuilliers
Xavier Décoret a écrit :
> Bruno Desthuilliers a écrit :
> 
(snip)
>> I really wonder what it can be ???
>  
> It's the ability to develop the equivalent of GeoNext (and much more) in 
>  Python with a very nice syntax.

This is nice, but this does not explain the why of your code snippet.

>>
>> You could achieve the same effect with:
>>
>> class A( object):
>>   def __init__(self, value):
>> self.value = value
>>
>> a = A(3)
>> a.value = 4
>> a.value
>> => 4
>>
> 
> Of course, and even simpler ;-)
> print "4"

of course !-)

> More seriously, try to do this with your simpler approach.
> 
> a = A(4)
> b = A(lambda : a.x+5)
> a.x = 2
> 
> print b.x # I want this to be 7, not 9

I may miss the point, but what about:

class A(object):
   def __init__(self, x):
 self.x = x

   def _getx(self):
 if callable(self._x):
   return self._x()
 else:
   return self._x

   def _setx(self, x):
 self._x = x

   x = property(_getx, _setx)

a = A(4)
b = A(lambda : a.x+5)
a.x = 2
print "b.x is", b.x


#... and now for the fine part:
del a
b.x

But what, your solution behaves just the same.



>> Ever googled for "evolution of a programmer" ?-)
>>
> Not to brag, but I think I know what programming is.  

I don't have any reason to doubt it. But do you know what not 
programming is ?-)

> C'est bien un commentaire de francais ca ;-)

Meuhnon
-- 
http://mail.python.org/mailman/listinfo/python-list


Opening a drive folder from Python

2005-06-14 Thread John Henry
Can somebody please tell me how to pop open a drive folder from a
Python script? 

Thanks.

--
John

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Cause for using objects?

2005-06-14 Thread John Machin
John Heasly wrote:
> 
>> John Heasly wrote:
>>
>>> Given:
>>> [{"mugshot": "nw_gradspeaker4_0608", "width": 67.0, "height": 
>>> 96.0}, \
>>> {"mugshot": "nw_gradspeaker2_0608", "width": 67.0, "height": 
>>> 96.0}, \
>>> {"freehand": "b1.developreport.0614", "width": 154.0, "height":
>>> 210.0}, \
>>> {"graphic": "bz_cafeparadiso_0613", "width": 493.0, "height": 
>>> 341.0}]
>>>
>>> Return:
>>> {"mugshot1": "nw_gradspeaker4_0608", "mugshot1.width": 67.0,
>>> "mugshot1.height": 96.0,\
>>> "mugshot2": "nw_gradspeaker2_0608", "mugshot2.width": 67.0,
>>> "mugshot2.height": 96.0, \
>>> "freehand1": "b1.developreport.0614", "freehand1.width": 154.0,
>>> "freehand1.width": 210.0, \
>>> "graphic1": "bz_cafeparadiso_0613", "graphic1.width": 493.0,
>>> "graphic1.height": 341.0}
>>>
>>> I'm trying to teach myself some OOP. Does grinding the Given above into
>>> the Return seem like a good candidate?
>>
>>
>> If that's all you're doing, and you must use that output format, then
>> I'd say no. OOP is not a panacea.
>>
>> Now if you're going to *do* something with the return information, then
>> I would say yes. But in that case, don't use a single dict as a return,
>> use objects.
>> -- 
>> Michael Hoffman
> 
> 
> Michael,
> 
> Thanks. I'm thinking maybe list comprehension is a more appropriate 
> tool. And I need to keep the return a single dict 'cause that's what the 
> next step in the process expects.
> 
> John
> 

All that means is that the next step in the process also needs an 
attitude transplant :-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is different with Python ?

2005-06-14 Thread Mike Meyer
Roy Smith <[EMAIL PROTECTED]> writes:

> Mike Meyer <[EMAIL PROTECTED]> wrote:
>> I've never seen someone explain why, for instance, string addition is 
>> O(n^2) beyond the very abstract "it creates a new string with each 
>> addition". No concrete details at all.
>
> I took a shot at that very question a while ago.  Elephants never forget, 
> and neither does google (http://tinyurl.com/9nrnz).

While that's an excellent explanation of why string addition is
O(n^2), it doesn't really look at the concrete details of the Python
string implementation - which is what I was referring to. I'm sorry
that I was unclear in what I said.

   http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is different with Python ?

2005-06-14 Thread Roy Smith
Mike Meyer <[EMAIL PROTECTED]> wrote:
> I've never seen someone explain why, for instance, string addition is 
> O(n^2) beyond the very abstract "it creates a new string with each 
> addition". No concrete details at all.

I took a shot at that very question a while ago.  Elephants never forget, 
and neither does google (http://tinyurl.com/9nrnz).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python in Games (was RE: [Stackless] Python in Games)

2005-06-14 Thread Patrick Down
My understanding is that the upcoming Civilization IV will have python
scripting.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to use pyparsing for identifiers that start with a constant string

2005-06-14 Thread Kent Johnson
[EMAIL PROTECTED] wrote:
> I am scanning text that has identifiers with a constant prefix string
> followed by alphanumerics and underscores. I can't figure out, using
> pyparsing, how to match for this. The example expression below seems to
> be looking for whitespace between the 'atod' and the rest of the
> identifier.
> 
> identifier_atod = 'atod' + pp.Word('_' + pp.alphanums)
> 
> How can I get pyparsing to match 'atodkj45k' and 'atod_asdfaw', but not
> 'atgdkasdjfhlksj' and 'atod asdf4er', where the first four characters
> must be 'atod', and not followed by whitespace?

Here is one way using pyparsing.Combine:

 >>> from pyparsing import *
 >>> tests = [ 'atodkj45k', 'atod_asdfaw', 'atgdkasdjfhlksj', 'atod asdf4er']
 >>> ident = Combine(Literal('atod') +  Word('_' + alphanums))
 >>> for t in tests:
 ...   try:
 ... print ident.parseString(t)
 ...   except:
 ... print 'No match', t
 ...
['atodkj45k']
['atod_asdfaw']
No match atgdkasdjfhlksj
No match atod asdf4er
 >>>

Kent
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Which Python Wiki engine?

2005-06-14 Thread Daniel Dittmar
Kenneth McDonald wrote:

> I'm looking for a Wiki engine to set up for my company, so that we  can 
> incrementally add user documentation for a fairly complex  program, plus 
> allow users to add their own comments for the benefit  of others. I'd 
> strongly prefer a Python-based Wiki, since that allows  me the chance to 
> add plugins with minimal effort (being a python  enthusiast and 
> programmer).

ZWiki has support for showing an outline of the pages. But other than 
that, I found it less useful than MoinMoin. Also, ZWiki is a Zope 
product, and to me, Zope programming is not really Python programming.

Daniel
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: MySQLDBAPI

2005-06-14 Thread Daniel Dittmar
Gregory Piñero wrote:
> building '_mysql' extension
> gcc -pthread -shared build/temp.linux-i686-2.4/_mysql.o -lz
> -lmysqlclient_r -o build/lib.linux-i686-2.4/_mysql.so
> /usr/bin/ld: cannot find -lmysqlclient_r
> collect2: ld returned 1 exit status
> error: command 'gcc' failed with exit status 1

Now search for mysqlclient_r.so or mysqlclient_r.a (probably in 
rpmmysql/usr/lib.

A mysqlclient.so (without _r meaning without support for threading) will 
do as well if you use Python as a CGI program.

Now enter the directory where you found mysqlclient to setup.py
library_dirs = ['']

If you found both .so and .a, rm the .so. The linker will then link the 
static library .a and you can copy the resulting _mysql.so everywhere.

If there is only an .so, be sure to copy the mysqlclient*.so to the 
server together with _mysql.so. You probably have to inspect the 
environment in your CGI run for LD_LIBRARY_PATH for a directory where 
you can copy mysqlclient*.so. (That's why it is easier to use the static 
library)

Daniel
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Cause for using objects?

2005-06-14 Thread John Heasly

> John Heasly wrote:
>> Given:
>> [{"mugshot": "nw_gradspeaker4_0608", "width": 67.0, "height": 
>> 96.0}, \
>> {"mugshot": "nw_gradspeaker2_0608", "width": 67.0, "height": 
>> 96.0}, \
>> {"freehand": "b1.developreport.0614", "width": 154.0, "height":
>> 210.0}, \
>> {"graphic": "bz_cafeparadiso_0613", "width": 493.0, "height": 
>> 341.0}]
>>
>> Return:
>> {"mugshot1": "nw_gradspeaker4_0608", "mugshot1.width": 67.0,
>> "mugshot1.height": 96.0,\
>> "mugshot2": "nw_gradspeaker2_0608", "mugshot2.width": 67.0,
>> "mugshot2.height": 96.0, \
>> "freehand1": "b1.developreport.0614", "freehand1.width": 154.0,
>> "freehand1.width": 210.0, \
>> "graphic1": "bz_cafeparadiso_0613", "graphic1.width": 493.0,
>> "graphic1.height": 341.0}
>>
>> I'm trying to teach myself some OOP. Does grinding the Given above 
>> into
>> the Return seem like a good candidate?
>
> If that's all you're doing, and you must use that output format, then
> I'd say no. OOP is not a panacea.
>
> Now if you're going to *do* something with the return information, then
> I would say yes. But in that case, don't use a single dict as a return,
> use objects.
> -- 
> Michael Hoffman

Michael,

Thanks. I'm thinking maybe list comprehension is a more appropriate 
tool. And I need to keep the return a single dict 'cause that's what 
the next step in the process expects.

John

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: eclipse, pydev and wxpython - standard output redirection ?

2005-06-14 Thread Philippe C. Martin
app = MyApp(False)
app.MainLoop()

will keep wxWidgets from using its own window.




Grzegorz wrote:

> Hello, I'm using eclipse with pydev plugin, I'm working on a program using
> wxpython .
> When I'm executing that application standard error output does not show in
> eclipse  console window - wxpython seems to redirect standard output to
> some another window , and closes that window immediately, so I can't see
> any error messagess.
> Is there a way to redirect standard output to eclipse console ?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Cause for using objects?

2005-06-14 Thread Michael Hoffman
John Heasly wrote:
> Given:
> [{"mugshot": "nw_gradspeaker4_0608", "width": 67.0, "height": 96.0}, \
> {"mugshot": "nw_gradspeaker2_0608", "width": 67.0, "height": 96.0}, \
> {"freehand": "b1.developreport.0614", "width": 154.0, "height": 
> 210.0}, \
> {"graphic": "bz_cafeparadiso_0613", "width": 493.0, "height": 341.0}]
> 
> Return:
> {"mugshot1": "nw_gradspeaker4_0608", "mugshot1.width": 67.0, 
> "mugshot1.height": 96.0,\
> "mugshot2": "nw_gradspeaker2_0608", "mugshot2.width": 67.0, 
> "mugshot2.height": 96.0, \
> "freehand1": "b1.developreport.0614", "freehand1.width": 154.0, 
> "freehand1.width": 210.0, \
> "graphic1": "bz_cafeparadiso_0613", "graphic1.width": 493.0, 
> "graphic1.height": 341.0}
> 
> I'm trying to teach myself some OOP. Does grinding the Given above into 
> the Return seem like a good candidate?

If that's all you're doing, and you must use that output format, then 
I'd say no. OOP is not a panacea.

Now if you're going to *do* something with the return information, then 
I would say yes. But in that case, don't use a single dict as a return, 
use objects.
-- 
Michael Hoffman
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Python in Games (was RE: [Stackless] Python in Games)

2005-06-14 Thread Delaney, Timothy C (Timothy)
Dave LeCompte (really) wrote:

>> Who is using Python in games
>> 
>> Python has been used in a number of games, including
>> 
>>* ToonTown - http://www.toontown.com/
>>* EveOnline - http://www.eve-online.com/
>>* Blade of Darkness - http://www.codemastersusa.com/blade/

Add to that:

- `The Temple of Elemental Evil`__
- `Vampire: The Masquerade: Bloodlines`__

.. __: http://www.troikagames.com/toee.htm
.. __: http://www.vampirebloodlines.com/

Moved to python-list because it's gone beyond Stackless :)

Tim Delaney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is different with Python ?

2005-06-14 Thread Mike Meyer
Andrea Griffini <[EMAIL PROTECTED]> writes:

> On Mon, 13 Jun 2005 21:33:50 -0500, Mike Meyer <[EMAIL PROTECTED]> wrote:
>
>>But this same logic applies to why you want to teach abstract things
>>before concrete things. Since you like concrete examples, let's look
>>at a simple one:
>>
>>   a = b + c
>>
> ...
n>>In a very
>>few languages (BCPL being one), this means exactly one thing. But
>>until you know the underlying architecture, you still can't say how
>>many operations it is.
>
> That's exactly why
>
>  mov eax, a
>  add eax, b
>  mov c, eax

Um, you didn't do the translation right.

> or, even more concrete and like what I learned first
>
>  lda $300
>  clc
>  adc $301
>  sta $302
>
> is simpler to understand.

No, it isn't - because you have to worry about more details. In
particular, when programming in an HLL the compiler will take care of
allocating storage for the variables. In assembler, the programmer has
to deal with it. These extra details make the code more complicated.

> Writing programs in assembler takes longer exactly beacuse
> the language is *simpler*. Assembler has less implicit
> semantic because it's closer to the limited brain of our
> stupid silicon friend.

You're right, but you have the wrong reasons. There were studies done
during the 70s/80s that showed that debugged LOC from programmers is
independent of the language being written. Assembler takes longer to
write not because it's simpler, but because it takes more LOC to do
the same operations.

You can avoid that problem - to a degree - if you use an assembler
that eschews the standard assembler syntax for something more
abstract. For instance, whitesmith had a z80 assembler that let you write:

  a = b + c

and it would generate the proper instructions via direct
translation. This didn't reduce the LOC to the level of C, but it
makes a significant dent in it.

Also, you can only claim that being closer to the chip is "simpler"
because you haven't dealt with a sufficiently complicated chip
yet. Try writing code where you have to worry about gate settling
times or pipeline stalls, and then tell me whether you think it's
"simpler" than dealing with an HLL.

> Programming in assembler also really teaches (deeply
> to your soul) who is the terrible "undefined behaviour"
> monster you'll meet when programming in C.
>
>>Anything beyond the abstract statement "a gets the result
>>of adding b to c" is wasted on them.
>
> But saying for example that
>
>  del v[0]
>
> just "removes the first element from v" you will end up
> with programs that do that in a stupid way, actually you
> can easily get unusable programs, and programmers that
> go around saying "python is slow" for that reason.

That's an implementation detail. It's true in Python, but isn't
necessarily true in other languages. Yes, good programmers need to
know that information - or, as I said before, they need to know that
they need to know that information, and where to get it.

>>It's true that in some cases, it's easier to remember the
>>implementation details and work out the cost than to
>>remember the cost directly.
>
> I'm saying something different i.e. that unless you
> understand (you have a least a rough picture, you
> don't really need all the details... but there must
> be no "magic" in it) how the standard C++ library is
> implemented there is no way at all you have any
> chance to remember all the quite important implications
> for your program. It's just IMO impossible to memorize
> such a big quantity of unrelated quirks.
> Things like for example big O, but also undefined
> behaviours risks like having iterators invalidated
> when you add an element to a vector.

That may well be true of the standard C++ library - I don't write
it. But it certainly doesn't appear to be true of, for instance,
Python internals. I've never seen someone explain why, for instance, 
string addition is O(n^2) beyond the very abstract "it creates a new
string with each addition". No concrete details at all.


>>> Are you genuinely saying that abelian groups are
>>> easier to understand than relative integers ?
>>
>>Yup. Then again, my formal training is as a mathematician. I *like*
>>working in the problem space - with the abstact. I tend to design
>>top-down.
>
> The problem with designing top down is that when
> building (for example applications) there is no top.

This is simply false. The top of an application is the
application-level object

> I found this very simple and very powerful rationalization
> about my gut feeling on building complex systems in
> Meyer's "Object Oriented Software Construction" and
> it's one to which I completely agree. Top down is a
> nice way for *explaining* what you already know, or
> for *RE*-writing, not for creating or for learning.

I also like OOSC - because it makes the abstract type system a part of
the language. The approach Meyer takes emphasis the abstract.

You haven't stated how you think 

Cause for using objects?

2005-06-14 Thread John Heasly
Given:
[{"mugshot": "nw_gradspeaker4_0608", "width": 67.0, "height": 96.0}, \
{"mugshot": "nw_gradspeaker2_0608", "width": 67.0, "height": 96.0}, \
{"freehand": "b1.developreport.0614", "width": 154.0, "height": 
210.0}, \
{"graphic": "bz_cafeparadiso_0613", "width": 493.0, "height": 341.0}]

Return:
{"mugshot1": "nw_gradspeaker4_0608", "mugshot1.width": 67.0, 
"mugshot1.height": 96.0,\
"mugshot2": "nw_gradspeaker2_0608", "mugshot2.width": 67.0, 
"mugshot2.height": 96.0, \
"freehand1": "b1.developreport.0614", "freehand1.width": 154.0, 
"freehand1.width": 210.0, \
"graphic1": "bz_cafeparadiso_0613", "graphic1.width": 493.0, 
"graphic1.height": 341.0}

I'm trying to teach myself some OOP. Does grinding the Given above into 
the Return seem like a good candidate?

John H.
Eugene, Ore.
jheasly at guardnet dot com

-- 
http://mail.python.org/mailman/listinfo/python-list


how to use pyparsing for identifiers that start with a constant string

2005-06-14 Thread phil_nospam_schmidt
I am scanning text that has identifiers with a constant prefix string
followed by alphanumerics and underscores. I can't figure out, using
pyparsing, how to match for this. The example expression below seems to
be looking for whitespace between the 'atod' and the rest of the
identifier.

identifier_atod = 'atod' + pp.Word('_' + pp.alphanums)

How can I get pyparsing to match 'atodkj45k' and 'atod_asdfaw', but not
'atgdkasdjfhlksj' and 'atod asdf4er', where the first four characters
must be 'atod', and not followed by whitespace?

Thanks!

-- 
http://mail.python.org/mailman/listinfo/python-list


Tkinter question

2005-06-14 Thread Nicholas . Vaidyanathan
Title: Tkinter question






I'm sure there must be a way to do this, but I can't figure it out for the life of me… I'm writing a program where I would like to use a button's text field as part of an if statement. I set up my button like this:

 i = [ "7", "8","9", "/", "4", "5", "6", "*", "1", "2", "3", "-", "0", ".", "=", "+"]

 t = 0   #iterator through the sequence


for x in range(4):

    for y in range(4):

    self.buttonx = Button(self, text = "%s" %i[t] , width=10, command = self.pressed)

    self.buttonx.grid( row=x+1, column = y, sticky = W+E+S)

    t+=1


What I would like to do is is check which buttons' text values are digits, and if the text is, I would like to append the number to a label. But:

if(self.buttonx.title.isdigit):


Doesn't work. How do I access the button's text field?


Thanks!



"MMS " made the following annotations.
--
--- NOTICE ---
This message is for the designated recipient only and may contain confidential, privileged or proprietary information.  If you have received it in error, please notify the sender immediately and delete the original and any copy or printout.  Unintended recipients are prohibited from making any other use of this e-mail.  Although we have taken reasonable precautions to ensure no viruses are present in this e-mail, we accept no liability for any loss or damage arising from the use of this e-mail or attachments, or for any delay or errors or omissions in the contents which result from e-mail transmission.

==

-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Where is Word?

2005-06-14 Thread guy lateur
Thanks for all the feedback, everyone. What a helpfull community this is! 
It's actually kinda hard keeping up with y'all..

Cheers,
g


"Guy Lateur" <[EMAIL PROTECTED]> schreef in bericht 
news:[EMAIL PROTECTED]
> Hi all,
>
> I need a way to get the path where MS Word/Office has been installed. I 
> need to start Word from a script (see earlier post), but it doesn't work 
> if I don't know its path. So "os.system("winword.exe %s" % fileName)" 
> doesn't always work; I need to say "os.system("C:\Program Files\Microsoft 
> Office\Office10\winword.exe %s" % fileName)".
>
> Any ideas?
>
> TIA,
> g
> 


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Where is Word?

2005-06-14 Thread Cameron Laird
In article <[EMAIL PROTECTED]>,
Tomasz Lisowski  <[EMAIL PROTECTED]> wrote:
.
.
.
>import win32com.client
>wordCOMID = "Word.Application"
>
>word = win32com.client.Dispatch(wordCOMID)
>
>Then you can use the methods of the word object, provided by the COM 
>object definition. Unfortunately I don't know them - you may do a 
>research by making a reference to the Microsoft Word type library in 
>Visual Basic, declaring the variable of type Word.Application, and then 
>watching the code assistant showing the available methods and 
>properties. You may also use the object browser.
.
.
.
http://wiki.tcl.tk/4472 > has still more alternatives.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Using PAMIE to upload and download files...is it possible?

2005-06-14 Thread scrimp
Theres one problem with the code that I saw off the bat. My PAMIE
script takes IE all the way up the window thats called "File Download".
It has 4 buttons Open, Save, Cancel, More Info. The code u gave to me
is for the next window I reach AFTER I click manually on Save. It
brings up the Save As window.

Anyways, I did the PAMIE part manually and the Save As window was open
waiting for the SaveAsDocDialog to click Save. It never did, in fact
all it did was freeze up python and crash it. So, im still at a stand
still here.

I know for sure my PAMIE part of the code works. It gets me to where I
need to use winGuiAuto. winGuiAuto just sits there and does nothing for
me. The window name "File Download" does NOT work for me. I have no
idea where or how to find the className of the window.

Again, thanx for all the help. Ill keep on trying it though

-- 
http://mail.python.org/mailman/listinfo/python-list


CodeWarrior Automation with Python?

2005-06-14 Thread [EMAIL PROTECTED]
When looking for a pythonic way to convert some Mac codewarrior
projects, I came across some files hidden deap into the
Python.Framework under:


plat-mac/lib-scriptpackages/CodeWarrior


What is this stuff? Would any of this be helpful in my search for an
automated conversions of the exported xml file generated by CodeWarrior
8, 9 into a project file?


Brian Ray
http://brianray.chipy.org

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Thread priorities?

2005-06-14 Thread Tim Peters
[Gary Robinson]
> In the application we're writing (http://www.goombah.com) it would be
> helpful for us to give one thread a higher priority than the others. We
> tried the recipe here:
> http://groups-beta.google.com/group/comp.lang.python/msg/6f0e118227a5f5de
> and it didn't seem to work for us.

If you need to fiddle thread priorities, then you'll need to do such
platform-specific things, and fight with the OS documentation to
figure out when and why they don't seem to work.

> We don't need many priority levels. We just need one thread to
> *temporarily* have a higher priority than others.
>
> One thing that occurred to me: There wouldn't by any chance be some way
> a thread could grab the GIL and not let it go until it is ready to do
> so explicitly?

No, unless that thread is running in a C extension and never calls
back into Python until it's willing to yield.

> That would have the potential to solve our problem.
>
> Or maybe there's another way to temporarily let one thread have
> priority over all the others?

No way in Python, although specific platforms may claim to support
relevant gimmicks in their native threads (and Python threads
generally are native platform threads).

A portable approach needs to rely on thread features Python supports
on all platforms.  For example, maybe this crude approach is good
enough:

"""
import threading

class Influencer(object):
def __init__(self):
self.mut = threading.Lock()
self.proceed = threading.Event()
self.proceed.set()
self.active = None

def grab(self):
self.mut.acquire()
self.active = threading.currentThread()
self.proceed.clear()
self.mut.release()

def release(self):
self.mut.acquire()
self.active = None
self.proceed.set()
self.mut.release()

def maybe_wait(self):
if (self.proceed.isSet() or
  self.active is threading.currentThread()):
pass
else:
self.proceed.wait()
"""

The idea is that all threads see an (shared) instance of Influencer,
and call its .maybe_wait() method from time to time.  Normally that
doesn't do anything.  If a thread T gets it into its head that it's
more important than other threads, it calls .grab(), which returns at
once.  Other threads then block at their next call to .maybe_wait(),
until (if ever) some thread calls .release().  Season to taste; e.g.,
maybe other threads are willing to pause no more than 0.1 second; etc.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Where is Word?

2005-06-14 Thread guy lateur

> No, the subject is a good way to refer to past posts.  I just meant
> forcing us to dig back, when the post may no longer even be on our 
> servers, is not helpful.

I agree, my bad.


> (Perhaps I should ask why anyone would want to waste time putting 
> arbitrary fonts and colours and such around a simple directory listing, 
> but I won't. )

Please don't.. ;)

g


-- 
http://mail.python.org/mailman/listinfo/python-list


eclipse, pydev and wxpython - standard output redirection ?

2005-06-14 Thread Grzegorz
Hello, I'm using eclipse with pydev plugin, I'm working on a program using 
wxpython .
When I'm executing that application standard error output does not show in 
eclipse  console window - wxpython seems to redirect standard output to some 
another window , and closes that window immediately, so I can't see any 
error messagess.
Is there a way to redirect standard output to eclipse console ?


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is different with Python ?

2005-06-14 Thread Andrea Griffini
On 14 Jun 2005 00:37:00 -0700, "Michele Simionato"
<[EMAIL PROTECTED]> wrote:

>It looks like you do not have a background in Physics research.
>We *do* build the world! ;)
>
>   Michele Simionato

Wow... I always get surprises from physics. For example I
thought that no one could drop confutability requirement
for a theory in an experimental science... I mean that I
always agreed with the logic principle that unless you
tell me an experiment whose result could be a confutation
of your theory or otherwise you're not saying anything
really interesting.
In other words if there is no means by which the theory
could be proved wrong by an experiment then that theory
is just babbling without any added content.
A friend of mine however told me that this principle that
I thought was fundamental for talking about science has
indeed been sacrified to get unification. I was told that
in physics there are current theories for which there
is no hypotetical experiment that could prove them wrong...
(superstrings may be ? it was a name like that but I
don't really remember).
To me looks like e.g. saying that objects are moved around
by invisible beings with long beards and tennis shoes
and that those spirits like to move them under apparent
laws we know because they're having a lot of fun fooling
us. However every now and then they move things a bit
differently just to watch at our surprised faces while we
try to see where is the problem in our measuring instrument.

My temptation is to react for this dropping of such a logical
requirement with a good laugh... what could be the result
of a theory that refuses basic logic ? On a second thought
however laughing at strange physics theories is not a good
idea. Especially if you live in Hiroshima.

Andrea
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tiff Image Reader/writer

2005-06-14 Thread Fredrik Lundh
"PyPK" <[EMAIL PROTECTED]> wrote:

> I get a decoder error when i do a get pixel on the Image
>
> >>> im.getpixel((12,34))
>
> Traceback (most recent call last):
>   File "", line 1, in ?
>   File "Image.py", line 858, in getpixel
> self.load()
>   File "/usr/local/lib/python2.4/site-packages/PIL/ImageFile.py", line
> 180, in load
> d = Image._getdecoder(self.mode, d, a, self.decoderconfig)
>   File "Image.py", line 328, in _getdecoder
> raise IOError("decoder %s not available" % decoder_name)
> IOError: decoder group4 not available

PIL doesn't support CCITT encodings out of the box.  the following
patch might help:

http://mail.python.org/pipermail/image-sig/2003-July/002354.html

(unfortunately, this currently depends on libtiff internals, which is
why it wasn't added to 1.1.5)

an alternative solution is to pipe your files through tiffcp (see James
mail for details).





-- 
http://mail.python.org/mailman/listinfo/python-list


Re: "also" to balance "else" ?

2005-06-14 Thread Ron Adam
Sion Arrowsmith wrote:
> Fredrik Lundh <[EMAIL PROTECTED]> wrote:

>>nope.  else works in exactly the same way for all statements that
>>support it: if the controlling expression is false, run the else suite
>>and leave the statement.
> 
> 
> For example, consider the behaviour of:
> 
> condition = False
> if condition:
> print "true"
> else:
> print "false"
> 
> and
> 
> condition = False
> while condition:
> print "true"
> break
> else:
> print "false"
> 
> From this, it's clear that while/else gets its semantics from if/else.
> Then:
> 
> i = 0
> while i < 10:
> print i
> i += 1
> else:
> print "Done!"
> 
> for i in range(10):
> print i
> else:
> print "Done!"
> 
> So for/else behaves while/else, hence for/else really is the same way
> round as if/else. It may not be "intuitive", but it's consistent, and
> personally I'd rather have that.
> 

Thanks Fredric and Sion.

That makes it clearer.  So for's else is not dependent on entering the 
loop at all.

I'm trying to understand just why it is not intuitive in the first place.

In an if-else,  if the if-block executes, the else-block will not 
execute.  So the else block is the *abnormal* or counter result of the 
if condition.

So the (my) confusion comes from the tendency to look at it in terms of 
overall program flow rather than in terms of the specific conditional 
logic.

In a for loop the normal, as in terminating normally, behavior of a loop 
is one where the loop test evaluates as 'False' ending the loop.  And 
the abnormal or counter behavior is when a break statement executes. 
Thus the 'else' block is the normal result, and the skipping the 'else' 
block becomes the abnormal counter behavior.

So while the logic is consistent, the expected context is reversed.

Why is else needed in loops?  I was working from the point of view that 
if there was enough reason for the else to be in loops, and possibly the 
same reasoning would apply to an also or counter else.  But maybe else 
shouldn't be part of the loop to start with?

Regards, Ron























-- 
http://mail.python.org/mailman/listinfo/python-list


Re: collect data using threads

2005-06-14 Thread James Tanis
Previously, on Jun 14, Peter Hansen said: 

# James Tanis wrote:
# > I may be wrong here, but shouldn't you just use a stack, or in other 
# > words, use the list as a stack and just pop the data off the top. I 
# > believe there is a method pop() already supplied for you. 
# 
# Just a note on terminology here.  I believe the word "stack" generally 
# refers to a LIFO (last-in first-out) structure, not what the OP needs 
# which is a FIFO (first-in first-out).

What can I say? Lack of sleep.

# 
# Assuming you would refer to the .append() operation as "putting data on 
# the bottom", then to pop off the "top" you would use pop(0), not just 
# pop().

Right, except I'm not writing his code for him, and I don't think he 
expects me too. I was just referring to the existance of a pop() 
function, perhaps I should have said pop([int]) to be clearer. Its use 
would of course have to be tailored to his code depending on what he 
requires.

# 
# Normally though, I think one would refer to these as the head and tail 
# (not top and bottom), and probably call the whole thing a queue, rather 
# than a stack.

I agree, its been a while and I mixed the two names up, nothing more.

---
James Tanis
[EMAIL PROTECTED]
http://pycoder.org
-- 
http://mail.python.org/mailman/listinfo/python-list


contract python developer in Campbell is needed at Stratalight

2005-06-14 Thread Patrick Melone








I understand that job listings are ok on this board so…

 

StrataLight Communications, a 40 GB/s
DWDM transport system company, develops innovative fiber transmission
subsystems for use by carriers in building next-generation long-haul optical
networks. We are located in Campbell CA. and are looking for a contract python
developer.

 

www.stratalight.com

 

Development
of Python scripts to automate the test execution of OTS-4000 linecards and the development of a test and measurement
database that will be used for pass/fail determination and test report
generation.


 Extensive experience with
 Python. 


·
BSCS/EE
and 3 to 5 years of work experience

·
Hands on experience with electrical
and optical test instruments. 

·
Strong
technical (e.g., programming) and analytical skills 

·
Strong
working knowledge database schema development and  mySQL 

·
Familiar
with Linux operating system 

·
Strong
interpersonal skills 

·
Desire
to engage in extremely challenging assignments. 

·
Excellent
verbal and written communication skills, and strong
collaborative skills. 

·
Self-managed
proactive work style and the ability to work independently and in a team
environment. 

·
Strong
organizational and problem solving abilities 

 

If interested please contact:

 

Patrick Melone

StrataLight Communications

[EMAIL PROTECTED]

ph) 408/961-6250

fax)408/626-9440

 






-- 
http://mail.python.org/mailman/listinfo/python-list

Re: What is different with Python ?

2005-06-14 Thread Andrew Dalke
Peter Maas wrote:
> Yes, but what did you notice first when you were a child - plants
> or molecules? I imagine little Andrew in the kindergarten fascinated
> by molecules and suddenly shouting "Hey, we can make plants out of
> these little thingies!" ;)

One of the first science books that really intrigued me
was a book on stars I read in 1st or 2nd grade.

As I mentioned, I didn't understand the science of biology
until I was in college.

Teaching kids is different than teaching adults.  The
latter can often take bigger steps and start from a
sound understanding of logical and intuitive thought.
"Simple" for an adult is different than for a child.

Andrew
[EMAIL PROTECTED]

-- 
http://mail.python.org/mailman/listinfo/python-list


Thread priorities?

2005-06-14 Thread Gary Robinson
In the application we're writing (http://www.goombah.com) it would be 
helpful for us to give one thread a higher priority than the others. We 
tried the recipe here: 
http://groups-beta.google.com/group/comp.lang.python/msg/6f0e118227a5f5de  
and it didn't seem to work for us.

We don't need many priority levels. We just need one thread to 
*temporarily* have a higher priority than others.

One thing that occurred to me: There wouldn't by any chance be some way 
a thread could grab the GIL and not let it go until it is ready to do 
so explicitly? That would have the potential to solve our problem.

Or maybe there's another way to temporarily let one thread have 
priority over all the others?

Gary

-- 

Gary Robinson
CTO
Emergent Music, LLC
[EMAIL PROTECTED]
207-942-3463
Company: http://www.goombah.com
Blog:http://www.garyrobinson.net
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is Python Suitable for Large Find & Replace Operations?

2005-06-14 Thread Gilles Lenfant
rbt a écrit :
> Here's the scenario:
> 
> You have many hundred gigabytes of data... possible even a terabyte or 
> two. Within this data, you have private, sensitive information (US 
> social security numbers) about your company's clients. Your company has 
> generated its own unique ID numbers to replace the social security numbers.
> 
> Now, management would like the IT guys to go thru the old data and 
> replace as many SSNs with the new ID numbers as possible. You have a tab 
> delimited txt file that maps the SSNs to the new ID numbers. There are 
> 500,000 of these number pairs. What is the most efficient way  to 
> approach this? I have done small-scale find and replace programs before, 
> but the scale of this is larger than what I'm accustomed to.
> 
> Any suggestions on how to approach this are much appreciated.

Are this huge amount of data to rearch/replace stored in an RDBMS or in 
flat file(s) with markup (XML, CSV, ...) ?

--
Gilles
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: extending Python base class in C

2005-06-14 Thread Scott David Daniels
harold fellermann wrote:
> ...
> This gives me a pointer to the class I want to use as base class.
> Does anyone know how to assign this to the extension class? I tried
> to build a tuple (BaseClass,) and assign it (after the respective
> PyType_Ready call) ...
I think this is your problem -- call PyType_Ready _after_ setting up
the base class, not before.

--Scott David Daniels
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is different with Python ?

2005-06-14 Thread Magnus Lycka
Peter Maas wrote:
> Learning is investigating. By top-down I mean high level (cat,
> dog, table sun, sky) to low level (molecules, atoms, fields ...).

Aha. So you must learn cosmology first then. I don't think so. ;)

I don't know if you really think that you learn things top
down, but I doubt that you do. I know I don't. It's very
rare that I have a good understanding of the overall workings
of a system before I start to learn details. As I learn little
details here and there, my understanding of the entire system
is gradually growing and changing. Sometimes, a minor detail
might completely change my overall picture of a system.

In my experience, software designs developed by people who
lack a good hands-on understanding of the details in a software
system rarely work. We can't know the "top" properly unless
we know a lot about the "bottom".

Do you think children learn to speak by arriving at some
kind of general understanding of grammer before they learn
individual words? :) People typically don't learn things top
down, and I think there are good reasons for that.

Regarding software development, Bertrand Meyer said something
like this: "Top-down design doesn't work, because real software
systems have no top." His view of Object-Oriented development
is that it's a process where we go from that which is known
to us, to that which is (still) unknown. It might go up or
down, but we start with what we know, and gradually expand our
understanding into new territories armed with what we have
learnt so far.

Analysis or decomposition is only half of logical thinking.
Synthesis or composing parts into entire systems are just
as important, and we can't just do one part first, the other
after, and then be done with it.

We are all different intellectually, both genetically and by
training and education. Some people find it easier to grasp
theories, and others need more tangible examples. For each
person, the useful approach will probably depend on the previous
experience in that particular field, or in related areas.

> And to know the lowest levels is not strictly necessary for
> programming. I have seen good programmers who didn't know about
> logic gates.

People might be "good programmers" in some sense, but they will
make mistakes if they don't understand the underlying mechanisms.
This doesn't mean that you need to understand all details down
to the quantum mechanics level, but if you see programing as a
purely "logical" activity, without regards for the technical
implementation, you will run into plenty of problems.

One classical trap is to fail to understand how floating point
numbers are represented in computers. Other common problems among
people who lack a technical understanding for computers is that
they fail to see how and why their solutions use up different
amounts of resources, be it memory, CPU time or whatever. I've
also often seen confusion because people fail to understand the
distinction between other logical and an internal representations,
such as cunfusion over the fact that a date which looks like
eight digits don't use eight bytes in the database, and
frustration over the fact that the database doesn't allow you
to store -00-00 in a date field.

It's just the same as with cars. You can be a fair driver without
knowing anything about mechanics, but the more you know about how
the car works from a mechanical and physical point of view, the
easier it will be to understand why it behaves the way it does,
and the less likely you are to make mistakes when unusual things
happen.

Just as you can learn how cars behave from experience, or from
advice from others with experience, without understanding the
underlying mechanisms, you can learn programming this way. We
have learned things that way for thousands of years. I don't
think it's optimal though.

Robert Pirsig's "Zen and the Art of Motorcycle Maintenance"
covers this subject.

But we all have to start somewhere, and it's never to late to
learn something new. Curiosity and an open mind often means
more than formal education. Some people with a very "good"
education seem to believe that the thing they've learnt is
all that matters, and they will fall into other traps. There
is always another perspective that might give us a new insight.
-- 
http://mail.python.org/mailman/listinfo/python-list


ANN: Version 0.9 of NetEpi Case Manager

2005-06-14 Thread Tim Churches
Version 0.9 of NetEpi Case Manager is now available via
http://www.netepi.org

NetEpi Case Manager is a tool (built using Python, the Albatross Web
application framework for Python, and PostgreSQL) for securely
collecting structured information about cases and contacts of
communicable (and other) diseases of public health importance, through
Web browsers and the Internet.

New data collection forms can be designed and deployed quickly
by epidemiologists, using a Web browser 'point-and-click' interface,
without the need for knowledge of or training in any programming
language. Data can then be collected from authenticated users of the
system, who can be located anywhere in the world, into a centralised
database. All that is needed by users of the system is a relatively
recent Web browser and an Internet connection (“NetEpi” is short for
“Network-enabled Epidemiology”).

Development of NetEpi Case Manager has been motivated in large part by
the challenge of collecting rapidly changing data from many sources in
the event of an outbreak of an emerging communicable disease, such as
SARS and HPAI (highly pathogenic avian influenza). However, we hope that
it has utility in addressing other distributed, ad hoc data collection
problems in the public health and health care domains.

A list of prerequisites and installation notes are available at
http://sourceforge.net/docman/display_doc.php?docid=28865&group_id=123700

Version 0.9 incorporates a large number of improvements over previous
versions, including:

* simplification of and cosmetic improvements to the user interface and
  workflow - sample screenshots available
  at http://sourceforge.net/project/screenshots.php?group_id=123700;

* greater robustness and improved security;

* improved validation of field inputs;

* the ability to specify help pages (and images) for each question on
  a form;

* the ability to roll-forward data collected with previous versions of
  a form to the latest version;

* the ability to export contact as well as case information in a
  "flattened" format suitable for analysis and reporting;

* comprehensive end-user and administrator guides (the latter over 100
  pages long);

* additional installation options to allow easier customisation;

* much greater speed when deployed via FastCGI on the Web server;

* an initial suite of functional tests using the excellent open source
  Selenium web application test environment, as well as some  additional
  unit tests.

We welcome feedback (and bug reports) on this new release, as well as
contributions to future releases. Please contact us directly by email or
use the NetEpi mailing list (see
http://lists.sourceforge.net/lists/listinfo/netepi-discuss ).

We have a long list of additional features and potential improvements
which could be added to Case Manager, and we would be very happy to hear
from experienced Python programmers wishing to contribute to this work.
We would also be very happy to hear from anyone willing to do further
work on the documentation (using OpenOffice2), and from anyone willing
to write additional Selenium test scripts, either in the Selenese
scripting language or in Python via the Selenium "driven" mode (or more
Python unit tests, for that matter).

Tim Churches and Andrew McNamara
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tough Scrolling question with Tkinter

2005-06-14 Thread Eugene Druker
Hi Saqib,

AFAIU, you want to change the scrollregion, not the size. So try:

def _b1PressEvt(event):
x0,y0,x1,y1 = canvas.config('scrollregion')[4]
print x0,y0,x1,y1
canvas.config(scrollregion=(int(x0),int(y0),int(x1)+100,int(y1)))

First click will show nothing, because first change keeps the scrollregion
entirely in the window.

Eugene

<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Please take a look at and run the code snippet shown below.
>
> It creates a canvas with vertical & Horizontal scroll-bars.
> If you shrink the window to smaller than the area of the canvas, the
> scroll-bars work as advertised. That's great.
>
> However, if you click the Left Mouse button, it calls code which
> expands the width of the canvas by 100 pixels. The area being viewed
> expands correspondingly. BUT I DON'T WANT IT TO!!
>
> I want to know how to expand the size of a canvas without changing the
> area/size of what is currently shown by the scroll bars. I would like
> to find code that expands the width of the canvas and simply adjusts
> the H-Scrollbar without changing what is shown on in the area of the
> canvas being displayed.
>
> I have tried seemingly every combination of messing with the
> canvas.config and scrollregion parameters to no avail. Can someone out
> there show me how its done??
>
> -Saqib
>
> -
> import Tkinter
>
> def _b1PressEvt(event):
> print "B1"
> _canvas.config(width=300)
>
> tkRoot = Tkinter.Tk()
> _canvas = Tkinter.Canvas(tkRoot, background="white", width=200,
> height=200,)
>
> # Scroll Bars
> vScrollbar = Tkinter.Scrollbar(tkRoot)
> vScrollbar.pack(side=Tkinter.RIGHT, expand=True, fill=Tkinter.Y)
>
> hScrollbar = Tkinter.Scrollbar(tkRoot)
> hScrollbar.pack(side=Tkinter.BOTTOM, expand=True, fill=Tkinter.X)
>
> _canvas.config(
> width=200,
> height=200,
> scrollregion=(0,0,100,100),
> yscrollcommand=vScrollbar.set,
> xscrollcommand=hScrollbar.set,
> )
>
> vScrollbar.config(orient=Tkinter.VERTICAL, command=_canvas.yview)
> hScrollbar.config(orient=Tkinter.HORIZONTAL, command=_canvas.xview)
>
> #tkRoot.pack()
> _canvas.pack(expand=Tkinter.NO)
> vScrollbar.pack(side=Tkinter.RIGHT, expand=True, fill=Tkinter.Y)
> hScrollbar.pack(side=Tkinter.BOTTOM, expand=True, fill=Tkinter.X)
>
> # Function Bindings
> _canvas.bind("", _b1PressEvt)
>
> tkRoot.mainloop()
>


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: MySQLDBAPI

2005-06-14 Thread =?ISO-8859-1?Q?Gregory_Pi=F1ero?=
While waiting for answers to the above questions, I went ahead and
tried the following:

1. Downloaded the RPM for the server's version of MySql:
http://downloads.mysql.com/archives/mysql-3.23/MySQL-devel-3.23.57-1.i386.rpm

2. Copy file to server, and extract to a new folder i made called rpmmysql:
[EMAIL PROTECTED] gpinero]$ cd rpmmysql/
[EMAIL PROTECTED] rpmmysql]$ rpm2cpio
/home/gpinero/MySQL-devel-3.23.56-1.i386.rpm | cpio -d -i
3936 blocks
[EMAIL PROTECTED] rpmmysql]$ ls
usr
[EMAIL PROTECTED] rpmmysql]$ cd usr
[EMAIL PROTECTED] usr]$ ls
bin  include  lib
[EMAIL PROTECTED] usr]$ cd include/
[EMAIL PROTECTED] include]$ ls
mysql
[EMAIL PROTECTED] include]$ cd mysql
[EMAIL PROTECTED] mysql]$ ls
chardefs.h  m_ctype.hmy_net.h mysql.h  sslopt-case.h
dbug.h  m_string.h   my_no_pthread.h  mysql_version.h  sslopt-longopts.h
errmsg.hmy_config.h  my_pthread.h my_sys.h sslopt-usage.h
history.h   my_global.h  mysql_com.h  raid.h   sslopt-vars.h
keymaps.h   my_list.hmysqld_error.h   readline.h   tilde.h
[EMAIL PROTECTED] mysql]$

3. Edited setup.py to include the new directory.  Here's my whole file
just in case you need it:

#!/usr/bin/env python

"""\
=
Python interface to MySQL
=

MySQLdb is an interface to the popular MySQL_ database server for
Python.  The design goals are:

- Compliance with Python database API version 2.0 [PEP-0249]_

- Thread-safety

- Thread-friendliness (threads will not block each other) 

MySQL-3.22 through 4.1 and Python-2.3 through 2.4 are currently
supported.

MySQLdb is `Free Software`_.

.. _MySQL: http://www.mysql.com/
.. _`Free Software`: http://www.gnu.org/
.. [PEP-0249] http://www.python.org/peps/pep-0249.html

"""

import os
import sys
from distutils.core import setup
from distutils.extension import Extension

mysqlclient = os.getenv('mysqlclient', 'mysqlclient_r')
mysqlstatic = eval(os.getenv('mysqlstatic', 'False'))
embedded_server = (mysqlclient == 'mysqld')

name = "MySQL-%s" % os.path.basename(sys.executable)
if embedded_server:
name = name + "-embedded"
version = "1.2.1c3"

extra_objects = []

if sys.platform == "win32":
mysqlroot = os.getenv('mysqlroot', None)
if mysqlroot is None:
print "You need to set the environment variable mysqlroot!"
print "This should be the path to your MySQL installation."
print "Probably C:\Program Files\MySQL 4.1\ or something like that."
sys.exit(1)

include_dirs = [os.path.join(mysqlroot, "include")]
library_dirs = [os.path.join(mysqlroot, "libs")]
libraries = ['zlib', 'msvcrt', 'libcmt', 'wsock32', 'advapi32']
if mysqlstatic:
extra_objects.append(os.path.join(
library_dirs[0], mysqlclient+'.lib'))
else:
libraries.append(mysqlclient)

else:

def config(what):
from os import popen
f = popen("mysql_config --%s" % what)
data = f.read().strip().split()
if f.close(): data = []
return data

# This dequote() business is required for some older versions
# of mysql_config

def dequote(s):
if (s[0] == "'" or s[0] == '"') and (s[0] == s[-1]):
s = s[1:-1]
return s

include_dirs = [ dequote(i[2:]) for i in config('include') if
i.startswith('-i') ]
#include_dirs.append('/usr/local/mysql/include/mysql')
#include_dirs=['/usr/local/mysql/include/mysql']

if mysqlclient == "mysqlclient":
libs = config("libs")
elif mysqlclient == "mysqlclient_r":
libs = config("libs_r")
elif mysqlclient == "mysqld":
libs = config("embedded")
library_dirs = [ dequote(i[2:]) for i in libs if i.startswith("-L") ]
libraries = [ dequote(i[2:]) for i in libs if i.startswith("-l") ]

# Workaround for a pre-4.1.9 bug
if "z" not in libraries:
libraries.append("z")

extra_compile_args = config("cflags")

if mysqlstatic:
extra_objects.append(os.path.join(
library_dirs[0],'lib%s.a' % mysqlclient))
else:
libraries.append(mysqlclient)


classifiers = """
Development Status :: 5 - Production/Stable
Environment :: Other Environment
License :: OSI Approved :: GNU General Public License (GPL)
Operating System :: MacOS :: MacOS X
Operating System :: Microsoft :: Windows :: Windows NT/2000
Operating System :: OS Independent
Operating System :: POSIX
Operating System :: POSIX :: Linux
Operating System :: Unix
Programming Language :: C
Programming Language :: Python
Topic :: Database
Topic :: Database :: Database Engines/Servers
"""

metadata = {
'name': name,
'version': version,
'description': "Python interface to MySQL",
'long_description': __doc__,
'author': "Andy Dustman",
'author_email': "[EMAIL PROTECTED]",
'license': "GPL",
'platforms': "ALL",
'url': "http://sourceforge.net/projects/mysql-python";,
'download_url': "http://prdownloads.sourceforge.

Re: collect data using threads

2005-06-14 Thread Kent Johnson
Qiangning Hong wrote:
> I actually had considered Queue and pop() before I wrote the above code.
>  However, because there is a lot of data to get every time I call
> get_data(), I want a more CPU friendly way to avoid the while-loop and
> empty checking, and then the above code comes out.  But I am not very
> sure whether it will cause serious problem or not, so I ask here.  If
> anyone can prove it is correct, I'll use it in my program, else I'll go
> back to the Queue solution.

OK, here is a real failure mode. Here is the code and the disassembly:
 >>> class Collector(object):
 ... def __init__(self):
 ... self.data = []
 ... def on_received(self, a_piece_of_data):
 ... """This callback is executed in work bee threads!"""
 ... self.data.append(a_piece_of_data)
 ... def get_data(self):
 ... x = self.data
 ... self.data = []
 ... return x
 ...
 >>> import dis
 >>> dis.dis(Collector.on_received)
  6   0 LOAD_FAST0 (self)
  3 LOAD_ATTR1 (data)
  6 LOAD_ATTR2 (append)
  9 LOAD_FAST1 (a_piece_of_data)
 12 CALL_FUNCTION1
 15 POP_TOP
 16 LOAD_CONST   1 (None)
 19 RETURN_VALUE
 >>> dis.dis(Collector.get_data)
  8   0 LOAD_FAST0 (self)
  3 LOAD_ATTR1 (data)
  6 STORE_FAST   1 (x)

  9   9 BUILD_LIST   0
 12 LOAD_FAST0 (self)
 15 STORE_ATTR   1 (data)

 10  18 LOAD_FAST1 (x)
 21 RETURN_VALUE

Imagine the thread calling on_received() gets as far as LOAD_ATTR (data), 
LOAD_ATTR (append) or LOAD_FAST (a_piece_of_data), so it has a reference to 
self.data; then it blocks and the get_data() thread runs. The get_data() thread 
could call get_data() and *finish processing the returned list* before the 
on_received() thread runs again and actually appends to the list. The appended 
value will never be processed.

If you want to avoid the overhead of a Queue.get() for each data element you 
could just put your own mutex into on_received() and get_data().

Kent
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is different with Python ? (OT I guess)

2005-06-14 Thread Magnus Lycka
Scott David Daniels wrote:
> Magnus Lycka wrote:
> 
>> It seems to me that *real* computer scientists are very rare.
> 
> I suspect the analysis of algorithms people are among that group.
> It is intriguing to me when you can determine a lower and upper
> bound on the time for the best solution to a problem relatively
> independent of the particular solution.

On the other hand, you could argue that algorithms and mathematics
are branches of philosophy rather than science. :) Very useful for
science, just as many other parts of philosophy, but algorithms
are really abstract concepts that stand on their own, regardless
of the physical world. But perhaps that distinction is fuzzy. After
all, all philosophical theories rest on observations of the world,
just as scientific theories. Hm...we're really far off topic now.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: extending Python base class in C

2005-06-14 Thread harold fellermann


> "harold fellermann" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> Hi all,
>
> I once read that it is possible to use a python base class for a C
> extension class.

On 14.06.2005, at 09:29, Grigoris Tsolakidis wrote:

> There was good article of how to do this on DDJ home page www.ddj.com

unfortunately, I could not find it yet. I managed to do the following:
I the initmodule function of my extension, I import the module and look
for the class I want to use as a base class:

PyObject *base_module = PyImport_ImportModule("module_name");
if (!base_module) return;

PyObject *base_class = PyMapping_GetItemString(
PyModule_GetDict(base_module,"BaseClass")
);
if (!base_class) return;


This gives me a pointer to the class I want to use as base class.
Does anyone know how to assign this to the extension class? I tried
to build a tuple (BaseClass,) and assign it (after the respective
PyType_Ready call) to CClass.__bases__ like this:

PyObject_SetAttrString(
&cclassType,
"__bases__",
Py_BuildValue("(O,)",base_class)
);

but this raises a TypeError when executed during import:

TypeError: can't set attributes of built-in/extension type 
'ext_module.CClass'

Any ideas how to proceed?

- harold -

--
You can imagine the opposite
-- Maurizio Nannucci

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: collect data using threads

2005-06-14 Thread Toby Dickenson
On Tuesday 14 June 2005 17:47, Peter Hansen wrote:
> Kent Johnson wrote:
> > Peter Hansen wrote:
> >> That will not work, and you will get data loss, as Jeremy points out.
> >>
> > Can you explain why not? self.data is still bound to the same list as x. 
> > At least if the execution sequence is x = self.data
> >self.data.append(a_piece_of_data)
> > self.data = []
> 
> Ah, since the entire list is being returned, you appear to be correct. 
> Interesting... this means the OP's code is actually appending things to 
> a list, over and over (presumably), then returning a reference to that 
> list and rebinding the internal variable to a new list.  If another 
> thread calls on_received() and causes new data to be appended to "the 
> list" between those two statements, then it will show up in the returned 
> list (rather magically, at least to my way of looking at it) and will 
> not in fact be lost.

But it might not "show up" until too late.

The consumer thread that called get_data presumably does something with that 
list, such as iterating over its contents. It might only "show up" after that 
iteration has finished, when the consumer has discarded its reference to the 
shared list.

-- 
Toby Dickenson
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is Python Suitable for Large Find & Replace Operations?

2005-06-14 Thread Steve Holden
Brian wrote:
> Hi Rbt,
> 
> To give an example of processing a lot of data, I used Python to read 
> and process every word in a single text file that contained the entire 
> King James Bible version.  It processed it within about one second -- 
> split the words, etc.  Worked quite well.
> 
> Hope this helps,
> 
Hardly "big" by the OP's standards at only 4.5 MB (and roughly 790,000 
words, if anyone's interested).

The problem with processing terabytes is frequently the need to 
accomodate the data with techniques that allow the virtual memory to 
avoid becoming swamped. The last thing you need to do under such 
circumstances is create an in-memory copy of hte entire data set, since 
on most real computers this will inflict swapping behavior.

regards
  Steve
-- 
Steve Holden+1 703 861 4237  +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Problem with simple C extension

2005-06-14 Thread harold fellermann

On 14.06.2005, at 18:58, harold fellermann wrote:

> Am I stupid or what?

Yes I was ...

> // PhysicsDPD instance structure
> typedef struct {
>PyObject_HEAD
>double cutoff;
>double friction;
>double noise;
>double dt;
> } hyper_PhysicsDPD;
>
>
> //
> // tp_init
> //
> static int
> hyper_PhysicsDPD_init(hyper_PhysicsDPD *self, PyObject *args, PyObject
> *kwds)
> {
>if (!PyArg_ParseTuple(args,"",
>   &self->cutoff,
>   &self->friction,
>   &self->noise,
>   &self->dt
>   ))
>  return -1;
>
>printf("%f %f %f
> %f\n",self->cutoff,self->friction,self->noise,self->dt);
>
>return 1;
> }

format string must be "" - as the members are defined as doubles,
not floats. Sorry to bother you.

- harold -

--
A country without army is like a fish without bicycle.
--

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: collect data using threads

2005-06-14 Thread Peter Hansen
Peter Hansen wrote:
> James Tanis wrote:
> 
>> I may be wrong here, but shouldn't you just use a stack, or in other 
>> words, use the list as a stack and just pop the data off the top. I 
>> believe there is a method pop() already supplied for you. 
> 
> Just a note on terminology here.  I believe the word "stack" generally 
> refers to a LIFO (last-in first-out) structure, not what the OP needs 
> which is a FIFO (first-in first-out).

Or, perhaps he doesn't need either... as Kent points out (I should have 
read his post before replying above) this isn't what I think James and I 
both thought it was but something a little less usual...

-Peter
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: collect data using threads

2005-06-14 Thread Qiangning Hong
James Tanis wrote:

> # > > > A class Collector, it spawns several threads to read from serial port.
> # > > > Collector.get_data() will get all the data they have read since last
> # > > > call.  Who can tell me whether my implementation correct?
> # > > >  
> # Here's the original code:
> # 
> # class Collector(object):
> #def __init__(self):
> #self.data = []
> #spawn_work_bees(callback=self.on_received)
> # 
> #def on_received(self, a_piece_of_data):
> #"""This callback is executed in work bee threads!"""
> #self.data.append(a_piece_of_data)
> # 
> #def get_data(self):
> #x = self.data
> #self.data = []
> #return x
> # 
> I may be wrong here, but shouldn't you just use a stack, or in other 
> words, use the list as a stack and just pop the data off the top. I 
> believe there is a method pop() already supplied for you. Since 
> you wouldn't require an self.data = [] this should allow you to safely 
> remove the data you've already seen without accidentally removing data 
> that may have been added in the mean time.
> 

I am the original poster.

I actually had considered Queue and pop() before I wrote the above code.
 However, because there is a lot of data to get every time I call
get_data(), I want a more CPU friendly way to avoid the while-loop and
empty checking, and then the above code comes out.  But I am not very
sure whether it will cause serious problem or not, so I ask here.  If
anyone can prove it is correct, I'll use it in my program, else I'll go
back to the Queue solution.

To Jeremy Jones: I am very sorry to take you too much effort on this
weird code.  I should make it clear that there is only *one* thread (the
main thread in my application) calls the get_data() method,
periodically, driven by a timer.  And for on_received(), there may be up
to 16 threads accessing it simultaneously.


-- 
Qiangning Hong

 ___
/ BOFH Excuse #208: \
|   |
| Your mail is being routed through Germany ... and they're |
\ censoring us. /
 ---
  \ ._  .
   \|\_|/__/|
   / / \/ \  \
  /__|O||O|__ \
 |/_ \_/\_/ _\ |
 | | () | ||
 \/\___/\__/  //
 (_/ ||
  |  ||
  |  ||\
   \//_/
\__//
   __ || __||
  (()
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: collect data using threads

2005-06-14 Thread Peter Hansen
Kent Johnson wrote:
> Peter Hansen wrote:
>> That will not work, and you will get data loss, as Jeremy points out.
>>
> Can you explain why not? self.data is still bound to the same list as x. 
> At least if the execution sequence is x = self.data
>self.data.append(a_piece_of_data)
> self.data = []

Ah, since the entire list is being returned, you appear to be correct. 
Interesting... this means the OP's code is actually appending things to 
a list, over and over (presumably), then returning a reference to that 
list and rebinding the internal variable to a new list.  If another 
thread calls on_received() and causes new data to be appended to "the 
list" between those two statements, then it will show up in the returned 
list (rather magically, at least to my way of looking at it) and will 
not in fact be lost.

Good catch Kent. :-)

-Peter
-- 
http://mail.python.org/mailman/listinfo/python-list


Problem with simple C extension

2005-06-14 Thread harold fellermann
Am I stupid or what?

I want to implement a very simple extension class in C (as I did
it many times before...) The python equivalent of my class whould
look like:

class physics_DPD :
def __init__(self,cutoff,friction,noise,dt) :
self.cutoff = cutoff
self.friction = friction
self.noise = noise
self.dt = dt

That's all fir the start. Simple, heh? My C implementation is
the following:


#include 
#include "structmember.h"

// PhysicsDPD instance structure
typedef struct {
   PyObject_HEAD
   double cutoff;
   double friction;
   double noise;
   double dt;
} hyper_PhysicsDPD;


//--
// tp_init
//--
static int
hyper_PhysicsDPD_init(hyper_PhysicsDPD *self, PyObject *args, PyObject 
*kwds)
{
   if (!PyArg_ParseTuple(args,"",
&self->cutoff,
&self->friction,
&self->noise,
&self->dt
))
 return -1;

   printf("%f %f %f 
%f\n",self->cutoff,self->friction,self->noise,self->dt);

   return 1;
}

//--
// method table
//--
static PyMethodDef hyper_PhysicsDPD_methods[] = {
   {NULL}  /* Sentinel */
};

//--
// instance members
//--
static PyMemberDef hyper_PhysicsDPD_members[] = {
   {"cutoff", T_DOUBLE, offsetof(hyper_PhysicsDPD,cutoff), 0, "cutoff 
radius"},
   {"friction", T_DOUBLE, offsetof(hyper_PhysicsDPD,friction), 0, 
"friction"},
   {"noise", T_DOUBLE, offsetof(hyper_PhysicsDPD,noise), 0, "noise"},
   {"dt", T_DOUBLE, offsetof(hyper_PhysicsDPD,dt), 0, "time step"},
   {NULL}  /* Sentinel */
};

//--
// type structure
//--
static PyTypeObject hyper_PhysicsDPDType = {
 PyObject_HEAD_INIT(NULL)
 0, /* ob_size */
 "simulation.hyper.physics_DPD",   /* tp_name */
 sizeof(hyper_PhysicsDPD),  /* tp_basicsize */
 0, /* tp_itemsize */
 0, /* tp_dealloc */
 0, /* tp_print */
 0, /* tp_getattr */
 0, /* tp_setattr */
 0, /* tp_compare */
 0, /* tp_repr */
 0, /* tp_as_number */
 0, /* tp_as_sequence */
 0, /* tp_as_mapping */
 0, /* tp_hash */
 0, /* tp_call */
 0, /* tp_str */
 0, /* tp_getattro */
 0, /* tp_setattro */
 0, /* tp_as_buffer */
 Py_TPFLAGS_DEFAULT
 | Py_TPFLAGS_BASETYPE ,/* tp_flags */
 "DPD physics", /* tp_doc */
 0, /* tp_traverse */
 0, /* tp_clear */
 0, /* tp_richcompare */
 0, /* tp_weaklistoffset */
 0, /* tp_iter */
 0, /* tp_iternext */
 hyper_PhysicsDPD_methods,  /* tp_methods */
 hyper_PhysicsDPD_members,  /* tp_members */
 0, /* tp_getset */
 0, /* tp_base */
 0, /* tp_dict */
 0, /* tp_descr_get */
 0, /* tp_descr_set */
 0, /* tp_dictoffset */
 (initproc)hyper_PhysicsDPD_init, /* tp_init */
 0, /* tp_alloc */
 0, /* tp_new */
 0, /* freefunc tp_free */
 0, /* inquiry tp_is_gc */
 0, /* PyObject *tp_bases */
 0, /* PyObject *tp_mro */
 0, /* PyObject *tp_cache */
 0, /* PyObject *tp_subclasses */
 0, /* PyObject *tp_weaklist */
 0, /* destructor tp_del */
};


//--
// module hyper
//--

static PyMethodDef hyper_methods[] = {
   {NULL}  /* Sentinel */
};

#ifndef PyMODINIT_FUNC  /* declarations for DLL import/export */
#define PyMODINIT_FUNC void
#endif
PyMODINIT_FUNC inithyper(void)
{
   PyObject* m;
   m 

Re: collect data using threads

2005-06-14 Thread Peter Hansen
James Tanis wrote:
> I may be wrong here, but shouldn't you just use a stack, or in other 
> words, use the list as a stack and just pop the data off the top. I 
> believe there is a method pop() already supplied for you. 

Just a note on terminology here.  I believe the word "stack" generally 
refers to a LIFO (last-in first-out) structure, not what the OP needs 
which is a FIFO (first-in first-out).

Assuming you would refer to the .append() operation as "putting data on 
the bottom", then to pop off the "top" you would use pop(0), not just 
pop().

Normally though, I think one would refer to these as the head and tail 
(not top and bottom), and probably call the whole thing a queue, rather 
than a stack.

-Peter
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Using PAMIE to upload and download files...is it possible?

2005-06-14 Thread erinhouston
So here is a class that should do what you want.  I don't use pamie we
use a in house python ie driver.  But it has the same problem.  Here is
a class that should do what you want.

import winGuiAuto
import threading


class SaveAsDocDialog (threading.Thread):
'''Some Internet Explorer dialog windows will halt all other
IE functionality until they are populated.  This class is
used to handle these dialog windows.
This little class saves a document to the pc'''
def __init__(self, docPath):
'''The constructor method.'''
threading.Thread.__init__(self)
self.windowName = "Save As"
self.hwnd = None
self.document = docPath

def fetchWindow (self,attempts=20):
'''Grab the handle of the dialog window'''
tries = 0
while trieshttp://mail.python.org/mailman/listinfo/python-list


Dynamic class inheritance && something else

2005-06-14 Thread Vero

Hi.  My name is Veronica, I am a master student at UNAM.  I am working on something related to Artificial Inteligence and I have been looking for the most appropriated programming language to implement my algorithms.  I found python to be very close to what I need, but there are still a couple of details that I haven't been able to solve.
 
First, (and most important) I would like to be able to dynamically modify the classes from which a class inherits.  I haven't found any way to do it with the language as it is.  If there is a way, any suggestion will be truly appreciated.  If I had to modify the source code to achieve this, I hope that you could give me some hints; I have an idea of how something like this could be achieved but since I don't know deeply the python sourcode I could get lost.
 
Second, since my program will be modifying classes during run time, I would like to have a way to write on a file the python code that would have defined the class with the functions and attributes as they were left, just as if it had been writen like that at the very begining.  I need it to be python code because I will be using that latter.  Maybe I will have to solve this second problem by myself but I just wrote in case anybody had a good idea.
 
Thank you very much for your help.


Vero
 
  La sociedad es inherentemente democrática: la mayoría decide si pensar por si misma o si dejar que alguien más les diga qué pensar. http://mx.geocities.com/aqua_azul_2000/ 
__Correo Yahoo!Espacio para todos tus mensajes, antivirus y antispam ¡gratis! Regístrate ya - http://correo.yahoo.com.mx/ -- 
http://mail.python.org/mailman/listinfo/python-list

Re: ZCatalog for standalone Zodb?

2005-06-14 Thread Almad

Thomas Guettler wrote:
> Hi,

Hi, 
 
> There was someone who said that he has ported ZCatalog to "standalone"
> ZODB. Look in the archive of zodb-dev.

Thanks, I'll try. 

> AFAIK IndexedCatalog is still in 
> development. Maybe the mailing list is calm, but I think it is not
> orphaned.

As developers on #async told me, they are not using IC for their product any
more. So, They will fix reported bugs, but not adding new features. 
 
>  HTH,
>Thomas

Thanks, 
 

-- 
Lukas "Almad" Linhart
[:: http://www.almad.net/ ::]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: sudo open() ? (python newbee question)

2005-06-14 Thread Dan Sommers
On Tue, 14 Jun 2005 16:18:19 +0300,
Christos "TZOTZIOY" Georgiou <[EMAIL PROTECTED]> wrote:

> I believe that the suid bit on scripts (either *sh or python) is
> completely ignored on most *nix systems.

Most *modern* systems, yes.  ;-)

I must be getting old.  :-(

Regards,
Dan

-- 
Dan Sommers

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: collect data using threads

2005-06-14 Thread James Tanis
Previously, on Jun 14, Jeremy Jones said: 

# Kent Johnson wrote:
# 
# > Peter Hansen wrote:
# >  
# > > Qiangning Hong wrote:
# > > 
# > >
# > > > A class Collector, it spawns several threads to read from serial port.
# > > > Collector.get_data() will get all the data they have read since last
# > > > call.  Who can tell me whether my implementation correct?
# > > >  
# > > [snip sample with a list]
# > > 
# > >
# > > > I am not very sure about the get_data() method.  Will it cause data lose
# > > > if there is a thread is appending data to self.data at the same time?
# > > >  
# > > That will not work, and you will get data loss, as Jeremy points out.
# > > 
# > > Normally Python lists are safe, but your key problem (in this code) is
# > > that you are rebinding self.data to a new list!  If another thread calls
# > > on_received() just after the line "x = self.data" executes, then the new
# > > data will never be seen.
# > >
# > 
# > Can you explain why not? self.data is still bound to the same list as x. At
# > least if the execution sequence is x = self.data
# >self.data.append(a_piece_of_data)
# > self.data = []
# > 
# > ISTM it should work.
# > 
# > I'm not arguing in favor of the original code, I'm just trying to understand
# > your specific failure mode.
# > 
# > Thanks,
# > Kent
# >  
# Here's the original code:
# 
# class Collector(object):
#def __init__(self):
#self.data = []
#spawn_work_bees(callback=self.on_received)
# 
#def on_received(self, a_piece_of_data):
#"""This callback is executed in work bee threads!"""
#self.data.append(a_piece_of_data)
# 
#def get_data(self):
#x = self.data
#self.data = []
#return x
# 
# The more I look at this, the more I'm not sure whether data loss will occur.
# For me, that's good enough reason to rewrite this code.  I'd rather be clear
# and certain than clever anyday. 
# So, let's say you a thread T1 which starts in ``get_data()`` and makes it as
# far as ``x = self.data``.  Then another thread T2 comes along in
# ``on_received()`` and gets as far as ``self.data.append(a_piece_of_data)``.
# ``x`` in T1's get_data()`` (as you pointed out) is still pointing to the list
# that T2 just appended to and T1 will return that list.  But what happens if
# you get multiple guys in ``get_data()`` and multiple guys in
# ``on_received()``?  I can't prove it, but it seems like you're going to have
# an uncertain outcome.  If you're just dealing with 2 threads, I can't see how
# that would be unsafe.  Maybe someone could come up with a use case that would
# disprove that.  But if you've got, say, 4 threads, 2 in each methodthat's
# gonna get messy. 
# And, honestly, I'm trying *really* hard to come up with a scenario that would
# lose data and I can't.  Maybe someone like Peter or Aahz or some little 13
# year old in Topeka who's smarter than me can come up with something.  But I do
# know this - the more I think about this as to whether this is unsafe or not is
# making my head hurt.  If you have a piece of code that you have to spend that
# much time on trying to figure out if it is threadsafe or not, why would you
# leave it as is?  Maybe the rest of you are more confident in your thinking and
# programming skills than I am, but I would quickly slap a Queue in there.  If
# for nothing else than to rest from simulating in my head 1, 2, 3, 5, 10
# threads in the ``get_data()`` method while various threads are in the
# ``on_received()`` method.  Aaaagghhh.needmotrin..
# 
# 
# Jeremy Jones
# 

I may be wrong here, but shouldn't you just use a stack, or in other 
words, use the list as a stack and just pop the data off the top. I 
believe there is a method pop() already supplied for you. Since 
you wouldn't require an self.data = [] this should allow you to safely 
remove the data you've already seen without accidentally removing data 
that may have been added in the mean time.

---
James Tanis
[EMAIL PROTECTED]
http://pycoder.org
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Controlling assignation

2005-06-14 Thread Terry Reedy

"Xavier Décoret" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
>> class A( object):
>>   def __init__(self, value):
>> self.value = value

>More seriously, try to do this with your simpler approach.
>a = A(4)
>b = A(lambda : a.x+5)
>a.x = 2
>print b.x # I want this to be 7, not 9

As written, it will be neither, since b.x is a function.  But if you call 
it, its value *is* 7, not 9, as you specified wanting.  So I don't 
understand your point.

>>> class A:
...   def __init__(self,val): self.x = val
...
>>> a = A(4)
>>> b = A(lambda : a.x+5)
>>> a.x=2
>>> b.x
 at 0x008D1650>
>>> b.x()
7

Terry J. Reedy




-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Using httplib to read a file online

2005-06-14 Thread Fredrik Lundh
Oyvind Ostlund wrote:

> There is a server called noteme.com and a file called
> index.php on it, but why doesn't it work. If I changed
> it to 'vbforums.com' and 'index.php' then it worked.

  server.putrequest('GET', filename)# send request andheaders
+ server.putheader('Host', servername)  # identify server
  server.putheader('Accept', 'text/html')   # POST requests workhere too
  server.endheaders()   # as do cgi script file 
names





-- 
http://mail.python.org/mailman/listinfo/python-list


Re: collect data using threads

2005-06-14 Thread Jeremy Jones




Kent Johnson wrote:

  Peter Hansen wrote:
  
  
Qiangning Hong wrote:



  A class Collector, it spawns several threads to read from serial port.
Collector.get_data() will get all the data they have read since last
call.  Who can tell me whether my implementation correct?
  

[snip sample with a list]



  I am not very sure about the get_data() method.  Will it cause data lose
if there is a thread is appending data to self.data at the same time?
  


That will not work, and you will get data loss, as Jeremy points out.

Normally Python lists are safe, but your key problem (in this code) is 
that you are rebinding self.data to a new list!  If another thread calls 
on_received() just after the line "x = self.data" executes, then the new 
data will never be seen.

  
  
Can you explain why not? self.data is still bound to the same list as x. At least if the execution sequence is 
x = self.data
self.data.append(a_piece_of_data)
self.data = ""

ISTM it should work.

I'm not arguing in favor of the original code, I'm just trying to understand your specific failure mode.

Thanks,
Kent
  

Here's the original code:

class Collector(object):
def __init__(self):
self.data = ""
spawn_work_bees(callback=self.on_received)

def on_received(self, a_piece_of_data):
"""This callback is executed in work bee threads!"""
self.data.append(a_piece_of_data)

def get_data(self):
x = self.data
self.data = ""
return x

The more I look at this, the more I'm not sure whether data loss will
occur.  For me, that's good enough reason to rewrite this code.  I'd
rather be clear and certain than clever anyday.  

So, let's say you a thread T1 which starts in ``get_data()`` and makes
it as far as ``x = self.data``.  Then another thread T2 comes along in
``on_received()`` and gets as far as
``self.data.append(a_piece_of_data)``.  ``x`` in T1's get_data()`` (as
you pointed out) is still pointing to the list that T2 just appended to
and T1 will return that list.  But what happens if you get multiple
guys in ``get_data()`` and multiple guys in ``on_received()``?  I can't
prove it, but it seems like you're going to have an uncertain outcome. 
If you're just dealing with 2 threads, I can't see how that would be
unsafe.  Maybe someone could come up with a use case that would
disprove that.  But if you've got, say, 4 threads, 2 in each
methodthat's gonna get messy.  

And, honestly, I'm trying *really* hard to come up with a scenario that
would lose data and I can't.  Maybe someone like Peter or Aahz or some
little 13 year old in Topeka who's smarter than me can come up with
something.  But I do know this - the more I think about this as to
whether this is unsafe or not is making my head hurt.  If you have a
piece of code that you have to spend that much time on trying to figure
out if it is threadsafe or not, why would you leave it as is?  Maybe
the rest of you are more confident in your thinking and programming
skills than I am, but I would quickly slap a Queue in there.  If for
nothing else than to rest from simulating in my head 1, 2, 3, 5, 10
threads in the ``get_data()`` method while various threads are in the
``on_received()`` method.  Aaaagghhh.needmotrin..


Jeremy Jones


-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Hopefully simple regular expression question

2005-06-14 Thread [EMAIL PROTECTED]
Thank you! I had totally forgot about that. It works.

-- 
http://mail.python.org/mailman/listinfo/python-list


Tough Scrolling question with Tkinter

2005-06-14 Thread syed_saqib_ali
Please take a look at and run the code snippet shown below.

It creates a canvas with vertical & Horizontal scroll-bars.
If you shrink the window to smaller than the area of the canvas, the
scroll-bars work as advertised. That's great.

However, if you click the Left Mouse button, it calls code which
expands the width of the canvas by 100 pixels. The area being viewed
expands correspondingly. BUT I DON'T WANT IT TO!!

I want to know how to expand the size of a canvas without changing the
area/size of what is currently shown by the scroll bars. I would like
to find code that expands the width of the canvas and simply adjusts
the H-Scrollbar without changing what is shown on in the area of the
canvas being displayed.

I have tried seemingly every combination of messing with the
canvas.config and scrollregion parameters to no avail. Can someone out
there show me how its done??

-Saqib

-
import Tkinter

def _b1PressEvt(event):
print "B1"
_canvas.config(width=300)

tkRoot = Tkinter.Tk()
_canvas = Tkinter.Canvas(tkRoot, background="white", width=200,
height=200,)

# Scroll Bars
vScrollbar = Tkinter.Scrollbar(tkRoot)
vScrollbar.pack(side=Tkinter.RIGHT, expand=True, fill=Tkinter.Y)

hScrollbar = Tkinter.Scrollbar(tkRoot)
hScrollbar.pack(side=Tkinter.BOTTOM, expand=True, fill=Tkinter.X)

_canvas.config(
width=200,
height=200,
scrollregion=(0,0,100,100),
yscrollcommand=vScrollbar.set,
xscrollcommand=hScrollbar.set,
)

vScrollbar.config(orient=Tkinter.VERTICAL, command=_canvas.yview)
hScrollbar.config(orient=Tkinter.HORIZONTAL, command=_canvas.xview)

#tkRoot.pack()
_canvas.pack(expand=Tkinter.NO)
vScrollbar.pack(side=Tkinter.RIGHT, expand=True, fill=Tkinter.Y)
hScrollbar.pack(side=Tkinter.BOTTOM, expand=True, fill=Tkinter.X)

# Function Bindings
_canvas.bind("", _b1PressEvt)

tkRoot.mainloop()

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: MySQLDBAPI

2005-06-14 Thread =?ISO-8859-1?Q?Gregory_Pi=F1ero?=
see below

On 6/10/05, Daniel Dittmar <[EMAIL PROTECTED]> wrote:
> Gregory Piñero wrote:
> > Is that something I can install all to my home directory?
> 
> If you have a similar Linux distribution at home, simply build the mysql
> extension on that machine and then copy it to the web server.

I have Ubuntu running at home and Redhat is running on the server. 
Would this still work for me?  Do I need to install the same old
version of MySql on my home computer?

> 
> Otherwise:
> 
> You don't have to actually install it. Just make sure that Setup.py
> finds the headers and libs
> 
> 1a) get the rpm and extract the files

Are you referring to the rpm for Mysql?  I would just get the same
version as the server has?
> 
> or 1b) compile (but don't install) mysql from sources
> 
> 2) specify the locations of the header files and the libs to Setup.py or
> patch the module such that the defaults point to your directories. From
> your error message, the current default for the includes seems to be
> /usr/local/mysql/include/mysql

So the new location will be where I extracted the RPM to?

> 
> 3) You can then delete the directories created in 1a or 1b

So the new python module, the dpapi will be installed in my home
directory?  So when I import it from another script I would just
append my home directory to the sys.path first to use it?
> 
> Daniel
> --
> http://mail.python.org/mailman/listinfo/python-list 
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: implicit variable declaration and access

2005-06-14 Thread Ali Razavi
Steven D'Aprano wrote:
> On Mon, 13 Jun 2005 12:18:31 -0400, Ali Razavi wrote:
> 
> 
>>Is there any reflective facility in python
>>that I can use to define a variable with a
>>name stored in another variable ?
>>like I have :
>>x = "myVarName"
>>
>>what can I do to declare a new variable with the name of the string
>>stored in x. And how can I access that implicitly later ?
> 
> 
> Any time you find yourself wanting to indirectly define variables like
> this, the chances are you would get better results (faster, less security
> risks, easier to maintain, easier to re-factor and optimise, more
> readable) if you change the algorithm.
> 
> Instead of:
> 
> x = "myVarName"
> create_real_variable(x, some_value)
> print myVarName
> 
> why not do something like this:
> 
> data = {"myVarName": some_value}
> print data["myVarName"]
> 
> It is fast, clean, easy to read, easy to maintain, no security risks from
> using exec, and other Python programmers won't laugh at you behind your
> back 
> 
> 
I ain't writing a real program, just summarizing a few languages
(Python, Smalltalk, Ruby, ...) meta programming facilities and compare 
them with each other, it will only be an academic paper eventually. Thus 
I am only trying out stuff, without worrying about their real world 
consequences. And yes you are right, I am not a Python programmer, well 
to be honest, I am not a real "any language" programmer, as I have never 
written any big programs except my school works, and I don't even intend
to become one, Sorry it's just too boring and repetitive, there are much
more exciting stuff for me in computer engineering and science than 
programming, so I will leave the hard coding job to you guys and let you 
laugh behind the back of whoever you want!
Have a good one!

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: windows directory

2005-06-14 Thread Trent Mick
[Peter Hansen wrote]
> Richard Lewis wrote:
> > If you want to know where a particular directory is (on a Windows
> > 'drive') you could use:
> > 
> > for drive_label in ["C", "D"]:
> > if "Program Files" in os.listdir(drive_label + ":/"): return
> > drive_label
> 
> This would cause trouble in at least two cases that I've seen.  One was 
> a multiboot machine that had Windows 2000 on D: and Windows XP on C:. 
> The other was a machine that had the Program Files folder copied, for 
> reasons I don't recall (and perhaps only temporarily), to the D: drive.

And on non-English locales the folder name isn't actually "Program
Files". And on some 64-bit architectures you can have "Program Files"
and "Program Files (x86)". :)

> Use one of the defined APIs for getting this information, not a hack 
> like this please.

Amen.

Trent

-- 
Trent Mick
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Using httplib to read a file online

2005-06-14 Thread Oyvind Ostlund
I am trying to read a file online, and was just testing a bit. This is what I 
tried.

--
import sys, httplib
showlines = 6

try:
servername, filename = sys.argv[1:]   # cmdline args?
except:
servername, filename = 'noteme.com', '/index.php'

print servername, filename
server = httplib.HTTP(servername) # connect to httpsite/server
server.putrequest('GET', filename)# send request andheaders
server.putheader('Accept', 'text/html')   # POST requests workhere too
server.endheaders()   # as do cgi script
file names 

errcode, errmsh, replyheader = server.getreply()  # read reply info headers
if errcode != 200:# 200 means success
print 'Error sending request', errcode
print 'Message', errmsh
print 'RepHeader', replyheader
else:
file = server.getfile()   # file obj for data
received
data = file.readlines()
file.close()  # show lines with eolnat end
for line in data[:showlines]: print line, # to save, write datato file 
-

There is a server called noteme.com and a file called index.php on it, but why 
doesn't it work. If I changed it to 'vbforums.com' and 'index.php' then it 
worked. What is the difference? Anyone have a qlue?''

Thanks in advance
- ØØ -
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is different with Python ? (OT I guess)

2005-06-14 Thread Scott David Daniels
Magnus Lycka wrote:
> It seems to me that *real* computer scientists are very rare.
I suspect the analysis of algorithms people are among that group.
It is intriguing to me when you can determine a lower and upper
bound on the time for the best solution to a problem relatively
independent of the particular solution.

> Oh well, I guess it's a bit late to try to rename the Computer
> Science discipline now.
The best I've heard is "Informatics" -- I have a vague impression
that this is a more European name for the field.

--Scott David Daniels
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is different with Python ? (OT I guess)

2005-06-14 Thread Michele Simionato
Magnus Lycka:
> While scientists do build and create things,
> the ultimate goal of science is understanding. Scientists build
> so that they can learn. Programmers and engineers learn so that
> they can build.

Well put! I am going to add this to my list of citations :)

 Michele Simionato

-- 
http://mail.python.org/mailman/listinfo/python-list



Re: [Python-Dev] A bug in pyconfig.h under Linux?

2005-06-14 Thread Fernando Perez
Jeff Epler wrote:

> [sent to python-list and poster]
> 
> Did you follow the direction that Python.h be included before any system
> header?
> 
> This is mentioned at least in
> http://docs.python.org/ext/simpleExample.html

OK, I'll try to make it work this way.  It's not totally trivial, b/c this code
is auto-genenrated on the fly by scipy's weave, but I'll muck in the weave
internals to try and change it.

Many thanks for the feedback,

f.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: collect data using threads

2005-06-14 Thread Kent Johnson
Peter Hansen wrote:
> Qiangning Hong wrote:
> 
>> A class Collector, it spawns several threads to read from serial port.
>> Collector.get_data() will get all the data they have read since last
>> call.  Who can tell me whether my implementation correct?
> 
> [snip sample with a list]
> 
>> I am not very sure about the get_data() method.  Will it cause data lose
>> if there is a thread is appending data to self.data at the same time?
> 
> 
> That will not work, and you will get data loss, as Jeremy points out.
> 
> Normally Python lists are safe, but your key problem (in this code) is 
> that you are rebinding self.data to a new list!  If another thread calls 
> on_received() just after the line "x = self.data" executes, then the new 
> data will never be seen.

Can you explain why not? self.data is still bound to the same list as x. At 
least if the execution sequence is 
x = self.data
self.data.append(a_piece_of_data)
self.data = []

ISTM it should work.

I'm not arguing in favor of the original code, I'm just trying to understand 
your specific failure mode.

Thanks,
Kent
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Problem with 'struct' module

2005-06-14 Thread Matt Feinstein
On Tue, 14 Jun 2005 14:24:56 -, Grant Edwards <[EMAIL PROTECTED]>
wrote:

>
>Your example is not using standard alignment.  It's using
>native alignment:
>
>By default, C numbers are represented in the machine's native
>format and byte order, and properly aligned by skipping pad
>bytes if necessary (according to the rules used by the C
>compiler).
>
>Alternatively, the first character of the format string can
>be used to indicate the byte order, size and alignment of
>the packed data, according to the following table:
>
>   CharacterByte orderSize and alignment
> @native   native
> =native   standard
>  >big-endian   standard
> !network (= big-endian)   standard
>
>If the first character is not one of these, "@" is assumed.
>
>Native byte order is big-endian or little-endian, depending
>on the host system. For example, Motorola and Sun
>processors are big-endian; Intel and DEC processors are
>little-endian.
>
>Native size and alignment are determined using the C compiler's
>sizeof expression. This is always combined with native byte
>order.
>
>Standard size and alignment are as follows: no alignment is
>required for any type (so you have to use pad bytes); short is
>2 bytes; int and long are 4 bytes; long long (__int64 on
>Windows) is 8 bytes; float and double are 32-bit and 64-bit
>IEEE floating point numbers, respectively.
>
>Note the difference between "@" and "=": both use native
>byte order, but the size and alignment of the latter is
>standardized. 

Thanks. I clearly missed the point of the explanation...

Matt Feinstein

--
There is no virtue in believing something that can be proved to be true.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Python-Dev] A bug in pyconfig.h under Linux?

2005-06-14 Thread Jeff Epler
[sent to python-list and poster]

Did you follow the direction that Python.h be included before any system
header?

This is mentioned at least in
http://docs.python.org/ext/simpleExample.html

It's a crummy thing for Python to insist on, but if you can re-organize
your headers to do this it should make the warnings go away.

Jeff


pgpClgUkWxGW5.pgp
Description: PGP signature
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: What is different with Python ? (OT I guess)

2005-06-14 Thread Bill Mill
On 6/14/05, Magnus Lycka <[EMAIL PROTECTED]> wrote:
> Andrew Dalke wrote:
> > Andrea Griffini wrote:
> >
> >>This is investigating. Programming is more similar to building
> >>instead (with a very few exceptions). CS is not like physics or
> >>chemistry or biology where you're given a result (the world)
> >>and you're looking for the unknown laws. In programming *we*
> >>are building the world. This is a huge fundamental difference!
> >
> > Philosophically I disagree.  Biology and physics depends on
> > models of how the world works.  The success of a model depends
> > on how well it describes and predicts what's observed.
> >
> > Programming too has its model of how things work; you've mentioned
> > algorithmic complexity and there are models of how humans
> > interact with computers.  The success depends in part on how
> > well it fits with those models.
> 
> And this is different from building? I don't disagree with the
> other things you say, but I think Andrea is right here, although
> I might have said construction or engineering rather than building.
> 
> To program is to build. While scientists do build and create things,
> the ultimate goal of science is understanding. Scientists build
> so that they can learn. Programmers and engineers learn so that
> they can build.
> 

> 
> It seems to me that *real* computer scientists are very rare.

I'd like to say that I think that they do, in fact, exist, and that
it's a group which should grow and begin to do things more like their
biological counterparts. Why? Because, as systems get more complex,
they must be studied like biological systems.

I spent a while in college studying latent semantic indexing (LSI)
[1], which is an algorithm that can be used to group things for
clustering, searching, and other uses. It is known *to* be effective
in some circumstances, but nobody (at least when I was studying it ~2
years ago) knows *why* it is effective.

With the help of my professor, I was helping to try and determine that
*why*. We had a hypothesis [2], and my job was basically to build
experiments to test our hypothesis. First, I built a framework to
perform LSI on arbitrary documents (in python of course, let's keep it
on topic :), then I started to do experiments on different bodies of
text and different variations of our hypothesis. I kept a lab journal
detailing what I had changed between experiments, some of which took
days to run.

I believe that there are at least a fair number of computer scientists
working like this, and I believe that they need to recognize
themselves as a separate discipline with separate rules. I'd like to
see them open source their code when they publish papers as a matter
of standard procedure. I'd like to see them publish reports much more
like biologists than like mathematicians. In this way, I think that
the scientific computer scientists could begin to become more like
real scientists than like engineers.

Just my 2 cents.

Peace
Bill Mill

[1] http://javelina.cet.middlebury.edu/lsa/out/lsa_definition.htm
[2] http://llimllib.f2o.org/files/lsi_paper.pdf
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Using PAMIE to upload and download files...is it possible?

2005-06-14 Thread scrimp
I dont see the modaltest.py would u please send me a link to it. I
still have not been able to gets winGuiAuto to work. I have pamie
logging into a site, navigating to the downloads section, and clicking
the link of the file to download and it stops right there.

I am downloading a zip file and there are two windows that come up. The
first one is the File download window in which it asks to either Open,
Save, Cancel, or More Info and then after clicking Save it brings up
another window Save As and asks where you want the file This is my
code:

rVal = None
dnldpath = "C:\\"
dnld = findTopWindow("File Download")
btnSave = findControl(dnld, "&Save", "Button")
clickButton(btnSave)

save = findTopWindow("Save As")
btnSave2 = findControl(save, "&Save", "Button")
editPath = findControl(save, None, "Edit")
if dnldPath != None:
setEditText(editPath, dnldPath)
rVal = getEditText(editPath)
clickButton(btnSave2)

and then I just quit IE right after that. Thanks again!

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ZCatalog for standalone Zodb?

2005-06-14 Thread Thomas Guettler
Am Tue, 14 Jun 2005 11:45:30 +0200 schrieb Almad:

> Hello, 
> 
> is ZCatalog available for standalone zodb? As far as I read tutorial, the
> relation to zope is obvious. 
> 
> I knew there is IndexedCatalog, but its not developed any more...and without
> indexing, oodbms are unusable for cms, imo. 

Hi,

There was someone who said that he has ported ZCatalog to "standalone"
ZODB. Look in the archive of zodb-dev.AFAIK IndexedCatalog is still in
development. Maybe the mailing list is calm, but I think it is not
orphaned.

 HTH,
   Thomas

-- 
Thomas Güttler, http://www.thomas-guettler.de/


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Problem with 'struct' module

2005-06-14 Thread Grant Edwards
On 2005-06-14, Matt Feinstein <[EMAIL PROTECTED]> wrote:

> Using the 'struct' module (Win32, python version 2.4.1)--
>
> The library documentation says that 'no alignment is required
> for any type'.

Right.  It says that for Standard alignment, and that's correct.

> However, struct.calcsize('fd') gives 16 while
> struct.calcsize('df') gives 12, implying that double precision
> data has to start on a double-word boundary. 

Your example is not using standard alignment.  It's using
native alignment:

By default, C numbers are represented in the machine's native
format and byte order, and properly aligned by skipping pad
bytes if necessary (according to the rules used by the C
compiler).

Alternatively, the first character of the format string can
be used to indicate the byte order, size and alignment of
the packed data, according to the following table:

   CharacterByte orderSize and alignment
 @native   native
 =native   standard
 big-endian   standard
 !network (= big-endian)   standard

If the first character is not one of these, "@" is assumed.

Native byte order is big-endian or little-endian, depending
on the host system. For example, Motorola and Sun
processors are big-endian; Intel and DEC processors are
little-endian.

Native size and alignment are determined using the C compiler's
sizeof expression. This is always combined with native byte
order.

Standard size and alignment are as follows: no alignment is
required for any type (so you have to use pad bytes); short is
2 bytes; int and long are 4 bytes; long long (__int64 on
Windows) is 8 bytes; float and double are 32-bit and 64-bit
IEEE floating point numbers, respectively.

Note the difference between "@" and "=": both use native
byte order, but the size and alignment of the latter is
standardized. 

-- 
Grant Edwards   grante Yow!  ... I want FORTY-TWO
  at   TRYNEL FLOATATION SYSTEMS
   visi.cominstalled withinSIX AND A
   HALF HOURS!!!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Geometry library

2005-06-14 Thread Alex Gittens
The Polygon library for Python:
http://www.dezentral.de/warp.html?http://www.dezentral.de/soft/Polygon/index.html
provides some support for dealing with polygons, which seems to be the
only hard thing on this list. The rest you should be able to implement
easily.

Alex

On 6/14/05, Cyril BAZIN <[EMAIL PROTECTED]> wrote:
> Hello,
>  
>  I am looking for a geometry library for Python. 
>  I want to make some computations like: 
>   -distance between vertex and polygon, vertex and polyline, vertex and
> segment, etc
>   -if a point is inside a polygon, if a polyline intersect a polygon, etc


-- 
ChapterZero: http://tangentspace.net/cz/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Going crazy...

2005-06-14 Thread Scott David Daniels
Jan Danielsson wrote:
> Gary Herron wrote:
>>... a more recent addition to the language is Sets, ...
>from sets import Set
>Set([1,2,3,4,5,6]) - Set([2,3,6])
>>
>>Set([1, 4, 5])

If you are using 2.4 or later, you can simply use "set" without
importing anything.

 set(['apple', 'orange', 5]) - set([5])

--Scott David Daniels
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Problem with 'struct' module

2005-06-14 Thread Matt Feinstein
Using the 'struct' module (Win32, python version 2.4.1)--

The library documentation says that 'no alignment is required for any
type'. However,  struct.calcsize('fd') gives 16 while
struct.calcsize('df') gives 12, implying that double precision data
has to start on a double-word boundary. 

Matt Feinstein

--
There is no virtue in believing something that can be proved to be true.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: implicit variable declaration and access

2005-06-14 Thread Scott David Daniels
Tom Anderson wrote:
> ... If it's not, try:
> x = "myVarName"
> y = "myVarValue"
> locals()[x] = y

Sorry, this works with globals(), but not with locals().
There isn't a simple way to fiddle the locals (the number
is determined when the function is built).

I do, however, agree with you about what to use.  I use:
   class Data(object):
  def __init__(self, **kwargs):
 for name, value in kwargs.iteritems():
 setattr(self, name, value)
  def __repr__(self):
 return '%s(%s)' % (type(self).__name__, ', '.join(
['%s=%r' % (name, getattr(self, name))
 for name in dir(self) if name[0] != '_']))

When I want to fiddle with named values.
 el = Data(a=5, b='3')
 el.c = el.a + float(el.b)
 setattr(el, 'other', getattr(el, 'a') + getattr(el, 'c'))
 el

--Scott David Daniels
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is different with Python ? (OT I guess)

2005-06-14 Thread Magnus Lycka
Andrew Dalke wrote:
> Andrea Griffini wrote:
> 
>>This is investigating. Programming is more similar to building
>>instead (with a very few exceptions). CS is not like physics or
>>chemistry or biology where you're given a result (the world)
>>and you're looking for the unknown laws. In programming *we*
>>are building the world. This is a huge fundamental difference!
> 
> Philosophically I disagree.  Biology and physics depends on
> models of how the world works.  The success of a model depends
> on how well it describes and predicts what's observed.
> 
> Programming too has its model of how things work; you've mentioned
> algorithmic complexity and there are models of how humans
> interact with computers.  The success depends in part on how
> well it fits with those models.

And this is different from building? I don't disagree with the
other things you say, but I think Andrea is right here, although
I might have said construction or engineering rather than building.

To program is to build. While scientists do build and create things,
the ultimate goal of science is understanding. Scientists build
so that they can learn. Programmers and engineers learn so that
they can build.

There is a big overlap between science and engineering. I hope we
can embrace each other's perspectives and see common goals, but
I also think the distinction is useful.

It seems to me that a lot of so called science is really more
focused on achieving a certain goal than to understand the
world. I think Richard Feynman said something like "disciplines
with the word 'science' in their names aren't", and I feel that
he had a point.

I find the idea of computer science a bit odd. Fields like civil
engineering or electronics rely solidly on science and the laws
of nature. We must, or else our gadgets fail. We work closely
with field such as physics and chemistry, but we're not scientists,
because we learn to build, not vice versa. Our goal is problem
solving and solutions, not knowledge and understanding.

As you said:
"The success of a model depends on how well it describes and
predicts what's observed."
It's quite obvious that this is as true when we build houses,
airplanes or bridges, and when we build programs. Right?

It seems to me that *real* computer scientists are very rare. I
suspect that the label computer scientist comes from a lack of
a better word. Erh, computer engineering without engineering?
What do we call this? I don't mean to offend anyone. I have all
respect for both the education and the students of the discipline
called computer science, and I think it's vital that there is a
foundation of science and mathematics in this field, but most
practitioners aren't scientists any more than engineers are
scientists. Ok, my degree is "Master of Science" in English,
but my academic discipline is electronic engineering, not
electronic science--because the goal with the education is to
be able to use scientific knowledge to solve practical problems,
which is, by definition, what engineers do.

Oh well, I guess it's a bit late to try to rename the Computer
Science discipline now.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is different with Python ?

2005-06-14 Thread Claudio Grondi
> > High and low tides aren't caused by the moon.
> They're not???

I suppose, that the trick here is to state,
that not the moon, but the earth rotation relative
to the moon causes it, so putting the moon at
cause is considered wrong, because its existance
alone were not the cause for high and low tides
in case both rotations were at synch. It is probably
a much more complicated thingy where also the
sun and maybe even the planets must be
considered if going into the details, but this is
another chapter.

I experienced once a girl who pointing me to the
visible straight beams from earth to sky one can see
as result of sunlight coming through the clouds
said: "look, along this visible beams the water from
the lake wents upwards and builds the clouds".
She was very convinced it's true, because she
learned it at school, so I had no chance to go the
details explaining, that there is no need for the
visible straight light beams coming through the
holes in the clouds for it.

I can imagine, that many believe that the
moon is orbiting each day around the earth
even if they know, that earth rotates around
its own axle and around the sun. Its not that
important for them to ask for details, so that
is the mechanism how the "lies" are born -
caused by lack of the necessity or the laziness
to achieve deeper understanding.

Claudio

"Roy Smith" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
news:[EMAIL PROTECTED]
> Steven D'Aprano <[EMAIL PROTECTED]> wrote:
> > High and low tides aren't caused by the moon.
>
> They're not???


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is different with Python ?

2005-06-14 Thread Peter Maas
Andrew Dalke schrieb:
> Peter Maas wrote:
> 
>>I think Peter is right. Proceeding top-down is the natural way of
>>learning (first learn about plants, then proceed to cells, molecules,
>>atoms and elementary particles).
> 
> 
> Why in the world is that way "natural"?  I could see how biology
> could start from molecular biology - how hereditary and self-regulating
> systems work at the simplest level - and using that as the scaffolding
> to describe how cells and multi-cellular systems work.

Yes, but what did you notice first when you were a child - plants
or molecules? I imagine little Andrew in the kindergarten fascinated
by molecules and suddenly shouting "Hey, we can make plants out of
these little thingies!" ;)

-- 
---
Peter Maas,  M+R Infosysteme,  D-52070 Aachen,  Tel +49-241-93878-0
E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64')
---
-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   >