[ANN] python-dateutil 1.0

2005-07-20 Thread Gustavo Niemeyer
Changes since 0.9
-

* Fixing parsing of XXhXXm formatted time after day/month/year
  has been parsed.

* Adding patch by Jeffrey Harris optimizing rrule.__contains__.


What is it?
---
The dateutil module provides powerful extensions to the standard
datetime module, available in Python 2.3+.

Features


* Computing of relative deltas (next month, next year,
  next monday, last week of month, and a lot more);

* Computing of relative deltas between two given
  date and/or datetime objects;

* Computing of dates based on very flexible recurrence rules
  (every month, every week on Thursday and Friday, every
  Friday 13th, and a *LOT* more), using a superset of the
  iCalendar RFC specification. Parsing of RFC strings is
  supported as well.

* Generic parsing of dates in almost any string format;

* Timezone (tzinfo) implementations for tzfile(5) format
  files (/etc/localtime, /usr/share/zoneinfo, etc), TZ
  environment string (in all known formats), iCalendar
  format files, given ranges (with help from relative deltas),
  local machine timezone, fixed offset timezone, UTC
  timezone, and Windows registry-based timezones.

* Internal up-to-date world timezone information based on
  Olson's database.

* Computing of Easter Sunday dates for any given year,
  using Western, Orthodox or Julian algorithms;

* More than 400 test cases.

Where to get it?

https://moin.conectiva.com.br/DateUtil

-- 
Gustavo Niemeyer
http://niemeyer.net
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations.html


[ANN] Release 0.43 of Task Coach

2005-07-20 Thread Frank Niessink
Hi all,

Unfortunately, release 0.42 of Task Coach introduced a bug, causing Task 
Coach to not update information correctly in the tree and list view. 
Release 0.43 is meant to fix that.

Bug fixed:

 * Tree and list view were not updated correctly when changing sort 
key or sort order, or marking tasks completed.



What is Task Coach?

Task Coach is a simple task manager that allows for hierarchical
tasks, i.e. tasks in tasks. Task Coach is open source (GPL) and is
developed using Python and wxPython. You can download Task Coach from:

http://taskcoach.niessink.com
https://sourceforge.net/projects/taskcoach/

A binary installer is available for Windows XP, in addition to the
source distribution.

Note that Task Coach is alpha software, meaning that it is wise to back
up your task file regularly, and especially when upgrading to a new release.

Cheers, Frank



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

Support the Python Software Foundation:
http://www.python.org/psf/donations.html


Re: Could anyone write a small program to log the Signal-to-Noise figures for a Netgear DG834 router?

2005-07-20 Thread Chris
In article [EMAIL PROTECTED], 
[EMAIL PROTECTED] [EMAIL PROTECTED] writes
Chris, How would a wireless router show a signal to noise ratio?
Especially if it's providing the signal?

The Netgear DG834 is a wired router.
Its statistics page gives line loss and SNR.
-- 
Chris
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Could anyone write a small program to log the Signal-to-Noise figures for a Netgear DG834 router?

2005-07-20 Thread Chris
In article [EMAIL PROTECTED], 
Steven D'Aprano [EMAIL PROTECTED] writes
On Tue, 19 Jul 2005 07:24:19 +0100, Chris wrote:

 Could anyone write a small program to log the Signal-to-Noise figures
 for a Netgear DG834 router?

Are you offering to pay somebody to do it, or just suggesting a project
for some Python programmer who is bored and looking for a small project to
work on out of love?

Yes, Steven, the latter.  Sometimes programmers need an idea for a 
project - and, for them, knowing that someone would actually value what 
they did might make it more fun for them.
-- 
Chris
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Web Framework Reviews

2005-07-20 Thread flupke
Dave Cook wrote:
 On 2005-07-19, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 
 
On the other hand I even in its current form I don't see how I would to
the simple things that I need every day. Create a session, set a
cookie, redirect to another url,  perform HTTP autentication, create
filter,  use another templating language? This is also integral part of
the  functionality that I expect from an web framework. Web specific
things exposed in some python ic way.
 
 
 Take a look at the Nevow FAQ and examples.  Also, Nevow sits on top of
 Twisted, so you have all of Twisted's features available.
 
 http://divmod.org/users/wiki.twistd/nevow/moin.cgi/FrequentlyAskedQuestions
 
 Dave Cook

One could use twisted.web2 also without the nevow part.
The docs @ http://twistedmatrix.com/projects/web2/documentation/ are 
very clear and it contains a good example at the end.

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


Re: OO design

2005-07-20 Thread flupke
Robert Kern wrote:
 chris wrote:
 
 When I think about what I should do I end up with a class XY that has a
 method for everything I want to do eg.

 class XY:
   def read_file
   def scale_data
   def plot_data
   def shelve_data

 But somehow that doesn't feel right, especially when I expect the 
 number of
 methods will grow and grow, which would make the class very unwieldy.

snip great advice


 In short slogans: Just Do It. Make It Work, Then Make It Right. Refactor 
 Mercilessly. Do the Simplest Thing That Could Possibly Work.

+1 QOTW

Very good advice IMO.
I would like to add that for the simpler classes, thinking of how you 
want to use data can be a great starting point.
I recently programmed an interface to a firebird database and said, how 
do i want to be able to use the software?
I thought of this:

table = fb.Table(datafile.fdb,customers)
vals = {}
vals[name]=customer1
vals[city]=mytown
table.insert(vals)

It looked like a great way to access and use it and it hides all the sql 
details. Well, that's how i started and i had to refactor along the way 
too :)

Regards,
Benedict
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: main window in tkinter app

2005-07-20 Thread Christopher Subich
William Gill wrote:
 O.K. I tried from scratch, and the following snippet produces an 
 infinite loop saying:
 
   File C:\Python24\lib\lib-tk\Tkinter.py, line 1647, in __getattr__
   return getattr(self.tk, attr)
 
 If I comment out the __init__ method, I get the titled window, and print 
 out self.var ('1')
 
 
 import  os
 from Tkinter import *
 
 class MyApp(Tk):
 var=1
 def __init__(self):
   pass
 def getval(self):
   return self.var
 
 
 app = MyApp()
 
 app.title(An App)
 print app.getval()
 app.mainloop()

You're not calling the parent's __init__ inside your derived class.  I 
would point out where the Python Tutorial points out that you should do 
this, but it's not in the obvious place (Classes: Inheritance).

Python does -not- automagically call parent-class __init__s for derived 
classes, you must do that explicitly.  Changing the definition of your 
class to the following works:
  class MyApp(Tk):
 var=1
 def __init__(self):
   Tk.__init__(self)
   pass
 def getval(self):
   return self.var

It works when you comment out __init__ because of a quirk in Python's 
name resolution.  As you'd logically expect, if you don't define a 
function in a derived class but call it (such as instance.method()), it 
will call the method from the base class.

You just proved that this works for __init__ methods also.  When you 
didn't define __init__ for your derived class, MyApp() called 
Tk.__init__(), which Does the Right Thing in terms of setting up all the 
specific Tkinter-specific members.
-- 
http://mail.python.org/mailman/listinfo/python-list


Using SHFileOperation

2005-07-20 Thread avishay
Hi All,
I want to use SHFileOperation using Python and Win32 extentions, in
order to move a file to the trash can. The function itself can be
accessed by importing win32com.shell.shell. However, I cannot find
anywhere the SHFILEOPSTRUCT. This structure is mentioned in the
documentation of the Win32 extentions, but I can't find a way to access
it.
I would appreciate your help. If there's an alternative way to send a
file to the trash can, that can also help.

Best Regards
Avishay

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


is a file open ?

2005-07-20 Thread luis
for root, dirs, files in os.walk(path):
for file in files:
   # ¿ is opened ?


Best regards

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


Reg file uploading

2005-07-20 Thread praba kar
Dear All,
  I have doubt regarding file uploading.  When we
upload a file to the remote server we can get file
type through file extentions. How we can find out file
type  if a file doesn't have any extentions ?

with regards
PRabahar 






__
Free antispam, antivirus and 1GB to save all your messages
Only in Yahoo! Mail: http://in.mail.yahoo.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: goto

2005-07-20 Thread Sybren Stuvel
Mike Meyer enlightened us with:
 I dislike gotos because it is too easy to inadvertently create
 infinite loops. 10 WINK; 20 GOTO 10

 And it's impossible without them? while True: pass

I thought the same thing, but then I read it again and thought about
the inadvertently. As soon as you see a while True, you _know_
it's going to loop forever. As soon as you see a goto 10, you don't.

Sybren
-- 
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself? 
 Frank Zappa
-- 
http://mail.python.org/mailman/listinfo/python-list


Web shop in Python

2005-07-20 Thread Lad
Does anyone know about an e-shop solution written in Python?
Thanks for reply
Lad.

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


Re: Documentation bug: Python console behaviour changed

2005-07-20 Thread Claudio Grondi
 'Ctrl-Z' does not shut down the console but 'Ctrl-D' etc.
 Usually means you have a readline package installed.
Right. Readline uninstalled, Ctrl-Z works again.

By the way:
After trying to take over readline support from Gary Bishop,
I have inbetween given up trying to fix readline behaviour on
international keyboards in Windows (mainly because the
Python 2.4 IDLE works for me best, so I don't need IPython
anymore).
I haven't digged very deep into it, but I mean, that the whole
code must be probably more or less entirely rewritten by
someone with experience in internationalization matters on
Windows (various keyboards and localized Windows
versions) and readline behaviour on *nix systems.
Up to now, there is noone known to me willing to support
the readline package - any volunteers?
Michele Simionato and me can then test the outcome on
German and Italian Windows systems and keyboards.

Claudio

Tim Golden [EMAIL PROTECTED] schrieb im Newsbeitrag
news:[EMAIL PROTECTED]
[Lucas Raab]
| Peter Hansen wrote:
|  Kay Schluehr wrote:
| 
|  The documentation of the Python console behaviour is not correct
|  anymore for Python 2.4.1. At least for the Win2K system
| I'm working on
|  'Ctrl-Z' does not shut down the console but 'Ctrl-D' etc.
| 
|  The Python interpreter tells me instead:
| 
| 
|  quit
| 
| 
|  'Use Ctrl-Z plus Return to exit.'
| 
|  Nah, 'Ctrl-Z' is now undo :-)
| 
| 
|  Are you really using the console, started with the Command
| Prompt icon
|  from the Start Menu (or some equivalent)?  And are you sure
| you haven't
|  installed something else that magically changed the
| behaviour of Ctrl-Z?
| 
|  (I get the documented behaviour with Python 2.4.1, under Win XP.)
| 
|  -Peter
|
| I'm getting the same behavior as Kay.

Usually means you have a readline package installed:

I know that this one gives the effect described:

http://sourceforge.net/projects/uncpythontools/

Don't know about this one:

http://newcenturycomputers.net/projects/readline.html

TJG


This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk



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


Re: email format in python

2005-07-20 Thread dimitri pater
hello,
this one works quite well on validating email syntax:
http://www.secureprogramming.com/?action="">

regards,
DimitriOn 7/20/05, Dark Cowherd [EMAIL PROTECTED] wrote:
This seems to give reasonable results.import repattern = r'[EMAIL PROTECTED],4}\b'pattobj = re.compile(pattern)ps = pattobj.searchif ps(stringtocheck):But as lots of people have already told you on this list. This should
only be used to give a warning and not prevent the use of thatparticular address.DarkCowherd--http://mail.python.org/mailman/listinfo/python-list
-- Please visit dimitri's website: www.serpia.com
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: dictionary as property

2005-07-20 Thread Benjamin Niemann
Thanos Tsouanas wrote:

 Hello.
 
 (How) can I have a class property d, such that d['foo'] = 'bar' will run
 a certain function of the class with 'foo' and 'bar' as it's arguments?

I think you mean:

class A:
  def __init__(self):
self.d = {}

  def dict_change(self, key, value):
print key, value

a = A()
a.d['foo'] = 'bar'
-- foo bar

'a' only has a reference to 'd', it won't know, who has a copy of this
reference and what done to it.
What you could create, is a wrapper around 'd', that passes __getitem__,
__setitem__ and every other required method to the underlying dict and call
the appropriate hook method of A

class WrappedDict:
  def __init__(self, owner, d):
self.owner = owner
self.d = d

  def __setitem__(self, key, value):
self.owner.dict_changed(key, value)
self.d[key] = value

  def __getitem(self, key):
return self.d[key]

  

And in A.__init__
  self.d = WrappedDict(self, {})

You may also subclass WrappedDict from dict...

-- 
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Opinions on KYLIX 3 (Delphi 4 Linux)

2005-07-20 Thread David Trudgett
Thomas Bartkus [EMAIL PROTECTED] writes:


 Good question!  Wither Borland?

 My impression (second hand - based on no direct experience with
 Kylix!) is that Borlands wonderful Delphi product ported to Linux
 has been a dissapointment.

   * * * Someone with real experience on Kylix - please jump in here!

It has been two or three years since I gave Kylix a try, so my memory
is a bit vague on the specifics. I was working in a Delphi shop and
wanted to port (at least some of) our apps to Linux using Kylix (I
think it was version 3). I think I ported one and a half apps and more
or less gave up or put it on the back burner. My impression was that
Kylix still wasn't ready for serious development work.

The type of application I was working on (porting) involved
client/server database access, and TCP communications with other
applications. It never really worked correctly (I forget what the
problems were just now), but probably could have been made to work
correctly. The point was, however, that porting (a relatively simple)
Delphi app to Kylix shouldn't have been that hard.


 Calling Delphi similar to Visual Basic is hurtful because I
 believe that VB is the product of looting and pillaging the talent
 that came out of Borland.  I'm guessing that Microsoft has
 successfully targeted this perceived competitor with destruction.

 If Kylix were of the quality of Delphi, it would be a killer Linux app.

Possibly. Unfortunately, I don't believe that the whole GUI building
approach of Delphi/Kylix (or other similar tools) is much chop. It
encourages one, for instance, to just place elements on the screen in
fixed positions that make no allowance for differing fonts, screen
resolutions, etc. Java (my experience is with JBuilder) is much better
in this regard, although the different paradigm takes some getting
used to. However, all GUI builders with which I'm familiar (not many)
seem to have very real limitations when it comes to designing very
complex interfaces. Kenny Tilton's Cells project (ask on
comp.lang.lisp) has set me to thinking along these lines. In the past,
I never gave it much consideration.

Programmers who like Pascal should look at Ada as a better
alternative. If I wanted to program in a Pascal-like language on
Linux, Ada (the GNU Gnat compiler, integrated with GCC) is the one
that I would use. Ada, you could say, is like Pascal on
steroids. Caveat: I've read Ada books, but haven't programmed in it,
and my main concern is that its ultra strong typing might get in my
way -- or alternatively, force greater rigour, as the Ada folks might
say ;-).

These days, for hacking about, I prefer Common Lisp. It's faster
(sometimes approaching the speed of compiled C/Pascal) and much more
powerful than Python, but doesn't have the same library support
(smaller community), and application bundling and delivery *can* be a
potential problem, depending on various factors (such as whether you
want to license a commercial Common Lisp). Also, similar to Python,
there is no standard GUI framework defined for Common Lisp, so
choosing from the GUI frameworks available can be a challenge (I've
only programmed a simple GUI app using the great little Ltk library by
Peter Herth, which talks to Tk over a socket).

My advice would be to steer clear of Kylix and choose one of the other
environments suggested to you. If you really like Pascal, fpc may be a
possibility as someone mentioned. I haven't looked into it any time in
the last couple of years, though, so I don't know its status. I really
would suggest a serious look at Ada, though, if you want to develop
fast, industrial strength applications, or take advantage of built-in
concurrency support and lots of other goodies.

David



-- 

David Trudgett
http://www.zeta.org.au/~wpower/

I was in the pub last night, and a guy asked me for a light for his
cigarette. I suddenly realised that there was a demand here and money
to be made, and so I agreed to light his cigarette for 10 pence, but I
didn't actually give him a light, I sold him a licence to burn his
cigarette.  My fire-licence restricted him from giving the light to
anybody else, after all, that fire was my property. He was drunk, and
dismissed me as a loony, but accepted my fire (and by implication the
licence which governed its use) anyway. Of course in a matter of
minutes I noticed a friend of his asking him for a light and to my
outrage he gave his cigarette to his friend and pirated my fire! I was
furious, I started to make my way over to that side of the bar but to
my added horror his friend then started to light other people's
cigarettes left, right, and centre! Before long that whole side of the
bar was enjoying MY fire without paying me anything. Enraged I went
from person to person grabbing their cigarettes from their hands,
throwing them to the ground, and stamping on them.  

Strangely the door staff exhibited no respect for my property rights
as they threw me out the door.

-- Ian Clarke
-- 

Re: Python IDE

2005-07-20 Thread Fuzzyman
Hmmm.. I've *never* hada problem with SPE crashing.. at least not under
Windoze...

Regards,

Fuzzy
http://www.voidspace.org.uk/python

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


Re: Python Programming Contest

2005-07-20 Thread Brian Quinlan
Raymond Hettinger wrote:
 I'm curious about the stability of your timing setup.  If you run your
 own version of fly.py several times with the same starting seed, how
 much variation do you see between runs?

There is very little variation (about 0.1%) but my solution is over an 
order of magnitude slower than some of the submissions that I've gotten. 
It is likely that the overhead of my timing code is significant when 
running your solution.

I may have to *slightly* revise my test code to get better results. I 
think that I can do so without changing the distribution of the random 
schedule so as not to be biased against some solutions.

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


Re: Reg file uploading

2005-07-20 Thread Sybren Stuvel
praba kar enlightened us with:
 When we upload a file to the remote server we can get file type
 through file extentions.

No you can't, you can only make a better guess. If I name my PNG file
somefile.jpg, you won't be able to get the file type through file
extentions.

 How we can find out file type  if a file doesn't have any
 extentions?

One method is to look at the Content-type header the client sent along
with the file. Another way is through the 'file' command.

Sybren
-- 
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself? 
 Frank Zappa
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Ordering Products

2005-07-20 Thread Ron Adam
Kay Schluehr wrote:
 Ron Adam wrote:
 
 Kay Schluehr wrote:

 BTW.. Usually when people say I don't want to discourage..., They
  really want or mean the exact oppisite.
 
 Yes, but taken some renitence into account they will provoke the 
 opposite. Old game theoretic wisdoms ;)

True..  but I think it's not predictable which response you will get
from an individual you aren't familiar with.  I prefer positive
reinforcement over negative provocation myself. :-)


 But you seem to fix behaviour together with an operation i.e.
 declaring that __mul__ is commutative. But in a general case you
 might have elements that commute, others that anti-commute ( i.e. a*b
 = -b*a ) and again others where no special rule is provided i.e. they
 simply don't commute.
 
 But much worse than this the definition of the operations __add__, 
 __mul__ etc. use names of subclasses A,D explicitely(!) what means
 that the framework can't be extended by inheritance of A,D,M etc.
 This is not only bad OO style but customizing operations ( i.e.
 making __mul__ right associative ) for certain classes is prevented
 this way. One really has to assume a global behaviour fixed once as a
 class attribute.

I don't know if it's bad OO style because I chose a flatter model.
Your original question wasn't what would be the best class structure to
use where different algebra's may be used.  It was how can sorting be
done to an expression with constraints. And you gave an example which 
set __mul__ as associative as well.

So this is a different problem.  No use trying to point that what I did
doesn't fit this new problem, it wasn't suppose to.  ;-)

I'm not sure what the best class structure would be.  With the current
example,  I would need to copy and edit F and it's associated sub
class's to create a second algebra type, F2, A2, M2.. etc.  Not the best
solution to this additional problem which is what you are pointing out I
believe.

So...  We have factors (objects), groups (expressions), and algebras
(rules), that need to be organized into a class structure that can
be extended easily.

Does that describe this new problem adequately?  I'm not sure what the
best, or possible good solutions would be at the moment.  I'll have to 
think about it a bit.


 c*3*a*d*c*b*7*c*d*a = (21*a*a*b*c*c*c*d*d)
 
 
 I still don't see how you distinguish between factors that might 
 commute and others that don't. I don't want a and b commute but c and
 d with all other elements.

In my example factors don't commute.  They are just units, however
factors within a group unit may commute because a group is allowed to 
commute factors if the operation the group is associated to is commutable.


 If you have fun with those identities you might like to find 
 simplifications for those expressions too:
 
 a*0   - 0 a*1   - a 1/a/b - b/a a+b+a - 2*a+b a/a   - 1 a**1  -
 a
 
 etc.

Already did a few of those.  Some of these involve changing a group into 
a different group which was a bit of a challenge since an instance can't 
magically change itself into another type of instance, so the parent 
group has to request the sub-group to return a simplified or expanded 
instance, then the parent can replace the group with the new returned 
instance.

a*a*a - a**3 change from a M group to a P group.
a*0   - 0change from a M group to an integer.
a*1   - achange from a M group to a F unit.
a+b+a - 2*a+bchange a A subgroup to a M group.
a/a   -  change a D group to an integer.
a**1  -  change a P group to a M group to a F unit.

Some of those would be done in the simplify method of the group.  I've 
added an expand method and gotten it to work on some things also.

   a*b**3  -  a*b*b*b
   c*4 -  c+c+c+c


 What do you mean by 'sub-algebra generation'?
  
 Partially what I described in the subsequent example: the target of
 the addition of two elements x,y of X is again in X. This is not
 obvious if one takes an arbitrary nonempty subset X of Expr.

Would that be similar to the simultaneous equation below?

z = x+y-  term x+y is z
x = a*z+b  -  z is in term x
x = a(x+y)+b   -  x is again in x  (?)

I think this would be...

  x, y = F('x'), F('y')
  z = x+y
  x = a*z+b
  x
(((x+y)*a)+b)

This wouldn't actually solve for x since it doesn't take into account 
the left side of the = in the equation.  And it would need an eval 
method to actually evaluated it.  eval(str(expr)) does work if all the 
factors are given values first.


Cheers,
Ron

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


Re: is a file open ?

2005-07-20 Thread John Machin
luis wrote:
 for root, dirs, files in os.walk(path):
for file in files:
   # ¿ is opened ?
 

¡ rtfm ! files is a list of fileNAMEs -- i.e. strings.
¿ How could you possibly imagine that your sample code would open a 
file? What a design-nonsense that would be: instant complaints from folk 
who wanted to do some further selection before opening (if they ever 
wanted to open the files at all).
¿ Did you contemplate *trying* this code to see what happened ?
¡ Don't use file as a name; it shadows the built-in file function !
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: is a file open ?

2005-07-20 Thread Daniel Dittmar
luis wrote:
 for root, dirs, files in os.walk(path):
for file in files:
   # ¿ is opened ?

On Linux and some other Unixes, you can probably read the /proc filesystem.

On Windows, you'll probably get the quickest result by running 
handle.exe (http://www.sysinternals.com/Utilities/Handle.html).

Either way, the information you'll get is restricted by your permissions.

Either information will get stale really fast, so it's not suitable if 
your task is something like 'can I backup this directory or is someone 
writing to a file?'

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


Re: Python IDE

2005-07-20 Thread Franz Steinhaeusler
On 18 Jul 2005 22:32:43 -0700, linuxfreak [EMAIL PROTECTED] wrote:

Tried SPE and
Dr.Pyhton but the former crashes regulary and the latter is quite
unweildy and does not have a great many features


Hello,

what are you missing in DrPython?
Did you took a look at the plugins?
What do you mean by unweildly?

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


Re: is a file open ?

2005-07-20 Thread John Machin
Daniel Dittmar wrote:
 luis wrote:
 
 for root, dirs, files in os.walk(path):
for file in files:
   # ¿ is opened ?
 
 
 On Linux and some other Unixes, you can probably read the /proc filesystem.
 
 On Windows, you'll probably get the quickest result by running 
 handle.exe (http://www.sysinternals.com/Utilities/Handle.html).
 
 Either way, the information you'll get is restricted by your permissions.
 
 Either information will get stale really fast, so it's not suitable if 
 your task is something like 'can I backup this directory or is someone 
 writing to a file?'

If that's what the OP had in mind, the question might have been better 
phrased as given the path to a file, how can I tell if it is currently 
opened by another process/thread, and better directed to OS-specifc 
newsgroup(s).

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


Re: Python IDE

2005-07-20 Thread Franz Steinhaeusler
On 19 Jul 2005 19:56:49 -0700, Luis M. Gonzalez [EMAIL PROTECTED]
wrote:

Have you tried PyCrust?
http://sourceforge.net/projects/pycrust/

It is long time ago, that pycrust was delevoped 
as sourceforge project.

It is part of the wxPython distribution and 
I have recently added some features.

You could take a look at wxPython-user mailing list.

Pycrust is great to try/play with Python and wxPython.

But also DrPython has a powerful shell prompt.
-- 
Franz Steinhaeusler
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: list implementation

2005-07-20 Thread Heikki Orsila
Raymond Hettinger [EMAIL PROTECTED] wrote:
 [sj]
 Thus, random access is an O(1) operation while insertion/deletion is an
 O(n) operation.

 Yes.

Unfortunately no. Check Terry Reeds answer. Random access is O(1),
insertion/deletion to front is O(n), and i/d to back is O(1). The back
i/d operation has amortized O(1) cost.

-- 
Heikki Orsila   Barbie's law:
[EMAIL PROTECTED]   Math is hard, let's go shopping!
http://www.iki.fi/shd
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OO design

2005-07-20 Thread chris
Extremely grateful for all the responses. I've pasted them all into a
document and can now read all your valuable ideas together. Even at a first
reading they have already helped clarify my thinking.

Also minor clarifications::

 I'm hoping some of you python
 lamas out there might be able to share some of your wisdom on the subject.

lama = guru = teacher(not a furry animal, although my dog has certainly
taught me a few tricks ... like when to take her for a walk, when to play
ball, and when its time for a tummy rub.)

 bwaha

be well and happy always






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


Re: How to send a query to the browser from time to time?

2005-07-20 Thread Admin
On Tue, 19 Jul 2005 19:43:25 -0300, [EMAIL PROTECTED] [EMAIL PROTECTED]  
wrote:

 otherwise, my only suggestion is to use another protocol instead of
 http.

What do you suggest?


-- 
Thanks,

Admin.
Want to buy me a book? http://tinyurl.com/78xzb :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: access the text being generated in other windows

2005-07-20 Thread bmgz
algebraist wrote:
 is there a way python can access the text being generated in other
 windows, by other programs/processes?

my guess- you will probably have to resort to some rather downright 
dirty screen scraping.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: goto

2005-07-20 Thread Peter Hansen
Sybren Stuvel wrote:
 Mike Meyer enlightened us with:
 
I dislike gotos because it is too easy to inadvertently create
infinite loops. 10 WINK; 20 GOTO 10

And it's impossible without them? while True: pass
 
 
 I thought the same thing, but then I read it again and thought about
 the inadvertently. As soon as you see a while True, you _know_
 it's going to loop forever. 

Unless it doesn't, of course:

while True:
 break
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Strange os.path.exists() behaviour

2005-07-20 Thread Casey Hawthorne
Does this work differently under other platforms?

Pierre Quentel [EMAIL PROTECTED] wrote:

os.path.exists(path) returns True if path exists

But on Windows it also returns True for path followed by any number of 
dots :

Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)] on win32
Type help, copyright, credits or license for more information.
  import os
  os.path.exists('Lib/os.py')
True# expected
  os.path.exists('Lib/os.py.')
True# unexpected
  os.path.exists('Lib/os.py.')
True# unexpected
 

Is there a reason for this ? Is there a test that returns True only for 
the really existing path ?

Pierre

--
Regards,
Casey
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python certification

2005-07-20 Thread [EMAIL PROTECTED]
hi
i bassically need it cuz i am appyling to colleges this year and
i know this kind of stuff really helps.
besides since i am learning python i thought i might get some credit
for it as well.
its bassically for a mention in my resume/bio-data/appliccation
i am willing to spend about $50-100 but any more is out of my bugdet.
even $50 is hard on me.
i did find this great site that would  let me give a perl exam in $9.99
but they don't have python.

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


Re: python certification

2005-07-20 Thread dimitri pater
Hello,
Python is not about certificates or diplomas, so do not spend any money
on it (the other guy was only joking). If you want to show your python
skills to others (like the teachers from the college you want to go
to), use this list. Participate in discusions, ask quesions, maybe even
write a tutorial. Maybe then they will think: hey, this guy (or girl)
is really doing something with his skills.

Just an idea,
DimitriOn 20 Jul 2005 05:41:39 -0700, [EMAIL PROTECTED] 
[EMAIL PROTECTED] wrote:hii bassically need it cuz i am appyling to colleges this year and
i know this kind of stuff really helps.besides since i am learning python i thought i might get some creditfor it as well.its bassically for a mention in my resume/bio-data/appliccationi am willing to spend about $50-100 but any more is out of my bugdet.
even $50 is hard on me.i did find this great site that wouldlet me give a perl exam in $9.99but they don't have python.--http://mail.python.org/mailman/listinfo/python-list
-- All
truth passes through three stages. First, it is ridiculed. Second, it
is violently opposed. Third, it is accepted as being self-evident.Arthur Schopenhauer -Please visit dimitri's website: www.serpia.com
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Python s60 Contact DB

2005-07-20 Thread xen0n
I have already posted the question to the Nokia forum, but, for now,
noone seems to have an answer... Hope this is a bug of py2sis... I dont
want to rewrite my entire application for a stupid bug!

could ildg ha scritto:
 You should raise this question at Nokia python for series60 forum,
 I'm sure you can the answer there.
 http://discussion.forum.nokia.com/forum/forumdisplay.php?s=85e4c1acee330fddde6b47a7b2feae73forumid=102


 On 19 Jul 2005 06:47:10 -0700, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
  Hi, i hope the expert can help me!
  I have a little problem:
 
  This piece of code, in python console s60, before compiling will work
  great:
 
  try:
  ..db = contacts.open()
  ..names = []
  ..numbers = []
 
  The problem is that, if i compile it with py2sis (pyrsc_template.tmp
  replaced with the original to solve the submenus bug) it doesnt work,
  when that piece of code is executed, i receive error -50 and nothing
  happen! hope u can help me! 10ks a lot in advance
 
  Regards.
  
  --
  http://mail.python.org/mailman/listinfo/python-list
 

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


is this pythonic?

2005-07-20 Thread Mage
Or is there better way?

for (i, url) in [(i,links[i]) for i in range(len(links))]:
  ...

links is a list.

   Mage


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


Re: is this pythonic?

2005-07-20 Thread Simon Brunning
On 7/20/05, Mage [EMAIL PROTECTED] wrote:
 Or is there better way?
 
 for (i, url) in [(i,links[i]) for i in range(len(links))]:

for i, url in enumerate(links):

-- 
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: main window in tkinter app

2005-07-20 Thread William Gill
That does it!, thanks.

Thinking about it, when I created a derived class with an  __init__ 
method, I  overrode the base class's init.  It should have been 
intuitive that I needed to explicitly call baseclass.__init(self), it 
wasn't.  It might have hit me if the fault was related to someting in 
baseclass.__init() not taking place, but the recursion loop didn't give 
me a clue.  Any idea why failing to init the base class caused the loop?


Bill


Christopher Subich wrote:
 William Gill wrote:
 
 O.K. I tried from scratch, and the following snippet produces an 
 infinite loop saying:

   File C:\Python24\lib\lib-tk\Tkinter.py, line 1647, in __getattr__
   return getattr(self.tk, attr)

 If I comment out the __init__ method, I get the titled window, and 
 print out self.var ('1')


 import  os
 from Tkinter import *

 class MyApp(Tk):
 var=1
 def __init__(self):
   pass
 def getval(self):
   return self.var


 app = MyApp()

 app.title(An App)
 print app.getval()
 app.mainloop()
 
 
 You're not calling the parent's __init__ inside your derived class.  I 
 would point out where the Python Tutorial points out that you should do 
 this, but it's not in the obvious place (Classes: Inheritance).
 
 Python does -not- automagically call parent-class __init__s for derived 
 classes, you must do that explicitly.  Changing the definition of your 
 class to the following works:
   class MyApp(Tk):
 var=1
 def __init__(self):
   Tk.__init__(self)
   pass
 def getval(self):
   return self.var
 
 It works when you comment out __init__ because of a quirk in Python's 
 name resolution.  As you'd logically expect, if you don't define a 
 function in a derived class but call it (such as instance.method()), it 
 will call the method from the base class.
 
 You just proved that this works for __init__ methods also.  When you 
 didn't define __init__ for your derived class, MyApp() called 
 Tk.__init__(), which Does the Right Thing in terms of setting up all the 
 specific Tkinter-specific members.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: socket programming

2005-07-20 Thread gry
What I have done in similar circumstances is put in a random sleep
between connections to fool the server's load manager.  Something like:

.import time
.min_pause,max_pause = (5.0, 10.0) #seconds
.while True:
.   time.sleep(random.uniform(min_pause, max_pause))
.   do_connection_and_query_stuff()

It works for me.  Just play with the pause parameters until it fails
and add a little.

-- George

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


Re: Python IDE

2005-07-20 Thread projecktzero
You should probably stick with Xemacs. I use VIM, but I would be
surprised if Xemacs doesn't have those features you want. Also, it's
probably better to learn one editor well than a little bit of a bunch
of different editors.

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


Re: How do I send keystrokes to a console window in Windows XP?

2005-07-20 Thread RTG
Thank you, Peter.

The application is a continuously running interactive program and
we want to automatically interact with it (e.g. sendkeys and capture
certain text responses).

I will look for the thread you mentioned.

- Roy

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


Re: How to kill easygui dialog?

2005-07-20 Thread utabintarbo
William,

Thanks for the reply. No flames, but I am running on both Linux and
Windows, so I need a x-platform  solution. I thought I had it with
easygui...

Must try some other ideas

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


Re: socket programming

2005-07-20 Thread Helge Aksdal
* gry@ll.mit.edu gry@ll.mit.edu [2005/07/20 15:26]:

 What I have done in similar circumstances is put in a random sleep
 between connections to fool the server's load manager.  Something like:
 
 .import time
 .min_pause,max_pause = (5.0, 10.0) #seconds
 .while True:
 .   time.sleep(random.uniform(min_pause, max_pause))
 .   do_connection_and_query_stuff()
 
 It works for me.  Just play with the pause parameters until it fails
 and add a little.

thanks for the tip. i'll give that a shot.

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


getting the class name of a subclass

2005-07-20 Thread flupke
I have the following test code setup, trying to get the class name of a 
subclass in the super class. (Reason why i want this is described below)

file class_name_start.py

import class_name as cn

obj = cn.B()
obj.printclass()



file class_name.py

class A(object):
 def __init__(self):
 print I'm A

 def printclass(self):
 print Name ,__name__
 print Class ,A.__name__

class B(A):
 def __init__(self):
 super(B,self).__init__()
 print I'm B


Output:
I'm A
I'm B
Name  class_name
Class A

I would want the last line to be Class B
The reason i want this is since i have a number of dialogs all deriving 
from the same super class. In the superclass i have a save function and 
i thought it would be easy to get the classname and write the properties 
in a filename with the classes name as the filename.
However it turns out i get the class name of the superclass for all.
All the different dialogs are in seperate files.

Is there a way to get the name of the subclass. If not i could always 
pass a param to the init function but in my real life code i already 
have several params shipped to the init so i wanted to solve it slightly 
more elegant.

Regards,
Benedict
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python certification

2005-07-20 Thread Fabien
 Python is not about certificates or diplomas, so do not spend any
 money on it (the other guy was only joking).

Even if Python is not about certificates, I think it's not the case for
some company. And when you say to a company that you know how to dev. in
Python, they don't know anything about your level.

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


Re: How to kill easygui dialog?

2005-07-20 Thread Martin Franklin
[EMAIL PROTECTED] wrote:
 William,
 
 Thanks for the reply. No flames, but I am running on both Linux and
 Windows, so I need a x-platform  solution. I thought I had it with
 easygui...
 
 Must try some other ideas
 


Can you post an example... the following works for me...


  import easygui
  while 1:
... rv = easygui.enterbox()
... if rv:
... print Done
... break
...
...
Done

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


Re: python certification

2005-07-20 Thread Cyril Bazin
Fine, 

Go to http://www.pythonchallenge.com and try the challenge, if you
are able to get to the level 17-18, you can say you start to have good
skills in Python. You will prove:
you are not stupid, 
you know regex, basic sound/image treatment, the basics of zip/bz2, you
understood how to use urllib/urllib2 and xmlrpc and many other things.

When you get to the level 17-18, go to the IRC and ask to theSamet a
certification. If he is in a good mood, maybe he will give you an
ascii-art diplom like Rocco! ;-)

Cyril
On 20 Jul 2005 05:41:39 -0700, [EMAIL PROTECTED] [EMAIL PROTECTED]
 wrote:hii bassically need it cuz i am appyling to colleges this year and
i know this kind of stuff really helps.besides since i am learning python i thought i might get some creditfor it as well.its bassically for a mention in my resume/bio-data/appliccationi am willing to spend about $50-100 but any more is out of my bugdet.
even $50 is hard on me.i did find this great site that wouldlet me give a perl exam in $9.99but they don't have python.--http://mail.python.org/mailman/listinfo/python-list

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

Crafting IP packets with DNS queries .........newbie

2005-07-20 Thread laksh
hi all

im looking for some code that can capture the IP packets from my system
and craft them so that im able to put lots of DNS requests in them and
send them to the server.

is it possible and will the DNS server takes it for legal DNS request
packets?? and should i need to incorporate some code at the server end
to decode the packets from my machine and encode the results from the
DNS??

is all this possible ?

first of all i want to know to craft some IP packets in python with
loads of DNS queries in them..

regards
laksh

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


wxPython field validation

2005-07-20 Thread lux
Hi all,
I'm using wxPython and I need to block
the cursor (focus) in a TextCtrl until the field
value is valid.

I've look EVT_KILL_FOCUS but I can't stop the
focus beavoir (no focus to next field)

Any ideas?

Tanks a lot and sorry for my english.

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


Re: python certification

2005-07-20 Thread Andreas Kostyrka
On Wed, Jul 20, 2005 at 04:22:10PM +0200, Fabien wrote:
  Python is not about certificates or diplomas, so do not spend any
  money on it (the other guy was only joking).
 
 Even if Python is not about certificates, I think it's not the case for
 some company. And when you say to a company that you know how to dev. in
 Python, they don't know anything about your level.

Well, that's what CVs, project histories and interviews are about.

Asking for certification in Python (and propably for any other programming
language) usually only shows that the person who asks doesn't have a clue
what they are asking about ;)

(These are the people look for Pearl and Pyhton programmers ;) )

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


Re: Windows command line problem

2005-07-20 Thread Benji York
[EMAIL PROTECTED] wrote:
 I think the lesson there is 'dont depend on getopt, write your own
 command line parser'. I always write my own, as it's so easy to do.

While I'll agree that getopt isn't ideal, I find optparse to be much better.
--
Benji York

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


Re: python certification

2005-07-20 Thread Kay Schluehr


[EMAIL PROTECTED] schrieb:
 hi
 i bassically need it cuz i am appyling to colleges this year and
 i know this kind of stuff really helps.
 besides since i am learning python i thought i might get some credit
 for it as well.
 its bassically for a mention in my resume/bio-data/appliccation
 i am willing to spend about $50-100 but any more is out of my bugdet.
 even $50 is hard on me.
 i did find this great site that would  let me give a perl exam in $9.99
 but they don't have python.

Before you spend some of your few money for an obscure certification
without any authority you should feel certain that you need Python at
your college. Better you participate in an open source project for fun
and gathering some experience if it's not too hard for you to access a
computer. Of course I don't know your supervisors and I'm not sure
whether they are more impressed about people learning the Python
tutorial, than about people using it to write real world applications.

Kay

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


Re: python certification

2005-07-20 Thread Kay Schluehr
Andreas Kostyrka schrieb:

 (These are the people look for Pearl and Pyhton programmers ;) )

Or Phyton :)

Kay

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


Re: getting the class name of a subclass

2005-07-20 Thread George Sakkis
flupke [EMAIL PROTECTED] wrote:

 I have the following test code setup, trying to get the class name of a
 subclass in the super class. (Reason why i want this is described below)

 file class_name_start.py
 
 import class_name as cn

 obj = cn.B()
 obj.printclass()
 


 file class_name.py
 
 class A(object):
  def __init__(self):
  print I'm A

  def printclass(self):
  print Name ,__name__
  print Class ,A.__name__

 class B(A):
  def __init__(self):
  super(B,self).__init__()
  print I'm B
 

 Output:
 I'm A
 I'm B
 Name  class_name
 Class A

 I would want the last line to be Class B
 The reason i want this is since i have a number of dialogs all deriving
 from the same super class. In the superclass i have a save function and
 i thought it would be easy to get the classname and write the properties
 in a filename with the classes name as the filename.
 However it turns out i get the class name of the superclass for all.
 All the different dialogs are in seperate files.

 Is there a way to get the name of the subclass. If not i could always
 pass a param to the init function but in my real life code i already
 have several params shipped to the init so i wanted to solve it slightly
 more elegant.

 Regards,
 Benedict


Make printclass a class method:

class A(object):
def __init__(self):
print I'm A

# for python 2.4
@classmethod
def printclass(cls):
print Module, cls.__module__
print Class, cls.__name__
# for 2.3 or older
printclass = classmethod(printclass)


Regards,
George


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


Re: getting the class name of a subclass

2005-07-20 Thread flupke
George Sakkis wrote:
snip

 Make printclass a class method:
 
 class A(object):
 def __init__(self):
 print I'm A
 
 # for python 2.4
 @classmethod
 def printclass(cls):
 print Module, cls.__module__
 print Class, cls.__name__
 # for 2.3 or older
 printclass = classmethod(printclass)
 
 
 Regards,
 George

George,

it works like a charm.

Thanks!
Benedict
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: wxPython field validation

2005-07-20 Thread fred.dixon
why not validate then put cursor back into that field until satisfied.
might use the lost focus (cant remember exact name right now)

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


Re: getting the class name of a subclass

2005-07-20 Thread Dan Sommers
On Wed, 20 Jul 2005 14:06:57 GMT,
flupke [EMAIL PROTECTED] wrote:

 file class_name.py
 
 class A(object):
  def __init__(self):
  print I'm A

  def printclass(self):
  print Name ,__name__
  print Class ,A.__name__

Why A.__name__ and not self.__class__.__name__?

Regards,
Dan

-- 
Dan Sommers
http://www.tombstonezero.net/dan/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What does :: mean?

2005-07-20 Thread qwweeeit
Hi Robert,
I didn't succeed in reversing a string with the full form you
proposed:
live[len(live)-1:-1:-1] # where live=live
The result is an empty string.
To  reverse live (in a full form), I have to put a char in front of
the string and...:
('x'+live)[len(live)+1:0:-1]   # -- evil
Is it due to the Python's version (I still have 2.3.4)?
Bye.

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


Need to interrupt to check for mouse movement

2005-07-20 Thread stringy
I have a program that shows a 3d representation of a cell, depending on
some data that it receives from some C++. It runs with wx.timer(500),
and on wx.EVT_TIMER, it updates the the data, and receives it over the
socket.
In my program I also want to be able to rotate the 3d representation,
and can do so, and all the code works. However, I have a problem in
that while the program is updating itself (pretty much all the time
unless I tell it not to), it won't detect mouse motion, I'm guessing
because it doesn't have time to.

Is there any manual way to get a program to check for mouse movement,
that way I'd be able to check for mouse movement half way through my
updating the data over the socket, and then do the necessary rotations
before it finishes updating the data.

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


Re: What does :: mean?

2005-07-20 Thread Robert Kern
[EMAIL PROTECTED] wrote:
 Hi Robert,
 I didn't succeed in reversing a string with the full form you
 proposed:
 live[len(live)-1:-1:-1] # where live=live
 The result is an empty string.
 To  reverse live (in a full form), I have to put a char in front of
 the string and...:
 ('x'+live)[len(live)+1:0:-1]   # -- evil
 Is it due to the Python's version (I still have 2.3.4)?

No, it's because I am stupid. There isn't a full form. 
live[len(live)::-1] is the closest expansion.

-- 
Robert Kern
[EMAIL PROTECTED]

In the fields of hell where the grass grows high
  Are the graves of dreams allowed to die.
   -- Richard Harter

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


Re: Image orientation and color information with PIL?

2005-07-20 Thread tvmaly
Jeff, this was exactly what I was looking for.  I wrote a script with
this code and it worked perfectly.

  Thanks 

 Ty

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


ANN: PyDev 0.9.6 released

2005-07-20 Thread Fabio Zadrozny
Hi All,

PyDev - Python IDE (Python Development Enviroment for Eclipse) version 
0.9.6 has just been released.

This is to be considered a stable release for all features but the 
debugger, as there are still some integration issues for it to work with 
Eclipse 3.1, so, if you are using PyDev because of its debugger support, 
you should stick to version 3.0.x until those issues are fixed.

Check the homepage (http://pydev.sourceforge.net/) for more details.

The major release highlights is that it Eclipse 3.1 is now supported. 
Older versions of Eclipse are no longer supported.

Regards,

-- 
Fabio Zadrozny
--
Software Developer

ESSS - Engineering Simulation and Scientific Software
www.esss.com.br

PyDev - Python Development Enviroment for Eclipse
pydev.sf.net
pydev.blogspot.com


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


convert ascii escapes into binary form

2005-07-20 Thread Hans-Peter Jansen
Hi Pythonistas,

I need to convert ascii escapes into binary form, e.g.:
\f - ^L
[EMAIL PROTECTED] - [EMAIL PROTECTED]@

(rvalues in terminal representation)

Any idea, how to do this most elegantly in python?
Do I really need to do a search n'replace orgy, combined with 
regex for this task?

TIA,
Pete


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


Re: python certification

2005-07-20 Thread Sebastian Bassi
On 16 Jul 2005 09:51:55 -0700, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:
 i want to get a small certificate or diploma in python.
 it should be online cuz i live in pakistan and wont have teast centers
 near me.
 it should be low cost as i am not rich.
 and hopefully it would be something like a a begginer certification cuz
 i am new to python.

I could make a program, upload it to sourceforge (or similar OSS
repository) and add that to your resume. Another opcion is to help in
the development of any python-based program and work enought to be
included in the authors list. That could be useful too (because you
learn and do some good for more people). I believe more in a working
program than a paper based certificate.


-- 
a href=http://www.spreadfirefox.com/?q=affiliatesid=24672t=1;La
web sin popups ni spyware: Usa Firefox en lugar de Internet
Explorer/a
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie question: Explain this behavior - a followup

2005-07-20 Thread David Smith
max wrote:
 David Smith [EMAIL PROTECTED] wrote in
 news:[EMAIL PROTECTED]: 
 
 
range statements, the example doesn't work.

Given that the beginning and ending values for the inner range
statement are the same, the inner range statement will never be
 
 
 Is your question about the semantics of for else blocks or about the 
 suitability of the algorithm given in the example? The for else block 
 is behaving exactly as expected...
 
 

Good question.  The question was directed at the latter, the suitability 
of algorithm for determining prime numbers.

range(1,1)
 
 []
 
range(500,500)
 
 []
 
 
 see 
 http://groups-
 beta.google.com/group/comp.lang.python/browse_frm/thread/d6c084e791a00
 2f4?q=for+elsehl=en
 
 for a good explanation of when the else part of the loop is executed. 
 Basically, whenever the loop is exited normally, which is what happens 
 when you iterate over an empty list like the one returned by 
 range(1,1)
 
 
 max
 
 
-- 
http://mail.python.org/mailman/listinfo/python-list


How to store 3D data? (data structure question)

2005-07-20 Thread Sebastian Bassi
Hello,

I have to parse a text file (was excel, but I translated to CSV) like
the one below, and I am not sure how to store it (to manipulate it
later).

Here is an extract of the data:

Name,Allele,RHA280,RHA801,RHA373,RHA377,HA383
TDF1,181,
,188,
,190,
,193,*,*,,,
,None,,,*,*,*
,,
TDF2,1200,*,*,,,*
,None,,,*,*,
,,
TDF3,236,
,240,
,244,*,,*,,*
,252,*,*,,,
,None*,
,,

Should I use lists? Dictionary? Or a combination?
The final goal is to count how many stars (*) has any LINE (a line
is RHA280 for instance).
RHA280 has 1 star in TDF1 and 1 star in TDF2 and 2 stars in TDF3.

I am lost because I do analize the data line by line (for Line in
FILE) so it is hard to count by column.



-- 
a href=http://www.spreadfirefox.com/?q=affiliatesid=24672t=1;La
web sin popups ni spyware: Usa Firefox en lugar de Internet
Explorer/a
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: convert ascii escapes into binary form

2005-07-20 Thread Robert Kern
Hans-Peter Jansen wrote:
 Hi Pythonistas,
 
 I need to convert ascii escapes into binary form, e.g.:
 \f - ^L
 [EMAIL PROTECTED] - [EMAIL PROTECTED]@
 
 (rvalues in terminal representation)
 
 Any idea, how to do this most elegantly in python?
 Do I really need to do a search n'replace orgy, combined with 
 regex for this task?

In [11]: s = '\\f'

In [12]: s.decode('string_escape')
Out[12]: '\x0c'

-- 
Robert Kern
[EMAIL PROTECTED]

In the fields of hell where the grass grows high
  Are the graves of dreams allowed to die.
   -- Richard Harter

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


Re: main window in tkinter app

2005-07-20 Thread Christopher Subich
William Gill wrote:
 That does it!, thanks.
 
 Thinking about it, when I created a derived class with an  __init__ 
 method, I  overrode the base class's init.  It should have been 
 intuitive that I needed to explicitly call baseclass.__init(self), it 
 wasn't.  It might have hit me if the fault was related to someting in 
 baseclass.__init() not taking place, but the recursion loop didn't give 
 me a clue.  Any idea why failing to init the base class caused the loop?

You never pasted the first part of the traceback:

   File pyshell#204, line 1, in -toplevel-
 app.title('frob')
   File C:\Python24\Lib\lib-tk\Tkinter.py, line 1531, in wm_title
 return self.tk.call('wm', 'title', self._w, string)
   File C:\Python24\Lib\lib-tk\Tkinter.py, line 1654, in __getattr__
 return getattr(self.tk, attr)
   File C:\Python24\Lib\lib-tk\Tkinter.py, line 1654, in __getattr__
 return getattr(self.tk, attr)

When you didn't call Tk.__init__(self), self.tk was never initialized. 
Further, it's obvious from the traceback that Tk implements a 
__getattr__ method; from the python docs:

__getattr__(self,name): Called when an attribute lookup has not found 
the attribute in the usual places

Since self.tk doesn't exist, __getattr__(self,tk) was called.  Without 
looking at the TKinter source code, we can surmise that there's a 
default behavior of if self doesn't have it, return the relevant 
attribute from within self.tk.  The problem, of course, arises when 
self.tk doesn't exist -- this causes the self.tk reference to call 
self.__getattr__('tk'), which is recursive.

The infinite recursion, then, is a mild bug in TKinter that doesn't show 
itself during normal use.  The proper solution should be to replace the 
self.tk call with either self.__dict__['tk'], or to make Tk a new-style 
class and use object.__getattribute__(self,'tk'). (Note: there are 
probably some fine details that I'm missing in this 'solution', so take 
it with a potato-sized grain of salt.  The general principle still 
applies though.)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie - chapter 19 in How to think like a CS in python

2005-07-20 Thread MooMaster
Well, being a lowly CS student myself this sounded like fun, so I went
ahead and took the challenge. The first thing you have to consider is
how to add the new element to the list. Obviously you have to iterate
through the list, find the first element that the new one is greater
than, and insert this one before it while keeping the list structure
intact. You must also remember to update the head if necessary, and add
at the end if the element to be added is less than what is already in
the list...So this is what I came up with:

First of all, however, add this to your Improved Queue Class-
 def printQueue(self):
if(self.isEmpty()):
print Empty
else:
pointer = self.head
while(pointer != None):
print str(pointer.cargo)
pointer = pointer.next

Then--
class PriorityQueueList(ImprovedQueue):
def __init__(self):
ImprovedQueue.__init__(self)

def insert(self, cargo):
newNode = Node(cargo)
if self.length == 0:
self.head = self.last = newNode
else:
#iterate through the list, keeping a reference to a
node and the node before it
tracker = self.head
while(tracker !=None):
copy2 = tracker.prev
if(newNode.cargo  tracker.cargo):
#add the new node by updating links, then update
head while keeping list intact
tracker.prev = newNode
newNode.next = tracker
self.head = newNode
newNode.prev = copy2
if(copy2 !=None):
copy2.next = newNode
break
else:
tracker = tracker.next
#if a repeat element is added
#we want to add to end to preserve the queue structure,
thus if the element hasn't
#been added at this point it should be added at the end

if(newNode.prev ==None and newNode.next ==None):
last = self.last
last.next = newNode
self.last = newNode
self.length = self.length + 1

This produces the following output-
 l = PriorityQueueList()
 l.insert(1)
 l.insert(2)
 l.insert(1)
 l.printQueue()
2
1
1
 l.insert(10)
 l.printQueue()
10
2
1
1

Hope this helps!

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


Re: Need to interrupt to check for mouse movement

2005-07-20 Thread MooMaster
Have you tried binding EVT_MOTION(func) to your window?

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


Re: How to store 3D data? (data structure question)

2005-07-20 Thread Graham Fawcett
Sebastian Bassi wrote:
 Hello,

 I have to parse a text file (was excel, but I translated to CSV) like
 the one below, and I am not sure how to store it (to manipulate it
 later).

 Here is an extract of the data:

[snip]

This looks a lot like 2D data (row/column), not 3D. What's the third
axis? It looks, too, that you're not really interested in storage, but
in analysis...

Since your line columns all have names, why not use them as keys in a
dictionary? The associated values would be lists, in which you could
keep references to matching rows, or parts of those rows (e.g. name and
allele). Count up the length of the row, and you have your number of
matches.



import csv  # let Python do the grunt work

f = file('name-of-file.csv')
reader = csv.reader(f)

headers = reader.next() # read the first row
line_names = headers[2:]

results = {}# set up the dict
for lname in line_names:# each key is a line-name
results[lname] = []

for row in reader:  # iterate the data rows
row_name, allele = row[:2]
line_values = row[2:]   # get the line values.
# zip is your friend here. It lets you iterate
# across your line names and corresponding values
# in parallel.
for lname, value in zip(line_names, line_values):
if value == '*':
results[lname].append((row_name, allele))

# a quick look at the results.
for lname, matches in results.items():
print '%s %d' % (lname, len(matches))


Graham

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


Re: Using SHFileOperation

2005-07-20 Thread Roger Upole
SHFILEOPSTRUCT is just a tuple, with the elements
listed in docs.

from win32com.shell import shell, shellcon
shell.SHFileOperation((0, shellcon.FO_DELETE, 'somefilename', None, 
shellcon.FOF_ALLOWUNDO|shellcon.FOF_NOCONFIRMATION))

   hth
   Roger

avishay [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]
 Hi All,
 I want to use SHFileOperation using Python and Win32 extentions, in
 order to move a file to the trash can. The function itself can be
 accessed by importing win32com.shell.shell. However, I cannot find
 anywhere the SHFILEOPSTRUCT. This structure is mentioned in the
 documentation of the Win32 extentions, but I can't find a way to access
 it.
 I would appreciate your help. If there's an alternative way to send a
 file to the trash can, that can also help.

 Best Regards
 Avishay
 



== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ 
Newsgroups
= East and West-Coast Server Farms - Total Privacy via Encryption =
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to store 3D data? (data structure question)

2005-07-20 Thread Sebastian Bassi
On 20 Jul 2005 10:47:50 -0700, Graham  Fawcett [EMAIL PROTECTED] wrote:
 This looks a lot like 2D data (row/column), not 3D. What's the third
 axis? It looks, too, that you're not really interested in storage, but
 in analysis...

I think it as 3D like this:
1st axis: [MARKER]Name, like TDF1, TDF2.
2nd axis: Allele, like 181, 188 and so on.
3rd axis: Line: RHA280, RHA801.

I can have a star in MarkerName TDF1, Allele 181 and Line RHA280.
I can have an empty (o none) in TDF1, Allele 181 and Line RHA801.

What I like to know is what would be a suitable structure to handle this data?
thank you very much!

-- 
a href=http://www.spreadfirefox.com/?q=affiliatesid=24672t=1;La
web sin popups ni spyware: Usa Firefox en lugar de Internet
Explorer/a
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: convert ascii escapes into binary form

2005-07-20 Thread Hans-Peter Jansen
Robert Kern wrote:

 Hans-Peter Jansen wrote:
 Hi Pythonistas,
 
 I need to convert ascii escapes into binary form, e.g.:
 \f - ^L
 [EMAIL PROTECTED] - [EMAIL PROTECTED]@
 
 (rvalues in terminal representation)
 
 Any idea, how to do this most elegantly in python?
 Do I really need to do a search n'replace orgy, combined with
 regex for this task?
 
 In [11]: s = '\\f'
 
 In [12]: s.decode('string_escape')
 Out[12]: '\x0c'

That did the trick, thanks a lot, Peter. Unfortunately, on the 
target system, there's still python 2.0 running :-( Looks like 
I've to bite the apple..

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


Re: access the text being generated in other windows

2005-07-20 Thread algebraist
yeah, someone else mentioned getting the window's handle (can use
spyxx.exe for this) and then using hooks... but i'm not sure where to
go to learn about using window hooks, in python (or in general,
actually)...

is this 'downright dirty screen scraping'?

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


EasyDialogs in MacOSX Tiger

2005-07-20 Thread Ian A. York

When I use EasyDialogs.Message in OSX (10.4.2), I have to manually switch 
to Python, the icon for which jumps in the dock until I click it.  This is 
the case using pythonw with either 2.3 or 2.4.  

This question has come up before (EasyDialogs module problem with python 
2.4.1, April 18/05), and the answer that was give then was 

 One application is active at any point in time, and this application 
 controls the menu, has its windows displayed, and so on. So when the 
 Terminal.app is active, Python cannot be.

However, this is new behaviour.  Wen I used EasyDialogs in earlier 
versions of OSX (10.3 and 10.2) this did not happen; the EasyDialogs 
dialog box popped up at once with no further interaction required.  Unless 
MacOSX has changed its use of active applications, then, I think this 
explanation isn't correct.

Does anyone have any thoughts on how to make EasyDialogs work the way it 
used to in OS 10.3?  

Ian
-- 
Ian York   ([EMAIL PROTECTED])  http://www.panix.com/~iayork/
-but as he was a York, I am rather inclined to suppose him a
 very respectable Man. -Jane Austen, The History of England
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OO design

2005-07-20 Thread Terry Hancock
On Wednesday 20 July 2005 07:22 am, chris wrote:
 Also minor clarifications::
 
  I'm hoping some of you python
  lamas out there might be able to share some of your wisdom on the subject.
 
 lama = guru = teacher(not a furry animal, although my dog has certainly
 taught me a few tricks ... like when to take her for a walk, when to play
 ball, and when its time for a tummy rub.)

Ah, of course.  My mistake. ;-)

--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com

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


Re: How to store 3D data? (data structure question)

2005-07-20 Thread Sebastian Bassi
On 20 Jul 2005 10:47:50 -0700, Graham  Fawcett [EMAIL PROTECTED] wrote:
 # zip is your friend here. It lets you iterate
 # across your line names and corresponding values
 # in parallel.

This zip function is new to me, the only zip I knew was pkzip :). So
will read about it.

-- 
a href=http://www.spreadfirefox.com/?q=affiliatesid=24672t=1;La
web sin popups ni spyware: Usa Firefox en lugar de Internet
Explorer/a
-- 
http://mail.python.org/mailman/listinfo/python-list


Printing a variable's name not its value

2005-07-20 Thread travislspencer
Hey,

I am trying to write a function that takes an arbitrary number of
arguments and does one of two things.  If the variable is a key in a
dictionary, it prints the key and its value.  Otherwise, if any of the
variables isn't in the dictionary, the function prints the variable's
name and value.

Here is what I have so far:

globals = {}
HOME_DIR = The user's home directory
SHELL = The user's shell

def someFunction():
someString = This is a test
globals[VERBOSE] = True
globals[HOME_DIR] = os.getenv(HOME)
globals[SHELL] = os.getenv(SHELL)

printVerbose(someString, HOME_DIR, SHELL)

def printVerbose(*args):
if VERBOSE in globals:
for a in args:
value = 

if a in globals:
value = globals[a]
#else
#a = a.__name__
#value = a

print %s: %s % (a, value)

This prints something like this:

The user's home directory: /home/tspencer
The use's shell: zsh

But what I would like it to print is this:

The user's home directory: /home/tspencer
The use's shell: zsh
someString: This is a test

I've been told on #python that there isn't a way to get a variable's
name.  I hope this isn't so.  If it helps, I am trying to do something
like what the C preprocessor's # operator does.

TIA.

--

Regards,

Travis Spencer

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


Re: How to store 3D data? (data structure question)

2005-07-20 Thread Graham Fawcett
Sebastian Bassi wrote:
 On 20 Jul 2005 10:47:50 -0700, Graham  Fawcett [EMAIL PROTECTED] wrote:
  This looks a lot like 2D data (row/column), not 3D. What's the third
  axis? It looks, too, that you're not really interested in storage, but
  in analysis...

 I think it as 3D like this:
 1st axis: [MARKER]Name, like TDF1, TDF2.
 2nd axis: Allele, like 181, 188 and so on.
 3rd axis: Line: RHA280, RHA801.

 I can have a star in MarkerName TDF1, Allele 181 and Line RHA280.
 I can have an empty (o none) in TDF1, Allele 181 and Line RHA801.

Okay. I think what will drive your data-structure question is the way
that you intend to use the data. Conceptually, it will always be 3D, no
matter how you model it, but trying to make a 3D data structure is
probably not what is most efficient for your application.

If 90% of your searches are of the type, 'does TDF1/181/RHA280 have a
star?' then perhaps a dict using (name,allele,line) as a key makes most
sense:

  d = {('TDF1',181,'RHA280'):'*', ...}
  query = ('TDF1', 181, 'RHA280')
  assert query in d

Really, you don't need '*' as a value for this, just use None if you
like, since all the real useful info is in the keyspace of the dict.

If you're always querying based on line first, then something like my
earlier 'results' dict might make sense:

  d = {'RHA280':[('TDF1',181), ...], ...}
  for name, allele in d['RHA280']:
  if allele == 181:  # or some other query within
RHA280
  ...

You get the idea: model the data in the way that makes it most useable
to you, and/or most efficient (if this is a large data set).

But note that by picking a structure like this, you're making it easy
to do certain lookups, but possibly harder (and slower) to do ones you
hadn't thought of yet.

The general solution would be to drop it into a relational database and
use SQL queries. Multidimensional analysis is what relational DBs are
for, after all. A hand-written data structure is almost guaranteed to
be more efficient for a given task, but maybe the flexibility of a
relational db would help serve multiple needs, where a custom structure
may only be suitable for a few applications.

If you're going to roll your own structure, just keep in mind that
dict-lookups are very fast in Python, far more efficient than, e.g.,
checking for membership in a list.

Graham

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


Re: Printing a variable's name not its value

2005-07-20 Thread Simon Dahlbacka
as you have been told, there is no way to get a variable's name, take a
look at http://effbot.org/zone/python-objects.htm to find out why this
is so.

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


Re: How to store 3D data? (data structure question)

2005-07-20 Thread Sebastian Bassi
On 20 Jul 2005 11:51:56 -0700, Graham  Fawcett [EMAIL PROTECTED] wrote:
 You get the idea: model the data in the way that makes it most useable
 to you, and/or most efficient (if this is a large data set).

I don't think this could be called a large dataset (about 40Kb all the file).
It would be an overkill to convert it in MySQL (or any *SQL).
I only need to parse it to reformat it.
May I send the text file to your email and a sample of the needed
output? It seems you understand a lot on this topic and you could do
it very easily (I've been all day trying to solve it without success
:(
I know this is not an usual request, but this would help me a lot and
I would learn with your code (I still trying to understand the zip
built-in function, that seems useful).




-- 
a href=http://www.spreadfirefox.com/?q=affiliatesid=24672t=1;La
web sin popups ni spyware: Usa Firefox en lugar de Internet
Explorer/a
-- 
http://mail.python.org/mailman/listinfo/python-list


wxPython wxGlade

2005-07-20 Thread Mike L.G.

Hello!

Is there a way to span columns using wxGlade?
I'd like to get a layout that looks like
this:

|---|
||-||--||
||edit ||button||
||-||--||
||-||
||   button||
||-||
|---|

I would like the 2nd button on the 2nd row to
span to the 2nd column.  I've been able to span
rows and columns using wxGridBagSizer, but wxGlade does
not seem to offer this type of sizer.  Is
this layout visibly possible using wxGlade?
Thank you for your time.

-- 

Mike L.G.
http://www.mahalosoft.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OO design

2005-07-20 Thread Florian Diesch
chris [EMAIL PROTECTED] wrote:
 I've been scripting with python for a while now. Basically writing a few
 functions and running in the ipython shell. That's been very useful. But the
 more I do this the more I see that I'm doing more or less the same thing
 over and over again. So its feels like I need to get into class programming
 with all its attendant benefits. However my biggest problem is a conceptual
 one. I just can't get my head around defining suitable classes, how they
 aquire data and communicate with each other. I'm hoping some of you python
 lamas out there might be able to share some of your wisdom on the subject.

Just some thoughts about it:

 What I basically do is a lot of the following::

 1. get arbitrary numerical data (typically large data sets in columnar
 format or even via COM from other packages. I generally have to deal with
 one or more sets of X,Y data)

You may create a class for each data format that reads that data and
creates a set from it.

 2. manipulate the data (scaling, least squares fitting, means, peaks,
 add/subtract one XY set from another etc)

This methods may either manipulate youe set's data or create a new set
with the data

 3. plot data (original set, results of manipulation, scatterplot, histograms
 etc  - I use matplotlib)

I never useds matplotlib. Maybe it's usefull to have one or more classes
covering the functions you need.

 4. export data (print, csv, shelve)

Again have a class for each output format.


 I have no problem writing bits of functional code to do any of the above.
 But for the life of me I can't see how I can hook them altogether in an OO
 based framework that I can build and extend (with more data formats,
 manipulations, GUI etc).

 When I think about what I should do I end up with a class XY that has a
 method for everything I want to do eg.

 class XY:
   def read_file
   def scale_data
   def plot_data
   def shelve_data

 But somehow that doesn't feel right, especially when I expect the number of
 methods will grow and grow, which would make the class very unwieldy.

 Even if that was a legitimate option, I don't understand conceptualy how I
 would, for example, plot two different XY objects on the same graph or add
 them together point by point. How do two different XY objects communicate

Have a look at the IntervalSet module someone announced here some time
before to get some ideas.

 and how do you deal with the thing that they must have in common (the plot
 screen for example).

Create classes for this things. Then you may either pass XY to method of Thing
or the Thing to a method of XY.


   Florian
-- 
begin  signature_virus
 Hi! I'm a signature virus. Please copy me to your signature to help me spread.
end
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python IDE

2005-07-20 Thread Florian Diesch
linuxfreak [EMAIL PROTECTED] wrote:
Got going with python...and i must say its a pretty cool language.
 Been using Xemacs to write me programs. But I want an IDE that would

I'm using GNU emacs

 give me auto-completion, 

Read the manual about tags and abbrevs
Emacs Language Sensitive Editor (ELSE) http://www.zipworld.com.au/~peterm
looks interesting too.

 online help 

python-mode has C-c C-h for py-help-at-point

 and the like... Tried SPE and
 Dr.Pyhton but the former crashes regulary and the latter is quite
 unweildy and does not have a great many features. I quite like the UML
 feature found in SPE but the damn thing crashes way too often. What are
 you guys using and what do you think is the best IDE...or should i
 stick with Xemacs/emacs???

I don't like specialized IDE's as I'm using different languages and
don't want to switch my editor for them.

   Florian
-- 
begin  signature_virus
 Hi! I'm a signature virus. Please copy me to your signature to help me spread.
end
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Printing a variable's name not its value

2005-07-20 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit :
 Hey,
 
 I am trying to write a function that takes an arbitrary number of
 arguments and does one of two things.  If the variable is a key in a
 dictionary, it prints the key and its value.  Otherwise, if any of the
 variables isn't in the dictionary, the function prints the variable's
 name and value.
 
 Here is what I have so far:
 
 globals = {}

globals() is a builtin function, you should no shadow it.

 HOME_DIR = The user's home directory
 SHELL = The user's shell
 
 def someFunction():
 someString = This is a test
 globals[VERBOSE] = True
 globals[HOME_DIR] = os.getenv(HOME)
 globals[SHELL] = os.getenv(SHELL)
 
 printVerbose(someString, HOME_DIR, SHELL)

- printVerbose(HOME_DIR, SHELL, someString=someString)

 def printVerbose(*args):
def printVerbose(*args, **kwargs):

 if VERBOSE in globals:
 for a in args:
 if a in globals:
 value = globals[a]

  for k, v in kwargs:
 print %s: %s % (k, v)
 

(snip)

 I've been told on #python that there isn't a way to get a variable's
 name.  I hope this isn't so.  

It is so. In fact, there is nothing like a 'variable' in Python. What we 
have are names bound to objects. Names 'knows' what objects are bound to 
them, but objects knows *nothing* about names they are bound to.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to store 3D data? (data structure question)

2005-07-20 Thread Cyril Bazin
The question of the type of the data sutructure depends of your use of the data. 
You could avoid some confusion without naming your columns lines...

Anyway, here is a piece of code that read the file and count the star on the fly:
(The result is a dict of dict of int.)

-
import itertools
import csv

f = open(toto.data) #change your file name
lineReader = csv.reader(f)
 
#Set the lines titles (RHA280, etc)
l = lineReader.next() 
linesTitles = l[2:]

#We construct the data structure and count the stars on the fly
datas = {}
for l in lineReader:
 name, allele = l[:2]
 if not allele: #empty line
 continue
 if name: #new block defining a TD*
 currentName = name
 d = dict.fromkeys(linesTitles, 0)
 datas[currentName] = d
 lines = l[2:]
 #add 1 to the lines not empty (= with a star)
 for title, value in itertools.izip(linesTitles,lines): 
 if value:
 d[title] += 1
 
#little tests
print datas
print datas[TDF1][RHA280]
print datas[TDF3][RHA280]
-
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: How to store 3D data? (data structure question)

2005-07-20 Thread Sebastian Bassi
On 7/20/05, Cyril Bazin [EMAIL PROTECTED] wrote:
 The question of the type of the data sutructure depends of your use of the
 data. 
  You could avoid some confusion without naming your columns lines...

Yes, that is because they are plant lines, that is why is called lines :)

  Anyway, here is a piece of code that read the file and count the star on
 the fly:
  (The result is a dict of dict of int.)

THANK YOU, I will check it out!

-- 
a href=http://www.spreadfirefox.com/?q=affiliatesid=24672t=1;La
web sin popups ni spyware: Usa Firefox en lugar de Internet
Explorer/a
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Printing a variable's name not its value

2005-07-20 Thread travislspencer
Bruno Desthuilliers wrote:
 [EMAIL PROTECTED] a écrit :
  globals = {}

 globals() is a builtin function, you should no shadow it.

Oh, woops.  I'll fix that.

 def printVerbose(*args, **kwargs):

  if VERBOSE in globals:
  for a in args:
  if a in globals:
  value = globals[a]

   for k, v in kwargs:
  print %s: %s % (k, v)
 

Perfect.  Thanks for the pointer.

  I've been told on #python that there isn't a way to get a variable's
  name.  I hope this isn't so.

 It is so. In fact, there is nothing like a 'variable' in Python. What we
 have are names bound to objects. Names 'knows' what objects are bound to
 them, but objects knows *nothing* about names they are bound to.

OK.  This seems like it might take some getting used to.  Thanks again
for the help.

--

Regards,

Travis Spencer

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


Re: Printing a variable's name not its value

2005-07-20 Thread travislspencer
Simon Dahlbacka wrote:
 as you have been told, there is no way to get a variable's name, take a
 look at http://effbot.org/zone/python-objects.htm to find out why this
 is so.

Thanks, Simon, for the link.

--

Regards,

Travis Spencer

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


Re: is this pythonic?

2005-07-20 Thread Caleb Hattingh
Wow, I didn't know about enumerate.

Many thanks
Caleb

On Wed, 20 Jul 2005 15:19:50 +0200, Simon Brunning  
[EMAIL PROTECTED] wrote:

 On 7/20/05, Mage [EMAIL PROTECTED] wrote:
 Or is there better way?

 for (i, url) in [(i,links[i]) for i in range(len(links))]:

 for i, url in enumerate(links):


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


mod_python Apache/2.0.52 (Win32) Python 2.4

2005-07-20 Thread Dieter Raber
Hi there,

I am wondering if there is a mod_python for the above configuration. I
downloaded mod_python-3.1.3.win32-py2.3.exe, which of course as the
name implies keeps on asking me for a python 2.3 installation. I
imagine one could cheat a little bit with a fake registry entry that
says it was about python 2.3 but that points to python 2.4. Then again
I don't know what entry mod_python's installer is looking for.

Thanks for your help

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


Lots of pdf files

2005-07-20 Thread Greg Lindstrom
Hello-
I'm running Python 2.3 on a Linux system and have lots (about 2000) 
files in pdf format to print each day.  If I just wind up and fire all 
the files at the printer at once (as 2000 separate print jobs), the 
print server throws a fit and our system admin comes down and slaps me 
around for a few minutes (which, I guess, is fair).

There does not appear to be a simple way to merge many pdf's into one.  
I could, for example, merge all of the files for a particular provider 
into one pdf for that provider and then print it (or, better 
yet...encrypt it and ship it!), but I do not see a way.

Any suggestions?  As it stands now, I'm printing sending 200 files, 
waiting until the queue is clear, then another 200, and so forth.  
Eventually we will be paperless (if for no other reason this seems 
insane to me), but what can I do in the meantime?

Thanks for your help!

--greg

-- 
Greg Lindstrom   501 975.4859 (office)
Senior Programmer501 219-4455 (fax)
NovaSys Health   [EMAIL PROTECTED]
Little Rock, Arkansas

We are the music makers, and we are the dreamers of dreams.  W.W.


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


returning list of strings from Python COM to Visual basic 6

2005-07-20 Thread Philippe C. Martin
Hi,

Is it possible ?

ex: return ['1','2']

If so which type should I use in VB ?

dim res as ???

Set testObj = CreateObject()

res = testObj.AMethodThatReturnsAListOfStrings()


Thanks,

Philippe

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


Re: wxPython wxGlade

2005-07-20 Thread Simon Dahlbacka
basically, you can just stack an outer vertical box sizer with two
items and in the upper slot you put a horizontal box sizer with your
two buttons and in the bottom slot you put the big button

hope this helps

/Simon

ps. as this is a wxpython related question, you might get better
answers on the wxpython mailinglist (but afaik, this is the way this
particular thing is done).

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


Re: convert ascii escapes into binary form

2005-07-20 Thread Hans-Peter Jansen
Hi Robert,

Hans-Peter Jansen wrote:
 Robert Kern wrote:
 
 That did the trick, thanks a lot, Peter. Unfortunately, on the
s/Peter/Robert/g

Sorry, Robert. That's the price to pay for doing multiple replies at 
the same time. Mea culpa.. 

 target system, there's still python 2.0 running :-( Looks like
 I've to bite the apple..
 
 Pete

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


Re: is this pythonic?

2005-07-20 Thread Bill Mill
On 7/20/05, Bill Mill [EMAIL PROTECTED] wrote:
 On 7/20/05, Simon Brunning [EMAIL PROTECTED] wrote:
  On 7/20/05, Mage [EMAIL PROTECTED] wrote:
   Or is there better way?
  
   for (i, url) in [(i,links[i]) for i in range(len(links))]:
 
  for i, url in enumerate(links):
 
 
 +2 for creating seeing a need and crafting a reasonable solution, but
 -1 for not reading the section on builtins to see if it existed
 already.
 

-1 for me for not reading over my email before sending. creating
seeing should be seeing.

Peace
Bill Mill
bill.mill at gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: returning list of strings from Python COM to Visual basic 6

2005-07-20 Thread Philippe C. Martin
Sorry, it was in the book: Variant !

Regards;

Philippe



Philippe C. Martin wrote:

 Hi,
 
 Is it possible ?
 
 ex: return ['1','2']
 
 If so which type should I use in VB ?
 
 dim res as ???
 
 Set testObj = CreateObject()
 
 res = testObj.AMethodThatReturnsAListOfStrings()
 
 
 Thanks,
 
 Philippe

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


Re: Printing a variable's name not its value

2005-07-20 Thread tiissa
Simon Dahlbacka wrote:
 as you have been told, there is no way to get a variable's name

Well, if you really want to, you can get all the names bound to a given 
object:


def get_names(obj):
 g = globals()
 names = []
 for name in g:
 if g[name] is obj:
 names.append(name)
 return names


Then you can play around:

   list1 = []
   list2 = [list1]
   get_names(list2)
  ['list2']
   list3 = list2
   get_names(list2)
  ['list3', 'list2']
   get_names(1)
  []
   a = 1
   get_names(1)
  ['a']
   b = 1
   get_names(1)
  ['a', 'b']
   get_names(a)
  ['a', 'b']
   c = 4/3.
   d = 4/3.
   get_names(c)
  ['c']
   get_names(d)
  ['d']
   get_names(4/3.)
  []
  


But I wouldn't do it. If I want a name to be attached to some objects, I 
usually include it as a member/property of my class.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Lots of pdf files

2005-07-20 Thread Wojciech Mula
Greg Lindstrom wrote:
 There does not appear to be a simple way to merge many pdf's into one.  

Program pdftk can merge pdf's, but I have never tried it.
You may also use pdflatex --- there is a package called pdfpages
provides powerful command \includepdf.

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


Re: Printing a variable's name not its value

2005-07-20 Thread travislspencer
[EMAIL PROTECTED] wrote:
 Bruno Desthuilliers wrote:
  def printVerbose(*args, **kwargs):
 
   if VERBOSE in globals:
   for a in args:
   if a in globals:
   value = globals[a]
 
  for k, v in kwargs.iteritems():
   print %s: %s % (k, v)
  

 Perfect.  Thanks for the pointer.

Well, almost perfect ;)

--

Regards,

Travis Spencer

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


  1   2   >