should I distribute .pyc files?

2006-12-18 Thread akbar
Hi,

I am creating not-so-important opensource application written in python
for Linux. I have two files python source in src directory, named
blabla1.py and blabla2.py. There are byte compiled files too, named
blabla1.pyc and blabla2.pyc. Should I distribute these files (pyc
files) to users? If I don't distribute them, and user installed my
application into /usr (not writable by normal user) then run it as
normal user, off course, the python cannot make byte-compiled version.
Will my program runs slower in user computer then in my computer
because I have byte compiled version?

Thank you.

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


trouble getting google through urllib

2006-12-18 Thread Dr. Locke Z2A
So I'm writing a bot in python that will be able to do all kinds of
weird shit. One of those weird shit is the ability to translate text
from one language to another, which I figured I'd use google translate
to do. Here is the section for translation that I'm having trouble
with:

elif(line[abuindex+1]=="translate"):#if user inputs
translate
text=""
for i in range(abuindex+2, len(line)):#concantenate all
text to be translated
text=text+"%20"+line[i]

t_url="http://translate.google.com/translate_t?text='"+text+"'&hl=en&langpair=es|en&tbb=1"
print "url: %s" % t_url#debug msg
urlfi=urllib.urlopen(t_url)#make a file object from what
google sends
t_html=urlfi.read( )#read from urlfi file
print "html: %s" % t_html #debug msg
print "text: %s" % text#debug msg

This uses urllib to open the url and abuindex+2 is the first word in
the string to be translated and line is an array of the message sent to
the bot from the server. After this I'll add something to parse through
the html and take out the part that is the translated text. The problem
is that when I run this the html output is the following (I asked it to
translate como estas here):



403 Forbidden






Google  
 
Error
 

Forbidden
Your client does not have permission to get URL
/translate_t?text='%20como%20estas'&hl=en&langpair=es%7Cen&tbb=1
from this server.






Does anyone know how I would get the bot to have permission to get the
url? When I put the url in on firefox it works fine. I noticed that in
the output html that google gave me it replaced some of the characters
in the url with different stuff like the "&" and "%7C", so I'm
thinking thats the problem, does anyone know how I would make it keep
the url as I intended it to be?

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


Re: Good Looking UI for a stand alone application

2006-12-18 Thread Luc Heinrich
Peter Decker <[EMAIL PROTECTED]> wrote:

> I don't have a Mac, although I would certainly like one. But one of
> the two authors of Dabo is a Mac user, and says that he does all his
> development on a Mac, and then tests it on the other platforms. Look
> at the screencasts on the Dabo site - most of them are recorded on OS
> X.

Yeah, I have watched three of them and they are glaring examples of what
I'm talking about. The applications presented not only don't look right,
at all, they apparently don't feel right either.

> OK, it's true: you don't have 100% access to the lickable Aqua stuff
> that a Cocoa app might be able to use. But paged controls use native
> Aqua tabs; progress bars are native Aqua bars, buttons are native Aqua
> buttons... Perfect? Of course not. But stating that it sucks is a load
> of crap.

No it's not, because you insist on presenting only one part of the
problem. Using native widgets is *far* from enough.

> Such self-important pronouncements would be better received if you
> brought them down the mountain on stone tablets.

No problem, let me get my chisel, do you prefer Fedex or UPS ? :p

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


Re: Good Looking UI for a stand alone application

2006-12-18 Thread Luc Heinrich
Paul McNett <[EMAIL PROTECTED]> wrote:

> It looks/feels like a native app on OS X.

I'm sorry, but the screenshots I'm seeing on the Dabo website all look
like ugly Windows ports (when they don't look like straight X11 crap). I
can't comment on the feel of course, but I wouldn't hold my breath. I'm
downloading the screencasts as we "speak", but I'm not holding my breath
either.

[UPDATE] I have watched three of the Dabo screencasts and the presented
application are *very* far from looking/feeling like native OS X
applications. Sorry.

> Why not use the best crossplatform native toolkit (wxPython) and then if
> you need native features that aren't provided, use ctypes or something
> to get access to the native GUI? Nothing in wxPython or Dabo prevents
> you from doing that.

Eh, funny, I have used wx thingy for quite some time (when it was
actually still called wxWindows and then when they switched to
wxWidgets) and it's probably the worst of all crossplatform toolkits I
have ever used. So I'm not sure you'll be able to convince me here :D

Ok, now here's a question for you: if crossplatform toolkits/frameworks
are so great and automagically allow to produce superlickable and
native-looking/feeling applications on all three major platforms, why is
there so few of those applications on OS X ? 

"Because Mac users are elitists assholes" is not the good answer by the
way :)

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


Re: How would I create an class with a "Person.Address.City" property?

2006-12-18 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Jamie J. Begin
wrote:

> Let's say I wanted to create an object that simply outputted something
> like this:
> 
 import employees
 person = employee("joe") # Get Joe's employment file
 print employee.Title # What does Joe do?
> Developer
 print person.Address.City # Which city does Joe live in?
> Detroit
 print person.Address.State # Which state?
> Michigan
> 
> To do this would I create nested "Address" class within the "employee"
> class? Would it make more sense to just use "print
> person.Address('City')" instead?

That depends on the usage of the addresses.  If you need them as objects
with "behavior" i.e. methods then you would write an `Address` class.  If
you can live with something more simple than a `dict` as `address`
attribute of `Employee` objects might be enough.

BTW you wouldn't create a nested `Address` *class*, but hold a reference
to an `Address` *object* within the `Employee` *object*.

class Address(object):
def __init__(self, city, state):
self.city = city
self.state = state

class Employee(object):
def __init__(self, name, title, address):
self.name = name
self.title = title
self.address = address

employees = { 'Joe': Employee('Joe',
  'Developer',
  Address('Detroit', 'Michigan')) }

def employee(name):
return employees[name]


def main():
person = employee('Joe')
print person.title
print person.address.city
print person.address.state

Ciao,
Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list


How would I create an class with a "Person.Address.City" property?

2006-12-18 Thread Jamie J. Begin
I'm very new to the world of Python and am trying to wrap my head around
it's OOP model. Much of my OOP experience comes from VB.Net, which is
very different.

Let's say I wanted to create an object that simply outputted something
like this:

>>> import employees
>>> person = employee("joe") # Get Joe's employment file
>>> print employee.Title # What does Joe do?
Developer
>>> print person.Address.City # Which city does Joe live in?
Detroit
>>> print person.Address.State # Which state?
Michigan

To do this would I create nested "Address" class within the "employee"
class? Would it make more sense to just use "print
person.Address('City')" instead?

Thanks for your help!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: regular expression

2006-12-18 Thread Paddy

Asper Faner wrote:
> I seem to always have hard time understaing how this regular expression
> works, especially how on earth do people bring it up as part of
> computer programming language. Natural language processing seems not
> enough to explain by the way. Why no eliminate it ?
If you try to eliminate what you don't understand you won't learn
anything!

I suggest that you put the learning of regexps aside for a while and
come back to it 'later'.

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


RE:

2006-12-18 Thread Divya Prakash
Hi

I don't know how to implement these API's .When I use the method
"Parse   (file object) " it gives error. 
So, I m blank how to implement it in order to get all the info of java file
and thn represent them in xml format..

Regards
Divya 

-Original Message-
From: Gabriel Genellina [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, December 19, 2006 6:21 AM
To: Divya Prakash
Cc: python-list@python.org
Subject: Re:

At Monday 18/12/2006 03:34, Divya Prakash wrote:


> I would like to parse java files and detect class name's, 
> attributes name's type's and visibility (and or list of
> methods).
> Is there any module who can parse easily a java file using jython?

You could try javadoc (the java package), it is easier to use than a 
pure reflection approach.

-- 
Gabriel Genellina
Softlab SRL 

__
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam !gratis! 
!Abrm tu cuenta ya! - http://correo.yahoo.com.ar

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


Re: textwrap.dedent replaces tabs?

2006-12-18 Thread Tom Plunket
Frederic Rentsch wrote:

> > Well, there is that small problem that there are leading tabs that I
> > want stripped.  I guess I could manually replace all tabs with eight
> > spaces (as opposed to 'correct' tab stops), and then replace them when
> > done, but it's probably just as easy to write a non-destructive dedent.
>
> This should do the trick:
> 
>  >>> Dedent = re.compile ('^\s+')
>  >>> for line in lines: print Dedent.sub ('', line)

The fact that this doesn't do what dedent() does makes it not useful.
Stripping all leading spaces from text is as easy as calling lstrip() on
each line:

text = '\n'.join([line.lstrip() for line in text.split('\n')])

alas, that isn't what I am looking for, nor is that what
textwrap.dedent() is intended to do.

-tom!

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


Script Error

2006-12-18 Thread Forced_Ambitions
Hi Guys,

I am facing a problem with a script that i had written to automate
opening a website and signing on to it. It was running fine for a long
time but all of a sudden it has stopped progressing beyond opening the
URL. I ran the code line by line on the pythonwin's IDE and it ran fine
but when i execute the whole script it gives this error:


Traceback (most recent call last):
  File
"C:\Python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py",
line 307, in RunScript
debugger.run(codeObject, __main__.__dict__, start_stepping=0)
  File
"C:\Python24\Lib\site-packages\pythonwin\pywin\debugger\__init__.py",
line 60, in run
_GetCurrentDebugger().run(cmd, globals,locals, start_stepping)
  File
"C:\Python24\Lib\site-packages\pythonwin\pywin\debugger\debugger.py",
line 631, in run
exec cmd in globals, locals
  File "C:\Documents and
Settings\Desktop\pi\Ressurection\Dec\19\CoE.py", line 4, in ?
ie.SetTextBox(username,'txtUserId',0)
  File "cPAMIE.py", line 387, in SetTextBox
doc = self._ie.Document.forms[frmName]
  File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", line
216, in __getitem__
return self._get_good_object_(self._enum_.__getitem__(index))
  File "C:\Python24\Lib\site-packages\win32com\client\util.py", line
37, in __getitem__
return self.__GetIndex(index)
  File "C:\Python24\Lib\site-packages\win32com\client\util.py", line
56, in __GetIndex
raise IndexError, "list index out of range"
IndexError: list index out of range

The code i was using is:

import cPAMIE

ie= cPAMIE.PAMIE()

ie.Navigate ('URL')
ie.SetTextBox(username,'txtUserId',0)
ie.SetTextBox(pwd,'txtPassword',0)
ie.ClickButton('btnSubmit',0)

Any ideas as to why am i getting this error when running the code as a
script 

Thanks in advance,
Forced

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


Re: textwrap.dedent replaces tabs?

2006-12-18 Thread Tom Plunket
Peter Otten wrote:

> > I guess I could manually replace all tabs with eight
> > spaces (as opposed to 'correct' tab stops), and then replace them when
> > done, but it's probably just as easy to write a non-destructive dedent.
> 
> You mean, as easy as
> 
> >>> "\talpha\tbeta\t".expandtabs()
> 'alpha   beta'
> 
> ?

Umm, no, that's why I wrote "eight spaces (as opposed to 'correct' tab
stops)".

In either case, though, it'd be hard to know how to replace the tabs, so
it'd be better not to remove them in the first place.  Indeed, dedent()
would work perfectly for my cases if it simply didn't do the
expandtabs() in the first place, but there'd be some pretty glaring
holes in its logic then.

I've since written up a fairly reasonable (IMO) replacement though, that
started with textwrap.dedent(), removed the expandtabs() call, and 
Does The Right Thing with tabs vs. spaces (e.g. it doesn't treat a tab
at the beginning of a line as the same as eight spaces).


-tom!

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


Class property with value and class

2006-12-18 Thread manstey
Hi,

Is is possible to have two classes, ClassA and ClassB, and
setattr(ClassA, 'xx',ClassB), AND to then have ClassA.xx store an
integer value as well, which is not part of ClassB?

e.g. If ClassB has two properties, name and address:

ClassA.xx=10
ClassA.xx.name = 'John'
ClassA.xx.address = 'Sydney'.

etc?  I've no idea if this is possible or desirable.

thanks,
matthew

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


Re: Python-URL! - weekly Python news and links (Dec 18)

2006-12-18 Thread Hendrik van Rooyen

 "Kay Schluehr" <[EMAIL PROTECTED]> wrote:


> Paul Boddie wrote:
>
> > Meanwhile, the EuroPython planners get ahead of themselves, thinking
about
> > conference venues as far in the future as 2010, if not 20010!
>
> Python 20010. It was a nice conference although a bit lame on the first
> day. My favourite talks were:
>
> Trevor Stent: "Whitespace as a universal constant"
> Mathais Fendro: "Snake gods and how they tamed chaons and simili"
> Taumaturg 7: "Technologia inversa. A short history of holistic
> semantics"
>
> There was also some interesting short talk about wormhole calculus.
> Unfortunetely I've forgotten the name of the lecturer. Maybe I was just
> too fascinated by his appeal as a small spinning bubble, shining in
> rainbow colors.


Lovely! - thanks for the update - I'm sorry I couldn't make it in time.

- Hendrik


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


Re: Can a Tkinter GUI check for abort script:

2006-12-18 Thread Hendrik van Rooyen
 Michael Yanowitz  top posted:

>   Presently what happens is that the script takes over and all the buttons on
the GUI disappear
>as the GUI is not given any cpu time to refresh or check if any activity in the
dialog.

Yuk!

you may have to run the script in a thread then, to preserve the GUI mainloop.

Check out the Threading and Thread modules

- Hendrik

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


Re: How to replace a comma

2006-12-18 Thread Hendrik van Rooyen

"Lad" <[EMAIL PROTECTED]> top posted:



> > re's are a pain.  Do this instead:
> >
> > >>> s = "hello, goodbye,boo"
> > >>> s.replace(', ',',')
> > 'hello,goodbye,boo'
> > >>> _.replace(',',', ')
> > 'hello, goodbye, boo'

> Thank you for ALL for help.
> Hendrik,
> your solution works great but
> what is `_`  in
> _.replace(',',', ')
> 
> for?

The underscore, in the interactive interpreter, stands for
the result of the last statement.  So in the above, you can 
think of it as the "name" of the string without spaces after 
the commas, on the previous line.

Note that to fix pathological stuff like:

s = "asasd, oipuopioiu,   this is bad shit,\tiuiuiu,,, , "

you will have to do more work than the simple solution
above...

I am constantly amazed by how different we all are, when
I read the diverse solutions to such a seemingly simple
problem - and the nice thing is that they all work...

Have a good look at Peter Otten's solution - try to 
understand it - it uses most of the very useful Python
functions.


- Hendrik

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


Re: Is there any python-twisted tutorial or texts?

2006-12-18 Thread [EMAIL PROTECTED]
The doc in the twisted web site is a good starting point. Also there is
a book .

Jia Lu wrote:
> Hi all
>  I want to study twisted of python . But I donot know how to start.
>  Any suggistions?
> 
>  Thank you

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


Lightweight embedding of Firefox Gecko into application whose top level is Python--possible?

2006-12-18 Thread Kenneth McDonald
Sorry for crossposting to several lists, but from what I can tell, what 
I want to do may involve several different areas of expertise. (None of 
which I have :-( )

I'd like to use Gecko as the UI for an application mostly implemented in 
Python. Ideally, I'd like to somehow come up with a Python module that 
wraps the Gecko, so that I can:

1) Create windows whose content is drawn by Gecko.
1) Dynamically manipulate what is shown by Gecko.
2) Respond to mouse events and keypresses occurring on the window Gecko 
is in.

I really don't need, or want, anything beyond this. Presumably Gecko 
does have some notion of the DOM, since it handles CSS (which I do want) 
and CSS needs the DOM to be meaningful. And I'm also assuming that Gecko 
has or requires JavaScript, in order to actually do things with the DOM, 
or at least to handle DOM events. (Or at the very least to handle mouse 
events, since key events could in theory be handled outside of the 
layout engine.) But I'd like to be able to build something with _just_ 
those features.

Given the above, using Firefox or even Xulrunner seems to be very 
heavyweight and unnecessary. It would be somewhat nice to be able to 
manipulate a XUL DOM to created panes, menus, etc. But even that is not 
necessary--so far as I can tell, DOM manipulation+CSS has the ability 
right now to do menus, scrollable sidebars, panes, etc.

I'd like to get away from the rest of the FF/Mozilla baggage (especially 
XPCOM) because:

1) I don't want to have to deal with XPCOM, chrome stuff, XUL, make 
details, XPIDL (or whatever it is), etc. etc. My brain is already too 
full. :-)
2) Even if I did want to deal with the above, I find the documentation 
for it disorganized and, more often than not, out of date. Not a 
criticism, just an unavoidable weakness of open source development with 
a large number of developers.

Given that the _only_ thing I really want to use is the Gecko layout 
engine with some sort of relatively rudimentary keyboard and mouse 
handling (I'll do all of the sophisticated handling in Python), it'd 
just be nice to be able to dispense with all of the rest of the stuff.

For the record, I do know that PyXPCOM is still being developed, and 
what little I've been able to glean suggests it's been going reasonably 
well. However, I'm not sure it will do what I want it to. It appears to 
be a way to write XPCOM components in Python, and I have no idea if that 
will allow me to just use Python in the same way JavaScript is used 
right now, which is what I want. From what little I've been able to 
track down it seems that PyXPCOM may only be the starting point for 
moving towards using Python for DOM scripting. Also, I'm not sure when 
it will actually be done. Up-to-date online info about PyXPCOM (aside 
from bug tracking) seems very sparse.

Given all of that, answers to the following questions (or suggestions 
related to the whole endeavour) would be appreciated.
1) Does this even seem feasible? Can Gecko be 'broken out' from the 
other Moz technologies to this extent?
2) Does anyone know of similar projects?
3) Can anyone point out a simple example of encapsulating Gecko in a 
small C/C++ app, and then running/communicating with Gecko from that 
code? (i.e. a Gecko embedding "Hello world") This is in some sense what 
I'd be doing, since using Gecko from Python would involve (I assume) 
wrapping Gecko in a Python-compatible C wrapper. I've come across a 
number of embedding Gecko tutorials, but nothing that starts at such a 
basic level.
4) Do I need to somehow provide/link in a windowing system of some sort, 
or do I get that with the version of Gecko appropriate for the target 
platform?
5) Will PyXPCOM let me do what I want? And is it close enough that I 
should just wait for it? (It doesn't bother me if all of the rest of the 
Moz/FF stuff is included in my app, just as long as I don't have to deal 
with it.)

Many thanks,
Ken McDonald
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: catching exceptions

2006-12-18 Thread Scott David Daniels
[EMAIL PROTECTED] wrote:
> 
> class Test(object):
> ...
> def _setx(self,strvalue):
> try:
> self._x = float(strvalue)
> except ValueError:
> print 'Warning : could not set x attribute to %s' % strvalue
> ...

I think what you are looking for is:
  class Test(object):
  ...
  def _setx(self, strvalue):
  try:
  self._x = float(strvalue)
  except ValueError:
  print 'Warning : could not set x attribute to %s' % (
  strvalue)
  raise # re-raise the exception that got us here.
  ...

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


Re: urllib.unquote and unicode

2006-12-18 Thread Leo Kislov

George Sakkis wrote:
> The following snippet results in different outcome for (at least) the
> last three major releases:
>
> >>> import urllib
> >>> urllib.unquote(u'%94')
>
> # Python 2.3.4
> u'%94'
>
> # Python 2.4.2
> UnicodeDecodeError: 'ascii' codec can't decode byte 0x94 in position 0:
> ordinal not in range(128)
>
> # Python 2.5
> u'\x94'
>
> Is the current version the "right" one or is this function supposed to
> change every other week ?

IMHO, none of the results is right. Either unicode string should be
rejected by raising ValueError or it should be encoded with ascii
encoding and result should be the same as
urllib.unquote(u'%94'.encode('ascii')) that is '\x94'. You can consider
current behaviour as undefined just like if you pass a random object
into some function you can get different outcome in different python
versions.

  -- Leo

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


python script terminating

2006-12-18 Thread Aditya Vaish
I have a python script running on Debian sarge. It loops and walk through a
directory

 

while 1:

for dirn in os.listdir(buildpath):

if os.path.exists(os.path.join(buildpath, dirn, 'pass')) and
dirn.find(build1) != -1:

#   case 1

Do something

 

elif os.path.exists(os.path.join(buildpath, dirn, 'pass')) and
dirn.find(build2) != -1:

#   case 2

Do something

 

The script in turn calls a perl script to do something. The problem is that
the python script is getting terminated while the perl script is running and
thus the program called by the perl script is hung.

 

ps aux|grep T

 

root  1123  0.0  0.0  4116   20 pts/0TDec18   0:00 python

root  1124  0.0  0.0  4112   20 pts/0TDec18   0:00 python

 

Regards,

Aditya

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

regular expression

2006-12-18 Thread Asper Faner
I seem to always have hard time understaing how this regular expression
works, especially how on earth do people bring it up as part of
computer programming language. Natural language processing seems not
enough to explain by the way. Why no eliminate it ?

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


Re: Is there any python-twisted tutorial or texts?

2006-12-18 Thread Jonathan Curran
On Monday 18 December 2006 20:45, Jia Lu wrote:
> Hi all
>  I want to study twisted of python . But I donot know how to start.
>  Any suggistions?
>
>  Thank you

There is a book about using Twisted. It's called 'Twisted Network Programming 
Essentials.' It is an entry-level book at best, but it does go over quite a 
lot of things that the Twisted library is capable of.

Available at amazon.com: 
http://www.amazon.com/Twisted-Network-Programming-Essentials-Fettig/dp/0596100329/sr=8-1/qid=1166501681/ref=sr_1_1/102-5086830-3709707?ie=UTF8&s=books

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


Re: merits of Lisp vs Python

2006-12-18 Thread greg
Bill Atkins wrote:
> This is not a response to any particular post, but rather to the
> general argument that macros are not as useful as we Lispers claim.
> 
> Here is a fairly complete GUI RSS reader in 90 lines of Lisp

For comparison, here's how something with a similar
API might be used from Python.

class RSSInterface(Interface):

   def __init__(self):
 Interface.__init__(self,
   panes = [
 TextInput('url_pane',
   title = 'Feed URL:',
   callback = 'add_feed',
   callback_type = 'interface'),
 PushButton('add',
   text = 'Add Feed',
   callback = 'add_feed',
   callback_type = 'interface'),
 PushButton('refresh',
   text = 'Refresh All',
   callback = 'refresh_feeds',
   callback_type = 'interface'),
 PushButton('delete',
   text = 'Delete Feed',
   callback = 'delete_feed',
   callback_type = 'interface'),
 TreeView('tree',
   visible_min_width = ('character', 84),
   visible_min_height = ('character', 40),
   action_callback = 'browse_item',
   callback_type = 'item_interface',
   expandp_function = lambda: True, # not sure how best to translate
   children_function = 'tree_item_children',
   print_function = 'tree_item_string')
 ],
   layouts = [
 ColumnLayout('main', ('top', 'tree')),
 RowLayout('top', ('url_pane', 'add', 'refresh', 'delete'))
 ],
   title = 'Barebones RSS Reader v1.0')
 self.channels = [
   parse_rss_from_url(url) for url in [
 'http://planet.lisp.org/rss20.xml',
 'http://feeds.theonion.com/theonion/daily']]

   def add_feed(self):
 ...

   def delete_feed(self):
 ...

   # etc.

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


SQLAlchemy, py2exe and Python 2.5 problem?

2006-12-18 Thread Karlo Lozovina
I've just upgraded to Python 2.5, SQLAlchemy 0.3.3, and py2exe 0.6.5 
(the py2.5 version, yes).

Simple:

---
import sqlalchemy
print 'Test'
---

works when interpreted by Python, but when running it from compiled 
py2exe binary, it fails with this error:

Traceback (most recent call last):
  File "main.py", line 1, in 
  File "sqlalchemy\__init__.pyc", line 10, in 
  File "sqlalchemy\orm\__init__.pyc", line 12, in 
  File "sqlalchemy\orm\mapper.pyc", line 7, in 
  File "sqlalchemy\logging.pyc", line 30, in 
ImportError: No module named logging

Ofcourse, library.zip (in the dist directory) contains 'sqlalchemy
\logging.pyc'. After I copy logging.pyc to library.zips' root, I get 
this error:

Traceback (most recent call last):
  File "main.py", line 1, in 
  File "sqlalchemy\__init__.pyc", line 10, in 
  File "sqlalchemy\orm\__init__.pyc", line 12, in 
  File "sqlalchemy\orm\mapper.pyc", line 7, in 
  File "sqlalchemy\logging.pyc", line 30, in 
  File "sqlalchemy\logging.pyc", line 33, in 
AttributeError: 'module' object has no attribute 'getLogger'

Does anyone have a clue why this happens? And what is responsible for 
this? SQLAlchemy, or py2exe?

Thanks in advance...

-- 
 ___Karlo Lozovina - Mosor
|   |   |.-.-. web: http://www.mosor.net || ICQ#: 10667163
|   ||  _  |  _  | Parce mihi domine quia Dalmata sum.
|__|_|__||_|_|
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python-hosting.com projects: dead?

2006-12-18 Thread [EMAIL PROTECTED]
Carl Banks wrote:
> [EMAIL PROTECTED] wrote:
> > It looks to me like python hosting, aka webfaction, have shut down
> > access to all projects hosted under their free hosting for open source
> > python projects program. Including mine (nose). With no notice -- at
> > least none that I received.
> >
> > Surprised doesn't quite cover it. Perhaps someone from python hosting
> > can explain why this was done, why no notice was given (if it wasn't),
> > and how those of us trying to restart our projects elsewhere can get
> > access to our subversion repositories and trac data.
>
> Maybe you're overreacting?  Try checking the SVN tomorrow.  Even Python
> programs can have downtime.

I certainly hope so, but this is what I'm reacting to (from
http://www.webfaction.com/freetrac):

"We're sorry, we're not longer accepting applications for free trac/svn
accounts. People have left their Trac sites unattended and as a result
our server is being flooded with spam. We need to do some serious
cleanup and when that's done we'll accept new applications again (that
might take weeks, if not months though). "

Unless my reading comprehension skills have completely abandoned me,
they aren't saying that they are experiencing downtime. They are saying
that they have shut down the service, for weeks or months -- with no
notice (again, at least not any that I got). I can understand shutting
down projects that are dead and just accumulating spam. I can
understand shutting the whole thing down, with a decent notice so that
projects don't die with the service. This, I just don't get. I hope I'm
overreacting. I hope I can slurp up all of my tickets tomorrow and
import them into their new home at google. But I'm not counting on it.

JP

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


Re: python-hosting.com projects: dead?

2006-12-18 Thread Carl Banks
[EMAIL PROTECTED] wrote:
> It looks to me like python hosting, aka webfaction, have shut down
> access to all projects hosted under their free hosting for open source
> python projects program. Including mine (nose). With no notice -- at
> least none that I received.
>
> Surprised doesn't quite cover it. Perhaps someone from python hosting
> can explain why this was done, why no notice was given (if it wasn't),
> and how those of us trying to restart our projects elsewhere can get
> access to our subversion repositories and trac data.

Maybe you're overreacting?  Try checking the SVN tomorrow.  Even Python
programs can have downtime.


Carl Banks

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


python-hosting.com projects: dead?

2006-12-18 Thread [EMAIL PROTECTED]
It looks to me like python hosting, aka webfaction, have shut down
access to all projects hosted under their free hosting for open source
python projects program. Including mine (nose). With no notice -- at
least none that I received.

Surprised doesn't quite cover it. Perhaps someone from python hosting
can explain why this was done, why no notice was given (if it wasn't),
and how those of us trying to restart our projects elsewhere can get
access to our subversion repositories and trac data.

JP

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


Re: sha, PyCrypto, SHA-256

2006-12-18 Thread Tim Henderson
On Dec 16, 2:17 pm, [EMAIL PROTECTED] wrote:
> Operating system: Win XP
> Vsn of Python: 2.4
>
> Situation is this: Required to calcluate a message digest.  The process
> for calcluating the digest must use an SHA-256 algorithm.
>
> Questions:
> 1) Is it correct that the sha module comes with python 2.4?
> 2) Is it correct that the sha module that ships with python 2.4 does
> NOT have the SHA-256 capability as part of the module?
> 3) It looks like PyCrypto is a package that, among other things,
> permits one to calculate a message digest using an SHA-256
> algorithm...is that correct?
> 4) It looks like there are a couple couple possibilities available for
> the download...either download the source code and run the setup which
> (I'm assuming) compiles the various extension modules, or download the
> pycrypto-2.0.1.win32-py2.4.zip which extracts out to a .exe; when one
> runs the just-extracted .exe, it installs the stuff on one's
> workstation.  I'm leaning toward the second option because it seems
> like most of the work has been done for me.  A quick search on this
> site didn't turn up anything that suggested there were problems with
> running the installer.  So, my question is this: are you aware of any
> problems running the installer?
> 5) Besides PyCrypto, are there any other Python packages that permit
> one to calculate a message digest using an SHA-256 algorithm?
>
> Thank you.


I have run that exact installer many many times and it works fine. to
use SHA-256 with pycrypto:

>>> from Crypto.Hash import SHA256
>>> sha = SHA256.new()
>>> sha.update('message')
>>> sha.hexdigest() # sha.digest gives the raw form
'ab530a13e45914982b79f9b7e3fba994cfd1f3fb22f71cea1afbf02b460c6d1d'

cheers
tim

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


urllib.unquote and unicode

2006-12-18 Thread George Sakkis
The following snippet results in different outcome for (at least) the
last three major releases:

>>> import urllib
>>> urllib.unquote(u'%94')

# Python 2.3.4
u'%94'

# Python 2.4.2
UnicodeDecodeError: 'ascii' codec can't decode byte 0x94 in position 0:
ordinal not in range(128)

# Python 2.5
u'\x94'

Is the current version the "right" one or is this function supposed to
change every other week ?

George

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


Is there any python-twisted tutorial or texts?

2006-12-18 Thread Jia Lu
Hi all
 I want to study twisted of python . But I donot know how to start.
 Any suggistions?

 Thank you

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


Re: pyExcelerator question

2006-12-18 Thread John Machin
Gerry wrote:
> I'd like to word wrap some cells, but not others, in an Excel
> spreadsheet, using pyExcelerator and Excel 2003, SP1, under XP.
>
> The code below creates the spreadsheet, but both cells are
> word-wrapped.
>
> As far as I can tell, the second call to XFStyle() overwrites a GLOBAL
> wrap setting, and affects even cells written before the call to
> XFStyle.

You are mostly correct. In Style.py, each style gets initialised to
refer to a module-global bunch of default objects. No copying is done.
Have a look at the patched code down the bottom of this posting -- it
appears to work.

>
> Can anyone shed any light?
>
> Thanks,
>
> Gerry
>
> 
> from pyExcelerator import *
>
>
> w   = Workbook()
> ws  = w.add_sheet("alpha")
>
> style   = XFStyle()
> style.alignment.wrap= Alignment.NOT_WRAP_AT_RIGHT
> ws.write(1,1,"Not wrapped" + "-" * 50, style)
>
> style2   = XFStyle()
> style2.alignment.wrap= Alignment.WRAP_AT_RIGHT
> ws.write(2,1,"Wrapped" + "-" * 50, style2)
>
> w.save("test.xls")


if 0: # original

_default_num_format = 'general'
_default_font = Formatting.Font()
_default_alignment = Formatting.Alignment()
_default_borders = Formatting.Borders()
_default_pattern = Formatting.Pattern()
_default_protection = Formatting.Protection()

class XFStyle(object):

def __init__(self):
self.num_format_str  = _default_num_format
self.font= _default_font
self.alignment   = _default_alignment
self.borders = _default_borders
self.pattern = _default_pattern
self.protection  = _default_protection

else: # patch

class XFStyle(object):

def __init__(self):
self.num_format_str  = 'general'
self.font= Formatting.Font()
self.alignment   = Formatting.Alignment()
self.borders = Formatting.Borders()
self.pattern = Formatting.Pattern()
self.protection  = Formatting.Protection()

If this works for you, you might like to submit a patch to
http://sourceforge.net/tracker/?func=browse&group_id=134081&atid=730645

HTH,
John

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


Re: tuple.index()

2006-12-18 Thread greg
Nick Maclaren wrote:

> Unfortunately, you are confusing the issue, because there are far
> more extraneous aspects than relevant ones, and your view of the
> similarities requires looking at the issue in a very strange way.
> I think that I can see what you mean, but only just.

Each member of a struct has a distinct, predefined
role. Even if they all have the same type, you
can't swap their values around without destroying
the meaning of the data. That's what's meant by
"heterogeneous" in this context -- it's not about
the values themselves, but the way they're used.

This is the kind of thing for which Python tuples
are mainly designed -- use as a struct whose
members happen to be named by integers rather
than strings.

If you still don't understand, then I'm afraid
I've run out of ideas on how to explain it.

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


Re:

2006-12-18 Thread Gabriel Genellina

At Monday 18/12/2006 03:34, Divya Prakash wrote:


I would like to parse java files and detect class name's, 
attributes name's type's and visibility (and or list of

methods).
Is there any module who can parse easily a java file using jython?


You could try javadoc (the java package), it is easier to use than a 
pure reflection approach.


--
Gabriel Genellina
Softlab SRL 


__
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
-- 
http://mail.python.org/mailman/listinfo/python-list

Using DCOP from Python

2006-12-18 Thread Jeffrey Barish
The package python-dcop makes it possible to use DCOP from Python.  Does
anyone know of a tutorial for this package or an example of its use?  I
would like to use it to read a journal entry in Korganizer.  I got as far
as figuring out that DCOP offers the interface
korganizer.CalendarIface.openJournalEditor(QString text, QDate date)
but I'm having trouble figuring out how to call this function from Python. 
And will it become clear how to control whether I am reading or writing the
journal?
-- 
Jeffrey Barish

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


Tkdnd--does anyone use it?

2006-12-18 Thread Kevin Walzer
Does anyone use the Tkdnd module that comes with Tkinter to allow
drag-and-drop of Tkinter widgets in your application? (Not the binary
extension that hooks into Xdnd and OLE-dnd on Windows.) I've looked at
the various documents for Tkdnd, and it looks somewhat complicated,
particulary if you want to use it outside of the canvas widget; I've
also found very few examples of its actual use (as opposed to sample
code snippets). I'm curious if anyone is actually using it in a
production application and, if so, what your experience with it is.
-- 
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: writing serial port data to the gzip file

2006-12-18 Thread Petr Jakes
Hi Dennis,
thanks for your reply.
Dennis Lee Bieber napsal:
> > def dataOnSerialPort():
> > data=s.readLine()
>
>   Unless you are using a custom serial port module, that should be
> s.readline()
sorry for the typo
>
> > if data:
> > return data
> > else:
> > return 0
>
>   This if statement is meaningless -- if "data" evaluates to false,
> return a numeric value that evaluates to false.
I see, it is OK just to return data (or an empty string "")
>
> >
> > while 1:
> > g=gzip.GzipFile("/root/foofile.gz","w")
> > while dataOnSerialPort():
> > g.write(data)
>
>   "data" is an uninitialized value here
> > else: g.close()
>
>   And what is the purpose of closing the file if you immediately turn
> around and create it again (assuming gzip.GzipFile() behaves as open()
> does, a mode of "w" means delete the old file and create a new one.
> There is NO exit from the above.
>
>   Since I can't read your mind with regards to some of your looping...
>
> s = ... #somewhere you had to open the serial port
>
> g = gzip.GzipFile("/root/foofile.gz", "w")
> while True:
>   data = s.readline()
>   if not data: break
>   g.write(data)
> g.close()

what I am trying to say is g.close() does not close the g file (try to
add the line "print g" after g.close())
Petr

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


Re: ANN: Skimpy Gimpy ASCII Web Challenge CAPTCHA

2006-12-18 Thread Olexandr Melnyk

Looks interesting; have you considered making an audio alternative for
people with visual disabilities?


Olexandr Melnyk,
http://omelynk.net/

18 Dec 2006 14:40:14 -0800, [EMAIL PROTECTED] <
[EMAIL PROTECTED]>:


Please check it out and try it:

   http://skimpygimpy.sourceforge.net/

Find examples, documentation, links to demos
and download links there.

Skimpy Gimpy is a tool for generating HTML
representations for strings which
people can read but which web
robots and other computer programs
will have difficulty understanding.
Skimpy is an example of a  Captcha:
an acronym for "Completely Automated  Public
Turing test to tell Computers and Humans Apart".

The Skimpy program and API
(applications programmer interface)
is implemented in a single
self contained Python script (module).  The
input for Skimpy are words or phrases.
The output of the program and API are strings containing
HTML preformatted text.  The preformatted
text contains "ASCII art" representing the input
phrase, which looks like somewhat sloppy handwriting
on a speckled page, when viewed in an HTML browser.

It is intended that it is easy for a human to
read the word or phrase when rendered
as HTML, but it is difficult for a program to
extract the word or phrase automatically.
The program uses a number of techniques
to make the output difficult for a computer to
interpret: curve interpolation, random rotation,
random skew, random scale adjustment,
"smearing", and addition of noise.

The Skimpy tool is far easier to install, use,
and embed than other similar technologies.
All you need is python installed and the
skimpyGimpy.py source file.

Enjoy and happy holidays!  -- Aaron Watters
===
there ain't no sanity clause!

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

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

ANN: Skimpy Gimpy ASCII Web Challenge CAPTCHA

2006-12-18 Thread aaronwmail-usenet
Please check it out and try it:

   http://skimpygimpy.sourceforge.net/

Find examples, documentation, links to demos
and download links there.

Skimpy Gimpy is a tool for generating HTML
representations for strings which
people can read but which web
robots and other computer programs
will have difficulty understanding.
Skimpy is an example of a  Captcha:
an acronym for "Completely Automated  Public
Turing test to tell Computers and Humans Apart".

The Skimpy program and API
(applications programmer interface)
is implemented in a single
self contained Python script (module).  The
input for Skimpy are words or phrases.
The output of the program and API are strings containing
HTML preformatted text.  The preformatted
text contains "ASCII art" representing the input
phrase, which looks like somewhat sloppy handwriting
on a speckled page, when viewed in an HTML browser.

It is intended that it is easy for a human to
read the word or phrase when rendered
as HTML, but it is difficult for a program to
extract the word or phrase automatically.
The program uses a number of techniques
to make the output difficult for a computer to
interpret: curve interpolation, random rotation,
random skew, random scale adjustment,
"smearing", and addition of noise.

The Skimpy tool is far easier to install, use,
and embed than other similar technologies.
All you need is python installed and the
skimpyGimpy.py source file.

Enjoy and happy holidays!  -- Aaron Watters
===
there ain't no sanity clause!

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


Re: Good Looking UI for a stand alone application

2006-12-18 Thread Peter Decker
On 12/18/06, Luc Heinrich <[EMAIL PROTECTED]> wrote:

> > You're full of it. I routinely write GUI apps in Dabo for both Windows
> > and Linux users, and they look just fine on both platforms.
>
> Oh, I'm sure you do. Now go try to run one of your Dabo apps on a Mac
> and see how it looks/feels... :>

I don't have a Mac, although I would certainly like one. But one of
the two authors of Dabo is a Mac user, and says that he does all his
development on a Mac, and then tests it on the other platforms. Look
at the screencasts on the Dabo site - most of them are recorded on OS
X.

> Here's a hint directly taken from the Dabo homepage: "It also suffers
> from the same display limitations on some platforms (most notably OS X),
> but these should improve as the underlying toolkits improve."

OK, it's true: you don't have 100% access to the lickable Aqua stuff
that a Cocoa app might be able to use. But paged controls use native
Aqua tabs; progress bars are native Aqua bars, buttons are native Aqua
buttons... Perfect? Of course not. But stating that it sucks is a load
of crap.

> > Using sizers is the key; layouts just 'look right' no matter what the native
> > fonts and control sizes are.
>
> No, sizers are a tiny part of a much bigger problem. Sizers might be the
> key to solve parts of the "look" problem, they don't address any of the
> "feel" problem.

Huh? Based on what I've seen on the screencasts, the apps look better
on the Mac than they do on XP. How should I judge how they "feel"?
SIzers automatically take care of font metric differences and native
control size differences.

> But you clearly have a point here, so let me rephrase: "Crossplatform
> toolkits/frameworks suck. All of them. No exception. UNLESS you only
> target the lowest common denominator, aka Windows and its Linux
> followers".
>
> Now, the OP *explicitely* said that "[his] requirement is that the
> application needs to look as good on Windows as on the Apple Mac", so
> the rephrasing does not apply in this case. So here's a last try:

Well, I don't think *anything* looks as good on Windows as it does on
a Mac, whether it is from a platform-specific toolkit such as Winforms
or a cross-platform toolkit like wxPython. If you want it to look as
good on Windows, you'll have to use VNC or something like that.

> "Crossplatform toolkits/frameworks suck. All of them. No exception.
> ESPECIALLY if one of your target is Mac OS".

Such self-important pronouncements would be better received if you
brought them down the mountain on stone tablets.
-- 

# p.d.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Good Looking UI for a stand alone application

2006-12-18 Thread Paul McNett
Luc Heinrich wrote:
> Peter Decker <[EMAIL PROTECTED]> wrote:
> 
>> You're full of it. I routinely write GUI apps in Dabo for both Windows
>> and Linux users, and they look just fine on both platforms.
> 
> Oh, I'm sure you do. Now go try to run one of your Dabo apps on a Mac
> and see how it looks/feels... :>

It looks/feels like a native app on OS X.


> Here's a hint directly taken from the Dabo homepage: "It also suffers
> from the same display limitations on some platforms (most notably OS X),
> but these should improve as the underlying toolkits improve."

That was written a long time ago, and doesn't really apply anymore as a
lot of effort has gone into wxPython over the past three years getting
correctly interfaced to the OS X native API.

(Note to self: rewrite that (prescient) paragraph).


>> Using sizers is the key; layouts just 'look right' no matter what the native
>> fonts and control sizes are.
> 
> No, sizers are a tiny part of a much bigger problem. Sizers might be the
> key to solve parts of the "look" problem, they don't address any of the
> "feel" problem.

Admittedly, to some extent there is a lowest common denominator problem
inherent in any UI toolkit that tries to be crossplatform and use the
platform's native GUI. But for the most part, that just isn't the case
anymore in a practical sense.

Why not use the best crossplatform native toolkit (wxPython) and then if
you need native features that aren't provided, use ctypes or something
to get access to the native GUI? Nothing in wxPython or Dabo prevents
you from doing that.


> But you clearly have a point here, so let me rephrase: "Crossplatform
> toolkits/frameworks suck. All of them. No exception. UNLESS you only
> target the lowest common denominator, aka Windows and its Linux
> followers".

Absolutism sucks. Please try not to be so black and white about things,
and you may find you enjoy life more.


> Now, the OP *explicitely* said that "[his] requirement is that the
> application needs to look as good on Windows as on the Apple Mac", so
> the rephrasing does not apply in this case. So here's a last try:
> 
> "Crossplatform toolkits/frameworks suck. All of them. No exception.
> ESPECIALLY if one of your target is Mac OS".

It is much more nuanced than that.


-- 
pkm ~ http://paulmcnett.com


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


Re: def index(self):

2006-12-18 Thread Gert Cuykens
> FWIW, the first version raises an exception (unless of course the name
> 'index' is already bound in the enclosing scope). And the second won't
> probably work as expected with CherryPy.


class HelloWorld:
 def index(self):
  return "Hello world!"
 index.exposed = True #DOOH!


i skipped reading the chapter about 2.1.8 Indentation. Guess how many
hours it took to realize 2 spaces isn't the same as 1 space lol

Any other chapters i should read horizontal instead of vertical for a
php5 htm jso wane be snake user :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: writing serial port data to the gzip file

2006-12-18 Thread Petr Jakes
Maybe I am missing something. Expect data is comming continually to the
serial port for the period say 10min. (say form the GPS), than it stops
for 1 minute and so on over and over. I would like to log such a data
to the different gzip files.
My example was written just for the simplicity (I was trying to
demonstrate the problem, it was not the real code and I was really
tired trying to solve it by myself, sorry for the bugy example)

the better way how to write such a infinite loop can be probably:
= 8< =
g=0
x=0
while 1:
if not g:
x+=1
g=gzip.GzipFile("/root/foofile%s.gz" % x,"w")
data=dataOnSerialPort()
while data:
myFlag=1
g.write(data)
data=dataOnSerialPort():
else:
if myFlag:
g.close()
pring g
myFlag=0

But it looks like g.close() method does not close the file (while
trying to print the g object, it  still exists)


> Your while loop is discarding result of dataOnSerialPort, so you're
> probably writing empty string to the file many times. Typically this
> kind of loop are implemented using iterators. Check if your s object
> (is it from external library?) already implements iterator. If it does
> then
>
> for data in s:
> g.write(data)
>
> is all you need. If it doesn't, you can use iter to create iterator for
> you:
> 
> for data in iter(s.readLine, ''):
> g.write(data)
> 
>   -- Leo

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


Crash in PyImport_Import()

2006-12-18 Thread Geert Van Muylem
Hi, 

The following script works fine when I call it from the python interpreter 
but not when I call it from a c application (embedded python) 
It crashes in the PyImport_Import() 

import ldap 
import distutils.sysconfig 

def TestInit(): 

   l = ldap.open("192.168.1.2") 
   l.simple_bind_s("","") 
   l.search_s("c=BE", ldap.SCOPE_SUBTREE, "objectclass=*") 

   s = distutils.sysconfig.get_config_var('LINKFORSHARED') 


-> Python (2.5) and python-ldap (2.2.1) are recompiled for my environment
(hardened linux.)



Here is part of my makefile: 

VERSION = Python-2.5 

VERSION_LDAP = python-ldap-2.2.1 

compile: .python .python-ldap 

.python:makefile.python .glibc $(VERSION).Setup.local 
$(EXTRACT_PACKAGE) && \ 
$(CP) ../$(VERSION).Setup.local Modules/Setup.local
&& \ 
./configure --prefix=/usr --enable-shared=no && \ 
make && \ 
make install 
cp $(VERSION)/libpython2.5.a /usr/lib/libpython.a 
(cd /usr/include; $(LN) -sf python2.5 python ) 
touch .python 


.python-ldap: makefile.python .python .sasl .glibc .openldap
python-ldap.setup.cfg 
(rm -rf $(VERSION_LDAP)  ||  /bin/true)  && \ 
tar xjf $(ARCHIVE_PACKAGES)/$(VERSION_LDAP).tar.bz2  && \ 
cd $(VERSION_LDAP) && \ 
$(CP) ../python-ldap.setup.cfg setup.cfg && \ 
python setup.py build && \ 
python setup.py install 
rm -rf $(VERSION_LDAP) 
touch .python-ldap 


And my setup.cfg 

# Example for setup.cfg 
# You have to edit this file to reflect your system configuation 
# $Id: setup.cfg.suse-linux,v 1.1 2003/08/20 10:04:34 stroeder Exp $ 

[_ldap] 
# Section for compiling the C extension module 
# for wrapping OpenLDAP 2 libs 

library_dirs = /usr/lib/ /usr/lib/sasl2/ 
include_dirs = /usr/include/sasl/ /usr/include/sasl2/ 
extra_compile_args = 
extra_objects = 

# Example for full-featured SuSE build: 
# Support for StartTLS/LDAPS, SASL bind and reentrant libldap_r. 
# This needs recent OpenLDAP 2.0.26+ or 2.1.3+ built with 
#./configure --with-cyrus-sasl --with-tls 
libs = python ldap_r lber sasl2 ssl crypto resolv dl db m util pthread 

[install] 
# Installation options 
compile = 1 
optimize = 1 

Everything is done in a chroot-ed environment...when building python-ldap,
it uses 
the newly installed python includes 
The test application is linked against the static version libpython.a

 

int 

CPyLDAP::Init()

{

m_iPython = 1;

 

printf ("Before Py_Initialize...\n");

Py_Initialize();

printf ("After Py_Initialize...\n");

 

PyObject *pName = PyString_FromString("PyTest");

if ( pName != NULL )

{

// Load the Python module

printf ("Before Import...\n");

m_pModule = PyImport_Import(pName);

printf ("After Import...\n");

if (m_pModule != NULL)

{

m_iPython = 0;

m_pDictionary = PyModule_GetDict(m_pModule);

}

}



return (m_iPython);

}


Hope someone can give me a hint? 

thanks, 
Geert

 

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

Re: When Closure get external variable's value?

2006-12-18 Thread Jussi Salmela
Huayang Xia kirjoitti:
> It will print 15. The closure gets the value at run time.
> 
> Could we treat closure as part of the external function and it shares
> the local variable with its holder function?
> 

I don't quite get what you are trying to tell us but if you think that 
in your example code:

 def testClosure(maxIndex) :

 def closureTest():
 return maxIndex

 maxIndex += 5

 return closureTest()

 print testClosure(10)

you are returning a callable function you are all wrong. This can be 
easily seen by:

 >>> type(testClosure(10))
15


The mistake is that you shouldn't return closureTest() but closureTest 
instead. The correct way would be:

 >>> def testClosure2(maxIndex):
def closureTest():
return maxIndex
maxIndex += 5
return closureTest

 >>> f2 = testClosure2(10)

 >>> type(f2)

 >>> print f2()
15

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


pyExcelerator question

2006-12-18 Thread Gerry

I'd like to word wrap some cells, but not others, in an Excel
spreadsheet, using pyExcelerator and Excel 2003, SP1, under XP.

The code below creates the spreadsheet, but both cells are
word-wrapped.

As far as I can tell, the second call to XFStyle() overwrites a GLOBAL
wrap setting, and affects even cells written before the call to
XFStyle.

Can anyone shed any light?

Thanks,

Gerry


from pyExcelerator import *


w   = Workbook()
ws  = w.add_sheet("alpha")

style   = XFStyle()
style.alignment.wrap= Alignment.NOT_WRAP_AT_RIGHT
ws.write(1,1,"Not wrapped" + "-" * 50, style)

style2   = XFStyle()
style2.alignment.wrap= Alignment.WRAP_AT_RIGHT
ws.write(2,1,"Wrapped" + "-" * 50, style2)

w.save("test.xls")

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


Re: Core dump revisited

2006-12-18 Thread Sheldon

Nick Craig-Wood skrev:

> Sheldon <[EMAIL PROTECTED]> wrote:
> >  gdb msgppscomp.py core.3203
>
> Run
>
>   gdb python
>
> Then type
>
>   run msgppscomp.py
>
> at the gdb prompt.
>
> When it crashes, type "bt" for a back trace.  This will pinpoint
> exactly where it crashes.
>
> Hopefully that will make things clearer.  If not post the output.
>
> --
> Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick

Wonderful! Now I know how to used gdb with python. The are results area
posted below. Since I am new at this I could used some help in
interpreting the problem. What I do know is this: my allocation of the
array is good but when freeing the array, a problem arises. The problem
is given below but since I am new as well to C I sure could use some
help.

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1077321856 (LWP 32710)]
0x40297b83 in mallopt () from /lib/tls/libc.so.6
(gdb) bt
#0  0x40297b83 in mallopt () from /lib/tls/libc.so.6
#1  0x402958ba in free () from /lib/tls/libc.so.6
#2  0x405e070a in MemoryFreeOrd () at msgppsmodule_area.c:1675
#3  0x405dae0a in msgppsarea (self=0x0, args=0x4042aa7c, kwargs=0x0) at
msgppsmodule_area.c:328
#4  0x40073b16 in PyCFunction_Call () from /usr/lib/libpython2.3.so.1.0


I appreciate your help so far and could use some more.

/S

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


Re: sha, PyCrypto, SHA-256

2006-12-18 Thread Klaas

Dennis Benzinger wrote:
>
> Python 2.5 comes with SHA-256 in the hashlib module.
> So you could install Python 2.5 instead of the PyCrypto module.

You can download the python2.5 hashlib module for use with python2.4

-MIke

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


Re: def index(self):

2006-12-18 Thread Bruno Desthuilliers
Gert Cuykens a écrit :
> Is there a difference between
> 
> 
> class HelloWorld:
> def index(self):
>  index.exposed = True
>  return "Hello world!"
> 
> 
> and
> 
> 
> class HelloWorld:
> def index(self):
>  self.exposed = True
>  return "Hello world!"
> 

Ask yourself what are the names 'index' and 'self' refering to in the 
context of this function, and you'll have the answer. And if you can't 
answer, then it may be time to learn Python...

FWIW, the first version raises an exception (unless of course the name 
'index' is already bound in the enclosing scope). And the second won't 
probably work as expected with CherryPy.



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

Re: def index(self):

2006-12-18 Thread Chris Lambacher
On Mon, Dec 18, 2006 at 08:40:13PM +0100, Gert Cuykens wrote:
> Is there a difference between
Yes. The first one causes an exception and the second one doesn't.
> 
> 
> class HelloWorld:
>  def index(self):
>   index.exposed = True
index is not defined. HelloWorld.index is and self.index is, but index is not.
>   return "Hello world!"
> 
> 
> and
> 
> 
> class HelloWorld:
>  def index(self):
>   self.exposed = True
>   return "Hello world!"
> 

If you are just starting to explore Python, the console is great for trying
stuff out.

-Chris


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


Re: def index(self):

2006-12-18 Thread Jussi Salmela
Gert Cuykens kirjoitti:
> Is there a difference between
> 
> 
> class HelloWorld:
> def index(self):
>  index.exposed = True
>  return "Hello world!"
> 
> 
> and
> 
> 
> class HelloWorld:
> def index(self):
>  self.exposed = True
>  return "Hello world!"
> 

The resident experts seemingly being absent for a while, I'll strike:

Yes: the first gives a runtime error and the second is OK.
I've renamed the second class to HelloWorld2 and then:

 >>> hw = HelloWorld()
 >>> hw2 = HelloWorld2()

 >>> hw.index()
Traceback (most recent call last):
   File "", line 1, in 
 hw.index()
   File "C:\Python\Dive into Python\Py\apihelper.py", line 40, in index
 index.exposed = True
NameError: global name 'index' is not defined

 >>> hw2.index()
'Hello world!'

The error message shows that the Python compiler has interpreted the 
construction 'index.exposed' to refer to a global variable 'index' that 
doesn't exist at run time. The second class succesfully defines an 
instance attribute 'exposed' as can be seen by:

 >>> print hw2.exposed
True

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


Re: Good Looking UI for a stand alone application

2006-12-18 Thread Luc Heinrich
Peter Decker <[EMAIL PROTECTED]> wrote:

> You're full of it. I routinely write GUI apps in Dabo for both Windows
> and Linux users, and they look just fine on both platforms.

Oh, I'm sure you do. Now go try to run one of your Dabo apps on a Mac
and see how it looks/feels... :>

Here's a hint directly taken from the Dabo homepage: "It also suffers
from the same display limitations on some platforms (most notably OS X),
but these should improve as the underlying toolkits improve."

> Using sizers is the key; layouts just 'look right' no matter what the native
> fonts and control sizes are.

No, sizers are a tiny part of a much bigger problem. Sizers might be the
key to solve parts of the "look" problem, they don't address any of the
"feel" problem.

But you clearly have a point here, so let me rephrase: "Crossplatform
toolkits/frameworks suck. All of them. No exception. UNLESS you only
target the lowest common denominator, aka Windows and its Linux
followers".

Now, the OP *explicitely* said that "[his] requirement is that the
application needs to look as good on Windows as on the Apple Mac", so
the rephrasing does not apply in this case. So here's a last try:

"Crossplatform toolkits/frameworks suck. All of them. No exception.
ESPECIALLY if one of your target is Mac OS".

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


Re: skip last line in loops

2006-12-18 Thread tobiah
> See the documentation for xreadlines.
> 
> James

Hmm...

This method returns the same thing as iter(f). New in version 2.1.
Deprecated since release 2.3. Use "for line in file" instead.

-- 
Posted via a free Usenet account from http://www.teranews.com

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


Re: When Closure get external variable's value?

2006-12-18 Thread Huayang Xia
It will print 15. The closure gets the value at run time.

Could we treat closure as part of the external function and it shares
the local variable with its holder function?

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


Is htmlGen still alive?

2006-12-18 Thread kgmuller
Does anybody know whether htmlGen, the Python-class library for
generating HTML, is still being maintained? Or from where it can be
downloaded? The Starship site where it used to be hosted is dead.

Thanks for your help!

Klaus Muller

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


Re: Core dump revisited

2006-12-18 Thread Sheldon

Nick Craig-Wood skrev:

> Sheldon <[EMAIL PROTECTED]> wrote:
> >  gdb msgppscomp.py core.3203
>
> Run
>
>   gdb python
>
> Then type
>
>   run msgppscomp.py
>
> at the gdb prompt.
>
> When it crashes, type "bt" for a back trace.  This will pinpoint
> exactly where it crashes.
>
> Hopefully that will make things clearer.  If not post the output.
>
> --
> Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick

Wonderful! Now I know how to used gdb with python. The are results area
posted below. Since I am new at this I could used some help in
interpreting the problem. What I do know is this: my allocation of the
array is good but when freeing the array, a problem arises. The problem
is given below but since I am new as well to C I sure could use some
help.

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1077321856 (LWP 32710)]
0x40297b83 in mallopt () from /lib/tls/libc.so.6
(gdb) bt
#0  0x40297b83 in mallopt () from /lib/tls/libc.so.6
#1  0x402958ba in free () from /lib/tls/libc.so.6
#2  0x405e070a in MemoryFreeOrd () at msgppsmodule_area.c:1675
#3  0x405dae0a in msgppsarea (self=0x0, args=0x4042aa7c, kwargs=0x0) at
msgppsmodule_area.c:328
#4  0x40073b16 in PyCFunction_Call () from /usr/lib/libpython2.3.so.1.0


I appreciate your help so far and could use some more.

/S

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


Re: Is there a way to push data into Ical from Python ?

2006-12-18 Thread Max M
has skrev:
> dwhall wrote:
> 
>> One way would be to use
>> Python's tie-ins to Applescript_ and apple events (AE).  As you will
>> read, this support isn't as strong as it used to be.
> 
> What gave you that impression, if you don't mind my asking?


http://www.google.dk/search?q=python+icalendar


-- 

hilsen/regards Max M, Denmark

http://www.mxm.dk/
IT's Mad Science
-- 
http://mail.python.org/mailman/listinfo/python-list


When Closure get external variable's value?

2006-12-18 Thread Huayang Xia
What will the following piece of code print? (10 or 15)

def testClosure(maxIndex) :

def closureTest():
return maxIndex

maxIndex += 5

return closureTest()

print testClosure(10)

My question is when the closure function gets value for maxindex? Run
time or compile time?

Thanks.

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


Re: merits of Lisp vs Python

2006-12-18 Thread Bruno Desthuilliers
Paul Rubin a écrit :
> Bruno Desthuilliers <[EMAIL PROTECTED]> writes:
> 
>>Strictly speaking, only first-class functions are required, and
>>tail-recursion optimisation is only an implentation detail. Now it's
>>obvious that when it comes to real-life-size programs, this is a
>>*very* important detail !-)
> 
> 
> I don't buy this. 

Fine - I'm not trying to sell it !-)

> One of my favorite quotes about specifications
> (http://www.sgi.com/tech/stl/drdobbs-interview.html):
> 
(snip).

 From a purely logical POV, the fact that a stack implementation has 
constant-time access or not is totally irrelevant (real-time problems 
set aside). This doesn't mean it's not important in practice.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python-URL! - weekly Python news and links (Dec 18)

2006-12-18 Thread Kay Schluehr
Paul Boddie wrote:

> Meanwhile, the EuroPython planners get ahead of themselves, thinking about
> conference venues as far in the future as 2010, if not 20010!

Python 20010. It was a nice conference although a bit lame on the first
day. My favourite talks were:

Trevor Stent: "Whitespace as a universal constant"
Mathais Fendro: "Snake gods and how they tamed chaons and simili"
Taumaturg 7: "Technologia inversa. A short history of holistic
semantics"

There was also some interesting short talk about wormhole calculus.
Unfortunetely I've forgotten the name of the lecturer. Maybe I was just
too fascinated by his appeal as a small spinning bubble, shining in
rainbow colors.

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


Re: writing serial port data to the gzip file

2006-12-18 Thread jim-on-linux



If someone hasn't already commented, 

Aside from any other problems, the file you are 
trying to write to is (opened)?? in the "w" mode. 
Every time a file is opened in the 'w' mode, 
everything in the file is deleted.

If you open a file in the 'a' mode, then 
everything in the file is left untouched and the 
new data is appended to the end of the file.

Your while loop is deleting everything in the file 
on each loop with the 'w' mode.

try, 
vfile = open('vfile', 'a')
rather than 
vfile = open('vfile', 'w')

jim-on-linux
http:\\www.inqvista.com


> while 1:
> g=gzip.GzipFile("/root/foofile.gz","w")
> while dataOnSerialPort():
> g.write(data)
> else: g.close()



On Sunday 17 December 2006 20:06, Petr Jakes 
wrote:
> I am trying to save data it is comming from the
> serial port continually for some period.
> (expect reading from serial port is 100% not a
> problem) Following is an example of the code I
> am trying to write. It works, but it produce an
> empty gz file (0kB size) even I am sure I am
> getting data from the serial port. It looks
> like g.close() does not close the gz file.
> I was reading in the doc:
>
> Calling a GzipFile object's close() method does
> not close fileobj, since you might wish to
> append more material after the compressed
> data...
>
> so I am completely lost now...
>
> thanks for your comments.
> Petr Jakes
>  snippet of the code  
> def dataOnSerialPort():
> data=s.readLine()
> if data:
> return data
> else:
> return 0
>
> while 1:
> g=gzip.GzipFile("/root/foofile.gz","w")
> while dataOnSerialPort():
> g.write(data)
> else: g.close()
-- 
http://mail.python.org/mailman/listinfo/python-list


def index(self):

2006-12-18 Thread Gert Cuykens
Is there a difference between


class HelloWorld:
 def index(self):
  index.exposed = True
  return "Hello world!"


and


class HelloWorld:
 def index(self):
  self.exposed = True
  return "Hello world!"

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


Re: Windows Authetication vs seperate process

2006-12-18 Thread Jonathan Curran
On Monday 18 December 2006 10:24, [EMAIL PROTECTED] wrote:
> I was wondering of someone could steer me in the right direction.
>
> We have a package that we would like to "secure" so that only specific
> individuals can access specific portions of the application.  Our
> wxPython application will revolve around updating a central database
> with information submitted from the app.  We will eventually have a web
> front end fo rsome aspects of the app.
>
> With several packages I have seen options to "Use Windows
> Authentication", which seems to mean that "If the user has
> authenticated and signed onto Windows, then our application will use
> their windows userid and we will just focus on the the tasks within our
> application the user is authorized to perform"
>
> Does anyone have any experience using this type of authentication
> scheme ?
>
> Any related tips or suggestions ?
>
> I have found a few wikipedia entries, but they seem to be more related
> to webpages, etc.
>
> Thanks.

Using windows authentication IMHO should only be used if there is an Active 
Directory/LDAP server set up against which the users are authenticated. I 
googled for 'active directory python' and came across 
http://tgolden.sc.sabren.com/python/ad_cookbook.html It seems to be very 
simple to use.

If I were to implement an authentication system like you want. I would:
1. Check to see if the local machine was part of a domain. If not then inform 
the user that they need to be.
2. Check to see if the user who ran the application is part of a specific 
group in AD.

I would assign each group a certain 'level' of privilege and accordingly let 
the user do what they should be able to do.

I hope this is a good starting point.

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


SQLObject 0.8.0b1

2006-12-18 Thread Oleg Broytmann
Hello!

I'm pleased to announce the 0.8.0b1 release of SQLObject. This is the first
beta of the new branch. Taking into account that it is a result of rather
large job the beta period will be prolonged. Meanwhile the stable 0.7
branch will be maintained, and there will be at least 0.7.3 release.


What is SQLObject
=

SQLObject is an object-relational mapper.  Your database tables are described
as classes, and rows are instances of those classes.  SQLObject is meant to be
easy to use and quick to get started with.

SQLObject supports a number of backends: MySQL, PostgreSQL, SQLite, and
Firebird.  It also has newly added support for Sybase, MSSQL and MaxDB (also
known as SAPDB).


Where is SQLObject
==

Site:
http://sqlobject.org

Development:
http://sqlobject.org/devel/

Mailing list:
https://lists.sourceforge.net/mailman/listinfo/sqlobject-discuss

Archives:
http://news.gmane.org/gmane.comp.python.sqlobject

Download:
http://cheeseshop.python.org/pypi/SQLObject/0.8.0b1

News and changes:
http://sqlobject.org/devel/News.html


What's New
==

Features & Interface


* It is now possible to create tables that reference each other.
  Constraints (in the DBMSes that support constraints) are added after the
  tables have been created.

* Added ``createSQL`` as an option for sqlmeta. Here you can add
  related SQL you want executed by sqlobject-admin create after table
  creation. createSQL expects a string, list, or dictionary. If using
  a dictionary the key should be a dbName value (ex. 'postgres') and
  the value should be a string or list.  Examples in
  sqlobject/tests/test_sqlobject_admin.py or at
  

* Added method ``sqlhub.doInTransaction(callable, *args, **kwargs)``,
  to be used like::

  sqlhub.doInTransaction(process_request, os.environ)

  This will run ``process_request(os.environ)``.  The return
  value will be preserved.

* Added method ``.getOne([default])`` to ``SelectResults`` (these are
  the objects returned by ``.select()`` and ``.selectBy()``).  This
  returns a single object, when the query is expected to return only
  one object.  The single argument is the value to return when zero
  results are found (more than one result is always an error).  If no
  default is given, it is an error if no such object exists.

* Added a WSGI middleware (in ``sqlobject.wsgi_middleware``) for
  configuring the database for the request.  Also handles
  transactions.  Available as ``egg:SQLObject`` in Paste Deploy
  configuration files.

* New joins! ManyToMany and OneToMany; not fully documented yet, but still
  more sensible and smarter.

* SELECT FOR UPDATE

* New module dberrors.py - a hierarchy of exceptions. Translation of DB API
  module's exceptions to the new hierarchy is performed for SQLite and MySQL.

* SQLiteConnection got a new keyword "factory" - a name or a reference to
  a factory function that returns a connection class; useful for
  implementing functions or aggregates. See test_select.py and
  test_sqlite_factory.py for examples.

* SQLObject now disallows columns with names that collide with existing
  variables and methods, such as "_init", "expire", "set" and so on.

Small Features
--

* Configurable client character set (encoding) for MySQL.

* Added a close option to .commit(), so you can close the transaction as
  you commit it.

* DecimalValidator.

* Added .expireAll() methods to sqlmeta and connection objects, to expire
  all instances in those cases.

* String IDs.

* FOREIGN KEY for MySQL.

* Support for sqlite3 (a builtin module in Python 2.5).

* SelectResults cannot be queried for truth value; in any case it was
  meaningless - the result was always True; now __nonzero__() raises
  NotImplementedError in case one tries bool(MyTable.select()) or
  "if MyTable.select():..."

Bug Fixes
-

* Fixed problem with sqlite and threads; connections are no longer shared
  between threads for sqlite (except for :memory:).

* The reference loop between SQLObject and SQLObjectState eliminated using
  weak references.

For a more complete list, please see the news:
http://sqlobject.org/devel/News.html

Oleg.
-- 
 Oleg Broytmannhttp://phd.pp.ru/[EMAIL PROTECTED]
   Programmers don't die, they just GOSUB without RETURN.
-- 
http://mail.python.org/mailman/listinfo/python-list


Python-URL! - weekly Python news and links (Dec 18)

2006-12-18 Thread Paul Boddie
QOTW:  "c.l.python is just a small speck at the outer parts of the python
universe. most python programmers don't even read this newsgroup, except,
perhaps, when they stumble upon it via a search engine." -- Fredrik Lundh
(on comp.lang.python, prompting the editor to offer greetings to those of
you who are not reading Python-URL! via that channel)
http://groups.google.com/group/comp.lang.python/msg/4d73a2da72c87226

"That's the kind of features I have in mind, and the best thing is that 
conceptually a lot of the work consists of connecting dots that already out 
there. But as there are so many of them, a few extra pencils would be quite 
welcome " -- Willem Broekema (on comp.lang.python, referring to the
ongoing CLPython - Python in Common Lisp - project)
http://groups.google.com/group/comp.lang.python/msg/b72788cc5569d778
http://trac.common-lisp.net/clpython/


Registration for PyCon (the North American Python conference) is now open:

http://pycon.blogspot.com/2006/12/registration-for-pycon-2007-is-now.html
http://us.pycon.org/TX2007/Registration

Meanwhile, the EuroPython planners get ahead of themselves, thinking about 
conference venues as far in the future as 2010, if not 20010!
http://mail.python.org/pipermail/europython/2006-December/006158.html
http://mail.python.org/pipermail/europython/2006-December/006161.html

PyMite - the embedded Python interpreter - gets an update:

http://groups.google.com/group/comp.lang.python.announce/msg/b335a476d4033292
http://pymite.python-hosting.com/

This week's Python advocacy discovery had to be the revelation that YouTube 
runs on Python, helping to diminish concerns about Python's suitability for 
large scale Internet applications and services:
http://sayspy.blogspot.com/2006/12/youtube-runs-on-python.html
http://www.python.org/about/quotes/#youtube-com

Of related things "flexible and fast", development in the Cherokee Web
server community produces the 100% Python implementation of SCGI: the
logically named PySCGI.
http://www.alobbs.com/news/1193

And on the advocacy front, volunteers are sought to write informative 
materials (flyers, whitepapers) promoting Python in different domains:
http://wiki.python.org/moin/AdvocacyWritingTasks

Video conferencing on the OLPC (One Laptop Per Child) prototype takes
shape with a mixture of technologies and "a few lines of Python":
http://www.robot101.net/2006/12/12/telepathy-and-olpc/

After an influx of competing XML technologies and now drifting free
without an appointed maintainer, is the era of PyXML over?
http://mail.python.org/pipermail/xml-sig/2006-December/011620.html

On a more administrative level, the Python Software Foundation (PSF)
invites nominations for new directors:

http://pyfound.blogspot.com/2006/12/call-for-nominations-of-psf-directors.html

The PSF also suggests that you might consider a donation towards their
work of protecting the Python copyrights and trademarks:
http://pyfound.blogspot.com/2006/12/remember-psf-in-your-year-end.html



Everything Python-related you want is probably one or two clicks away in
these pages:

Python.org's Python Language Website is the traditional
center of Pythonia
http://www.python.org
Notice especially the master FAQ
http://www.python.org/doc/FAQ.html

PythonWare complements the digest you're reading with the
marvelous daily python url
 http://www.pythonware.com/daily
Mygale is a news-gathering webcrawler that specializes in (new)
World-Wide Web articles related to Python.
 http://www.awaretek.com/nowak/mygale.html
While cosmetically similar, Mygale and the Daily Python-URL
are utterly different in their technologies and generally in
their results.

For far, FAR more Python reading than any one mind should
absorb, much of it quite interesting, several pages index
much of the universe of Pybloggers.
http://lowlife.jp/cgi-bin/moin.cgi/PythonProgrammersWeblog
http://www.planetpython.org/
http://mechanicalcat.net/pyblagg.html

The Python Papers aims to publish "the efforts of Python enthusiats".
http://pythonpapers.org/

comp.lang.python.announce announces new Python software.  Be
sure to scan this newsgroup weekly.

http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python.announce

Python411 indexes "podcasts ... to help people learn Python ..."
Updates appear more-than-weekly:
http://www.awaretek.com/python/index.html

Steve Bethard continues the marvelous tradition early borne by
Andrew Kuchling, Michael Hudson, Brett Cannon, Tony Meyer, and Tim
Lesher of intelligently summarizing action o

Re: trees

2006-12-18 Thread Martin Manns
John Nagle wrote:

>SpeedTree, of course.
> 
> http://www.speedtree.com
> 
>They have great downloadable demos.

And how do you distribute the code in a python program?
Is there a wrapper for an available static library
or do I have to compile the speedtree source when
running the python program?

:)

M
--
>From the homepage:
What parts of SpeedTree can I distribute with my game?

Before any sort of distribution, a full license of SpeedTree must be purchased.
Following this, the SpeedTreeRT library must be fully integrated with your game
before distribution. This means that either a static library is used or the 
source
code must be built in (no DLLs may be distributed). No source code from the SDK 
can
be distributed, with some exceptions for modified wrapper classes from the 
samples
(contact [EMAIL PROTECTED] for verification).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Need Simple Way To Determine If File Is Executable

2006-12-18 Thread Tim Daneliuk
Gabriel Genellina wrote:
> At Monday 18/12/2006 13:41, Tim Daneliuk wrote:
> 
>> I was working on a new release and wanted to add file associations
>> to it.  That is, if the user selected a file and double clicked or
>> pressed Enter, I wanted the following behavior (in the following
>> steps, "type" means nothing more than "a file whose name ends with
>> a particular string"):
>>
>> 1) If an association for that file type exists, run the associated 
>> program.
>>
>> 2) If an association for that file type does not exist:
>>
>> a) If the file is not "executable", see if there is a "default"
>>association defined and run that program if there is.
>>
>> b) If the file *is* "executable", run it.
> 
> This is what os.startfile does. The underlying Win32 functions would be 

And on Windows, that's exactly what I use.

> ShellExecute, FindExecutable & their variants.
> Will you maintain your own registry for associations?

Yes, because I want common configuration syntax and runtime
semantics across FreeBSD, Linux, Windows, et al.  The only
semantic difference is that, on Windows, if my own association
is not found, then the Windows association will apply.  This
cannot be done in the *nix environment - at least not easily -
because there is no common association repository across the
various window managers, nor is there a startfile() type
call in the POSIX world.


This is implemented already and largely works as planned.
There are a few subtleties I want to work into the next
release, but things work as expected today...

-- 

Tim Daneliuk [EMAIL PROTECTED]
PGP Key: http://www.tundraware.com/PGP/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Windows Authetication vs seperate process

2006-12-18 Thread Gabriel Genellina

At Monday 18/12/2006 13:24, [EMAIL PROTECTED] wrote:


With several packages I have seen options to "Use Windows
Authentication", which seems to mean that "If the user has
authenticated and signed onto Windows, then our application will use
their windows userid and we will just focus on the the tasks within our
application the user is authorized to perform"


Search for SSPI. But it may be a bit tricky to get running.


--
Gabriel Genellina
Softlab SRL 


__
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Dictionary, iterate & update objects

2006-12-18 Thread Carl Banks

Dennis Lee Bieber wrote:
> On 16 Dec 2006 14:49:19 -0800, "jansenh" <[EMAIL PROTECTED]>
> declaimed the following in comp.lang.python:
>
> > Yes.
> > [... the temp object is by ref, and any manipulation of the temp object
> > is to the object itself..? It really simplifies my first attempt]
> >
>   For all practical purposes, everything in Python is "by ref" and the
> difference is whether the object itself is mutable (dictionaries, lists,
> class instances, modules) or immutable (strings, tuples, numbers). A
> mutable object is basically something that contains references to other
> objects

Not at all.  It's not even generally true of Python.  Mutability is
orthogonal to containership.

arrays, files, cStringIO objects, mmap objects, thread locks, some
iterator types, etc., are mutable but do not contain Python objects
(__dict__ excepted).

tuples, frozensets, instancemethods, are immutable but do contain
Python objects.


Carl Banks

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


Re: Strange error with getattr() function

2006-12-18 Thread Gabriel Genellina

At Monday 18/12/2006 13:25, Hole wrote:


> At this point, I got the error: attribute name must be string

I'm wondering if the exception is raised in a hidden function and not
in the explicit call to getattr(). How can I view the traceback in a
script running in zope??


(Which Zope version?)
If you don't catch the exception, an error page will be displayed, 
pointing to the error_log object.



--
Gabriel Genellina
Softlab SRL 







__ 
Preguntá. Respondé. Descubrí. 
Todo lo que querías saber, y lo que ni imaginabas, 
está en Yahoo! Respuestas (Beta). 
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas 

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

psp 2 game list

2006-12-18 Thread Charles Bishop
could you send me a list of games you have
 __
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com -- 
http://mail.python.org/mailman/listinfo/python-list

Re: Strange error with getattr() function

2006-12-18 Thread Gabriel Genellina

At Monday 18/12/2006 12:33, Hole wrote:


I'm trying to use Zope and the product OpenFlow.


Try posting in the Zope list, you surely will have more responses.


I got the following error while I was using the built-in function
getattr() to retrieve an OpenFlow object:

attribute name must be string


Actually, I surely pass a string as attribute name to getattr()

The code:

#following instruction returns me the string "WorkFlowTest"
openflow_id=container.aq_parent.id


Are you sure it's a string? Some objects have an id() method. You 
always should use getId().



if (hasattr(container,openflow_id):
#the interpreter enter in this block, so
#it's sure that container has an attribute called WorkFlowTest
openflow=getattr(container,openflow_id)

At this point, I got the error: attribute name must be string


getattr is acquisition-aware so you might be retrieving another thing...


The *strange* is that I get the same error even if I pass the attribute
name to the getattr() function as pure string:

getattr(container,"WorkFlowTest")
(sic!)


If you're really sure of this, I think the error may occur inside 
another function in the getattr chain.




--
Gabriel Genellina
Softlab SRL 







__ 
Preguntá. Respondé. Descubrí. 
Todo lo que querías saber, y lo que ni imaginabas, 
está en Yahoo! Respuestas (Beta). 
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas 

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

Re: Script to upload Files via http/cgi

2006-12-18 Thread Gabriel Genellina

At Monday 18/12/2006 12:30, Richard Konrad wrote:


Does anyone know about a python-script to upload Files via http/cgi?


See the urllib2 module.


--
Gabriel Genellina
Softlab SRL 


__
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: connecting webservers through HTTP port using python

2006-12-18 Thread Jonathan Curran
On Monday 18 December 2006 06:28, pradeep kumar wrote:
> hii iam working on socket programming,
> i've to connect webservers through HTTP port and send/receive data..
> so currently i'm installed apache server and trying to connect that server
> using python.
> so any tell me how to connect the apache server by python code.
> give suggestions..

Pradeep, first of all you might want to formulate your sentences properly so 
that it is understandable by the people who read it. Secondly, take the time 
to describe what your question/goal is.

>From what I've read & possibly misunderstood, it seems that you want to be 
able to retreive data from a web page. If so you might want to glance at 
http://diveintopython.org/http_web_services/ and also take a look at the SGML 
section that is mentioned earlier on in the book.

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


Re: connecting webservers through HTTP port using python

2006-12-18 Thread Gabriel Genellina

At Monday 18/12/2006 09:28, pradeep kumar wrote:


hii iam working on socket programming,
i've to connect webservers through HTTP port and send/receive data..
so currently i'm installed apache server and trying to connect that 
server using python.

so any tell me how to connect the apache server by python code.
give suggestions..


See the httplib module


--
Gabriel Genellina
Softlab SRL 


__
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Need Simple Way To Determine If File Is Executable

2006-12-18 Thread Gabriel Genellina

At Monday 18/12/2006 13:41, Tim Daneliuk wrote:


I was working on a new release and wanted to add file associations
to it.  That is, if the user selected a file and double clicked or
pressed Enter, I wanted the following behavior (in the following
steps, "type" means nothing more than "a file whose name ends with
a particular string"):

1) If an association for that file type exists, run the associated program.

2) If an association for that file type does not exist:

a) If the file is not "executable", see if there is a "default"
   association defined and run that program if there is.

b) If the file *is* "executable", run it.


This is what os.startfile does. The underlying Win32 functions would 
be ShellExecute, FindExecutable & their variants.

Will you maintain your own registry for associations?


--
Gabriel Genellina
Softlab SRL 


__
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
-- 
http://mail.python.org/mailman/listinfo/python-list

REPORT

2006-12-18 Thread mskelton
***
A virus (WORM_MYDOOM.GEN) was detected in the file (letter.zip/letter.html  

 .exe). Action taken = remove
***-***


Message could not be delivered


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

Re: merits of Lisp vs Python

2006-12-18 Thread jayessay
Paul Rubin  writes:

> [EMAIL PROTECTED] writes:
> > I should assume you meant Common Lisp, but there isn't really any
> > reason you couldn't
> > 
> >  (poke destination (peek source))
> 
> That breaks the reliability of GC.  I'd say you're no longer writing
> in Lisp if you use something like that.

Please note: GC is not part of CL's definition.  It is likely not part
of any Lisp's definition (for reasons that should be obvious), and for
the same reasons likely not part of any language's definition.  So,
your point here is actually a category error...


/Jon

-- 
'j' - a n t h o n y at romeo/charley/november com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: convert from date string to epoch

2006-12-18 Thread John Machin

Stefan Antonelli wrote:
> Amit Khemka  gmail.com> writes:
> >
> > Check out timegm function in calendar module. The following function
> > converts "mm/dd/" formats into epoch value, you can hack it for
> > your date formats.
> >
> > def convertToEpoch(date):
> >  tup = map(int,date.split('/'))
> >  l = (tup[2], tup[0], tup[1], 0, 0, 0)
> >  epochs = calendar.timegm(l)
> >  return (int(epochs))
>
>
> Thanks for your suggestion... For me this was the Solutions:
>
> # convert '-mm-dd hh:mm:ss' to epoch
> def toEpoch(timestamp):
>   split = str(timestamp).split(' ')

Binding the name "split" to this result is not a good idea, because it
leads to ...

>   tdate = map(int,split[0].split('-'))

... the above line being rather difficult to read without exclamations
:-)

>   ttime = map(int,split[1].split(':'))
>   tcode = (tdate[0], tdate[1], tdate[2], ttime[0], ttime[1], ttime[2])

... and the above causes the same problem.

tcode = ttime + tcode

might be better.

>   epoch = timegm(tcode)
>   return (int(epoch))
>

Try this:

 def toEpoch(timestamp):
  datestr, timestr = str(timestamp).split(' ')
  tdate = datestr.split('-')
  ttime = timestr.split(':')
  tcode = map(int, tdate + ttime)
  epoch = timegm(tcode)
  return int(epoch)

Note: the last 5 lines can be jammed into one line if you are desperate
:-)

HTH,
John

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


Re: Is there a way to push data into Ical from Python ?

2006-12-18 Thread Philip Austin
"The Night Blogger" <[EMAIL PROTECTED]> writes:

> Is there a way to pull & push data into (Apple Mac OS X Calendar) Ical from
> Python ?
>

see: http://vobject.skyhouseconsulting.com/

-- regards, Phil
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Shed Skin - Does it break any Python assumptions?

2006-12-18 Thread bearophileHUGS
Jean-Paul Calderone:
> So yes, it seems that what ShedSkin supports is pretty distant from what
> a seasoned Python developer might expect, aside from syntactic constructs.

At the moment SS doesn't allow to change the type of a variable during
its lifetime, but SS is a moving target, maybe in the (far) future it
will split it into two variables...
I'm sure Mark likes to receive practical suggestions on how to improve
SS to make it closer to Python. (And I think he likes to receive
patches too, but usually it's better for people to start from simpler
things, like speeding up a lib written with C++, etc).

Bye,
bearophile

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


Re: Roundtrip SQL data especially datetime

2006-12-18 Thread John Nagle
GHUM wrote:
>>One side effect of this being third party code is that hosting
>>services may not have it available, even when they have both Python
>>and MySQL up.  This is never a problem with Perl or PHP, so that's
>>a negative for Python.
> 
> 
> I for one think it is a good thing to not have MySQL adapters
> integrated into Python core. Neither the philopsophie, nor the licence
> of the two products fit together.

It's a wire protocol.  At one end of a socket, there's MySQL, and
at the other end, there's a client.  Neither side needs code from
the other.  The protocol is published.  So there's no license issue.

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


Re: Need Simple Way To Determine If File Is Executable

2006-12-18 Thread Tim Daneliuk
Gabriel Genellina wrote:
> On 17 dic, 19:21, "Roger Upole" <[EMAIL PROTECTED]> wrote:
> 
>   os.stat(selected)[ST_MODE] & (S_IXUSR|S_IXGRP|S_IXOTH
 This will tell you that "x.exe" is executable, even if "x.exe" contains
 nothing but zeros.
>>> Isn't the same with any other recipe, portable or not? Unless the OS
>>> actually tries to load and examine the file contents, which the OS's
>>> I'm aware of, don't do.
>> On windows, you can use win32file.GetBinaryType to check if a file is 
>> actually
>> a binary executable.
> 
> A similar function exists on Linux too. But even if a file has the
> right file format, if it does not have the execute bit set, won't run.
> And you could set that bit on a JPG image too - and nothing good would
> happen, I presume. So one must determine first what means "the file is
> executable".
> 

Well... sure, but that isn't the point. Here is the problem I was
trying to solve:

I wrote and maintain the 'twander' cross-platform file browser:

   http://www.tundraware.com/Software/twander/

I was working on a new release and wanted to add file associations
to it.  That is, if the user selected a file and double clicked or
pressed Enter, I wanted the following behavior (in the following
steps, "type" means nothing more than "a file whose name ends with
a particular string"):

1) If an association for that file type exists, run the associated program.

2) If an association for that file type does not exist:

a) If the file is not "executable", see if there is a "default"
   association defined and run that program if there is.

b) If the file *is* "executable", run it.


So ... all I really needed to know is whether or not the OS thinks the
file is executable.  Obvious - and this is true on most any system -
you can create the situation where the file appear executable from
the OS's point of view, but it is not actually.  But this is a pathology
that no application should really be expected to cope with...

-- 

Tim Daneliuk [EMAIL PROTECTED]
PGP Key: http://www.tundraware.com/PGP/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is there a way to push data into Ical from Python ?

2006-12-18 Thread has
dwhall wrote:

> One way would be to use
> Python's tie-ins to Applescript_ and apple events (AE).  As you will
> read, this support isn't as strong as it used to be.

What gave you that impression, if you don't mind my asking?

It's true that Python's built-in application scripting support
(aetools+gensuitemodule) has become increasingly broken on OS X and
should be avoided. Third-party support has been continually improving
over the last few years, however, and these days is pretty much on-par
with AppleScript in terms of functionality. See
 for more information and downloads.


> Another idea that would require more effort, but earn you some hacker
> points, is to use PyObjC_ and access iCal's public programming
> interface.

The CALCore framework is private in OS X 10.4, so the usual disclaimers
apply w.r.t. using that. See 
for a basic example of use. Scuttlebutt says there'll be a public iCal
framework in 10.5, although that won't help the OP right now unless
they're a paid-up ADC member.

has
-- 
http://appscript.sourceforge.net
http://rb-appscript.rubyforge.org

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


Re: Strange error with getattr() function

2006-12-18 Thread Hole

Hole ha scritto:

> Hi There!
>
> I'm trying to use Zope and the product OpenFlow.
>
> I got the following error while I was using the built-in function
> getattr() to retrieve an OpenFlow object:
>
> attribute name must be string
>
>
> Actually, I surely pass a string as attribute name to getattr()
>
> The code:
>
> #following instruction returns me the string "WorkFlowTest"
> openflow_id=container.aq_parent.id
>
> if (hasattr(container,openflow_id):
> #the interpreter enter in this block, so
> #it's sure that container has an attribute called WorkFlowTest
> openflow=getattr(container,openflow_id)
>
> At this point, I got the error: attribute name must be string
>

I'm wondering if the exception is raised in a hidden function and not
in the explicit call to getattr(). How can I view the traceback in a
script running in zope??

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


Windows Authetication vs seperate process

2006-12-18 Thread imageguy1206
I was wondering of someone could steer me in the right direction.

We have a package that we would like to "secure" so that only specific
individuals can access specific portions of the application.  Our
wxPython application will revolve around updating a central database
with information submitted from the app.  We will eventually have a web
front end fo rsome aspects of the app.

With several packages I have seen options to "Use Windows
Authentication", which seems to mean that "If the user has
authenticated and signed onto Windows, then our application will use
their windows userid and we will just focus on the the tasks within our
application the user is authorized to perform"

Does anyone have any experience using this type of authentication
scheme ?

Any related tips or suggestions ?

I have found a few wikipedia entries, but they seem to be more related
to webpages, etc.

Thanks.

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


RE: Can a Tkinter GUI check for abort script:

2006-12-18 Thread Michael Yanowitz
  Thank you (and Thanks to Hendrik). Both good ideas. I will need to do
those or something similar too.
But what I really want to know is what I need to do when pressing the "Run
Script" button, so that I
'return' to the GUI every once in a while, like every 100 milliseconds to
check if the "Abort Script"
button is pressed.
   Presently what happens is that the script takes over and all the buttons
on the GUI disappear
as the GUI is not given any cpu time to refresh or check if any activity in
the dialog.

Thanks in advance:
Michael Yanowitz
  -Original Message-
  From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of
Mohammad Tayseer
  Sent: Monday, December 18, 2006 10:40 AM
  To: python-list@python.org
  Subject: Re: Can a Tkinter GUI check for abort script:


  To view a button & hide the other, call .pack_forget() on the button you
want to hide & pack() on the button you want to show

  test3.py should contains a main() function that returns the new window. if
you press 'Abort script' button you should call new_window.destroy(),
pack_forget() the current button & pack() the 'run script' button



  __
  Do You Yahoo!?
  Tired of spam? Yahoo! Mail has the best spam protection around
  http://mail.yahoo.com
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: How to replace a comma

2006-12-18 Thread Lad

Nick Craig-Wood wrote:
> Lad <[EMAIL PROTECTED]> wrote:
> >  In a text I need to add a blank(space) after a comma but only if
> >  there was no blank(space) after the comman If there was a
> >  blank(space), no change is made.
> >
> >  I think it could be a task for regular expression but can not
> >  figure out the correct regular expression.
>
> You can do it with a zero width negative lookahead assertion, eg
>
>   >>> import re
>   >>> s="One, Two,Three,Four, File"
>   >>> re.sub(r",(?!\s)", ", ", s)
>   'One, Two, Three, Four, File'
>   >>>
>
> From the help :-
>
>   (?!...)
>   Matches if ... doesn't match next. This is a negative lookahead
>   assertion. For example, Isaac (?!Asimov) will match 'Isaac ' only if
>   it's not followed by 'Asimov'
>
> Or in a more straightforward but less efficient and accurate style -
> this matches the next character which gets added back into the string.
>
>   >>> re.sub(r",([^\s])", r", \1", s)
>   'One, Two, Three, Four, File'
>   >>>
>
> This shows a fundamental difference between the two methods
>
>   >>> t = ","
>   >>> re.sub(r",(?!\s)", ", ", t)
>   ', , , , , '
>   >>> re.sub(r",([^\s])", r", \1", t)
>   ', ,, ,,'
>   >>>
 Nick,
Thanks a lot.It works GREAT!
La.

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


Re: Over my head with descriptors

2006-12-18 Thread Sarcastic Zombie
> > Is there a reason you don't just use __init__ instead of __new__, and use
> > "self.age" and "self.weight" and so on?I was asking myself the same thing...
>
> Chris

"A lack of understanding," he answered sheepishly.

There are attributes (ie, question._qtext) that I do want to be the
same for every instance and thus don't want the extra memory overhead
of storing it anew for each instance.

Using the "instance" reference as you guys suggested, I'm now storing
the instance-specific information that the descriptors validate by
cramming it into instance._foo. Works great now!

Thanks for the additional understanding. It's a lot to wrap one's head
around at first.

-SZ

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


Re: How to replace a comma

2006-12-18 Thread Jussi Salmela
Lad kirjoitti:
> 
> Thank you for ALL for help.
> Hendrik,
> your solution works great but
> what is `_`  in
> _.replace(',',', ')
> 
> for?
When you are trying things out in the Python shell IDLE, _ is a 
shorthand way to use the last value printed by IDLE.

Thus when
s.replace(', ',',')
prints out
'hello,goodbye,boo'
_ refers to that value so the replace operation
_.replace(',',', ')

manipulates that value.

Cheers
Jussi
> Thank you
> La.
> 
>> re's are a pain.  Do this instead:
>>
> s = "hello, goodbye,boo"
> s.replace(', ',',')
>> 'hello,goodbye,boo'
> _.replace(',',', ')
>> 'hello, goodbye, boo'
>> Hope this helps - Hendrik
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Can a Tkinter GUI check for abort script:

2006-12-18 Thread Mohammad Tayseer
To view a button & hide the other, call .pack_forget() on the button you want 
to hide & pack() on the button you want to show

test3.py should contains a main() function that returns the new window. if you 
press 'Abort script' button you should call new_window.destroy(), pack_forget() 
the current button & pack() the 'run script' button



 __
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com -- 
http://mail.python.org/mailman/listinfo/python-list

Re: How to replace a comma

2006-12-18 Thread Duncan Booth
"Hendrik van Rooyen" <[EMAIL PROTECTED]> wrote:

> From: "Lad" <[EMAIL PROTECTED]> wrote:
> 
> 
>> In a text I need to
>> add a blank(space) after a comma but only if there was no blank(space)
>> after the comman
>> If there was a blank(space), no change is made.
>> 
>> I think it could be a task for regular expression but can not figure
>> out the correct regular expression.
> 
> re's are a pain.  Do this instead:
> 
 s = "hello, goodbye,boo"
 s.replace(', ',',')
> 'hello,goodbye,boo'
 _.replace(',',', ')
> 'hello, goodbye, boo'
 
> 
Personally I'd go one step further and regularise the whitespace around the 
commas completely (otherwise what if you have spaces before commas, or 
multiple spaces after them:

>>> s = "hello, goodbye ,  boo"
>>> print ', '.join(t.strip() for t in s.split(','))
hello, goodbye, boo
-- 
http://mail.python.org/mailman/listinfo/python-list


Strange error with getattr() function

2006-12-18 Thread Hole
Hi There!

I'm trying to use Zope and the product OpenFlow.

I got the following error while I was using the built-in function
getattr() to retrieve an OpenFlow object:

attribute name must be string


Actually, I surely pass a string as attribute name to getattr()

The code:

#following instruction returns me the string "WorkFlowTest"
openflow_id=container.aq_parent.id

if (hasattr(container,openflow_id):
#the interpreter enter in this block, so
#it's sure that container has an attribute called WorkFlowTest
openflow=getattr(container,openflow_id)

At this point, I got the error: attribute name must be string

The *strange* is that I get the same error even if I pass the attribute
name to the getattr() function as pure string:

getattr(container,"WorkFlowTest")

(sic!)

I'm a lot confused!
Thanks in advance.

-- 
H0le

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


Script to upload Files via http/cgi

2006-12-18 Thread Richard Konrad
Hi folks!

Does anyone know about a python-script to upload Files via http/cgi?

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


Re: Core dump revisited

2006-12-18 Thread Nick Craig-Wood
Sheldon <[EMAIL PROTECTED]> wrote:
>  gdb msgppscomp.py core.3203

Run

  gdb python

Then type

  run msgppscomp.py

at the gdb prompt.

When it crashes, type "bt" for a back trace.  This will pinpoint
exactly where it crashes.

Hopefully that will make things clearer.  If not post the output.

-- 
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to replace a comma

2006-12-18 Thread Nick Craig-Wood
Lad <[EMAIL PROTECTED]> wrote:
>  In a text I need to add a blank(space) after a comma but only if
>  there was no blank(space) after the comman If there was a
>  blank(space), no change is made.
> 
>  I think it could be a task for regular expression but can not
>  figure out the correct regular expression.

You can do it with a zero width negative lookahead assertion, eg

  >>> import re
  >>> s="One, Two,Three,Four, File"
  >>> re.sub(r",(?!\s)", ", ", s)
  'One, Two, Three, Four, File'
  >>> 

>From the help :-

  (?!...)
  Matches if ... doesn't match next. This is a negative lookahead
  assertion. For example, Isaac (?!Asimov) will match 'Isaac ' only if
  it's not followed by 'Asimov'

Or in a more straightforward but less efficient and accurate style -
this matches the next character which gets added back into the string.

  >>> re.sub(r",([^\s])", r", \1", s)
  'One, Two, Three, Four, File'
  >>> 

This shows a fundamental difference between the two methods

  >>> t = ","
  >>> re.sub(r",(?!\s)", ", ", t)
  ', , , , , '
  >>> re.sub(r",([^\s])", r", \1", t)
  ', ,, ,,'
  >>>

-- 
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to replace a comma

2006-12-18 Thread Lad


Thank you for ALL for help.
Hendrik,
your solution works great but
what is `_`  in
_.replace(',',', ')

for?
Thank you
La.

> re's are a pain.  Do this instead:
>
> >>> s = "hello, goodbye,boo"
> >>> s.replace(', ',',')
> 'hello,goodbye,boo'
> >>> _.replace(',',', ')
> 'hello, goodbye, boo'
> >>> 
> 
> Hope this helps - Hendrik

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


Re: Shed Skin - Does it break any Python assumptions?

2006-12-18 Thread Jean-Paul Calderone
On Mon, 18 Dec 2006 08:07:59 -0600, [EMAIL PROTECTED] wrote:
>I just noticed the announcement of Shed Skin 0.0.16 on Freshmeat with this
>(partial) change announcement:
>
>Changes: frozenset was added. time.sleep now works on Win32.
>
>Given Python's highly dynamic nature it's unclear to me how Shed Skin could
>know enough about the semantics of time.sleep to know whether or not it's
>broken on Win32.

Actually, this could just mean that on Windows, there is no suitable
implementation of the stdlib function time.sleep, and so attempts to
use it will result in bad behavior of some sort.

It does not necessarily mean that ShedSkin is doing anything which
might prevent the attribute `sleep' from being rebound on a module
importable as `time' to some other function which behaves differently.

Of course, what is not necessarily the case may still be the case. ;)

>This suggests that to gain speedups it probably implements
>a more static language than Python.  For example, does Shed Skin handle a
>case like this?
>
>>>> import time
>>>> time.sleep(1)
>>>> def _sleep(n):
>...   print "sleeping for", n, "seconds"
>...   time._sleep(n)
>...
>>>> time._sleep = time.sleep
>>>> time.sleep = _sleep
>>>> time.sleep(1)
>sleeping for 1 seconds
>
>What does this phrase in the announcement mean?  "... pure but implicitly
>statically typed Python ...".  Where does the static typing begin and end?
>Can one module tweak another module's attributes?  Can a class's attributes
>be modified from outside the class?  What about the attributes of a class
>instance?

From the ShedSkin README:

Do not use:
  ...
  -reflection (getattr, hasattr), eval, or other really dynamic stuff
  ...

I would say that the example you presented above falls into the "really
dynamic stuff" category. ;)

And in fact, attempting to compile a program somewhat like the one above
results in this:

[EMAIL PROTECTED]:~/Scratch/Source/shedskin-0.0.16$ make
g++ -O3  -I./lib ./lib/builtin.cpp ./lib/time.cpp foo.cpp -lgc  -o foo
foo.cpp: In function ‘int __foo__::__main()’:
foo.cpp:6: error: assignment of function ‘void __time__::sleep(double)’
foo.cpp:6: error: cannot convert ‘unsigned int ()(unsigned int)’ to ‘void 
()(double)’ in assignment
make: *** [foo] Error 1
[EMAIL PROTECTED]:~/Scratch/Source/shedskin-0.0.16$ 

So yes, it seems that what ShedSkin supports is pretty distant from what
a seasoned Python developer might expect, aside from syntactic constructs.

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

Shed Skin - Does it break any Python assumptions?

2006-12-18 Thread skip
I just noticed the announcement of Shed Skin 0.0.16 on Freshmeat with this
(partial) change announcement:

Changes: frozenset was added. time.sleep now works on Win32.

Given Python's highly dynamic nature it's unclear to me how Shed Skin could
know enough about the semantics of time.sleep to know whether or not it's
broken on Win32.  This suggests that to gain speedups it probably implements
a more static language than Python.  For example, does Shed Skin handle a
case like this?

>>> import time
>>> time.sleep(1)
>>> def _sleep(n):
...   print "sleeping for", n, "seconds"
...   time._sleep(n)
...
>>> time._sleep = time.sleep
>>> time.sleep = _sleep
>>> time.sleep(1)
sleeping for 1 seconds

What does this phrase in the announcement mean?  "... pure but implicitly
statically typed Python ...".  Where does the static typing begin and end?
Can one module tweak another module's attributes?  Can a class's attributes
be modified from outside the class?  What about the attributes of a class
instance?

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


Re: How to get a substring with variable indices

2006-12-18 Thread Станислав Ягло
Tim Chase wrotes:
>> I have a string named text. I need to extract a substring from it 
>> starting by variable 's' and ending by 'e'.
>>
>> text[s:e] generates the following error:
>>
>> TypeError: slice indices must be integers or None
>
> Your syntax is correct...the error you get back is the clue: either 
> "s" or "e" fails to meet the criteria of being "integers or None".  
> Check your values/types of those two variables before this call and 
> you'll likely find that one or both is some other data-type.
>
> >>> text="hello world"
> >>> s = 4
> >>> e = 5
> >>> text[s:e]
> 'o'
>
> Darn those error messages that give away the answer... ;)
>
> -tkc
>
>
>
>
>
Yeah, you're right! I've already found that stupid error. I've entagled 
variable names.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Can a Tkinter GUI check for abort script:

2006-12-18 Thread Hendrik van Rooyen
"Michael Yanowitz" <[EMAIL PROTECTED]> Wrote:


> Hello:
> 
>I have successfully implemented a Tkinter GUI which has
> this (simplified here for explanation):
> +-+
> |  filename: [./test3.py] |
> | |
> |  [Run Script]   |
> +-+
> 
>But, now what I would like to do while the script is
> running, is replace the "Run Script" with "Abort Script".  
> 
> +-+
> |  filename: [./test3.py] |
> | |
> |  [Abort Script] |
> +-+
> 
>So, every tenth of a seconds or ??? better time, I
> would like to 'return' to the GUI and check if the
> "Abort Script" button has been pressed.
>How do I do this? Or is there a better way to
> implement this?

Use the configure method to change the command of the button,
to point away from "run" to "abort", as the first thing done in "run".

You can change the text too to read correctly, at the same time, 
as well as the background colour to red...

- Hendrik


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


  1   2   >