Re: My python annoyances so far

2007-04-26 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Steven Howe
wrote:

> And before someone get's all technical, I know everything in Python is 
> an 'object' even None, which implies class, or is it the other way around?

Objects don't imply classes.  There are object oriented languages without
classes like the Io language.  Everything there is an object and the base
object has a `clone()` method to make a copy.  So you make copies of
objects and modify them to tweak them into the way you want them.

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


regex question

2007-04-26 Thread proctor
hello,

i have a regex:  rx_test = re.compile('/x([^x])*x/')

which is part of this test program:



import re

rx_test = re.compile('/x([^x])*x/')

s = '/xabcx/'

if rx_test.findall(s):
print rx_test.findall(s)



i expect the output to be ['abc'] however it gives me only the last
single character in the group: ['c']

C:\test>python retest.py
['c']

can anyone point out why this is occurring?  i can capture the entire
group by doing this:

rx_test = re.compile('/x([^x]+)*x/')
but why isn't the 'star' grabbing the whole group?  and why isn't each
letter 'a', 'b', and 'c' present, either individually, or as a group
(group is expected)?

any clarification is appreciated!

sincerely,
proctor

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


Re: EuroPython vs PyconUK

2007-04-26 Thread EuGeNe Van den Bulke
Michele Simionato wrote:
  > I don't see the problem. In my view EuroPython is the big event in
> Europe. If you can
> go to only one conference and you have the possibility to travel to
> Vilnius, then go to EuroPython.
> The national conferences are of interest primarily for people of that
> national (of course, not
> exclusively).

Thanks, I didn't see it that way but that was ignorance on my behalf. I 
was WRONGLY under the impression that we were in front of a classical 
European pattern named "what WE can do collectively I can do better 
alone" - known use : European constitution :P (but I am digressing :D).

> BTW, this year I will go both to PyCon It and EuroPython, last year I
> went both to
> PyUK and EuroPython. The more, the better ;)

The more the merrier indeed in that respect! I learnt a lot from your 
"Using decorators" talk last year. Thanks.

EuGeNe -- http://www.3kwa.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Socket exceptions aren't in the standard exception hierarchy (M2Crypto issue)

2007-04-26 Thread John Nagle
On a related note, M2Crypto's exceptions are direct children
of Exception.  If we add NetworkError, there will be a better
place to put them.

Currently, you have to catch, at least,

M2Crypto.SSL.Checker.SSLVerificationError
M2Crypto.SSL.SSLError

both of which can be raised by socket operations if
M2Crypto is installed.   I'm not sure what errors the
stock SSL module raises.

(I'm running stress tests on a dedicated machine in a colocation
facility.  It's examining 11,000 known spam and malware sites right
now.  This exercises the error handling, forcing many unusual cases
and logging the problems.  That's why I'm discovering all these library
issues.)

John Nagle

Steve Holden wrote:
> John Nagle wrote:
> 
>> Steve Holden wrote:
>>
>>> John Nagle wrote:
>>>
 Steve Holden wrote:

> John Nagle wrote:
> [socket.error bug report]
>>
>>
>>> All these notes should be included in the bug report, as I suspect 
>>> the module would benefit from additional clarity. 
>>
>>
>>  Done.  See
>>
>> [ 1706815 ] socket.error exceptions not subclass of StandardError
>>
>> Also see
>>
>> [ 805194 ] Inappropriate error received using socket timeout
>> [ 1019808 ] wrong socket error returned
>> [ 1571878 ] Improvements to socket module exceptions
>> [ 708927 ] socket timeouts produce wrong errors in win32
>>
>> for related but not identical problems in that area.
>>
> Thanks. At least this is less likely to be overlooked now.
> 
> regards
>  Steve
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: EuroPython vs PyconUK

2007-04-26 Thread EuGeNe Van den Bulke
Alex Martelli wrote:
> I like the kudos, thanks!, but I'm not quite sure what you're saying
> about my travel plans... just to clarify, once again I'll have to miss
> EuroPython _and_ PythonUK, two events I attended most assiduously when I
> was living in Europe (but then, for two years running I've also missed
> PyCon, _despite_ living in the US, sigh).

I was just using your possible travel plans as an example to express my 
"concerns" :P

Re your effective travel plans, thanks God for Google Video then :D

Cheers,

EuGeNe -- http://www.3kwa.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pyqt4 signal/slot using PyObject* and shortcut

2007-04-26 Thread Pradnyesh Sawant
On 4/27/07, Pradnyesh Sawant wrote:
> Hello, i have the following code:
> #
> import time
> import sys
> from PyQt4 import QtGui, QtCore
>
> class Counter(QtCore.QThread):
> def __init__(self):
> QtCore.QThread.__init__(self)
> def run(self):
> cntr = 0
> while cntr < 10:
> cntr += 1
> self.emit(QtCore.SIGNAL("showCntr1(PyObject*)"), (cntr,
> "a"))   # line 1
> self.emit(QtCore.SIGNAL("showCntr2"), (cntr, "a"))
>   # line 2
> time.sleep(0.2)
> class Gui(QtGui.QDialog):
> def __init__(self, parent = None):
> QtGui.QDialog.__init__(self, parent)
> frameStyle = QtGui.QFrame.Sunken | QtGui.QFrame.Panel
>
> self.lCntr = QtGui.QLabel()
> self.lCntr.setFrameStyle(frameStyle)
> loGrd = QtGui.QGridLayout()
> loGrd.addWidget(self.lCntr, 0, 0)
> self.setLayout(loGrd)
> self.setWindowTitle(self.tr("Counter"))
> def showCntr1(self, val):
> print val, str(val)
> self.lCntr.setText(str(val))
> def showCntr2(self, val):
> print val, str(val)
> self.lCntr.setText(str(val))
> if __name__ == "__main__":
> app = QtGui.QApplication(sys.argv)
> dialog = Gui()
> cntr = Counter()
> cntr.start()
> QtCore.QObject.connect(cntr, QtCore.SIGNAL("showCntr1(PyObject*)"),
> dialog.showCntr1, QtCore.Qt.QueuedConnection)
> QtCore.QObject.connect(cntr, QtCore.SIGNAL("showCntr2"),
> dialog.showCntr1, QtCore.Qt.QueuedConnection)
There's a small bug in the above line, it should be dialog.showCntr2,
and not dialog.showCntr1. However, even with this change, the output
shown below remains the same :(
> sys.exit(dialog.exec_())
> #
> If i comment out "line 1", then i get the following output:
> 0.2 0.2
> 0.2 0.2
> 0.2 0.2
> 0.2 0.2
> 0.2 0.2
> 0.2 0.2
> 0.2 0.2
> 0.2 0.2
> 0.2 0.2
> 0.2 0.2
> Notice that 0.2 is the time value of the sleep instruction. Why is
> this happening?
>
> On the other hand, if i comment out "line 2", then i get the following output:
> (, 'a') (, )
> (, 'a') (, )
> (, 'a') (, )
> (, 'a') (, )
> (, 'a') (, )
> (, 'a') (, )
> (, 'a') (, )
> (, 'a') (, )
> (, 'a') (, )
> (, 'a') (, )
> What i get from the above is that a reference to "cntr" is being
> passed, but by the time the gui thread is actually run, both the
> values (cntr and "a") have been destroyed, hence the NULL values.
> ***How do i circumvent this problem?***
>
> Lastly, if i don't comment out any of line 1 or 2, then i get the foll output:
> (<__main__.Gui object at 0xb6a8f12c>, (<__main__.Gui object at
> 0xb6a8f12c>, (<__main__.Gui object at 0xb6a8f12c>, (<__main__.Gui
> object at 0xb6a8f12c>, (<__main__.Gui object at 0xb6a8f12c>,
> (<__main__.Gui object at 0xb6a8f12c>, (<__main__.Gui object at
> 0xb6a8f12c>, (<__main__.Gui object at 0xb6a8f12c>, (<__main__.Gui
> object at 0xb6a8f12c>, (<__main__.Gui object at 0xb6a8f12c>,
> (<__main__.Gui object at 0xb6a8f12c>, (<__main__.Gui object at
> 0xb6a8f12c>, (<__main__.Gui object at 0xb6a8f12c>, (<__main__.Gui
> object at 0xb6a8f12c>, (<__main__.Gui object at 0xb6a8f12c>,
> (<__main__.Gui object at 0xb6a8f12c>, (<__main__.Gui object at
> 0xb6a8f12c>, (<__main__.Gui object at 0xb6a8f12c>, ..
> i don't know what this means??? Can anyone kindly explain what's happening...
>
> I'm using:
> python: 2.4.4~c1-0ubuntu1
> qt4-dev-tools: not installed
> python-qt4: 4.0.1-1ubuntu1
> sip4: (4.4.5-2ubuntu1
> os: ubuntu edgy
> --
> warm regards,
> Pradnyesh Sawant
> --
> Be yourself, everyone else is taken. --Anon
>


-- 
warm regards,
Pradnyesh Sawant
--
Be yourself, everyone else is taken. --Anon
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: webbrowser.open works in IDLE and cmd shell but not from cygwin prompt

2007-04-26 Thread Paddy
On Apr 27, 5:09 am, Gregory Bloom <[EMAIL PROTECTED]> wrote:
> I'm running Python 2.5 under Windows.  If I fire up IDLE and enter:
>
> >>> import webbrowser
> >>> url = 'http://www.python.org'
> >>> webbrowser.open_new(url)
>
> it works like a champ, opening the page in Firefox.  Same thing goes
> from a Windows cmd shell: it works as advertised.
>
> But if I open a cygwin bash shell and try the same thing from a python
> prompt, I get:
>
> >>> import webbrowser
> >>> url = 'http://www.python.org'
> >>> webbrowser.open_new(url)
>
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "C:\Python25\lib\webbrowser.py", line 60, in open_new
> return open(url, 1)
>   File "C:\Python25\lib\webbrowser.py", line 55, in open
> if browser.open(url, new, autoraise):
>   File "C:\Python25\lib\webbrowser.py", line 185, in open
> p = subprocess.Popen(cmdline, close_fds=True, preexec_fn=setsid)
>   File "C:\Python25\lib\subprocess.py", line 551, in __init__
> raise ValueError("close_fds is not supported on Windows "
> ValueError: close_fds is not supported on Windows platforms
>
> What's up with that?  And, more to the point, how can I use webbrowser
> from scripts launched under cygwin?

I have X and kde for cygwin installed.
If i use startxwin to start an xterm, without starting kde, and do
the
above in cygwins python version 2.4.3 i have to wait around 3 minutes
then up pops konqueror at the requested page.

- Paddy.

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


pyqt4 signal/slot using PyObject* and shortcut

2007-04-26 Thread Pradnyesh Sawant
Hello, i have the following code:
#
import time
import sys
from PyQt4 import QtGui, QtCore

class Counter(QtCore.QThread):
def __init__(self):
QtCore.QThread.__init__(self)
def run(self):
cntr = 0
while cntr < 10:
cntr += 1
self.emit(QtCore.SIGNAL("showCntr1(PyObject*)"), (cntr,
"a"))   # line 1
self.emit(QtCore.SIGNAL("showCntr2"), (cntr, "a"))
  # line 2
time.sleep(0.2)
class Gui(QtGui.QDialog):
def __init__(self, parent = None):
QtGui.QDialog.__init__(self, parent)
frameStyle = QtGui.QFrame.Sunken | QtGui.QFrame.Panel

self.lCntr = QtGui.QLabel()
self.lCntr.setFrameStyle(frameStyle)
loGrd = QtGui.QGridLayout()
loGrd.addWidget(self.lCntr, 0, 0)
self.setLayout(loGrd)
self.setWindowTitle(self.tr("Counter"))
def showCntr1(self, val):
print val, str(val)
self.lCntr.setText(str(val))
def showCntr2(self, val):
print val, str(val)
self.lCntr.setText(str(val))
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
dialog = Gui()
cntr = Counter()
cntr.start()
QtCore.QObject.connect(cntr, QtCore.SIGNAL("showCntr1(PyObject*)"),
dialog.showCntr1, QtCore.Qt.QueuedConnection)
QtCore.QObject.connect(cntr, QtCore.SIGNAL("showCntr2"),
dialog.showCntr1, QtCore.Qt.QueuedConnection)
sys.exit(dialog.exec_())
#
If i comment out "line 1", then i get the following output:
0.2 0.2
0.2 0.2
0.2 0.2
0.2 0.2
0.2 0.2
0.2 0.2
0.2 0.2
0.2 0.2
0.2 0.2
0.2 0.2
Notice that 0.2 is the time value of the sleep instruction. Why is
this happening?

On the other hand, if i comment out "line 2", then i get the following output:
(, 'a') (, )
(, 'a') (, )
(, 'a') (, )
(, 'a') (, )
(, 'a') (, )
(, 'a') (, )
(, 'a') (, )
(, 'a') (, )
(, 'a') (, )
(, 'a') (, )
What i get from the above is that a reference to "cntr" is being
passed, but by the time the gui thread is actually run, both the
values (cntr and "a") have been destroyed, hence the NULL values.
***How do i circumvent this problem?***

Lastly, if i don't comment out any of line 1 or 2, then i get the foll output:
(<__main__.Gui object at 0xb6a8f12c>, (<__main__.Gui object at
0xb6a8f12c>, (<__main__.Gui object at 0xb6a8f12c>, (<__main__.Gui
object at 0xb6a8f12c>, (<__main__.Gui object at 0xb6a8f12c>,
(<__main__.Gui object at 0xb6a8f12c>, (<__main__.Gui object at
0xb6a8f12c>, (<__main__.Gui object at 0xb6a8f12c>, (<__main__.Gui
object at 0xb6a8f12c>, (<__main__.Gui object at 0xb6a8f12c>,
(<__main__.Gui object at 0xb6a8f12c>, (<__main__.Gui object at
0xb6a8f12c>, (<__main__.Gui object at 0xb6a8f12c>, (<__main__.Gui
object at 0xb6a8f12c>, (<__main__.Gui object at 0xb6a8f12c>,
(<__main__.Gui object at 0xb6a8f12c>, (<__main__.Gui object at
0xb6a8f12c>, (<__main__.Gui object at 0xb6a8f12c>, ..
i don't know what this means??? Can anyone kindly explain what's happening...

I'm using:
python: 2.4.4~c1-0ubuntu1
qt4-dev-tools: not installed
python-qt4: 4.0.1-1ubuntu1
sip4: (4.4.5-2ubuntu1
os: ubuntu edgy
-- 
warm regards,
Pradnyesh Sawant
--
Be yourself, everyone else is taken. --Anon
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Generalized range

2007-04-26 Thread Alex Martelli
Michael Hoffman <[EMAIL PROTECTED]> wrote:

> [EMAIL PROTECTED] wrote:
> > Thanks - you have covered a fair bit of gorund here - I will modify
> > myRange taking your suggestions into account. The one suggestion that
> > I'm going to have to think through is repeatedly incrementing res.
> > 
> > I deliberately did not use this as repeated addition can cause
> > rounding errors to accumulate, making the loop run a little longer or
> > shorter than necessary. I thought I would be far less likely to run
> > into rounding issues with a multiplicative construct - hence my use of
> > epsilon, and my question about an appropriate value for it
> 
> You are right about rounding issues--with a sufficiently small step, the
> way I have done it, it could become an infinite loop. But you can still
> do it with multiplication, without using an epsilon constant. How about
> something like this:
> 
> index = 0
> while res < maximum:
>  yield minimum + (step * index)
>  index += 1

Absolutely (with your later correction of actually assigning res), MUCH
better than the misguided attempts based on repeatedly adding 'step'.

I've taught "numerical computing" in university, and I would have had to
fail anybody who'd misunderstood floating-point computations badly
enough to try that "+=step" idea (including, sigh, the coders of several
Fortran compilers who were popular at that time).

These days, I _heartily_ recommend "Real Computing Made Real" by Foreman
Acton -- the best programming book without one line of code in any
language (it's all formulas and graphs).  Anybody who has trouble
following it must understand they should NOT use floating point numbers
until they've gotten the prereqs (which aren't all that deep:
engineering-undergrad-level algebra and calculus, plus
 and a couple
weeks' worth of refresher courses on fundamental algorithms such as
Newton's root-finding approach and the like -- I shudder to think how
many people with CS bachelor degrees and even post-grad degrees are just
never taught these fundamentals, yet end up having to program _some_
floating point computations, mistakenly thinking they can...).


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


Re: Command-line option equiv of PYTHONPATH

2007-04-26 Thread Martin v. Löwis
> The '-I' option adds the path to the list of directories that
> contains modules that can be included in a script. I can use it as "#!/
> usr/bin/perl -I" thereby not asking the user of
> the script to set the  in their environment.
> 
> Is there any equivalent command-line option to the python binary or a
> command-line version of PYTHONPATH?

To rephrase James Stroud's remark: The equivalent to

#/usr/bin/perl -I
TEXT

is

#/usr/bin/python
import sys
sys.path.append(path_to_my_modules)
TEXT

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


Re: Support for new items in set type

2007-04-26 Thread Raymond Hettinger
[Alex Martelli]
> In your shoes, I would write a class whose instances hold three sets:
> -- the "master set" is what you originally read from the file
> -- the "added set" is the set of things you've added since then
> -- the "deleted set" is the set of things you've deleted since them

FWIW, I've posted a trial implementation in the Python cookbook:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/511496


Raymond Hettinger

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


Re: Command-line option equiv of PYTHONPATH

2007-04-26 Thread James Stroud
Rajesh wrote:
> Hi,
> 
> The '-I' option adds the path to the list of directories that
> contains modules that can be included in a script. I can use it as "#!/
> usr/bin/perl -I" thereby not asking the user of
> the script to set the  in their environment.
> 
> Is there any equivalent command-line option to the python binary or a
> command-line version of PYTHONPATH?
> 
> Regards
> Rajesh
> 

Why not just modify sys.path within the actual script?

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


Re: Python keywords

2007-04-26 Thread Alex Martelli
gtb <[EMAIL PROTECTED]> wrote:

> Have done some searching but have not found a place where I can look
> up python keywords.

>>> import keyword
>>> keyword.kwlist
['and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del',
'elif', 'else', 'except', 'exec', 'finally', 'for', 'from', 'global',
'if', 'import', 'in', 'is', 'lambda', 'not', 'or', 'pass', 'print',
'raise', 'return', 'try', 'while', 'with', 'yield']

call help(kw) from an interpreter prompt for any one of these values for
more information.  E.g.,

>>> help('and')

will give you section 5.1 (Boolean operations), all the way to
help('yield') giving 6.8 (The yield statement).  Some of the keywords
have no specific info, e.g. help('as') will not be very informative:-).


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


Re: EuroPython vs PyconUK

2007-04-26 Thread Alex Martelli
EuGeNe Van den Bulke <[EMAIL PROTECTED]> wrote:

> Alex Martelli, brilliant speaker and Python evangelist (in my Shu Ha 
> eyes anyway), lives in the States and is Italian. Busy as you'd expect
> from  someone working for Google, decides to make the trip to Europe for
> a Python related conference, henceforth spends 3 1/2 months in Europe so
> he can do Italy in June (he is listed as an organizer), Lithuania in 
> July and UK in September...

I like the kudos, thanks!, but I'm not quite sure what you're saying
about my travel plans... just to clarify, once again I'll have to miss
EuroPython _and_ PythonUK, two events I attended most assiduously when I
was living in Europe (but then, for two years running I've also missed
PyCon, _despite_ living in the US, sigh).

Besides Pycon Uno, in my short trip in early June, I hope to also visit
Cracow, and perhaps give a Python talk at the University there if my
Polish colleagues can arrange things, but that will be it.

It's not so much about working for Google, which isn't stopping e.g.
Guido from attending conferences of his choice -- it's more about my
also having accepted managerial responsibilities there, which means I
can't really do my "primary" job all that well by logging in remotely
from my laptop:-).


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


Re: mysql "rows affected"

2007-04-26 Thread Carl K
John Nagle wrote:
> Carl K wrote:
>> using MySQLdb, I do cursor.execute("update...")
>>
>> How can I tell how many rows were affected ?
>>
>> Carl K
> 
> cursor = db.cursor() # get cursor   
> cursor.execute(sqlstatement, argtuple) # do command
> rowsaffected = cursor.rowcount # get count of rows affected
> cursor.close() # close cursor
> db.commit() # commit transaction   
> 
> John Nagle   

cursor.rowcount - bingo.  Thanks a bunch.

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


Command-line option equiv of PYTHONPATH

2007-04-26 Thread Rajesh
Hi,

The '-I' option adds the path to the list of directories that
contains modules that can be included in a script. I can use it as "#!/
usr/bin/perl -I" thereby not asking the user of
the script to set the  in their environment.

Is there any equivalent command-line option to the python binary or a
command-line version of PYTHONPATH?

Regards
Rajesh

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


Re: My python annoyances so far

2007-04-26 Thread Steven D'Aprano
On Thu, 26 Apr 2007 19:36:09 -0700, Alex Martelli wrote:

> Steven D'Aprano <[EMAIL PROTECTED]> wrote:
>...
>> detail you shouldn't care about. Functions that cache the result of long
>> time-consuming complications are _good_. 
> 
> Not necessarily --

Absolutely -- I didn't mean to imply that functions should _always_ cache
their "complications" (I meant to write calculations, but obviously my
fingers weren't paying attention to my brain).


> 
> asserts the exactly opposite principle, "Don't save anything you can
> recalculate"... of course, the best approach is generally a compromise,
> but it's good to be aware of the potentially high costs of caching:-).

Yes -- I wouldn't cache anything that was cheap enough to calculate. What
cheap enough (in time or memory or other resources) means depends on the
circumstances. Nor would I cache things that were likely to change often.



-- 
Steven D'Aprano 

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


Re: EuroPython vs PyconUK

2007-04-26 Thread Michele Simionato
On Apr 26, 6:34 pm, EuGeNe Van den Bulke
<[EMAIL PROTECTED]> wrote:
> I do realize that the UK is not really part of Europe (no polemic :P)
> but I am nevertheless curious about the logic behind creating another
> major Python event in Europe. Wasn't EuroPython enough?
>
> Like many I am sure, I probably won't be able to attend both (and I
> really enjoyed the Geneva experience so definitely want to renew "it").
> How would you go about selecting which conference to attend?
>
> They are only 2 months apart, 6 would have been easier for the
> attendees! Could the organizers liaise one way or another to make
> Pythoneers life as easy and fun as the language and give as much
> information out as possible as early as possible (early bird early) for
> people to make the best decision?
>
> I know marketing matters but ...
>
> EuGeNe --http://www.3kwa.com

I don't see the problem. In my view EuroPython is the big event in
Europe. If you can
go to only one conference and you have the possibility to travel to
Vilnius, then go to EuroPython.
The national conferences are of interest primarily for people of that
national (of course, not
exclusively). I would be happy with a conference for any nationality.
Each nation will have
its national speakers. EuroPython will have all Europe to chose
speakers from.
BTW, this year I will go both to PyCon It and EuroPython, last year I
went both to
PyUK and EuroPython. The more, the better ;)



Michele Simionato

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


Re: Problem with Matplotlib and the Tk-Backend

2007-04-26 Thread James Stroud
thorstenkranz wrote:
> Hi everyone,
> 
> I'm new here and I have a question ( I guess as everybody who is new
> here ;-) ),
> 
> I'm having some strange problem with Matplotlib, using it in a Tkinter
> application.
> 
> I create a  Canvas, a figure, subplot and then a toolbar. It works
> fine, but only without the toolbar! When I want to add the toolbar, I
> get an error
> 
>  File "./tkViewer.py", line 102, in setupGUI
> self.toolbar = NavigationToolbar2TkAgg( self.canvas, master )
>   File "/usr/lib/python2.4/site-packages/matplotlib/backends/
> backend_tkagg.py", line 537, in __init__
> NavigationToolbar2.__init__(self, canvas)
>   File "/usr/lib/python2.4/site-packages/matplotlib/backend_bases.py",
> line 1107, in __init__
> self._init_toolbar()
>   File "/usr/lib/python2.4/site-packages/matplotlib/backends/
> backend_tkagg.py", line 577, in _init_toolbar
> borderwidth=2)
>   File "/usr/lib/python2.4/lib-tk/Tkinter.py", line 2378, in __init__
> Widget.__init__(self, master, 'frame', cnf, {}, extra)
>   File "/usr/lib/python2.4/lib-tk/Tkinter.py", line 1865, in __init__
> self.tk.call(
> _tkinter.TclError: bad screen distance "500.0"
> 
> Here is the part my code:
> 
> self.canvFrame = Frame(master)
> self.canvFrame.pack(side=TOP, fill=BOTH, expand=1)
> self.canvFrame2 = Frame(self.canvFrame)
> self.canvFrame2.pack(side=LEFT, fill=BOTH, expand=1)
> self.f = Figure(figsize=(5,4), dpi=100)
> self.a = self.f.add_subplot(111)
> self.subplAxis = self.f.get_axes()
> self.canvas = FigureCanvasTkAgg(self.f,
> master=self.canvFrame2)
> self.canvas.show()
> self.canvas.get_tk_widget().pack(side=TOP, fill=BOTH,
> expand=1)
> self.toolbar = NavigationToolbar2TkAgg( self.canvas,
> self.canvFrame2 )
> self.toolbar.update()
> self.canvas._tkcanvas.pack(side=TOP, fill=X, expand=1)
> 
> 
> master is a parameter passed to my method, which actually is set to
> Tk()
> 
> What did I get wrong? What is the problem? Thanks in advance...
> 
> Thorsten
>

Just prior to "self.toolbar = ...", try :

 master.winfo_toplevel().update_idletasks()

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


Re: How to find complementary colour for pixel

2007-04-26 Thread James Stroud
Johny wrote:
>  I use PIL to write some text to a picture.The text must  be seen wery
> clearly.
> I write the text to different pictures but to the same position. As 
> pictures maybe  different, colour, in the position where I write the
> text, is also different.
> Is there a way how to set the font colour so that it will be seen very
> clearly in the picture?
> For example, if the picture is bright ( for example yellow), the font
> colour should be dark( e.g. black) and vice versa.
> Is there a routine in PIL available  that calculates complementary
> colour for RGB pixel format?
> Can anyone help?
> Thanks
> L.
> 

Don't you just xor with black?
-- 
http://mail.python.org/mailman/listinfo/python-list


webbrowser.open works in IDLE and cmd shell but not from cygwin prompt

2007-04-26 Thread Gregory Bloom
I'm running Python 2.5 under Windows.  If I fire up IDLE and enter:

>>> import webbrowser
>>> url = 'http://www.python.org'
>>> webbrowser.open_new(url)

it works like a champ, opening the page in Firefox.  Same thing goes
from a Windows cmd shell: it works as advertised.

But if I open a cygwin bash shell and try the same thing from a python
prompt, I get:

>>> import webbrowser
>>> url = 'http://www.python.org'
>>> webbrowser.open_new(url)
Traceback (most recent call last):
  File "", line 1, in 
  File "C:\Python25\lib\webbrowser.py", line 60, in open_new
return open(url, 1)
  File "C:\Python25\lib\webbrowser.py", line 55, in open
if browser.open(url, new, autoraise):
  File "C:\Python25\lib\webbrowser.py", line 185, in open
p = subprocess.Popen(cmdline, close_fds=True, preexec_fn=setsid)
  File "C:\Python25\lib\subprocess.py", line 551, in __init__
raise ValueError("close_fds is not supported on Windows "
ValueError: close_fds is not supported on Windows platforms

What's up with that?  And, more to the point, how can I use webbrowser
from scripts launched under cygwin?

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


Re: File not read to end

2007-04-26 Thread bruce peng
"rb",,please






































<[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Hi,
>
> I'm trying to write a simple log parsing program. I noticed that it
> isn't reading my log file to the end.
>
> My log is around 200,000 lines but it is stopping at line 26,428. I
> checked that line and there aren't any special characters.
>
> This is the file reading code segment that I'm using:
>sysFile=open(sysFilename,'r')
>lineCount = 0
>for line in sysFile:
>lineCount +=1
>print str(lineCount) + " -- " + line
>
> I also stuck this same code bit into a test script and it was able to
> parse the entire log without problem. Very quirky.
>
> This is my first foray from Perl to Python so I appreciate any help.
>
> Thanks in advance.
>
> --Andrew
> 


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


Re: My python annoyances so far

2007-04-26 Thread 7stud
On Apr 26, 9:08 am, Michael Hoffman <[EMAIL PROTECTED]> wrote:
> 7stud wrote:
> > [EMAIL PROTECTED] wrote:
> >> Annoyances:
>
> > Every language has annoyances.  Python is no exception.  Post away.
> > Anyone that is offended can go drink a Guinness.
>
> I find Guinness annoying.
> --
> Michael Hoffman

lol.


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


Re: My python annoyances so far

2007-04-26 Thread John Nagle
Alex Martelli wrote:
> Steven D'Aprano <[EMAIL PROTECTED]> wrote:
>...
> 
>>detail you shouldn't care about. Functions that cache the result of long
>>time-consuming complications are _good_. 
> 
> 
> Not necessarily --
> 
> asserts the exactly opposite principle, "Don't save anything you can
> recalculate"... of course, the best approach is generally a compromise,
> but it's good to be aware of the potentially high costs of caching:-).
> 
> 
> Alex

 Abelson and Sussman has a better discussion of this subject.
Look under "memoization".

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


Re: I25 barcode generator?

2007-04-26 Thread Carsten Haese
On Thu, 26 Apr 2007 22:12:54 -0400, I wrote
> On Thu, 26 Apr 2007 18:39:23 -0300, Gerardo Herzig wrote
> > Hi. Im looking for an I25 barcode generator.[...]
> 
> [...]it shouldn't be too hard to make one.
> 

And it wasn't:

def i25(x):
   """i25(x) -> string

   Encode string of digits into I25 barcode.

   The input string must consist of an even number of digits.
   The output string represents the I25 barcode of the input string
   with N = narrow bar, W = wide bar, n = narrow space, w = wide space.
   """

   alphabet = (
 "NNWWN", "WNNNW", "NWNNW", "WWNNN", "NNWNW",
 "WNWNN", "NWWNN", "NNNWW", "WNNWN", "NWNWN"
   )
   if not x.isdigit():
  raise ValueError, "Input string must consist of digits."
   if len(x)%2!=0:
  raise ValueError, "Input string must be of even length."

   bars = "".join(alphabet[int(c)] for c in x[0::2])
   spaces = "".join(alphabet[int(c)] for c in x[1::2]).lower()
   interleaved = "".join(t[0]+t[1] for t in zip(bars,spaces))
   return "NnNn"+interleaved+"WnN"


Rendering the resulting string into the desired graphical format is left as an
exercise for the reader.

HTH,

Carsten.

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


Re: My python annoyances so far

2007-04-26 Thread Alex Martelli
Steven D'Aprano <[EMAIL PROTECTED]> wrote:
   ...
> detail you shouldn't care about. Functions that cache the result of long
> time-consuming complications are _good_. 

Not necessarily --

asserts the exactly opposite principle, "Don't save anything you can
recalculate"... of course, the best approach is generally a compromise,
but it's good to be aware of the potentially high costs of caching:-).


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


Re: If Dict Contains a particular key

2007-04-26 Thread Alex Martelli
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
   ...
> > > >  if 'a' in thedict:
   ...
> > > if thedict.has_key('a'):
   ...
> > Why consume twice as much time with no advantages whatever?!
> 
> Did I wander into comp.lang.perl by mistake?

Of course not -- note that the faster, modern idiom is also simpler,
more concise, _and_ more readable, _and_ also more general/polymorphic
than the tired old way that's still kept around only for backwards
compatibility.

Simplicity, terseness, readability, generality, _and_ speed, all at the
same time, as long as you use the "new" way (meaning, in this case, the
one that's been around for "only" about seven years...!!!) -- now that's
a combination of factors that's reasonably typical of Python, but not
quite so frequent in other languages!-)


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


Re: I25 barcode generator?

2007-04-26 Thread Carsten Haese
On Thu, 26 Apr 2007 18:39:23 -0300, Gerardo Herzig wrote
> Hi. Im looking for an I25 barcode generator. I found a couple of 
> nice EAN barcode generators, but this application needs an I25 
> barcode. Since this will be an web application, i need to do it in 
> the server side. In python, off course :)

What format do you want to generate? EPS, PDF, PNG?

I don't know of a readily available generator in Python, but judging from
http://www.adams1.com/pub/russadam/i25code.html, it shouldn't be too hard to
make one.

-Carsten

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


Re: mysql "rows affected"

2007-04-26 Thread John Nagle
Carl K wrote:
> using MySQLdb, I do cursor.execute("update...")
> 
> How can I tell how many rows were affected ?
> 
> Carl K

cursor = db.cursor() # get cursor   
cursor.execute(sqlstatement, argtuple) # do command
rowsaffected = cursor.rowcount # get count of rows affected
cursor.close() # close cursor
db.commit() # commit transaction

John Nagle  

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


Re: Dedicated CPU core for Python?

2007-04-26 Thread Louise Hoffman
> Are you talking about CPU affinity
> (http://en.wikipedia.org/wiki/Processor_affinity) or an actual CPU that can
> directory execute Python byte code?  If the former, CPython only uses one
> CPU core right now because it's threads are all internal, and do not spawn
> system threads (IIRC).  If the latter, I don't think that would work very
> well because then, e.g., C extensions wouldn't work very well as they could
> not be executed by a Python Byte-code CPU.

Have I understood CPU affinity correct, that it is similar to SMP/
NUMA, only that I can force a process/thread to a cpu core?

In regards to forcing the Python virtual machine (thanks Michael for
the explanation=) ), is the problem that the "OS core" and the "VM
core" would need to copy each others cache/exchange data too often?

Hugs,
Louise

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


Re: Correct behavior?

2007-04-26 Thread DanBishop04
On Apr 26, 8:34 pm, asker <[EMAIL PROTECTED]> wrote:
> Hello:
> I have next Python 2.5.1 instructions:
>
> >>> a=12.34
> >>> b=11.23
> >>> print a+b
>
> 23.57
>
> >>> print "%15.2f" % (a+b)
>
>   23.57
>
> But:>>> print "%15.2f" % a+b
>
> Traceback (most recent call last):
>   File "", line 1, in 
> TypeError: cannot concatenate 'str' and 'float' objects
>
> Is this correct for Python to issue this error?

The % operator has higher precedence than +.  Thus, "%15.2f" % a+b ==
("%15.2f" % a)+b, an illegal str+float addition.

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


Correct behavior?

2007-04-26 Thread asker
Hello:
I have next Python 2.5.1 instructions:

>>> a=12.34
>>> b=11.23
>>> print a+b
23.57

>>> print "%15.2f" % (a+b)
  23.57

But:
>>> print "%15.2f" % a+b
Traceback (most recent call last):
  File "", line 1, in 
TypeError: cannot concatenate 'str' and 'float' objects

Is this correct for Python to issue this error?

Thanks

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


Re: Atribute error

2007-04-26 Thread gtb
Thanks for posting.

CompactTest is a class provided by MaxQ and inheritance generally
works as the files below worked OK. I was trying to re-arrange things
as newLogin() should be just one of many functions called by Test1.
The way the inheritance is setup below seems like the tail wagging the
dog especially since at some point I may no longer want to run the
logon function.

Thanks again,

john

#
# File Test1.py
# Generated by MaxQ [com.bitmechanic.maxq.generator.CompactGenerator]
from newLogon import newLogon

class Test1(newLogon):
# Recorded test actions.
def runTest(self):
self.msg('Test started')

self.logon
# ^^^ Insert new recordings here.  (Do not remove this line.)


# Code to load and run the test
if __name__ == 'main':
Test1('Test1').Run()

#~~~
# File newLogon.py
# Generated by MaxQ [com.bitmechanic.maxq.generator.CompactGenerator]
from CompactTest import CompactTest

class newLogon(CompactTest):
# Recorded test actions.
def logon(self):
self.msg('Test started')


# ^^^ Insert new recordings here.  (Do not remove this line.)


# Code to load and run the test
if __name__ == 'main':
newLogon('newLogon').Run()






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


Re: My python annoyances so far

2007-04-26 Thread James Stroud
Steve Holden wrote:
> [EMAIL PROTECTED] wrote:
> 
>> Hi all. I'm learning python these days. I'm going to use this thread
>> to post, from time to time, my annoyances with python. I hope someone
>> will clarify things to me where I have misunderstood them.
>>
>> Annoyances:
>> 2. There are modules, there are functions, and there are classes-
>> methods! Wouldn't it have been easier had everything either been a
>> function or a class method?
>>
> Actually, it's really simple. When you get right down to it, 
> *everything* in *every* current implementation of Python is either a one 
> or a zero. Would you like us to make it all zeros?
> 
> Perhaps you should meditate on the idea to the concept of "sufficient 
> and necessary complexity" ...

Here is something on which to meditate: classes become functions when 
you get the quantum mechanics just so!

py> class add(object):
...   def __new__(self, a, b):
... return a + b
...
py> c = add(3, 1)
py> c
4
py> type(c)

py> add

py> def add(a, b):
...   return a + b
...
py> add(3, 1)
4
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: passing tuple with pyqt4 signal/slot mechanism

2007-04-26 Thread Pradnyesh Sawant
> In the first version it didn't. In the second version it did.
in my case, it didn't in the second version either???
> The version of PyQt? The version of SIP? The version of Qt?
python2.4:  2.4.4~c1-0ubuntu1
pyqt4:  4.0.1-1ubuntu1
python-sip4:   4.4.5-2ubuntu1
qt4:  couldn't see just "qt4" in aptitude ???
(have qt4-qtconfig installed though).
qt4-dev-tools not installed (is that needed?)
-- 
warm regards,
Pradnyesh Sawant
--
Be yourself, everyone else is taken. --Anon
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python un-plugging the Interpreter

2007-04-26 Thread cfbolz
On 25 Apr., 16:09, Steve Holden <[EMAIL PROTECTED]> wrote:
> >  Python as a language is in good shape.  But the CPython
> > implementation is holding back progress.   What we need are better
> > and faster implementations of the language we've got.
>
> Hear, hear!
>
> >  PyPy, ShedSkin, and Jython all were steps in the right
> > direction, but none had enough momentum to make it.
> > Jython hasn't had a release since 2002, ShedSkin is basically
> > one guy, and the EU pulled the plug onPyPy.
>
> Hey there, loose talk costs lives, you know. That is a complete
> mischaracterization of the true position.

Indeed!

> Progress on Jython may not have been stellar, but it has occurred and is
> ongoing. Yes, Shedskin is "one guy", but so was Psyco and that was (and
> remains) a useful tool.
>
> As far as I am aware the PyPy project has come to the end of its initial
> EU funding, and they chose to focus on producing deliverables close to
> the end of the project phase rather that divert effort into securing
> ongoing funding. So nobody has "pulled the plug", and I believe there is
> every possibility of a further round of funded research and development
>   in the future. Certainly the results to date would justify that action
> on the part of the EU. I don't know if and when the request for further
> funding will be submitted.

Indeed here too. "pulling the plug" sounds like an extremely unfair
description. There never was the plan to get funding longer than what
we got so far (at least not with additional action from our side). And
yes, there is the possibility of getting additional funding in the
future, although we are not concretely thinking about it yet.

Apart from that, work on PyPy is definitely continuing, at least after
the much needed break most PyPy-developers are currently taking to
recover from the stress of the EU project (yes, funding has its
downsides too).

Cheers,

Carl Friedrich

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


Re: mysql "rows affected"

2007-04-26 Thread Ian Clark

Both cursor.execute() and cursor.executemany() return the number of rows
affected.

Here is a link to the documentation:
http://mysql-python.sourceforge.net/MySQLdb-1.2.2/public/MySQLdb.cursors.BaseCursor-class.html#execute

Ian

On 4/26/07, Carl K <[EMAIL PROTECTED]> wrote:


using MySQLdb, I do cursor.execute("update...")

How can I tell how many rows were affected ?

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

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

Re: Python CGI and Browser timeout

2007-04-26 Thread skulka3
Thanks for the response.

To further clarify the details:

I am printing the empty strings in a for loop. So the processing
happens in a loop when all the results from the query have been
already retrieved and each record is now being processed inside the
loop.

I also update the display periodically with the total number of
records processed(which is approximately after every 1/5th chunk of
the total number of records in the result).

Thanks,
Salil Kulkarni



On Apr 26, 6:01 pm, "Sebastian Bassi" <[EMAIL PROTECTED]>
wrote:
> On 26 Apr 2007 14:48:29 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> > In order to work around this problem, I started printing empty strings
> > (i.e. print "") so that the browser does not timeout.
>
> How do you print something while doing the query and waiting for the results?
> I saw some pages that display something like: "This page will be
> updated in X seconds to show the results" (X is an estimated time
> depending of server load), after a JS countdown, it refresh itself and
> show the result or another "This page will be updated in X seconds to
> show the results".
>
> --
> Sebastián Bassi (セバスティアン)
> Diplomado en Ciencia y Tecnología.
> GPG Fingerprint: 9470 0980 620D ABFC BE63 A4A4 A3DE C97D 8422 D43D
> Club de la razón (www.clubdelarazon.org)


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

mysql "rows affected"

2007-04-26 Thread Carl K
using MySQLdb, I do cursor.execute("update...")

How can I tell how many rows were affected ?

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


Re: My python annoyances so far

2007-04-26 Thread Steven D'Aprano
On Thu, 26 Apr 2007 10:45:22 -0700, Steven Howe wrote:

> [EMAIL PROTECTED] wrote:
>>> Well, why do some things in the library have to be functions, and
>>> other things have to be class methods?
>>> 
> Perhaps because some things are more naturally function like? For 
> 'instance' (pardon the pun), functions shouldn't retain data. They 
> perform an operation, return data and quit.

Why ever not? How the function performs the operation is an implementation
detail you shouldn't care about. Functions that cache the result of long
time-consuming complications are _good_. 

You might also consider generators and iterators and co-routines. None of
those could exist if functions couldn't store data.


[snip]
> Another example are with respect to  'int' and 'float' operations. Why
> should int(x) be a class? 

That's a terrible example, because in fact int and float _are_ classes
(actually types, which are conceptually the same as classes but
implemented differently).


-- 
Steven.

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


Re: EuroPython vs PyconUK

2007-04-26 Thread EuGeNe Van den Bulke
Fuzzyman wrote:
> I assume you have the same problem with the Italian one?

Not so much because the official language of Pycon Uno Italy is Italian 
so I don't feel too concerned (unfortunately my Italian is not quite 
good enough).

> Seriously though, it is *great* to see the UK Python scene flourishing
> (and the Italian one). The more events that happen the better, and I
> don't think they need be in competition with each other... I *hope*
> the Europython guys don't see it like that.

I agree it is great to see the Python scene grow (everywhere). The AFPY 
is organizing "journees python francophones" early June too cf. 
http://journees.afpy.org/.

I have only been to one conference before so I may be under the wrong 
impressions but I don't see how the three events won't be competing for 
Ri (as in Shu Ha Ri) speakers for example. Do I sound like a groupie?

Alex Martelli, brilliant speaker and Python evangelist (in my Shu Ha 
eyes anyway), lives in the States and is Italian. Busy as you'd expect 
from  someone working for Google, decides to make the trip to Europe for 
a Python related conference, henceforth spends 3 1/2 months in Europe so 
he can do Italy in June (he is listed as an organizer), Lithuania in 
July and UK in September...

I don't know how the EuroPython guys see it.

Cheers,

EuGeNe -- http://www.3kwa.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: My python annoyances so far

2007-04-26 Thread Steven D'Aprano
On Thu, 26 Apr 2007 09:07:03 -0700, flifus wrote:

> Well, why do some things in the library have to be functions, and
> other things have to be class methods?
> 
> Why aren't they all just either functions or class methods? like
> perhaps ruby.

Perhaps you should read about the Kingdom of Nouns:

http://steve-yegge.blogspot.com/2006/03/execution-in-kingdom-of-nouns.html



-- 
Steven.

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


Re: If Dict Contains a particular key

2007-04-26 Thread [EMAIL PROTECTED]
On Apr 26, 12:47 am, [EMAIL PROTECTED] (Alex Martelli) wrote:
> [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>...
>
> > >  if 'a' in thedict:
> > >  ...
>
> > > There's no need for the call to keys().
>
> > Why not
>
> > if thedict.has_key('a'):
> > pass
> > elde:
> > pass
>
> has_key exists only for backwards compatibility; the 'in' operator is
> preferable.
>
> $ python -mtimeit -s'd={}' 'd.has_key(23)'
> 100 loops, best of 3: 0.289 usec per loop
> $ python -mtimeit -s'd={}' '23 in d'  
> 1000 loops, best of 3: 0.139 usec per loop
>
> Why consume twice as much time with no advantages whatever?!

Did I wander into comp.lang.perl by mistake?

>
> Alex


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


statistical functions for Date/Time data series

2007-04-26 Thread John Henry
I am looking for a simple Python function for handling a set of time
series data.  For instance, I might have the following raw data
(year's worth):

1/1/200512:00 AM11.24
1/1/200512:10 AM12.31
1/1/200512:20 AM12.06
1/1/200512:30 AM11.61
1/1/200512:40 AM11.12
1/1/200512:50 AM11.74
1/1/20051:00 AM  12.59
1/1/20051:10 AM  11.46
1/1/20051:20 AM 12.51
1/1/20051:30 AM 12.78
1/1/20051:40 AM 12.43
1/1/20051:50 AM 11.87
1/1/20052:00 AM 12.42
1/1/20052:10 AM 12.11
1/1/20052:20 AM 12.11
1/1/20052:30 AM 10.06
1/1/20052:40 AM 10.44
1/1/20052:50 AM 10.19
1/1/20053:00 AM 10.34
1/1/20053:10 AM 10.28
1/1/20053:20 AM 9.88
1/1/20053:30 AM 9.85
.

and I want to know, for instance, what's the average value between
1:00AM and 2:00AM everyday for winter months, or average value every
15 minutes.

Does anybody know if there is a package that can do rudimentary time-
series statistical analysis before I roll my own?

Thanks,

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


Re: Python CGI and Browser timeout

2007-04-26 Thread Sebastian Bassi
On 26 Apr 2007 14:48:29 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Is there a better solution to avoid browser timeouts?

Raising timeout in Apache, by default is 300 seconds.
Limiting jobs size (both in the html form and from script size since
you should not trust on client validations).

-- 
Sebastián Bassi (セバスティアン)
Diplomado en Ciencia y Tecnología.
GPG Fingerprint: 9470 0980 620D ABFC BE63 A4A4 A3DE C97D 8422 D43D
Club de la razón (www.clubdelarazon.org)
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: EuroPython vs PyconUK

2007-04-26 Thread EuGeNe Van den Bulke
Steve Holden wrote:
  > So by this reasoning there should have been no "Python UK" conference
> for the last four years (in case you didn't know it ran as a track of 
> the C/C++ conference, but ths track has now broadened to include all 
> scripting languages). And what about the people who can't get the time 
> and/or money to attend EuroPython?

I am afraid there is a misunderstanding. I have no problem with PyCon UK 
but would like to have elements to help me choose (the official language 
of PyCon Uno Italy is Italian so that fixes it :P).

> Diversity is good, so it isn't one vs. the other. And the UK really *is* 
> part of Europe (no matter how its politicians behave) :P

I agree that diversity is good (you won't hear me say that there are too 
many web frameworks in Python :D) but isn't dilution a danger?

If Guido was a rock star and I was a groupie, I would want to know which 
festival to attend to see him on stage. I guess there is always Google 
Video ;)

More seriously in Geneva there were people from all over the place, 
speakers and attendees, which is one of the reason why such conferences 
are interesting (or am I deluded?). It is harder for someone from 
Australia to come twice to Europe in the space of 2 months than for a 
pythoneer lambda to spend a couple of days studying another web 
framework to see if it fits how his brain works and the problem he's got 
to solve.

Looking at the reactions to my post, I must be wrong. I didn't mean to 
offend anyone if I did. I'll go to Vilnius because I have never seen the 
city and try to go to Birmingham if the program looks interesting (not 
very rational or is it?).

Cheers,

EuGeNe -- http://www.3kwa.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python CGI and Browser timeout

2007-04-26 Thread Sebastian Bassi
On 26 Apr 2007 14:48:29 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> In order to work around this problem, I started printing empty strings
> (i.e. print "") so that the browser does not timeout.

How do you print something while doing the query and waiting for the results?
I saw some pages that display something like: "This page will be
updated in X seconds to show the results" (X is an estimated time
depending of server load), after a JS countdown, it refresh itself and
show the result or another "This page will be updated in X seconds to
show the results".



-- 
Sebastián Bassi (セバスティアン)
Diplomado en Ciencia y Tecnología.
GPG Fingerprint: 9470 0980 620D ABFC BE63 A4A4 A3DE C97D 8422 D43D
Club de la razón (www.clubdelarazon.org)
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Feedback on Until recipe

2007-04-26 Thread MRAB
On Apr 26, 11:58 am, Antoon Pardon <[EMAIL PROTECTED]> wrote:
> On 2007-04-24, Thomas Nelson <[EMAIL PROTECTED]> wrote:
>
> > Occasionally someone posts to this group complaining about the lack of
> > "repeat ... until" in python.  I too have occasionally wished for such
> > a construct, and after some thinking, I came up with the class below.
> > I'm hoping to get some feedback here, and if people besides me think
> > they might use it someday, I can put it on the python cookbook.  I'm
> > pretty happy with it, the only ugly thing is you have to use a
> > lambda.  Ideally i'd like to just see
> > while Until(i<3)
> > but that doesn't work.
> > Please tell me what you think, and thanks for your time.
>
> Maybe we should try to get the developers revive PEP 315.
>
> This PEP whould introduce a do-while statement that looks
> like the folowing:
>
>   do
> statements
>   while condition
> statements
>
> this would be equivallent to:
>
>   while 1:
> statements
> if not condition:
>   break
> statements
>
> Those wanting something like:
>
>   repeat
> statements
>   until condition
>
> Could then write something like:
>
>   do
> statements
>   while not condition
> pass
>
> Still not the most elegant but a vast improvement IMO.
>
At http://mail.python.org/pipermail/python-dev/2006-February/060718.html
Raymond Hettinger suggested removing the final colon after the 'while'
if there's no statement after it, which I agree with, although I would
prefer 'repeat' instead of 'do' (IMHO that doesn't suggest repetition
clearly enough):

repeat:
statements
while condition:
statements

and:

repeat:
statements
while condition

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


Re: Python CGI and Browser timeout

2007-04-26 Thread Gabriel Genellina
En Thu, 26 Apr 2007 18:48:29 -0300, <[EMAIL PROTECTED]> escribió:

> I am creating a simple cgi script which needs to retrieve and process
> a huge number of records from the database (more than 11,000) and
> write the results to a file on disk  and display some results when
> processing is complete.
>
> However, nothing needs to be displayed while the processing is on. I
> was facing browser timeout issue due to the time it takes to process
> these records.
>
> In order to work around this problem, I started printing empty strings
> (i.e. print "") so that the browser does not timeout.
>
> Is there a better solution to avoid browser timeouts?

You could spawn another process or thread, reporting the progress  
somewhere.
Then redirect to another page showing the progress (and auto-reloading  
itself each few seconds).
When it detects that processing is complete, redirect to another page  
showing the final results.

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


Re: Atribute error

2007-04-26 Thread Bjoern Schliessmann
gtb wrote:
> In file Test1.py below I get a attribute error on the line
> "self.logon()". 

Seems like the class doesn't have this attribute. 

> It worked earlier when Test1 was derived from 
> class newLogon but that does not seem logical to me. 

What's the definition of CompactTest?

Regards,


Björn

-- 
BOFH excuse #143:

had to use hammer to free stuck disk drive heads.

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


I25 barcode generator?

2007-04-26 Thread Gerardo Herzig
Hi. Im looking for an I25 barcode generator. I found a couple of nice 
EAN barcode generators, but this application needs an I25 barcode. Since 
this will be an web application, i need to do it in the server side. In 
python, off course :)

Anybody knows one?

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


Re: Python keywords

2007-04-26 Thread gtb
On Apr 26, 1:59 pm, "Hamilton, William " <[EMAIL PROTECTED]> wrote:
> > -Original Message-
> > From: [EMAIL PROTECTED]
> [mailto:python-
> > [EMAIL PROTECTED] On Behalf Of gtb
> > Sent: Thursday, April 26, 2007 1:50 PM
> > To: [EMAIL PROTECTED]
> > Subject: Re: Python keywords
>
> > On Apr 26, 10:16 am, Larry Bates <[EMAIL PROTECTED]> wrote:
> > >http://docs.python.org/ref/keywords.html
>
> > > in keyword is a general one and can be used for many objects.
>
> > > x in 'xyz'
>
> > > y in ['a','b','c','y','z'']
>
> > > z in ('a','b','c','y','z']
>
> > > key in {'key1':1, 'key2': 2}
>
> > > The in you see with a for isn't associated with the for loop
> > > but rather the sequence you are iterating over
>
> > > for i in range(10):
>
> > > -Larry
>
> > Thanks Larry. I saw that page you referenced above and that is how I
> > knew it was a keyword. But I still have found nodocumentation that
> > supports the examples you provided.
>
> http://docs.python.org/ref/comparisons.html#l2h-438
>
> This information is 2 clicks away from any page in the reference:  click
> the index link, then scroll down to the link to "in operator".
>
> ---
> -Bill Hamilton

Thanks, Bill.

I clicked there before and decided I must be experiencing an indexing
error or such due to using firefox instead of IE when I didn't see "in
operator" at the top of the page.

Best Regards,

john

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


Re: Dedicated CPU core for Python?

2007-04-26 Thread Gabriel Genellina
En Thu, 26 Apr 2007 15:54:38 -0300, Joshua J. Kugler  
<[EMAIL PROTECTED]> escribió:

> Are you talking about CPU affinity
> (http://en.wikipedia.org/wiki/Processor_affinity) or an actual CPU that  
> can directory execute Python byte code?  If the former, CPython only  
> uses one
> CPU core right now because it's threads are all internal, and do not  
> spawn system threads (IIRC).

Python threads are OS threads:
http://docs.python.org/lib/module-thread.html
"[The thread module] is supported on Windows, Linux, SGI IRIX, Solaris  
2.x, as well as on systems that have a POSIX thread (a.k.a. ``pthread'')  
implementation."

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


Re: My python annoyances so far

2007-04-26 Thread Paul McGuire
More samples from that thread:

fica = Percent(7)
fedtax = Percent(15)
medicare = Percent(3)
deductions = fica + fedtax + medicare
gross = 10
net = gross - deductions
print net # answer: 75000

wholesale = 10
markup = Percent(35)
retail = wholesale + markup
print retail # answer: 13.5

yearlyApprec = Percent(8)
basis = 1
newbasis = basis + yearlyApprec + yearlyApprec + yearlyApprec
print newbasis # answer: 12597.12

-- Paul

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


Python CGI and Browser timeout

2007-04-26 Thread skulka3
Hello,

I am creating a simple cgi script which needs to retrieve and process
a huge number of records from the database (more than 11,000) and
write the results to a file on disk  and display some results when
processing is complete.

However, nothing needs to be displayed while the processing is on. I
was facing browser timeout issue due to the time it takes to process
these records.

In order to work around this problem, I started printing empty strings
(i.e. print "") so that the browser does not timeout.

Is there a better solution to avoid browser timeouts?

Thanks,

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


Re: My python annoyances so far

2007-04-26 Thread Paul McGuire
On Apr 26, 1:22 pm, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote:
> On 26 Apr 2007 20:05:45 +0200, Neil Cerutti <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> >On 2007-04-26, Steven Howe <[EMAIL PROTECTED]> wrote:
> >> [EMAIL PROTECTED] wrote:
>  Well, why do some things in the library have to be functions,
>  and other things have to be class methods?
>
> >> Perhaps because some things are more naturally function like?
> >> For 'instance' (pardon the pun), functions shouldn't retain
> >> data. They perform an operation, return data and quit. While
> >> retaining data is a feature of an class/instance.
>
> >Functions do retain data. Classes and instances are just a
> >convenient notation. ;)
>
> > [snip]
>
> >Python's scoping rules make certain kinds of functional idioms
> >hard to use, though. I'm not sure how to get the following to
> >work in Python using functions:
>
>  def account(s):
> >...   b = s
> >...   def add(a):
> >... b += a
> >...   def balance():
> >... return b
> >...   return add, balance
> >...
>  add, balance = account(100)
>  balance()
> >100
>  add(5)
> >Traceback (most recent call last):
> >  File "", line 1, in ?
> >  File "", line 4, in add
> >UnboundLocalError: local variable 'b' referenced before assignment
>
> >Anyhow, it doesn't work, but you can see how closely it resembles
> >a class definition.
>
> Use the outfix closure operator, []:
>
> >>> def account(s):
> ... b = [s]
> ... def add(a):
> ... b[0] += a
> ... def balance():
> ... return b[0]
> ... return add, balance
> ...
> >>> add, balance = account(100)
> >>> add(5)
> >>> balance()
> 105
> >>>
>
> ;)
>
> Jean-Paul- Hide quoted text -
>
> - Show quoted text -

Check out the Percent class I posted at
http://www.programmingforums.org/forum/f43-python/t12461-arithmetic-by-percentage.html#post123290.
It allows you to write code like:

discount = Percent(20)
origprice = 35.00
saleprice = origprice - discount

-- Paul


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


Re: EuroPython vs PyconUK

2007-04-26 Thread Donald 'Paddy' McCarthy
EuGeNe Van den Bulke wrote:
> I do realize that the UK is not really part of Europe (no polemic :P) 
> but I am nevertheless curious about the logic behind creating another 
> major Python event in Europe. Wasn't EuroPython enough?
> 
> Like many I am sure, I probably won't be able to attend both (and I 
> really enjoyed the Geneva experience so definitely want to renew "it"). 
> How would you go about selecting which conference to attend?
> 
> They are only 2 months apart, 6 would have been easier for the 
> attendees! Could the organizers liaise one way or another to make 
> Pythoneers life as easy and fun as the language and give as much 
> information out as possible as early as possible (early bird early) for 
> people to make the best decision?
> 
> I know marketing matters but ...
> 
> EuGeNe -- http://www.3kwa.com

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


Re: override settrace

2007-04-26 Thread Raja
On Apr 25, 8:10 pm, Steve Holden <[EMAIL PROTECTED]> wrote:
> Raja wrote:
> > Hi,
> >   I want to override the sys.settrace() call, create a way to trace
> > the execution of a python program. Keep track of all objects created
> > and destroyed. Keep track of the call pattern throughout the execution
> > of the program and output a simplified "call graph" to standard out.
> > Please help me in this regard.
>
> > Thank You,
>
> How many times do you intend to post this question before waiting
> patiently for an answer?
>
> regards
>   Steve
> --
> Steve Holden   +1 571 484 6266   +1 800 494 3119
> Holden Web LLC/Ltd  http://www.holdenweb.com
> Skype: holdenwebhttp://del.icio.us/steve.holden
> Recent Ramblings  http://holdenweb.blogspot.com

Hi,
  I am sorry for the number of posts but there has been a problem
while I submitted and the post didnt appear for almost an hour after
my 1st post so I reposted it.


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


Re: urlopen

2007-04-26 Thread kyosohma
On Apr 26, 12:39 pm, "Dave Dean" <[EMAIL PROTECTED]> wrote:
> Hi all,
>   I'm running into some trouble using urllib.urlopen to grab a page from our
> corporate intranet.  The name of the internal site is simplyhttp://web(no
> www or com).  I can use urlopen to grab a site likehttp://www.google.com
> just fine.  However, when I use urlopen to grab the internal site, I instead
> get data fromhttp://www.web.com.  This is the url returned by the geturl()
> function.
>   There must be a way to stop Python, or whoever is doing it, from changing
> my url.  Maybe urllib is not the correct approach.  Does anyone know a
> solution to this?
> Thanks,
> Dave

Dunno for sure, but maybe you should be using urllib2. Good info on
the module can be found here: 
http://www.voidspace.org.uk/python/articles/urllib2.shtml#fetching-urls

I suppose you could also edit your hosts file too.

Mike

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


Re: Store variable name in another variable

2007-04-26 Thread Laurent Pointal
Cameron Laird wrote:

> In article <[EMAIL PROTECTED]>,
> Laurent Pointal  <[EMAIL PROTECTED]> wrote:
>>loial a �crit :
>>> I need to store a list of variable names in a dictionary or list. I
>>> then later need to retrieve the names of the variables and get the
>>> values from the named variables. The named variables will already have
>>> been created and given a value.
>>
>>"Named variables will already have been created"... in what namespace ?
>>
>>Store a list of names -> dict/list (see tutorial)
>>
>>Then,
>>use namespace.name
>>or  getattr(namespace,"name")
>>or  locals()["name"]
>>or  globals()["name"]
>>
>>
> 
> admin, I want to be sure you understand the advice you've been given.
> Yes, it is possible to "double dereference" through named variables;
> HOWEVER, it is essentially *never* advantageous to do so in application
> programming with Python (nor is it in Perl and PHP, despite what many
> senior people there teach).  Use a dictionary, perhaps one with
> multi-dimensional keys.

Yes, I understand. I just reply to OP question not searching the reason why
he wants to manage *variables* this way (he talk about dict, so I hope he
know that they can be used to map names to values). 
So, this is not an advice, just technical ways related to the question as it
was written.

And yes, personnally i use dictionnaries for such purpose.

A+

Laurent.

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

Re: Dedicated CPU core for Python?

2007-04-26 Thread John Nagle
Michael Hoffman wrote:
> Louise Hoffman wrote:
> 
>> I was wondering, if Python in the foerseeable future will allocate one
>> CPU core just for the interpreter, so heavy Python operations does
>> slow down the OS?
> 
> 
> When running scripts, or loading modules, Python does not really behave 
> as an interpreter. Instead it compiles the human-readable code to a 
> bytecode which it then runs on a virtual machine.

 That's how interpreters have worked since UCSD Pascal, circa 1977.
Very few direct source interpreters, where the source is reprocessed
each time a line is executed, are still used.  The original IBM PC
had one of those in ROM.  Everbody grinds the code down to some kind
of tree representation, and usually represents the tree as a string
of operations for a stack machine.  Then a little intepreter runs
the stack machine.  This is typically 10-100x slower than executing
code compiled to the real machine.

 I saw a true source interpreter in a Galil industrial
motor controller as recently as 2004, but that's one of the few
remaining uses for that obsolete technology.  When the documentation
says that comments take time to execute, you've found one of those
antiques.

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


Atribute error

2007-04-26 Thread gtb


In file Test1.py below I get a attribute error on the line
"self.logon()". It worked earlier when Test1 was derived from class
newLogon but that does not seem logical to me. Any suggestions?

Thanks,

john

#~~~
#File Test1.py

# Generated by MaxQ [com.bitmechanic.maxq.generator.CompactGenerator]
#Test1.py

from CompactTest import CompactTest
from newLogon import newLogon

class Test1(CompactTest):
# Recorded test actions.
def runTest(self):
self.msg('Test started')

self.logon()

# ^^^ Insert new recordings here.  (Do not remove this line.)


# Code to load and run the test
if __name__ == 'main':
Test1('Test1').Run()


#

#File newLogon.py
# Generated by MaxQ [com.bitmechanic.maxq.generator.CompactGenerator]
from CompactTest import CompactTest

class newLogon(CompactTest):
# Recorded test actions.
def logon(self):
self.msg('Test started')


# ^^^ Insert new recordings here.  (Do not remove this line.)


# Code to load and run the test
if __name__ == 'main':
newLogon('newLogon').Run()

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


Re: My python annoyances so far

2007-04-26 Thread Bjoern Schliessmann
[EMAIL PROTECTED] wrote:

> Hi. You wrote c++, didn't you?

Yes :) But I mostly don't anymore and ported my main project from
C++ to Python.

> Well, why do some things in the library have to be functions, and
> other things have to be class methods?

Easy. Some things abstractly operate on all kind of stuff
(called "overloaded" in other languages), while others are,
regarding their function, tied to a specific class.

> Why aren't they all just either functions or class methods? 

Easy. Not all code in Python operates on a class. But that's what
Python's class methods are for. Only.

> like perhaps ruby.

If I were rude, I would ask now why you don't use ruby. But I bet
ruby has some annoyances ready for you too.

Regards,


Björn

-- 
BOFH excuse #290:

The CPU has shifted, and become decentralized.

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


Re: Python keywords

2007-04-26 Thread gtb

Thanks Marc.

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


Re: My python annoyances so far

2007-04-26 Thread Fuzzyman
On Apr 25, 11:50 pm, [EMAIL PROTECTED] wrote:
> Hi all. I'm learning python these days. I'm going to use this thread
> to post, from time to time, my annoyances with python. I hope someone
> will clarify things to me where I have misunderstood them.
>
> Annoyances:
>
> 1. Underscores! What's the deal with that? Especially those double
> underscores. The best answer I read on this is that the double
> underscores denotes special methods that the interpreter may
> automatically use. For example, 4+4 get expanded by the interpreter to
> 4.__add__(4).
>

I can understand this one. I don't have a problem with this myself,
but a lot of people find the proliferation of underscores in Python
bewildering. All I can say about it is that you soon get used to it -
and the separation is a good enough reason for me.

Fuzzyman
http://www.voidspace.org.uk/ironpython/index.shtml

> 2. There are modules, there are functions, and there are classes-
> methods! Wouldn't it have been easier had everything either been a
> function or a class method?


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


Re: My python annoyances so far

2007-04-26 Thread Kay Schluehr
On Apr 26, 6:07 pm, [EMAIL PROTECTED] wrote:

> Well, why do some things in the library have to be functions, and
> other things have to be class methods?
>
> Why aren't they all just either functions or class methods? like
> perhaps ruby.

A good question. Part of the answer might be that their are no
abstract base classes / interfaces in the language so far. These have
a particular meaning and you might ask whether some object has certain
abilities like being "sizable". With ABCs or interfaces it feels
natural to implement abstract methods in subclasses. Without them you
can either add methods ad hoc, without any conceptual background and
consistency requirements of your model, or you are going to implement
interface constraints in terms of so called "protocols". A protocol is
a sequence of actions which require interfaces to be present ( they
are abstract algorihms / command patterns ). Special functions
( __add__, __len__, etc. ) are the mediators of protocols. For
instance the meaning of len() can be understood in terms of protocols:

def len(obj):
  return obj.__len__()

Other protocols are more implicit e.g. those that couple operators to
method calls. You already mentioned special methods for arithmetic
operations. I sometimes like to think that Python is a language
developed around protocols, and they have a strong backing in the
language. With Py3K Python will become a bit more Java like, at least
with regard to the supported language constructs.

Kay

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


Re: Parsing HTML/XML documents

2007-04-26 Thread Max M
Stefan Behnel skrev:
> [EMAIL PROTECTED] wrote:
>> I need to parse real world HTML/XML documents and I found two nice python
>> solution: BeautifulSoup and Tidy.
> 
> There's also lxml, in case you want a real XML tool.
> http://codespeak.net/lxml/
> http://codespeak.net/lxml/dev/parsing.html#parsers

I have used both BeautiullSoup and lxml. They are both good tools.

lxml is blindingly fast compared to BeautifulSoup though.

A simple tool for importing contact information from 6000 xml files of 
23 MBytes into Zope runs in about 30 seconds. No optimisations at all. 
Just inefficient xpath expressions.

That is pretty good in my book.

-- 

hilsen/regards Max M, Denmark

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


Re: EuroPython vs PyconUK

2007-04-26 Thread Fuzzyman
On Apr 26, 5:34 pm, EuGeNe Van den Bulke
<[EMAIL PROTECTED]> wrote:
> I do realize that the UK is not really part of Europe (no polemic :P)
> but I am nevertheless curious about the logic behind creating another
> major Python event in Europe. Wasn't EuroPython enough?
>
> Like many I am sure, I probably won't be able to attend both (and I
> really enjoyed the Geneva experience so definitely want to renew "it").
> How would you go about selecting which conference to attend?
>

I assume you have the same problem with the Italian one?

Seriously though, it is *great* to see the UK Python scene flourishing
(and the Italian one). The more events that happen the better, and I
don't think they need be in competition with each other... I *hope*
the Europython guys don't see it like that.

Fuzzyman
http://www.voidspace.org.uk/ironpython/index.shtml

> They are only 2 months apart, 6 would have been easier for the
> attendees! Could the organizers liaise one way or another to make
> Pythoneers life as easy and fun as the language and give as much
> information out as possible as early as possible (early bird early) for
> people to make the best decision?
>
> I know marketing matters but ...
>
> EuGeNe --http://www.3kwa.com


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


Re: Generalized range

2007-04-26 Thread Michael Hoffman
Michael Hoffman wrote:
 > How about something like this:
> 
> index = 0
> while res < maximum:
> yield minimum + (step * index)
> index += 1

Well it really would have to be something LIKE that since I never 
defined res. Let's try that again:

index = 0
res = minimum
while res < maximum:
 yield res
 res = minimum + (step * index)
 index += 1
-- 
Michael Hoffman
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: My python annoyances so far

2007-04-26 Thread Kay Schluehr
On Apr 26, 6:07 pm, [EMAIL PROTECTED] wrote:

> Well, why do some things in the library have to be functions, and
> other things have to be class methods?
>
> Why aren't they all just either functions or class methods? like
> perhaps ruby.

A good question. Part of the answer might be that their are no
abstract base classes / interfaces in the language so far. These have
a particular meaning and you might ask whether some object has certain
abilities like being "sizable". With ABCs or interfaces it feels
natural to implement abstract methods in subclasses. Without them you
can either add methods ad hoc, without any conceptual background and
consistency requirements of your model, or you are going to implement
interface constraints in terms of so called "protocols". A protocol is
a sequence of actions which require interfaces to be present ( they
are abstract algorihms / command patterns ). Special functions
( __add__, __len__, etc. ) are the mediators of protocols. For
instance the meaning of len() can be understood in terms of protocols:

def len(obj):
  return obj.__len__()

Other protocols are more implicit e.g. those that couple operators to
method calls. You already mentioned special methods for arithmetic
operations. I sometimes like to think that Python is a language
developed around protocols, and they have a strong backing in the
language. With Py3K Python will become a bit more Java like, at least
with regard to the supported language constructs.

Kay

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


Re: Generalized range

2007-04-26 Thread Michael Hoffman
[EMAIL PROTECTED] wrote:
> Thanks - you have covered a fair bit of gorund here - I will modify
> myRange taking your suggestions into account. The one suggestion that
> I'm going to have to think through is repeatedly incrementing res.
> 
> I deliberately did not use this as repeated addition can cause
> rounding errors to accumulate, making the loop run a little longer or
> shorter than necessary. I thought I would be far less likely to run
> into rounding issues with a multiplicative construct - hence my use of
> epsilon, and my question about an appropriate value for it

You are right about rounding issues--with a sufficiently small step, the 
way I have done it, it could become an infinite loop. But you can still 
do it with multiplication, without using an epsilon constant. How about 
something like this:

index = 0
while res < maximum:
 yield minimum + (step * index)
 index += 1
-- 
Michael Hoffman
-- 
http://mail.python.org/mailman/listinfo/python-list


http pipelining

2007-04-26 Thread swq22
Which python module is capable of  pipelining http requests?

(I know httplib can send mulitple requests per tcp connection, but in
a strictly serial way. )


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


Re: Generalized range

2007-04-26 Thread tkpmep
Thanks - you have covered a fair bit of gorund here - I will modify
myRange taking your suggestions into account. The one suggestion that
I'm going to have to think through is repeatedly incrementing res.

I deliberately did not use this as repeated addition can cause
rounding errors to accumulate, making the loop run a little longer or
shorter than necessary. I thought I would be far less likely to run
into rounding issues with a multiplicative construct - hence my use of
epsilon, and my question about an appropriate value for it

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


Re: File not read to end

2007-04-26 Thread andrew . jefferies
On Apr 26, 9:48 am, Facundo Batista <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > I've attached the whole script. Thanks again for your help.
>
> > --Andrew
>
> Andrew, tip:
>
> If you attach the whole script, what you get is that a lot of people
> goes away from the thread. Me for example. I won't read 100 lines of
> code to see where is the problem, and then try to solve.
>
> The best way to handle this, and effectively getting more help from the
> community, is start to trim your code. So, you take those 20 lines away,
> and the problem persist. You cut off another 15, and the problem
> persist.
>
> After ten minutes of work, you get a 15 lines code, which still shows
> your problem. You send that to the community, and surely you'll get more
> help.
>
> As a fantastic side effect of that process, normally you actually *find*
> the problem by yourself, which is always better, :)
>
> Regards,
>
> --
> .   Facundo
> .
> Blog:http://www.taniquetil.com.ar/plog/
> PyAr:http://www.python.org/ar/

Thanks for the input Facundo. I'm not a frequent poster so I'm not up
on the etiquette and do appreciate the feedback. I'll better control
code spews in future posts!


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


Re: SPE

2007-04-26 Thread Glich
After posting this message I realized the stupid mistake I had made!
But it was too late to change! I think patching it with py2exe would
be a good idea.

Greetings also,
Glich

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


RE: Python keywords

2007-04-26 Thread Hamilton, William
> -Original Message-
> From: [EMAIL PROTECTED]
[mailto:python-
> [EMAIL PROTECTED] On Behalf Of gtb
> Sent: Thursday, April 26, 2007 1:50 PM
> To: python-list@python.org
> Subject: Re: Python keywords
> 
> On Apr 26, 10:16 am, Larry Bates <[EMAIL PROTECTED]> wrote:
> > http://docs.python.org/ref/keywords.html
> >
> > in keyword is a general one and can be used for many objects.
> >
> > x in 'xyz'
> >
> > y in ['a','b','c','y','z'']
> >
> > z in ('a','b','c','y','z']
> >
> > key in {'key1':1, 'key2': 2}
> >
> > The in you see with a for isn't associated with the for loop
> > but rather the sequence you are iterating over
> >
> > for i in range(10):
> >
> > -Larry
> 
> Thanks Larry. I saw that page you referenced above and that is how I
> knew it was a keyword. But I still have found nodocumentation that
> supports the examples you provided.

http://docs.python.org/ref/comparisons.html#l2h-438

This information is 2 clicks away from any page in the reference:  click
the index link, then scroll down to the link to "in operator".


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


Re: Dedicated CPU core for Python?

2007-04-26 Thread Joshua J. Kugler
On Thursday 26 April 2007 09:16, Louise Hoffman wrote:

> Dear readers,
> 
> I was wondering, if Python in the foerseeable future will allocate one
> CPU core just for the interpreter, so heavy Python operations does
> slow down the OS?
> 
> It seams to me like a perfect use for a CPU core =)

Are you talking about CPU affinity
(http://en.wikipedia.org/wiki/Processor_affinity) or an actual CPU that can
directory execute Python byte code?  If the former, CPython only uses one
CPU core right now because it's threads are all internal, and do not spawn
system threads (IIRC).  If the latter, I don't think that would work very
well because then, e.g., C extensions wouldn't work very well as they could
not be executed by a Python Byte-code CPU.

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

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

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

Re: Python keywords

2007-04-26 Thread gtb
On Apr 26, 10:16 am, Larry Bates <[EMAIL PROTECTED]> wrote:
> gtb wrote:
> > Have done some searching but have not found a place where I can look
> > up python keywords. I was looking at a script that contained the
> > following line:
>
> > assert self.getResponseCode() in (200, 304, 302)
>
> > I can infer the usage here but previously I had thought that "in" was
> > only used with '"for". I looked thru 'the Python Reference Manual and
> > found "in" is a keyword but in skimming thru I found it only with
> > "for". The reference manual seems good but seems not to be setup for
> > searching. Or maybe I just missed something.
>
> > Thanks,
>
> > gtb
>
> http://docs.python.org/ref/keywords.html
>
> in keyword is a general one and can be used for many objects.
>
> x in 'xyz'
>
> y in ['a','b','c','y','z'']
>
> z in ('a','b','c','y','z']
>
> key in {'key1':1, 'key2': 2}
>
> The in you see with a for isn't associated with the for loop
> but rather the sequence you are iterating over
>
> for i in range(10):
>
> -Larry

Thanks Larry. I saw that page you referenced above and that is how I
knew it was a keyword. But I still have found nodocumentation that
supports the examples you provided.


Thanks again,

john

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


Re: Which are your favorite UML tools?

2007-04-26 Thread hg
Anastasios Hatzis wrote:

> Hello,
> 
> I'm working on the light-weight MDA tool pyswarm,
> http://pyswarm.sourceforge.net/ (it is about a code-generator for
> Python/PostgreSQL-based software. I plan to add support of UML CASE tools
> other than the one supported currently.
> 
> I would like to learn which UML tools you use (if any), preferrably if it
> comes to modeling a Python application. So I'm asking you to tell me the
> name of your favorite UML CASE tool(s).
> 
> Please also provide the version of the tool you use (and perhaps also the
> URL of the project/vendor). If this is not of general interest for this
> list you can also reply directly to my email address.
> 
> Thank you in advance.
> 
> Best regards
> Anastasios

umbrello seems to finally have python import support 

hg

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


Re: wtf

2007-04-26 Thread Shane Hathaway
Sergiy wrote:
> print 1 / 2
> print -1 / 2
> 
> 0
> -1
> 
> correct?

Yes.  It works like the floor() function.

>>> import math
>>> math.floor(1.0 / 2)
0.0
>>> math.floor(-1.0 / 2)
-1.0

Shane

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


Re: Dedicated CPU core for Python?

2007-04-26 Thread Michael Hoffman
Louise Hoffman wrote:

> I was wondering, if Python in the foerseeable future will allocate one
> CPU core just for the interpreter, so heavy Python operations does
> slow down the OS?

When running scripts, or loading modules, Python does not really behave 
as an interpreter. Instead it compiles the human-readable code to a 
bytecode which it then runs on a virtual machine.
-- 
Michael Hoffman (no relation)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: wtf

2007-04-26 Thread Jean-Paul Calderone
On Thu, 26 Apr 2007 21:35:03 +0300, Sergiy <[EMAIL PROTECTED]> wrote:
>print 1 / 2
>print -1 / 2
>
>0
>-1
>
>correct?

  Quoting http://www.python.org/doc/lib/typesnumeric.html:

(1)
For (plain or long) integer division, the result is an integer.
The result is always rounded towards minus infinity: 1/2 is 0, (-1)/2
is -1, 1/(-2) is -1, and (-1)/(-2) is 0. Note that the result is a long
integer if either operand is a long integer, regardless of the numeric
value.

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


wtf

2007-04-26 Thread Sergiy
print 1 / 2
print -1 / 2

0
-1

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


Re: My python annoyances so far

2007-04-26 Thread Jean-Paul Calderone
On 26 Apr 2007 20:05:45 +0200, Neil Cerutti <[EMAIL PROTECTED]> wrote:
>On 2007-04-26, Steven Howe <[EMAIL PROTECTED]> wrote:
>> [EMAIL PROTECTED] wrote:
 Well, why do some things in the library have to be functions,
 and other things have to be class methods?
>>
>> Perhaps because some things are more naturally function like?
>> For 'instance' (pardon the pun), functions shouldn't retain
>> data. They perform an operation, return data and quit. While
>> retaining data is a feature of an class/instance.
>
>Functions do retain data. Classes and instances are just a
>convenient notation. ;)
>
> [snip]
>
>Python's scoping rules make certain kinds of functional idioms
>hard to use, though. I'm not sure how to get the following to
>work in Python using functions:
>
 def account(s):
>...   b = s
>...   def add(a):
>... b += a
>...   def balance():
>... return b
>...   return add, balance
>...
 add, balance = account(100)
 balance()
>100
 add(5)
>Traceback (most recent call last):
>  File "", line 1, in ?
>  File "", line 4, in add
>UnboundLocalError: local variable 'b' referenced before assignment
>
>Anyhow, it doesn't work, but you can see how closely it resembles
>a class definition.

Use the outfix closure operator, []:

>>> def account(s):
... b = [s]
... def add(a):
... b[0] += a
... def balance():
... return b[0]
... return add, balance
...
>>> add, balance = account(100)
>>> add(5)
>>> balance()
105
>>>

;)

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


Re: passing tuple with pyqt4 signal/slot mechanism

2007-04-26 Thread Phil Thompson
On Thursday 26 April 2007 6:34 pm, Pradnyesh Sawant wrote:
> > > Also, in the modified code, why aint the method setLabel getting
> > > called?
> >
> > Works for me,
>
> Does the "setLabel" method get called in your case? In your previous
> reply, you mentioned that it doesn't. Can you tell me the reason why?

In the first version it didn't. In the second version it did.

> > and I still don't know what versions you are using and on
> > which
> > platform. Whatever they are, try the latest release.
>
> Python 2.4.4c1 (#2, Oct 11 2006, 21:51:02)
> [GCC 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu5)] on linux2

The version of PyQt? The version of SIP? The version of Qt?

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


Re: My python annoyances so far

2007-04-26 Thread Neil Cerutti
On 2007-04-26, Steven Howe <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
>>> Well, why do some things in the library have to be functions,
>>> and other things have to be class methods?
>
> Perhaps because some things are more naturally function like?
> For 'instance' (pardon the pun), functions shouldn't retain
> data. They perform an operation, return data and quit. While
> retaining data is a feature of an class/instance.

Functions do retain data. Classes and instances are just a
convenient notation. ;)

>>> def funmaker(f, x):
...   return lambda: f(x)
...
>>> d = funmaker(int, 10)
>>> d()
10

In addition, all functions in Python have data members, too.

>>> d.label = "d"
>>> d.label
'd'

Python's scoping rules make certain kinds of functional idioms
hard to use, though. I'm not sure how to get the following to
work in Python using functions:

>>> def account(s):
...   b = s
...   def add(a):
... b += a
...   def balance():
... return b
...   return add, balance
...
>>> add, balance = account(100)
>>> balance()
100
>>> add(5)
Traceback (most recent call last):
  File "", line 1, in ?
  File "", line 4, in add
UnboundLocalError: local variable 'b' referenced before assignment

Anyhow, it doesn't work, but you can see how closely it resembles
a class definition.

> And before someone get's all technical, I know everything in
> Python is an 'object' even None, which implies class, or is it
> the other way around?

Classes are just objects like everything else.

-- 
Neil Cerutti
Bach's death is attributed to the end of the Baroque era. --Music Lit Essay
-- 
http://mail.python.org/mailman/listinfo/python-list


urlopen

2007-04-26 Thread Dave Dean
Hi all,
  I'm running into some trouble using urllib.urlopen to grab a page from our 
corporate intranet.  The name of the internal site is simply http://web (no 
www or com).  I can use urlopen to grab a site like http://www.google.com 
just fine.  However, when I use urlopen to grab the internal site, I instead 
get data from http://www.web.com.  This is the url returned by the geturl() 
function.
  There must be a way to stop Python, or whoever is doing it, from changing 
my url.  Maybe urllib is not the correct approach.  Does anyone know a 
solution to this?
Thanks,
Dave


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


Re: My python annoyances so far

2007-04-26 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, flifus wrote:

> Well, why do some things in the library have to be functions, and
> other things have to be class methods?
> 
> Why aren't they all just either functions or class methods? like
> perhaps ruby.

To which class should `sorted()` belong to then?  Or the functions in the
`math` module?  What about `itertools`?

In languages without functions, like Java, you'll have to write static
methods where you really want functions, just because Java forces you to
stuff everything into classes.

And instead of a simple ``lambda`` function one needs to write an
anonymous class with a method.  Quite convoluted.

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


Re: My python annoyances so far

2007-04-26 Thread Steven Howe
[EMAIL PROTECTED] wrote:
>> Well, why do some things in the library have to be functions, and
>> other things have to be class methods?
>> 
Perhaps because some things are more naturally function like? For 
'instance' (pardon the pun), functions shouldn't retain data. They 
perform an operation, return data and quit. While retaining data is a 
feature of an class/instance.

If I'm looking up the time of day in L.A., why do I need the whole clock 
database of times including New York and London?

Another example are with respect to  'int' and 'float' operations. Why 
should int(x) be a class? Did you want to save and operate on the value 
of x again? No, you want the integer portion of x. Ditto float(x); 
somebody input '5' but you want it clear it 5.0. You typecast it your 
way. But the float operation doesn't need to retain the last input, nor 
even exist after it's last use. So, without have any current values 
referenced inside 'float', garbage collection can recover the memory 
space of 'float'.

And before someone get's all technical, I know everything in Python is 
an 'object' even None, which implies class, or is it the other way around?

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


Re: passing tuple with pyqt4 signal/slot mechanism

2007-04-26 Thread Pradnyesh Sawant
> > Also, in the modified code, why aint the method setLabel getting called?
>
> Works for me,
Does the "setLabel" method get called in your case? In your previous
reply, you mentioned that it doesn't. Can you tell me the reason why?
> and I still don't know what versions you are using and on
> which
> platform. Whatever they are, try the latest release.

Python 2.4.4c1 (#2, Oct 11 2006, 21:51:02)
[GCC 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu5)] on linux2

-- 
warm regards,
Pradnyesh Sawant
--
Be yourself, everyone else is taken. --Anon
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: EuroPython vs PyconUK

2007-04-26 Thread Steve Holden
Steve Holden wrote:
> EuGeNe Van den Bulke wrote:
[...]
> 
> Diversity is good, so it isn't one vs. the other. And the UK really *is* 
> part of Europe (no matter how its politicians behave) :P
> 
> regards
>   Steve

PS: Have you seen the new "[PyCon Uno Italy] Call For Papers" post? I 
hope you are going to rap their knuckles too :P ;-)

regards
  Steve
-- 
Steve Holden   +1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
Recent Ramblings   http://holdenweb.blogspot.com

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


problem in running python on winnt

2007-04-26 Thread Ashok
hello, I have built a standalone gui application using py2exe which
works fine in my WinXp SP2 machine and another WinXp machine. When i
try to run it in a Win NT SP6 machine, I get the following error.

Traceback (most recent call last):

File "auto.py", line 4, in ?
File "zipextimporter.pyo", line 82, in load_module
File "wx\_init_.pyo", line 45, in?
File "zipextimporter.pyo", line 82, in load_module
File "wx\_init_.pyo", line 4, in?
File "zipextimporter.pyo", line 98, in load_module
ImportError : MemoryLoadLibrary failed loading wx\_core_.pyd

I use python 2.4.2, wxpython 2.8, py2exe 0.6.6 for development

can anybody come up with a solution?

thanks in advance

AGK

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


Dedicated CPU core for Python?

2007-04-26 Thread Louise Hoffman
Dear readers,

I was wondering, if Python in the foerseeable future will allocate one
CPU core just for the interpreter, so heavy Python operations does
slow down the OS?

It seams to me like a perfect use for a CPU core =)

Lots of love,
Louise

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


[PyCon Uno Italy] Call For Papers

2007-04-26 Thread Nicola Larosa
PyCon Uno: Python first Italian conference about Python.

Call for Papers
===

Important dedalines
---

* April 30, 2007
Submission of paper and tutorial abstracts.

* May 5, 2007
Papers and tutorials admission notification.

* June 9, 2007
Submission of paper and tutorial final versions.

What is PyCon Uno?
--

PyCon Uno is the first Italian conference about the Python programming
language. It will be held in __Florence on June 9 and 10, 2007__.
The conference aims to help spreading the Python language, and better
expose professional developers, students, businesses and interested
people.

The conference official language is the Italian one.

Papers
--

The conference is made up of two parallel tracks: *tutorial* and
*advanced*.

* The *tutorial* track talks will mainly deal with introductory matters
  related to Python technologies and libraries;

* The *advanced* track will deal with more advanced matters, both from
  a technical point of view and regarding development methodologies,
  use cases (for example, Python for businesses) and management;

Here is a tentative and incomplete list of relevant matters:

* huge and/or distributed Python applications
* scientific and numeric applications
* integration with other languages and environenments, RPC and services
* web development and frameworks
* desktop and GUI toolkit programming
* Python as a system language (scripting, COM etc.)
* Python and databases
* Python as an instructional language

Papers will be evaluated according to content, relevance to the Python
community, writing style and quality.

Each talk will last at most 60 minutes, which comprise setup and
teardown time.

How to submit a talk proposal
-

Send talk proposals to the call-for-papers AT pycon.it email address,
with "[TALK] Talk title" as subject, and the abstract in the mail body.

What to send when, and how to send it
-

Please only send papers that have been explicitly accepted by the
organization. Send them before the conference starting date. Papers
must be your own original production: any paper containing materials
copyrighted by others will not be accepted.

Papers have to be written in the Italian language.

Papers may be submitted in text, HTML (one file), Postscript or PDF
format, or any other standard format that may be opened and printed on
many systems.

To submit a paper, proceed as follows:

1. create a tar/bz2/zip/gz file containing the paper, any supplementary
   files (like images), and a README file with your name, email and any
   further information;

2. send an email to call-for-papers AT pycon.it , attaching the above
   mentioned file.

Additional information
--

For any question, please contact us at info AT pycon.it .

Conference organizers
-

* Giovanni Bajo (Develer SRL)
* Marco Beri (Link I.T.)
* Antonio Cavedoni (Bunker)
* Enrico Franchi (Sviluppatore Indipendente)
* Alan Franzoni (Sviluppatore Indipendente)
* Nicola Larosa (Space SPA)
* Alex Martelli (Google Inc.)
* Stefano Masini (Pragma2000)
* Carlo Miron (Visiant Galyleo)
* David Mugnai (Space SPA)
* Lawrence Oluyede (Sviluppatore Indipendente)
* Manlio Perillo (Sviluppatore Indipendente)
* Fabio Pliger (Sia Verona SRL)
* Giovanni Porcari (Softwell SaS)
* Michele Simionato (StatPro Plc)
* Daniele Varrazzo (Develer SRL)
* Maurizio Volonghi
* Valentino Volonghi (Sviluppatore Indipendente)
* Simone Zinanni (Develer SRL)


-- 
Nicola Larosa - http://www.tekNico.net/

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


Re: EuroPython vs PyconUK

2007-04-26 Thread Steve Holden
EuGeNe Van den Bulke wrote:
> I do realize that the UK is not really part of Europe (no polemic :P) 
> but I am nevertheless curious about the logic behind creating another 
> major Python event in Europe. Wasn't EuroPython enough?
> 
> Like many I am sure, I probably won't be able to attend both (and I 
> really enjoyed the Geneva experience so definitely want to renew "it"). 
> How would you go about selecting which conference to attend?
> 
> They are only 2 months apart, 6 would have been easier for the 
> attendees! Could the organizers liaise one way or another to make 
> Pythoneers life as easy and fun as the language and give as much 
> information out as possible as early as possible (early bird early) for 
> people to make the best decision?
> 
> I know marketing matters but ...
> 
> EuGeNe -- http://www.3kwa.com

So by this reasoning there should have been no "Python UK" conference 
for the last four years (in case you didn't know it ran as a track of 
the C/C++ conference, but ths track has now broadened to include all 
scripting languages). And what about the people who can't get the time 
and/or money to attend EuroPython?

Diversity is good, so it isn't one vs. the other. And the UK really *is* 
part of Europe (no matter how its politicians behave) :P

regards
  Steve
-- 
Steve Holden   +1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
Recent Ramblings   http://holdenweb.blogspot.com

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


http://www.t-mobileapps.com/vs/istream_int2/LinkLibrary/Go.cfm?ID=1809

2007-04-26 Thread SWEETLADYFRMBAMA
Go
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Access to raw command line?

2007-04-26 Thread Grant Edwards
On 2007-04-26, Donn Cave <[EMAIL PROTECTED]> wrote:

>> One possible way to work around this is to get the raw command line
>> and do the shell expansions ourselves from within Python. Ignoring the
>> question of whether it is worth the trouble, does anybody know if it
>> is possible to obtain the raw (unexpanded) command line?
>
> If you're on VMS (well, you didn't say), you're in luck.
>
> The UNIX shell has already expanded the file globbing by the
> time your program starts up, but VMS leaves it to the application,
> with the help of a handy RMS$ function or two so it gets done in
> a consistent way.  This allows the command line interface to
> interact with the user in a little more transparent way, since
> the input seen by the program is congruent with what the user
> typed in.  E.g., "rename *.jpeg *.jpg" is trivial on VMS,
> impossible on UNIX.

Typing  rename '*.jpeg' '*.jpg' is impossible?

-- 
Grant Edwards   grante Yow! I'm not available
  at   for comment..
   visi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Access to raw command line?

2007-04-26 Thread Donn Cave
In article <[EMAIL PROTECTED]>,
 Pieter Edelman <[EMAIL PROTECTED]> wrote:

> One possible way to work around this is to get the raw command line
> and do the shell expansions ourselves from within Python. Ignoring the
> question of whether it is worth the trouble, does anybody know if it
> is possible to obtain the raw (unexpanded) command line?

If you're on VMS (well, you didn't say), you're in luck.

The UNIX shell has already expanded the file globbing by the
time your program starts up, but VMS leaves it to the application,
with the help of a handy RMS$ function or two so it gets done in
a consistent way.  This allows the command line interface to
interact with the user in a little more transparent way, since
the input seen by the program is congruent with what the user
typed in.  E.g., "rename *.jpeg *.jpg" is trivial on VMS,
impossible on UNIX.

   Donn Cave, [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


EuroPython vs PyconUK

2007-04-26 Thread EuGeNe Van den Bulke
I do realize that the UK is not really part of Europe (no polemic :P) 
but I am nevertheless curious about the logic behind creating another 
major Python event in Europe. Wasn't EuroPython enough?

Like many I am sure, I probably won't be able to attend both (and I 
really enjoyed the Geneva experience so definitely want to renew "it"). 
How would you go about selecting which conference to attend?

They are only 2 months apart, 6 would have been easier for the 
attendees! Could the organizers liaise one way or another to make 
Pythoneers life as easy and fun as the language and give as much 
information out as possible as early as possible (early bird early) for 
people to make the best decision?

I know marketing matters but ...

EuGeNe -- http://www.3kwa.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Access to raw command line?

2007-04-26 Thread Grant Edwards
On 2007-04-26, Pieter Edelman <[EMAIL PROTECTED]> wrote:

> All your posts pretty much confirmed my own thoughts on this subject.
> Every option requires a specific action from the user, and as Bjoern
> points out, it would differ from what everybody is used to.  I think
> there's no trivial and reliable way to do this, so I can better leave
> it the way it is (at least for now).

Quoting things on the command line that you don't want the
shell to expand is trivial and reliable.  It's also something
than any shell user should know.

-- 
Grant Edwards   grante Yow! I wonder if there's
  at   anything GOOD on tonight?
   visi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   3   >