Re: GUI for viewing/editing python data structures?

2007-09-27 Thread David
On 9/27/07, Joshua J. Kugler <[EMAIL PROTECTED]> wrote:
> A while back, I seem to remember coming across a small program that could
> view and edit python data structures via a nice expanding tree view.  I'm
> now in need of something like that (to verify data is imported correctly
> into a shelve file) and having a GUI would be much simpler than trying to
> wade through the output of str(d) or repr(d).
>
> I've tried googling with the obvious keywords (gui (view OR edit) python
> data structures) but t didn't get me anywhere.
>
> Pointers?
>

non-gui alternatives: Try pprint module. Or output as yaml (external
library) into a text file. You could also output as XML (using
built-in python modules), save to file and then use Firefox or another
XML gui to inspect it. I haven't done the latter before but it should
work.
-- 
http://mail.python.org/mailman/listinfo/python-list


marshal bug?

2007-09-27 Thread Anurag
I have been chasing a problem in my code since hours and it bolis down
to this
import marshal
marshal.dumps(str(123)) != marshal.dumps(str("123"))

Can someone please tell me why?
when
str(123) == str("123")

or are they different?

it also means that
if s = str(123)
marshal.dumps(s) != marshal.dumps(marshal.loads(marshal.dumps(s)))

rgds
Anurag

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


Python and SSL

2007-09-27 Thread Johny
I need to use Python with SSL comunication betweeen servers.
(I use hhtplib but I think urllib2 can also be used )
 I think I need to use SSL root certificate and tell  a program to
trust this certificate.
But how can I tell my Python program to trust my SSL certificate?
When I tried  before I received the error 503
Thank you for help
L,

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


Re: Python 3.0 migration plans?

2007-09-27 Thread John Nagle
TheFlyingDutchman wrote:
> It seems that Python 3 is more significant for what it removes than
> what it adds.
> 
> What are the additions that people find the most compelling?

I'd rather see Python 2.5 finished, so it just works.
All the major third-party libraries working and available with
working builds for all major platforms.  That working set
of components in all the major distros used on servers.
The major hosting companies having that up and running on
their servers.  Windows installers that install a collection
of components that all play well together.

That's what I mean by "working".

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


ANNOUNCE: wxPython 2.8.6.0

2007-09-27 Thread Robin Dunn
Announcing
--

The 2.8.6.0 release of wxPython is now available for download at
http://wxpython.org/download.php.  This release is mostly about fixing
a number of bugs and inconsistencies in wxWidgets and wxPython.

Source code is available, as well as binaries for Python 2.3, 2.4 and
2.5, for Windows and Mac, as well some pacakges for various Linux
distributions.  A summary of changes is listed below and also at
http://wxpython.org/recentchanges.php.


What is wxPython?
-

wxPython is a GUI toolkit for the Python programming language. It
allows Python programmers to create programs with a robust, highly
functional graphical user interface, simply and easily. It is
implemented as a Python extension module that wraps the GUI components
of the popular wxWidgets cross platform library, which is written in
C++.

wxPython is a cross-platform toolkit. This means that the same program
will usually run on multiple platforms without modifications.
Currently supported platforms are 32-bit Microsoft Windows, most Linux
or other Unix-like systems using GTK2, and Mac OS X 10.3+, in most
cases the native widgets are used on each platform to provide a 100%
native look and feel for the application.


Changes in 2.8.6.0
--

This release is mostly about fixing a number of bugs and
inconsistencies in wxWidgets and wxPython.  In other words, there have
been a whole lot more changes than what is listed here, but they are
not new features or API visible changes, which is what are usually
listed in this file.

Some Menu APIs added to make things more consistent.  Added
wx.MenuBar.SetMenuLabel, wx.MenuBar.GetMenuLabel,
wx.MenuBar.GetMenuLabelText, wx.Menu.GetLabelText,
wx.MenuItem.SetItemLabel, wx.MenuItem.GetItemLabel,
wx.MenuItem.GetItemLabelText, wx.MenuItem.GetLabelText.  The
Get...Label functions get the raw label with mnemonics and
accelerators, and the Get...LabelText functions get the text only,
without mnemonics/accelerators.

Added wx.BORDER_THEME style.  This style will attempt to use a theme
specific style, if the current platform and environment is themeable
and has a specific theme style.  For example, you could use this on
Windows XP on a custom control to give it a themed border style that
looks like what is used by default on the native wx.TextCtrl or
wx.ListBox.  Since there were not any more available bits for border
styles, this style replaces wx.BORDER_DOUBLE.

-- 
Robin Dunn
Software Craftsman
http://wxPython.org  Java give you jitters?  Relax with wxPython!

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


Re: Asynchronous Messaging

2007-09-27 Thread Gabriel Genellina
En Fri, 28 Sep 2007 00:52:57 -0300, wink <[EMAIL PROTECTED]> escribi�:

> Interesting, from the documentation for deque says;
> "Deques support thread-safe, ..." which would seem to
> imply a mutex of some sort would be used. But in
> looking at collectionsmodule.c for 2.5.1 I don't see
> any mutex which would seem to imply there is one
> place else, maybe the GIL, or the documentation is
> incorrect.

Uh, I had never noticed that append/pop claimed to be thread safe. Ok,  
they don't appear to call any Python code, neither Py_DECREF is used, so  
the GIL would make those methods thread safe, I think.
R. Hettinger, any comments?

-- 
Gabriel Genellina

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

ImportError: /usr/lib/python2.4/site-packages/_xmlplus/parsers/pyexpat.so: undefined symbol: PyUnicodeUCS4_Decode

2007-09-27 Thread Amal
When I am compiling some code, I am getting the following the above
mentioned error. So how can i go about solving this issue.

Should I recompile python using -enable-unicode=UCS4 option.  Is there no
other way to solve this issue.

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

Re: Numeric command-line options vs. negative-number arguments

2007-09-27 Thread Steven Bethard
Ben Finney wrote:
> Steven Bethard <[EMAIL PROTECTED]> writes:
> 
>> In most cases, argparse (http://argparse.python-hosting.com/)
>> supports negative numbers right out of the box, with no need to use
>> '--':
>>
>> >>> import argparse
>> >>> parser = argparse.ArgumentParser()
>> >>> parser.add_argument('-a', type=int)
>> >>> parser.add_argument('b', type=int)
>> >>> args = parser.parse_args('-a -42 -123'.split())
>> >>> args.a
>> -42
>> >>> args.b
>> -123
> 
> That would be irritating. I've used many programs which have numbers
> for their options because it makes the most sense, e.g. 'mpage' to
> indicate number of virtual pages on one page, or any number of
> networking commands that use '-4' and '-6' to specify IPv4 or IPv6.

Did you try it and find it didn't work as you expected? Numeric options 
seem to work okay for me::

 >>> import argparse
 >>> parser = argparse.ArgumentParser()
 >>> parser.add_argument('-1', dest='one', action='store_true')
 >>> args = parser.parse_args(['-1'])
 >>> args.one
 True

Argparse knows what your option flags look like, so if you specify one, 
it knows it's an option.  Argparse will only interpret it as a negative 
number if you specify a negative number that doesn't match a known option.

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


Re: GUI for viewing/editing python data structures?

2007-09-27 Thread Paddy
On Sep 26, 11:23 pm, "Joshua J. Kugler" <[EMAIL PROTECTED]> wrote:
> A while back, I seem to remember coming across a small program that could
> view and edit python data structures via a nice expanding tree view.  I'm
> now in need of something like that (to verify data is imported correctly
> into a shelve file) and having a GUI would be much simpler than trying to
> wade through the output of str(d) or repr(d).
>
> I've tried googling with the obvious keywords (gui (view OR edit) python
> data structures) but t didn't get me anywhere.
>

The magic googling phrase is:
  Python bean-editor

Which gave http://home.gna.org/oomadness/en/editobj/index.html

I've never used it. Could you tell me how you get on?

- Paddy.


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


Re: comparing elements of a list with a string

2007-09-27 Thread Gabriel Genellina
En Thu, 27 Sep 2007 07:44:08 -0300, Shriphani <[EMAIL PROTECTED]>  
escribi�:

> def listAllbackups(filename):
>   list_of_backups = glob(home+'/Desktop/backupdir/*%s*'%filename)
>   for element in list_of_back:
>   if element.find(file) != -1:
>   date_components = element.split('-')[-4:-1]
>   date = str(date_components[0]) + ":" + 
> str(date_components[1]) +
> ":" + str(date_components[2])
>   time = element.split('-')[-1]
>   yield (date, time)
> print listAllbackups('fstab')
>
>
> I ran it in the terminal and I got:
>
> 
>
> Why does it do that and not just print out all the values of (date,
> time)

Because listAllbackups is a generator function: each time someone asks it  
the next value, it runs until the "yield" statement, and pauses. Next time  
execution continues from the same point.
You have to iterate over it. Try:

for date,time in listAllbackups('fstab'):
 print date,time

or

items = list(listAllbackups('fstab'))
print items

-- 
Gabriel Genellina

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

Re: Emailing the attachment created with the Quick Screenshots Script (Python + PIL)

2007-09-27 Thread Gabriel Genellina
En Thu, 27 Sep 2007 10:37:05 -0300, Mark Bratcher  
<[EMAIL PROTECTED]> escribi�:

> The Quick Screenshots Script (Python + PIL) is a "dream come true", and  
> yet
> so simple to use reliably.  Does anyone have a suggestion or know how to
> include in the script, the ability to email the attachment?  This would  
> make
> the dream perfect!  Thanks!

See the second example from the email package; it creates a MIME message  
with an attachment and sends it using SMTP.


-- 
Gabriel Genellina

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

Re: Guitars for 0$ !!!!!

2007-09-27 Thread hg
 [EMAIL PROTECTED] wrote:

> http://free-guitars.blogspot.com/

And the chicks for free !
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Asynchronous Messaging

2007-09-27 Thread wink
>
> That't not the reason. A Queue is built around a container, and it happens
> to be a deque in the default implementation. But the important thing is
> that a Queue is a synchronized object - it performs the necesary
> synchronization to ensure proper operation even from multiple threads
> attempting to use it at the same time.
> So your comparison is meaningless, apart from telling that using mutexes
> is not cheap.
>
> --
> Gabriel Genellina

Interesting, from the documentation for deque says;
"Deques support thread-safe, ..." which would seem to
imply a mutex of some sort would be used. But in
looking at collectionsmodule.c for 2.5.1 I don't see
any mutex which would seem to imply there is one
place else, maybe the GIL, or the documentation is
incorrect.

On the other hand looking at the code in Queue.py there
is a more code plus the not_full Condition variable plus
the call to _put (which is a call to the deque.append)
plus a notify on the not_empty conditional, so it's not
surprising it's slower.

If and when I think Queue is a performance impediment
to an mproc I'll take another look at it, for now lots
of things to learn.

Thanks,

Wink

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


Re: Python 3.0 migration plans?

2007-09-27 Thread Eduardo O. Padoan
On 9/27/07, TheFlyingDutchman <[EMAIL PROTECTED]> wrote:
> It seems that Python 3 is more significant for what it removes than
> what it adds.
>
> What are the additions that people find the most compelling?

 - dict.items(), .values() and .keys() returns "dict views", and the
.iter*() removal
   http://www.python.org/dev/peps/pep-3106/
 - the new super()
   http://www.python.org/dev/peps/pep-3135/

etc...

-- 
http://www.advogato.org/person/eopadoan/
Bookmarks: http://del.icio.us/edcrypt
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 3.0 migration plans?

2007-09-27 Thread TheFlyingDutchman

>
>   - Abstract Base Classes
> http://www.python.org/dev/peps/pep-3119/>
>

I like how someone here characterized decorators - those silly @
things. They remind me of Perl. Not adding keywords for abstract and
static is like Perl not adding a keyword for class. But I know all
such additions are vigorously defended by the most ardent users of
each language.

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


Re: Python 3.0 migration plans?

2007-09-27 Thread Steve Holden
Paul Rubin wrote:
> Steve Holden <[EMAIL PROTECTED]> writes:
>> So what we need is a poll on what the questions should be. I *love* c.l.py.
> 
> One of the offered answers to the current question should be "never".
> That is, I'm hoping to skip 3.0 and switch directly to PyPy.

Well, "No current plans" certainly includes "never", even though it 
might not be quite assertive enough for your tastes.

I hope that PyPy will eventually become good enough to overtake CPython 
as the preferred implementation - it certainly seems to have much 
greater optimization possibilities than CPython.

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

Sorry, the dog ate my .sigline

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


Re: getopt with negative numbers?

2007-09-27 Thread Ben Finney
Casey <[EMAIL PROTECTED]> writes:

> Well, it is a hack and certainly not as clean as having getopt or
> optparse handle this natively (which I believe they should).

I believe they shouldn't because the established interface is that a
hyphen always introduced an option unless (for those programs that
support it) a '--' option is used, as discussed.

> But I think it is a simple and clever hack and still allows getopt
> or optparse to function normally.

Except that they *don't* function normally under that hack; they
function in a way contradictory to the normal way.

> So I wouldn't call it a kludge, which implies a more clumsy hack. As
> you say, it is all a matter of perspective.

Everyone is entitled to their own perspective, but not to their own
facts.

-- 
 \  "[...] a Microsoft Certified System Engineer is to information |
  `\ technology as a McDonalds Certified Food Specialist is to the |
_o__)   culinary arts." —Michael Bacarella |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Traveling Europe

2007-09-27 Thread Eric Sosman
[EMAIL PROTECTED] wrote:
> World's most popular traveling destinations
> 
> http://...

 "Nobody goes there any more; it's too crowded." -- LPB

-- 
Eric Sosman
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: developing an application

2007-09-27 Thread Benjamin
On Sep 27, 5:06 pm, yadin <[EMAIL PROTECTED]> wrote:
> hi!
> i was buiding an application using python...a program
> this was my first one...now that i got it working perfectly
> how can i put the bunch of files into one package?
> the user of the appliation will not know where to start? that is which
> file to click on in oder to start the program?
> thanks a lot

also you can make MacOS apps with the standard MacOS Python
distribution

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


Re: Python 3.0 migration plans?

2007-09-27 Thread Ben Finney
TheFlyingDutchman <[EMAIL PROTECTED]> writes:

> It seems that Python 3 is more significant for what it removes than
> what it adds.

That's certainly the focus of an explicitly backward-incompatible
upgrade, yes.

> What are the additions that people find the most compelling?

Most of the additions that will go into 2.6 are doing so because
they'll appear in 3.0. That's a benefit: anything from 3.0 that makes
sense to add to 2.6 will go in; the rest of 3.0's changes are mostly
backwards-incompatible (i.e. removals and conflicting changes).

I find the following compelling:

  - 'str' becomes Unicode type, 'int' becomes unified-int-and-long
type http://www.python.org/dev/peps/pep-3100/>

  - Consistent, unambiguous integer literal syntax
http://www.python.org/dev/peps/pep-3127/> and the 'bytes'
type for non-text strings
http://www.python.org/dev/peps/pep-3112/>

  - Default source encoding is UTF-8
http://www.python.org/dev/peps/pep-3120/> and support for
non-ASCII identifiers
http://www.python.org/dev/peps/pep-3131/>

  - Reorganisation of the standard library for consistency
http://www.python.org/dev/peps/pep-3108/>

  - Renaming raw_input to input, so 'input()' does the obvious thing
http://www.python.org/dev/peps/pep-3111/>

  - Clarification of 'raise' and 'except' semantics
http://www.python.org/dev/peps/pep-3109/>,
http://www.python.org/dev/peps/pep-3110/>

  - Abstract Base Classes
http://www.python.org/dev/peps/pep-3119/>

  - everything that's being added to 2.6 :-)

-- 
 \  "I bought a self learning record to learn Spanish. I turned it |
  `\on and went to sleep; the record got stuck. The next day I |
_o__)could only stutter in Spanish."  -- Steven Wright |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: cute use of lambda

2007-09-27 Thread Paul Rubin
Simon Forman <[EMAIL PROTECTED]> writes:
> class FakeQueue(list):
> put = list.append
> get = lambda self: self.pop(0)

from collections import deque
class FakeQueue(deque):
   put = deque.append
   get = deque.popleft
-- 
http://mail.python.org/mailman/listinfo/python-list


cute use of lambda

2007-09-27 Thread Simon Forman
class FakeQueue(list):
put = list.append
get = lambda self: self.pop(0)


;]

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


Re: Python 3.0 migration plans?

2007-09-27 Thread Aahz
In article <[EMAIL PROTECTED]>,
Steve Holden  <[EMAIL PROTECTED]> wrote:
>
>I wondered if a straw poll could get some idea of readers' thoughts 
>about when they will be migrating to 3.0 on, so I used the new widget on 
>Blogger to add a poll for that.
>
>I'd appreciate if if you would go to
>
>   http://holdenweb.blogspot.com/
>
>and register your vote on your intended migration timescale.

Does this require JavaScript?  If yes, count me as another "no" vote on
your survey.  ;-)
-- 
Aahz ([EMAIL PROTECTED])   <*> http://www.pythoncraft.com/

The best way to get information on Usenet is not to ask a question, but
to post the wrong information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 3.0 migration plans?

2007-09-27 Thread Paul Rubin
Steve Holden <[EMAIL PROTECTED]> writes:
> So what we need is a poll on what the questions should be. I *love* c.l.py.

One of the offered answers to the current question should be "never".
That is, I'm hoping to skip 3.0 and switch directly to PyPy.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: getopt with negative numbers?

2007-09-27 Thread Casey
On Sep 27, 7:57 pm, Neal Becker <[EMAIL PROTECTED]> wrote:
> One person's "brilliant" is another's "kludge".
Well, it is a hack and certainly not as clean as having getopt or
optparse handle this natively (which I believe they should).  But I
think it is a simple and clever hack and still allows getopt or
optparse to function normally.  So I wouldn't call it a kludge, which
implies a more clumsy hack. As you say, it is all a matter of
perspective.

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


Re: Python 3.0 migration plans?

2007-09-27 Thread TheFlyingDutchman
It seems that Python 3 is more significant for what it removes than
what it adds.

What are the additions that people find the most compelling?

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


Numeric command-line options vs. negative-number arguments (was: getopt with negative numbers?)

2007-09-27 Thread Ben Finney
Steven Bethard <[EMAIL PROTECTED]> writes:

> In most cases, argparse (http://argparse.python-hosting.com/)
> supports negative numbers right out of the box, with no need to use
> '--':
> 
> >>> import argparse
> >>> parser = argparse.ArgumentParser()
> >>> parser.add_argument('-a', type=int)
> >>> parser.add_argument('b', type=int)
> >>> args = parser.parse_args('-a -42 -123'.split())
> >>> args.a
> -42
> >>> args.b
> -123

That would be irritating. I've used many programs which have numbers
for their options because it makes the most sense, e.g. 'mpage' to
indicate number of virtual pages on one page, or any number of
networking commands that use '-4' and '-6' to specify IPv4 or IPv6.

If argparse treats those as numeric arguments instead of options,
that's violating the Principle of Least Astonishment for established
command-line usage (hyphen introduces an option).

-- 
 \   "I went to a general store. They wouldn't let me buy anything |
  `\  specifically."  -- Steven Wright |
_o__)  |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ValueError: too many values to unpack

2007-09-27 Thread Pablo Ziliani
Zentrader wrote:
> On Sep 27, 9:46 am, Shawn Minisall <[EMAIL PROTECTED]> wrote:
>   
>> line 3 - 19.1829.1578.75212.10
>> line 4 - 10020410.29
>> And this is the code I'm using:
>>
>>#read withdrawls from file on line3
>>line = infile.readline()
>>  #split withdrawls up
>>withdraw1, withdraw2, withdraw3, withdraw4 = string.split(line, "\t")
>>
>>#read deposits from file on line4
>>line = infile.readline()
>>#split deposits up
>>deposit1, deposit2, deposit3 = string.split(line, "\t")
>>
>> I have 4 strings to match line 3 and 3 to match the 3 on line 4...any
>> thoughts?
>> 
>
> A string.split returns a list so you don't have to know how many
> elements there are beforehand.  A simple example
> withdraw = line.split("\t")
> if len(withdraw) == 3:
>match_3(withdraw)
> elif len(withdraw) == 4::
>match_4(withdraw)
> else:
>print "line.split() is not 3 or 4", withdraw

Right, and then because error was caused for an unexpected extra tab you 
made the deposit pass as a withdrawal...
Not everybody trades just Zen :)

(tip: the unpacking mystery has been solved earlier this day)

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


Re: Python 3.0 migration plans?

2007-09-27 Thread Steve Holden
James Stroud wrote:
> Steve Holden wrote:
>> I wondered if a straw poll could get some idea of readers' thoughts 
>> about when they will be migrating to 3.0 on, so I used the new widget on 
>> Blogger to add a poll for that.
>>
>> I'd appreciate if if you would go to
>>
>>   http://holdenweb.blogspot.com/
>>
>> and register your vote on your intended migration timescale.
>>
>> Thanks!
> 
> I'm going to abstain voting until 'public beta + about 1 year' is a choice.
> 
Richard Jones wrote:
 > I'll use the "no plans" response for my actual "no simple answer" real
 > response.
 >
 >
So what we need is a poll on what the questions should be. I *love* c.l.py.

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

Sorry, the dog ate my .sigline

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


Re: ValueError: too many values to unpack

2007-09-27 Thread Zentrader
On Sep 27, 9:46 am, Shawn Minisall <[EMAIL PROTECTED]> wrote:
> I am trying to read a few lines of a file with multiple values, the rest
> are single and are reading in fine.
>
> With the multiple value lines, python says this "ValueError: too many
> values to unpack"
>
> I've googled it and it says that happens when you have too few or too
> many strings that don't match with the variables in number your trying
> to assign them too.  Below are the lines in reading in:
>
> line 3 - 19.1829.1578.75212.10
> line 4 - 10020410.29
> And this is the code I'm using:
>
>#read withdrawls from file on line3
>line = infile.readline()
>  #split withdrawls up
>withdraw1, withdraw2, withdraw3, withdraw4 = string.split(line, "\t")
>
>#read deposits from file on line4
>line = infile.readline()
>#split deposits up
>deposit1, deposit2, deposit3 = string.split(line, "\t")
>
> I have 4 strings to match line 3 and 3 to match the 3 on line 4...any
> thoughts?
>
> thx

A string.split returns a list so you don't have to know how many
elements there are beforehand.  A simple example
withdraw = line.split("\t")
if len(withdraw) == 3:
   match_3(withdraw)
elif len(withdraw) == 4::
   match_4(withdraw)
else:
   print "line.split() is not 3 or 4", withdraw

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


Re: Python 3.0 migration plans?

2007-09-27 Thread James Stroud
Steve Holden wrote:
> I wondered if a straw poll could get some idea of readers' thoughts 
> about when they will be migrating to 3.0 on, so I used the new widget on 
> Blogger to add a poll for that.
> 
> I'd appreciate if if you would go to
> 
>   http://holdenweb.blogspot.com/
> 
> and register your vote on your intended migration timescale.
> 
> Thanks!

I'm going to abstain voting until 'public beta + about 1 year' is a choice.

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


Re: Creating Table using Tkinter

2007-09-27 Thread Zentrader

Two existing solutions are TableList + TableListWrapper (Google for
it), and MultiListBox
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52266  In both
cases you send the program the titles and data and the program takes
care of all of the details.  BTW, you can attach a scrollbar to any Tk
app, so that shouldn't be a concern.  See here for some scrollbar
examples.
http://infohost.nmt.edu/tcc/help/pubs/tkinter/

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


Re: Python 3.0 migration plans?

2007-09-27 Thread Richard Jones
Steve Holden wrote:
> I wondered if a straw poll could get some idea of readers' thoughts
> about when they will be migrating to 3.0 on, so I used the new widget on
> Blogger to add a poll for that.
> 
> I'd appreciate if if you would go to
> 
>http://holdenweb.blogspot.com/
> 
> and register your vote on your intended migration timescale.

I'll use the "no plans" response for my actual "no simple answer" real
response.


Richard

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


Re: How to Catch Errors in SimpleXMLRPCServer

2007-09-27 Thread Jeff McNeil
Cool.. glad it works.  Just be careful not to expose methods you may not
want to; use decorators, attributes, or perhaps a custom method naming
scheme to flag methods as exposed if you do it this way.

On 9/27/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> On Sep 27, 5:08 pm, "Jeff McNeil" <[EMAIL PROTECTED]> wrote:
> > Yeah, that code was out of memory and I didn't test it, my apologies.
> > Need to actually return a value from _dispatch.
> >
> > class MyCalls(object):
> >def _dispatch(self, method, args):
> >try:
> >return getattr(self, method)(*args)
> >except:
> >handle_logging()
> >
> > server = SimpleXMLRPCServer(("localhost", 8000))
> > server.register_instance(MyCalls())
> > server.serve_forever()
> >
>
> Thanks, that works.  I'm not sure why I didn't notice it wasn't
> returning anything.
>
> -Greg
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: developing an application

2007-09-27 Thread timaranz
On Sep 28, 10:06 am, yadin <[EMAIL PROTECTED]> wrote:
> hi!
> i was buiding an application using python...a program
> this was my first one...now that i got it working perfectly
> how can i put the bunch of files into one package?
> the user of the appliation will not know where to start? that is which
> file to click on in oder to start the program?
> thanks a lot

Check out py2exe and distutils

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


Re: Importing Module To Use Variables In A Second Module

2007-09-27 Thread Steve Holden
[EMAIL PROTECTED] wrote:
> On 2007-09-27, Steve Holden <[EMAIL PROTECTED]> wrote:
> 
>> Self-evidently you are *not* creating the variables you think you are in
>> the variablePage module. Have you tried an interactive test? Try this at
>> the interpreter prompt:
>>
> import variablePage
> dir(variablePage)
>> and you will see exactly what names the module is defining in its 
>> namespace. You could also try
>>
> variablePage.__file__
>> to make sure that you are importing the module you think you are.
> 
> Steve,
> 
>   Many thanks.
> 
>   I _think_ the problem is that the wxPython objects are not instatiated
> when I'm trying to access the variables. Since they are instance variables,
> they just don't exist yet.
> 
>   Learning just when wxPython objects are instantiated is something I've
> just begun to do.
> 
> Rich

That could be. If they are instance variables, however, you will find 
you have to access them as

 variablePage.instancename.attributename

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

Sorry, the dog ate my .sigline

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


Re: Importing Module To Use Variables In A Second Module

2007-09-27 Thread rshepard
On 2007-09-27, Steve Holden <[EMAIL PROTECTED]> wrote:

> Self-evidently you are *not* creating the variables you think you are in
> the variablePage module. Have you tried an interactive test? Try this at
> the interpreter prompt:
>
> >>> import variablePage
> >>> dir(variablePage)
>
> and you will see exactly what names the module is defining in its 
> namespace. You could also try
>
> >>> variablePage.__file__
>
> to make sure that you are importing the module you think you are.

Steve,

  Many thanks.

  I _think_ the problem is that the wxPython objects are not instatiated
when I'm trying to access the variables. Since they are instance variables,
they just don't exist yet.

  Learning just when wxPython objects are instantiated is something I've
just begun to do.

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


Re: How to Catch Errors in SimpleXMLRPCServer

2007-09-27 Thread [EMAIL PROTECTED]
On Sep 27, 5:08 pm, "Jeff McNeil" <[EMAIL PROTECTED]> wrote:
> Yeah, that code was out of memory and I didn't test it, my apologies.
> Need to actually return a value from _dispatch.
>
> class MyCalls(object):
>def _dispatch(self, method, args):
>try:
>return getattr(self, method)(*args)
>except:
>handle_logging()
>
> server = SimpleXMLRPCServer(("localhost", 8000))
> server.register_instance(MyCalls())
> server.serve_forever()
>

Thanks, that works.  I'm not sure why I didn't notice it wasn't
returning anything.

-Greg


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


Re: getopt with negative numbers?

2007-09-27 Thread Neal Becker
Casey wrote:

> On Sep 27, 2:21 pm, "J. Clifford Dyer" <[EMAIL PROTECTED]> wrote:
>> If you can access the argument list manually, you could scan it for a
>> negative integer, and then insert a '--' argument before that,
>> if needed, before passing it to getopt/optparse.  Then you wouldn't have
>> to worry about it on the command line.
>>
>> Cheers,
>> Cliff
> 
> Brilliant!
> 
> 
> # Look for the first negative number (if any)
> for i,arg in enumerate(sys.argv[1:]):
> # stop if
> if arg[0] != "-": break
> # if a valid number is found insert a "--" string before it
> which
> # explicitly flags to getopt the end of options
> try:
> f = float(arg)
> sys.argv.insert(i+1,"--")
> break;
> except ValueError:
> pass
> 
> 

One person's "brilliant" is another's "kludge".

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


Re: mod_python preprocess/filter before proxy

2007-09-27 Thread Graham Dumpleton
Yes, use PythonInputFilter directive to specify an input filter.

  http://www.modpython.org/live/current/doc-html/dir-filter-if.html

Input filters which modify the length of the data may be an issue
though when doing proxying however.

If you cant work it out, possibly more appropriate to take your
questions to the official mod_python mailing list referenced on the
mod_python site.

Graham

On Sep 27, 9:26 pm, David Sánchez Martín <[EMAIL PROTECTED]> wrote:
> Hi!
>
>   I've seen the message below in this python list, that seems to be
> unanswered.
>
>   I'm trying to do the pretty same thing.
>
>   There's a way to preprocess the request with a mod_python handler and then
> proxying it with mod_proxy?
>
>   Thank you very much in advance, and sorry for trying to revive such an old
> message.
>
> Cheers.
>
>
>
>
>
> >whale whale at mycameo.com
> >Tue Mar 25 05:49:42 CET 2003
>
> >I use Apache2.0.44 and mod_python3.0.1.
> >I add ProxyPass and PythonHandler directives in httpd.conf
> >## httpd.conf
> >ProxyPass  /test/  http://www.test.com
> >ProxyPassReverse  /test/  http://www.test.com
> >
> >AddHandler python-program .htm .html
> >PythonHandler mptest
> >
>
> >And mptest.py:
> >from mod_python import apache
> >def handler(req):
> >req.write('Hello!!')
> >return apache.OK
>
> >ex. My apache server iswww.server.com.
> >When I browsed the local server request(ex.
> >http://www.server.com/1.html),
> >I received 'Hello!!' response, the python handler worked well.
> >But when I browse the proxy request(ex.
> >http://www.server.com/test/1.html),
> >the response I received is the original content of
> >http://www.test.com/1.html, not 'Hello!!'.
> >The proxy requests didn't seem to be processed by mod_python handler.
> >How could I pre-process the proxy request before mod_proxy module?
> >Thanks a lot!!
>
> ---
> David Sanchez Martin
> Administrador de Sistemas
> [EMAIL PROTECTED]
> GPG Key ID: 0x37E7AC1F
>
> E2000 Nuevas Tecnologías
> Tel : +34 902 19 61 77
>
>  David Sánchez Martín.vcf
> 1KDownload
>
>  smime.p7s
> 1KDownload


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


Python 3.0 migration plans?

2007-09-27 Thread Steve Holden
I wondered if a straw poll could get some idea of readers' thoughts 
about when they will be migrating to 3.0 on, so I used the new widget on 
Blogger to add a poll for that.

I'd appreciate if if you would go to

   http://holdenweb.blogspot.com/

and register your vote on your intended migration timescale.

Thanks!
-- 
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

Sorry, the dog ate my .sigline

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


Re: getopt with negative numbers?

2007-09-27 Thread Steven Bethard
Casey wrote:
> Is there an easy way to use getopt and still allow negative numbers as
> args?
[snip]
> Alternatively, does optparse handle this?

Peter Otten wrote:
> optparse can handle options with a negative int value; "--" can be used to
> signal that no more options will follow:
> 
 import optparse
 parser = optparse.OptionParser()
 parser.add_option("-a", type="int")
> 
 options, args = parser.parse_args(["-a", "-42", "--", "-123"])
 options.a
> -42
 args
> ['-123']

In most cases, argparse (http://argparse.python-hosting.com/) supports 
negative numbers right out of the box, with no need to use '--':

 >>> import argparse
 >>> parser = argparse.ArgumentParser()
 >>> parser.add_argument('-a', type=int)
 >>> parser.add_argument('b', type=int)
 >>> args = parser.parse_args('-a -42 -123'.split())
 >>> args.a
 -42
 >>> args.b
 -123


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


Re: making run time changes..

2007-09-27 Thread Gabriel Genellina
En Thu, 27 Sep 2007 13:52:39 -0300, Piyush Jain <[EMAIL PROTECTED]>  
escribi�:

>> I am new(almost) to python. I wish to making a server in which I can
>> make changes at run time. For example , add a method to a
>> class/attribute to object etc. by sending it messages.

To add a new attribute with a name known only at runtime, use setattr  
 either on the class (will  
be a class attribute then) or any individual instance.
To create a new method, just assign a function to the class.
I'd suggest first learning a bit more about Python until you are more  
fluent with the language. (And consider the risk of executing untrusted  
code from the outside).

-- 
Gabriel Genellina

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

Streaming files from python cgi

2007-09-27 Thread Salil Kulkarni
Hello,

I am trying to create a cgi which downloads a pdf/tiff file from an
ftpserver using ftplib.
Everything works until this point.
But, once the file has been retrieved, I want to be able to stream the file
to the browser so that the user gets an option to save it, or open it with
the necessary application. However, I am not able to figure out how this can
be done.

The code looks as follows:

 #!/usr/local/python2.1/bin/python

 import Path, cgi, sys, os
 from ftplib import FTP
 print "content-type: application/pdf\n\n"

  ftp = FTP("hostname", "salil", "passwd")

  try:
  ftp.cwd("/home/salil")
  except:
  print "Could change directory on remote server"
  sys.exit(1)


  f = open("temp.pdf", "w")
  ftp.retrbinary("RETR O_F.pdf", f.write)
  f.close()
  f = open("temp.pdf", "r")
 print f.read()


I am using Apache 1.3 for this cgi. It would be great if someone can point
out how this can be accomplished, or if there are any examples out there
which I can refer to.

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

Re: Importing Module To Use Variables In A Second Module

2007-09-27 Thread Steve Holden
[EMAIL PROTECTED] wrote:
>   I'm stymied by what should be a simple Python task: accessing the value of
> a variable assigned in one module from within a second module. I wonder if
> someone here can help clarify my thinking. I've re-read Chapter 16 (Module
> Basics) in Lutz and Ascher's "Learning Python" but it's not working for me.
> 
>   In one module (the "source"), variablePage.py, three wxPython widgets
> display values that are assigned to variables: curVar, UoDlow, and UoDhigh.
> I want to display then in equivalent widgets on a wxPython notebook tab in a
> different module, the "importer."
> 
>   At the top of the importer module I have:
> 
> from variablePage import curVar, UoDlow, UoDhigh
> 
> and I try to display the values of those variables in widgets on this page.
> But, python complains:
> 
> from variablePage import curVar, UoDlow, UoDhigh
> ImportError: cannot import name curVar
> 
>   I've also tried
> 
> import variablePage as VP
> 
>   and referenced the variables as VP.curVar, VP.UoDlow, and VP.UoDhigh, but
> python still doesn't like this:
> 
>   File "/data1/eikos/fuzSetPage.py", line 364, in loadParVar
> first = VP.curVar
> AttributeError: 'module' object has no attribute 'curVar'
> 
>   Both of these forms are used in the book (pages 260-261) in simple
> examples. I also get errors if I try importing using the class name before
> the variable name.
> 
>   A clue stick would be very helpful since I am not seeing just what I'm
> doing incorrectly.
> 
> Rich

Self-evidently you are *not* creating the variables you think you are in 
the variablePage module. Have you tried an interactive test? Try this at 
the interpreter prompt:

 >>> import variablePage
 >>> dir(variablePage)

and you will see exactly what names the module is defining in its 
namespace. You could also try

 >>> variablePage.__file__

to make sure that you are importing the module you think you are.

Otherwise, do you have circular imports? In other words, does the 
variablePage module by any chance import the module that's trying to 
import *it*? That's also a fruitful source of errors.

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

Sorry, the dog ate my .sigline

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


developing an application

2007-09-27 Thread yadin
hi!
i was buiding an application using python...a program
this was my first one...now that i got it working perfectly
how can i put the bunch of files into one package?
the user of the appliation will not know where to start? that is which
file to click on in oder to start the program?
thanks a lot

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


Re: getopt with negative numbers?

2007-09-27 Thread Casey
On Sep 27, 2:21 pm, "J. Clifford Dyer" <[EMAIL PROTECTED]> wrote:
> If you can access the argument list manually, you could scan it for a 
> negative integer,
> and then insert a '--' argument before that, if needed, before passing it to 
> getopt/optparse.
> Then you wouldn't have to worry about it on the command line.
>
> Cheers,
> Cliff

Brilliant!

# Look for the first negative number (if any)
for i,arg in enumerate(sys.argv[1:]):
# stop if a non-argument is detected
if arg[0] != "-": break
# if a valid number is found insert a "--" string before it which
# explicitly flags to getopt the end of options
try:
f = float(arg)
sys.argv.insert(i+1,"--")
break;
except ValueError:
pass

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


Re: getopt with negative numbers?

2007-09-27 Thread Casey
On Sep 27, 2:21 pm, "J. Clifford Dyer" <[EMAIL PROTECTED]> wrote:
> If you can access the argument list manually, you could scan it for a 
> negative integer, and then insert a '--' argument before that,
> if needed, before passing it to getopt/optparse.  Then you wouldn't have to 
> worry about it on the command line.
>
> Cheers,
> Cliff

Brilliant!


# Look for the first negative number (if any)
for i,arg in enumerate(sys.argv[1:]):
# stop if
if arg[0] != "-": break
# if a valid number is found insert a "--" string before it
which
# explicitly flags to getopt the end of options
try:
f = float(arg)
sys.argv.insert(i+1,"--")
break;
except ValueError:
pass


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


RE: A question on python performance.

2007-09-27 Thread Joe Goldthwaite
[EMAIL PROTECTED] wrote:

>Makes perfect sense to me! Think about it:
>
>method 1: looks up the method directly from the object (fastest)
>method 2: looks up __class__, then looks up __dict__, then gets the
>element from __dict__
>method 3: looks up caller, looks up __class__, looks up __dict__, gets
>element from __dict__
>
>To get the element directly from the object (method 1), Python has to
>internally check __class__.__dict__[element], which shows why method 1
>and method 2 are nearly the same speed. The last version has to look
>up caller in addition to the process described by method 2.
>
>The best way to do what you are doing:
>
>getattr(self, param)(self, *args)

I didn't know about the getattr function. I tried to search for that
type of function but not knowing how to word the search request,
I couldn't find it.  That's a lot cleaner way of doing what I was
trying to do.  I benchmarked it and it's so close in speed to the
hard-coded method as to be identical.

Paul Hankin wrote:

>You're calling a function (getValue) that just calls a method of trend
>(caller), that just calls another method of trend (Ptd or Qtd or ...).
>You can skip all these steps, and just call the method yourself: the
>code that calls getValue(trend, param, per) replace with
>trend.(per) if you're calling getValue with a static value
>for param, or getattr(trend, param)(per) if param is dynamic.

You're right, it makes sense.  Thanks for also pointing out the getattr
function.

Eric Jones wrote:

>What you're describing is a case of mulitple dispatch.  See http://
www.artima.com/weblogs/viewpost.jsp?thread=101605 for a short
>description and (as short) example by Guido.  You can probably fill
>that out and adapt it to your needs.  Alternatively, you could look
>into the multimethods module in the Gnosis Utilities package: http://
>pypi.python.org/pypi/Gnosis_Utils/1.2.1-a

Thanks Eric.  I read that article on multi-methods but I can't say I
really understand it.  I guess I still think of decorators as the people
who got the gym ready for the prom.  I've tried getting up to speed on
decorators but I haven't had much success.  Like I mentioned previously,
with Python, I still feel like a newbie.

Bruno Desthuilliers wrote:

>IOW, direct access to obj.__class__.__dict__ bypasses both inheritence
>and per-instance overriding.

Thanks for your response also Bruno. I don't understand the code you
posted well enough yet to even ask a useful question. There are a number
of things I haven't seen before.  Now I really feel like a newbie!
I'm working on it though so I may have some questions later.

Thanks again for everyone's input. I really appreciate it.






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


Re: Cross-platform time out decorator

2007-09-27 Thread Hrvoje Niksic
"Chris Mellon" <[EMAIL PROTECTED]> writes:

> You can use ctypes and the Python API to raise a Python exception in
> the thread.

How, by changing the thread's exception state?
-- 
http://mail.python.org/mailman/listinfo/python-list


Importing Module To Use Variables In A Second Module

2007-09-27 Thread rshepard
  I'm stymied by what should be a simple Python task: accessing the value of
a variable assigned in one module from within a second module. I wonder if
someone here can help clarify my thinking. I've re-read Chapter 16 (Module
Basics) in Lutz and Ascher's "Learning Python" but it's not working for me.

  In one module (the "source"), variablePage.py, three wxPython widgets
display values that are assigned to variables: curVar, UoDlow, and UoDhigh.
I want to display then in equivalent widgets on a wxPython notebook tab in a
different module, the "importer."

  At the top of the importer module I have:

from variablePage import curVar, UoDlow, UoDhigh

and I try to display the values of those variables in widgets on this page.
But, python complains:

from variablePage import curVar, UoDlow, UoDhigh
ImportError: cannot import name curVar

  I've also tried

import variablePage as VP

  and referenced the variables as VP.curVar, VP.UoDlow, and VP.UoDhigh, but
python still doesn't like this:

  File "/data1/eikos/fuzSetPage.py", line 364, in loadParVar
first = VP.curVar
AttributeError: 'module' object has no attribute 'curVar'

  Both of these forms are used in the book (pages 260-261) in simple
examples. I also get errors if I try importing using the class name before
the variable name.

  A clue stick would be very helpful since I am not seeing just what I'm
doing incorrectly.

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


Re: Creating Table using Tkinter

2007-09-27 Thread Ron Provost
Ankit,

Have you tried the HList (or one of the descendant widgets) in Tix?  The Tix 
library includes quite a few additional widgets and it's part of the 
standard python distribution.

Ron
- Original Message - 
From: "Ankit" <[EMAIL PROTECTED]>
Newsgroups: comp.lang.python
To: 
Sent: Thursday, September 27, 2007 2:42 PM
Subject: Creating Table using Tkinter


> Hi guys i need to make a table to store a certain data using
> Tkinter..I have searched on the group but i have not been able to find
> a solution that would work for me..The thing is that i want my table
> to be scrollable both horizontally and vertically and i also want to
> transmit the data from the table serially to a microcontroller so i
> also need to make sure that i am able to read all the data
> individually..I am writing my code on Windows..my table is dynamic
> that is the number of columns are fixed but the number of rows can
> vary that would depend on the user..Initially i ask him about the
> number of rows...Waiting for your replies..
>
> Regards
> Ankit Anand
>
> -- 
> http://mail.python.org/mailman/listinfo/python-list 

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


Re: How to Catch Errors in SimpleXMLRPCServer

2007-09-27 Thread Jeff McNeil
Yeah, that code was out of memory and I didn't test it, my apologies.
Need to actually return a value from _dispatch.

class MyCalls(object):
   def _dispatch(self, method, args):
   try:
   return getattr(self, method)(*args)
   except:
   handle_logging()

server = SimpleXMLRPCServer(("localhost", 8000))
server.register_instance(MyCalls())
server.serve_forever()

-Jeff


On 9/27

On 9/27/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> On Sep 27, 3:55 pm, "Jeff McNeil" <[EMAIL PROTECTED]> wrote:
> > Instead of register_function, use register_instance and provide a
> > _dispatch method in that instance that handles your exception logging.
> >
> > Pseudo:
> >
> > class MyCalls(object):
> > def _dispatch(self, method, args):
> > try:
> > self.getattr(self, method)(*args)
> > except:
> > handle_logging()
> >
> > server = SimpleXMLRPCServer(("localhost", 8000))
> > server.register_instance(MyCalls())
> > server.serve_forever()
> >
> > There might be an easier way... but this works for me.
>
> I wonder if there is something wrong with that.  I get this error on
> calling ever method:
>
> Fault 1: 'exceptions.TypeError:cannot marshal None unless allow_none
> is enabled' but I can't see anywhere None would be coming from.
>
> -Greg
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to Catch Errors in SimpleXMLRPCServer

2007-09-27 Thread [EMAIL PROTECTED]
On Sep 27, 3:55 pm, "Jeff McNeil" <[EMAIL PROTECTED]> wrote:
> Instead of register_function, use register_instance and provide a
> _dispatch method in that instance that handles your exception logging.
>
> Pseudo:
>
> class MyCalls(object):
> def _dispatch(self, method, args):
> try:
> self.getattr(self, method)(*args)
> except:
> handle_logging()
>
> server = SimpleXMLRPCServer(("localhost", 8000))
> server.register_instance(MyCalls())
> server.serve_forever()
>
> There might be an easier way... but this works for me.

I wonder if there is something wrong with that.  I get this error on
calling ever method:

Fault 1: 'exceptions.TypeError:cannot marshal None unless allow_none
is enabled' but I can't see anywhere None would be coming from.

-Greg


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


Re: Cross-platform time out decorator

2007-09-27 Thread Chris Mellon
On 9/27/07, Hrvoje Niksic <[EMAIL PROTECTED]> wrote:
> Joel <[EMAIL PROTECTED]> writes:
>
> >> Note that, unlike the original alarm code, it doesn't really interrupt
> >> the timed-out method, it just returns the control back to the caller,
> >> using an exception to mark that a timeout occurred.  The "timed out"
> >> code is still merrily running in the background.  I don't know if it's
> >> a problem in your case, but it's an important drawback.
> >
> > There should be a method to stop the thread though?
>
> Not in Python.  Thread killing primitives differ between systems and
> are unsafe in general, so they're not exposed to the interpreter.  On
> Windows you can attempt to use ctypes to get to TerminateThread, but
> you'll need to hack at an uncomfortably low level and be prepared to
> deal with the consequences, such as memory leaks.  If the timeouts
> happen rarely and the code isn't under your control (so you have no
> recourse but to terminate the thread), it might be worth it though.
> --


You can use ctypes and the Python API to raise a Python exception in
the thread. I don't normally mention this, because it has some
limitations, but it results in essentially the same effect as the
signal based method. They both have the limitation that C code can't
be interrupted.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Cross-platform time out decorator

2007-09-27 Thread Hrvoje Niksic
Joel <[EMAIL PROTECTED]> writes:

>> Note that, unlike the original alarm code, it doesn't really interrupt
>> the timed-out method, it just returns the control back to the caller,
>> using an exception to mark that a timeout occurred.  The "timed out"
>> code is still merrily running in the background.  I don't know if it's
>> a problem in your case, but it's an important drawback.
>
> There should be a method to stop the thread though?

Not in Python.  Thread killing primitives differ between systems and
are unsafe in general, so they're not exposed to the interpreter.  On
Windows you can attempt to use ctypes to get to TerminateThread, but
you'll need to hack at an uncomfortably low level and be prepared to
deal with the consequences, such as memory leaks.  If the timeouts
happen rarely and the code isn't under your control (so you have no
recourse but to terminate the thread), it might be worth it though.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ValueError: too many values to unpack,>>>

2007-09-27 Thread J. Clifford Dyer
On Thu, Sep 27, 2007 at 09:50:26PM +0200, Bruno Desthuilliers wrote regarding 
Re: ValueError: too many values to unpack,>>>:
> 
> Shawn Minisall a ?crit :
> > Fredrik Lundh wrote:
> > 
> >> Shawn Minisall wrote:
> >>
> >>  
> >>
> >>> Sorry, it looks like it's on the fourth line with the 3 values on 
> >>> line 4...its reading line 3 fine
> >>>
> >>> Traceback (most recent call last):
> >>>   File "", line 1, in 
> >>> main()
> >>>   File "I:\COMPUTER PROGRAMMING CLASS\PROJECT #1\project1.py", line 
> >>> 33, in main
> >>> deposit1, deposit2, deposit3 = string.split(line, "\t")
> >>> ValueError: too many values to unpack
> >>> 
> >>
> >>
> >> instead of fumbling around in the dark, try inserting a print 
> >> statement before the offending line, so you can see what you're trying 
> >> to unpack:
> >>
> >>  print string.split(line, "\t") # see what it is
> >>  deposit1, deposit2, deposit3 = string.split(line, "\t")
> >>
> >> 
> >>   
> > 
> > I did and it printed everything up until the 3rd line with 3 numbers for 
> > deposits.  I have since figured it out...the teacher put in an extra tab 
> > after the last value so python thought it was 4 values for three.  I 
> > went back into the file and deleted the extra tab after the 3rd number 
> > and saved it...now it's working fine.
> > I'm going to kill her...
> 
> You'd better learn how to deal with "this-cant-happen-here" situation, 
> because it's how it is in real-life.
> 

And preferably learn how to deal with it in your code, not in the data that's 
given to you.  I wouldn't be surprised if your teacher gave you that on 
purpose.  There's an old maxim which I think applies here: "Be liberal in what 
you accept and conservative in what you produce."

Note that you have *not* come up with code that handles the dataset given to 
you by your professor.  Do not expect full marks on this homework assignment, 
unless you go back and modify your code to handle extraneous tabs at the end of 
the line.

Cheers,
Cliff

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


Re: ValueError: too many values to unpack,>>>

2007-09-27 Thread Steve Holden
Shawn Minisall wrote:
> Fredrik Lundh wrote:
>> Shawn Minisall wrote:
>>
>>   
>>> Sorry, it looks like it's on the fourth line with the 3 values on line 
>>> 4...its reading line 3 fine
>>>
>>> Traceback (most recent call last):
>>>   File "", line 1, in 
>>> main()
>>>   File "I:\COMPUTER PROGRAMMING CLASS\PROJECT #1\project1.py", line 33, 
>>> in main
>>> deposit1, deposit2, deposit3 = string.split(line, "\t")
>>> ValueError: too many values to unpack
>>> 
>> instead of fumbling around in the dark, try inserting a print statement 
>> before the offending line, so you can see what you're trying to unpack:
>>
>>  print string.split(line, "\t") # see what it is
>>  deposit1, deposit2, deposit3 = string.split(line, "\t")
>>
>> 
>>   
> I did and it printed everything up until the 3rd line with 3 numbers for 
> deposits.  I have since figured it out...the teacher put in an extra tab 
> after the last value so python thought it was 4 values for three.  I 
> went back into the file and deleted the extra tab after the 3rd number 
> and saved it...now it's working fine. 
> 
> I'm going to kill her...
> 
> ;)
> 
Alternatively you could use the additional argument to split() that 
tells is the maximum number of splits to [erforms, then strip any 
trailing whitespace off before using the values.

That way tou might get an extra mark for not amending the data file. 
It's called "defensive programming", and you need t take it seriously 
(as does everyone who programs).

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

Sorry, the dog ate my .sigline

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


Re: How to Catch Errors in SimpleXMLRPCServer

2007-09-27 Thread Jeff McNeil
getattr, not self.getattr.

On 9/27/07, Jeff McNeil <[EMAIL PROTECTED]> wrote:
> Instead of register_function, use register_instance and provide a
> _dispatch method in that instance that handles your exception logging.
>
> Pseudo:
>
> class MyCalls(object):
> def _dispatch(self, method, args):
> try:
> self.getattr(self, method)(*args)
> except:
> handle_logging()
>
> server = SimpleXMLRPCServer(("localhost", 8000))
> server.register_instance(MyCalls())
> server.serve_forever()
>
> There might be an easier way... but this works for me.
>
> -Jeff
>
> On 9/27/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> > I have a pretty simple XMLRPCServer, something along the lines of the
> > example:
> >
> > server = SimpleXMLRPCServer(("localhost", 8000))
> > server.register_function(pow)
> > server.register_function(lambda x,y: x+y, 'add')
> > server.serve_forever()
> >
> > Now what I want to do is catch any errors that happen on requests, and
> > ideally have them emailed to me.  I have the email part all taken care
> > of, I just need to know how to get at the exceptions.
> >
> > Thanks in advance for any help,
> >
> > Greg
> >
> > --
> > http://mail.python.org/mailman/listinfo/python-list
> >
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to Catch Errors in SimpleXMLRPCServer

2007-09-27 Thread Jeff McNeil
Instead of register_function, use register_instance and provide a
_dispatch method in that instance that handles your exception logging.

Pseudo:

class MyCalls(object):
def _dispatch(self, method, args):
try:
self.getattr(self, method)(*args)
except:
handle_logging()

server = SimpleXMLRPCServer(("localhost", 8000))
server.register_instance(MyCalls())
server.serve_forever()

There might be an easier way... but this works for me.

-Jeff

On 9/27/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> I have a pretty simple XMLRPCServer, something along the lines of the
> example:
>
> server = SimpleXMLRPCServer(("localhost", 8000))
> server.register_function(pow)
> server.register_function(lambda x,y: x+y, 'add')
> server.serve_forever()
>
> Now what I want to do is catch any errors that happen on requests, and
> ideally have them emailed to me.  I have the email part all taken care
> of, I just need to know how to get at the exceptions.
>
> Thanks in advance for any help,
>
> Greg
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ValueError: too many values to unpack

2007-09-27 Thread George Sakkis
On Sep 27, 12:46 pm, Shawn Minisall <[EMAIL PROTECTED]> wrote:
> I am trying to read a few lines of a file with multiple values, the rest
> are single and are reading in fine.
>
> With the multiple value lines, python says this "ValueError: too many
> values to unpack"
>
> I've googled it and it says that happens when you have too few or too
> many strings that don't match with the variables in number your trying
> to assign them too.  Below are the lines in reading in:
>
> line 3 - 19.1829.1578.75212.10
> line 4 - 10020410.29
> And this is the code I'm using:
>
>#read withdrawls from file on line3
>line = infile.readline()
>  #split withdrawls up
>withdraw1, withdraw2, withdraw3, withdraw4 = string.split(line, "\t")
>
>#read deposits from file on line4
>line = infile.readline()
>#split deposits up
>deposit1, deposit2, deposit3 = string.split(line, "\t")
>
> I have 4 strings to match line 3 and 3 to match the 3 on line 4...any
> thoughts?
>
> thx

Just print out the split without unpacking to see how many elements
there are actually present:

print string.split(line, "\t")

By the way, most functions of the string module are deprecated in
favor of string methods; the above is better written as

print line.split("\t")


HTH,
George

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


Re: ValueError: too many values to unpack,>>>

2007-09-27 Thread Bruno Desthuilliers
Shawn Minisall a écrit :
> Fredrik Lundh wrote:
> 
>> Shawn Minisall wrote:
>>
>>  
>>
>>> Sorry, it looks like it's on the fourth line with the 3 values on 
>>> line 4...its reading line 3 fine
>>>
>>> Traceback (most recent call last):
>>>   File "", line 1, in 
>>> main()
>>>   File "I:\COMPUTER PROGRAMMING CLASS\PROJECT #1\project1.py", line 
>>> 33, in main
>>> deposit1, deposit2, deposit3 = string.split(line, "\t")
>>> ValueError: too many values to unpack
>>> 
>>
>>
>> instead of fumbling around in the dark, try inserting a print 
>> statement before the offending line, so you can see what you're trying 
>> to unpack:
>>
>>  print string.split(line, "\t") # see what it is
>>  deposit1, deposit2, deposit3 = string.split(line, "\t")
>>
>> 
>>   
> 
> I did and it printed everything up until the 3rd line with 3 numbers for 
> deposits.  I have since figured it out...the teacher put in an extra tab 
> after the last value so python thought it was 4 values for three.  I 
> went back into the file and deleted the extra tab after the 3rd number 
> and saved it...now it's working fine.
> I'm going to kill her...

You'd better learn how to deal with "this-cant-happen-here" situation, 
because it's how it is in real-life.

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


Re: How to Catch Errors in SimpleXMLRPCServer

2007-09-27 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit :
> I have a pretty simple XMLRPCServer, something along the lines of the
> example:
> 
> server = SimpleXMLRPCServer(("localhost", 8000))
> server.register_function(pow)
> server.register_function(lambda x,y: x+y, 'add')
> server.serve_forever()
> 
> Now what I want to do is catch any errors that happen on requests, and
> ideally have them emailed to me.  I have the email part all taken care
> of, I just need to know how to get at the exceptions.

Q&D :

try:
   server.serve_forever()
except Exception, e:
   mail_me_the_exception(e)
   raise
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Script to extract text from PDF files

2007-09-27 Thread Svenn Are Bjerkem
On Sep 26, 11:50 pm, [EMAIL PROTECTED] wrote:
> On Sep 26, 4:49 pm, Svenn Are Bjerkem <[EMAIL PROTECTED]>
> wrote:
>
> > I have downloaded this package and installed it and found that the
> > text-extraction is more or less useless. Looking into the code and
> > comparing with the PDF spec show a very early implementation of text
> > extraction. Luckily it is possible to overwrite the textextraction
> > method in the base class without having to fiddle with the original
> > code. I tried to contact the developer to offer some help on
> > implementing text extraction, but he didn't answer my emails.
> > --
> > Svenn
>
> Well, feel free to send any ideas or help to me! It seems simple... Do
> a binary read. Find 'stream' and 'endstream' sections.
> zlib.decompress() all the streams. Find BT and ET markers (Begin Text
> & End Text) and finally locate the parens within those and string the
> text together. This works great on 3 out of 10 PDF documents, but my
> main issue seems to be the zlib compressed streams. Some of them don't
> seem to be FlateDecodeable (although they claim to be) or the header
> is somehow incorrect. But, once I get a good stream and decompress it,
> things are OK from that point on. Seriously, if you have ideas, please
> let me know. I'll be glad to share what I've got so far.

So far I have found that extracting text from the IEEE journal papers
is not as simple as described above. The IEEE journals are typesetting
things in typical journal style with two columns body text and one
column abstract and a blob of header and author information. Take
figures and formulas and footnotes and spread them around in the
journal and you are basically using all block text layout commands
there is in PDF.

I wanted to to get the pdftotext from xpdf package to see what that
tool does to the IEEE pdfs in order to see if I should dive into the
sources to see what they do to get things right. So far I have not got
this far. Purpose of my work was to extract the abstract of each paper
to put into a database for later search, but IEEE also has a search
engine on their journal DVD => postpone python work.

Got my gentoo machine back on track so that may maybe change
again..
--
Svenn

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


How to Catch Errors in SimpleXMLRPCServer

2007-09-27 Thread [EMAIL PROTECTED]
I have a pretty simple XMLRPCServer, something along the lines of the
example:

server = SimpleXMLRPCServer(("localhost", 8000))
server.register_function(pow)
server.register_function(lambda x,y: x+y, 'add')
server.serve_forever()

Now what I want to do is catch any errors that happen on requests, and
ideally have them emailed to me.  I have the email part all taken care
of, I just need to know how to get at the exceptions.

Thanks in advance for any help,

Greg

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


Re: getopt with negative numbers?

2007-09-27 Thread Nanjundi
On Sep 27, 1:34 pm, Peter Otten <[EMAIL PROTECTED]> wrote:
...
> >>> args
>
> ['-123']
>
> Without the "--" arg you will get an error:
>
> >>> parser.parse_args(["-123"])
>
> Usage:  [options]
>
> : error: no such option: -1
> $
>
> Peter

Passing -a-123 works
>>> options, args = parser.parse_args(["-a-123"])
>>> options.a
-123

-N

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


Re: Launching command on windows

2007-09-27 Thread kyosohma
On Sep 27, 10:46 am, Alexandre Badez <[EMAIL PROTECTED]>
wrote:
> On Sep 27, 4:20 pm, [EMAIL PROTECTED] wrote:
>
>
>
> > I got it to work using subprocess.Popen
>
> > Not sure why it doesn't work with os.system though.
>
> > Mike
>
> Thanks Mike and Mauro,
>
> Mauro, your solution do not seems to work (or I made a mistake..)
> Mike your solution work great, thanks.
> But, I steel think it's a bug (python or window ??).
> I will try to take a look about it, when I have time.
>
> Alex

Some of those spawn methods from the os module don't work on Windows
although that one doesn't seem to be one of the excluded:
http://docs.python.org/lib/os-process.html.

You should use subprocess regardless as the os.system and os.spawn*
calls are to be deprecated.

http://docs.python.org/lib/module-subprocess.html

Replacing os.Popen* and os.spawn* calls with subprocess:
http://docs.python.org/lib/node534.html
http://docs.python.org/lib/node537.html

Mike

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


Re: ValueError: too many values to unpack,>>>

2007-09-27 Thread Shawn Minisall
Fredrik Lundh wrote:
> Shawn Minisall wrote:
>
>   
>> Sorry, it looks like it's on the fourth line with the 3 values on line 
>> 4...its reading line 3 fine
>>
>> Traceback (most recent call last):
>>   File "", line 1, in 
>> main()
>>   File "I:\COMPUTER PROGRAMMING CLASS\PROJECT #1\project1.py", line 33, 
>> in main
>> deposit1, deposit2, deposit3 = string.split(line, "\t")
>> ValueError: too many values to unpack
>> 
>
> instead of fumbling around in the dark, try inserting a print statement 
> before the offending line, so you can see what you're trying to unpack:
>
>  print string.split(line, "\t") # see what it is
>  deposit1, deposit2, deposit3 = string.split(line, "\t")
>
> 
>   
I did and it printed everything up until the 3rd line with 3 numbers for 
deposits.  I have since figured it out...the teacher put in an extra tab 
after the last value so python thought it was 4 values for three.  I 
went back into the file and deleted the extra tab after the 3rd number 
and saved it...now it's working fine. 

I'm going to kill her...

;)

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


Re: An Editor that Skips to the End of a Def

2007-09-27 Thread Bruno Desthuilliers
Neil Cerutti a écrit :
(snip)
> 
> Vim has Python integration if you want to control it with Python
> scripts. Cool! Of course, Vim needs such a capability more than
> Emacs, which has the very cool elisp scripting language.

FWIW, emacs is programmable in Python too IIRC.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: True of False

2007-09-27 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit :
> I tried writing a true and false If statement and didn't get
> anything?  I read some previous posts, but I must be missing
> something.  I just tried something easy:
> 
> a = ["a", "b", "c", "d", "e", "f"]
> 
> if "c" in a == True:
>  Print "Yes"
> 
> When I run this, it runs, but nothing prints.  What am I doing wrong?

See other answers for the details. Anyway, since '"c" in a' is already a 
boolean expression, testing the result of the evaluation of this 
expression against a boolean is a pure waste of time. The usual idiom - 
and this is definitively not Python-specific - is:

if "c" in a:
   print "Yes"

Also, in Python (and in some other languages too), there's a notion of 
"something" vs "nothing" - where, in a boolean context, "something" 
evals to true and "nothing" to false. wrt/ Python, the empty string, an 
empty container (list, tuple, dict, set etc), numerical zero's (int or 
float), and of course the None object all eval to false, and most other 
objects eval to true.
-- 
http://mail.python.org/mailman/listinfo/python-list


Creating Table using Tkinter

2007-09-27 Thread Ankit
Hi guys i need to make a table to store a certain data using
Tkinter..I have searched on the group but i have not been able to find
a solution that would work for me..The thing is that i want my table
to be scrollable both horizontally and vertically and i also want to
transmit the data from the table serially to a microcontroller so i
also need to make sure that i am able to read all the data
individually..I am writing my code on Windows..my table is dynamic
that is the number of columns are fixed but the number of rows can
vary that would depend on the user..Initially i ask him about the
number of rows...Waiting for your replies..

Regards
Ankit Anand

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


Re: getopt with negative numbers?

2007-09-27 Thread J. Clifford Dyer
If you can access the argument list manually, you could scan it for a negative 
integer, and then insert a '--' argument before that, if needed, before passing 
it to getopt/optparse.  Then you wouldn't have to worry about it on the command 
line. 

Cheers,
Cliff

On Thu, Sep 27, 2007 at 08:08:05PM +0200, Peter Otten wrote regarding Re: 
getopt with negative numbers?:
> 
> Casey wrote:
> 
> > On Sep 27, 1:34 pm, Peter Otten <[EMAIL PROTECTED]> wrote:
> >> optparse can handle options with a negative int value; "--" can be used
> >> to signal that no more options will follow:
> > 
> > Thanks, Peter.  getopt supports the POSIX "--" end of options indicator
> > as well, but that seems a little less elegant than being able to simply
> > set a value that tells the parser "I don't use any numeric values as
> > options, and I want to allow negative values as arguments".  At the
> > parser level implemening this would be trivial and I frankly was hoping
> > it had been implemented and it just wasn't mentioned in the spares
> > Python getopt library reference.
> 
> After a quick glance into the getopt and optparse modules I fear that both
> hardcode the "if it starts with '-' it must be an option" behaviour.
> 
> Peter
> -- 
> http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ValueError: too many values to unpack,>>>

2007-09-27 Thread Fredrik Lundh
Shawn Minisall wrote:

> Sorry, it looks like it's on the fourth line with the 3 values on line 
> 4...its reading line 3 fine
> 
> Traceback (most recent call last):
>   File "", line 1, in 
> main()
>   File "I:\COMPUTER PROGRAMMING CLASS\PROJECT #1\project1.py", line 33, 
> in main
> deposit1, deposit2, deposit3 = string.split(line, "\t")
> ValueError: too many values to unpack

instead of fumbling around in the dark, try inserting a print statement 
before the offending line, so you can see what you're trying to unpack:

 print string.split(line, "\t") # see what it is
 deposit1, deposit2, deposit3 = string.split(line, "\t")



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


Re: getopt with negative numbers?

2007-09-27 Thread Peter Otten
Casey wrote:

> On Sep 27, 1:34 pm, Peter Otten <[EMAIL PROTECTED]> wrote:
>> optparse can handle options with a negative int value; "--" can be used
>> to signal that no more options will follow:
> 
> Thanks, Peter.  getopt supports the POSIX "--" end of options indicator
> as well, but that seems a little less elegant than being able to simply
> set a value that tells the parser "I don't use any numeric values as
> options, and I want to allow negative values as arguments".  At the
> parser level implemening this would be trivial and I frankly was hoping
> it had been implemented and it just wasn't mentioned in the spares
> Python getopt library reference.

After a quick glance into the getopt and optparse modules I fear that both
hardcode the "if it starts with '-' it must be an option" behaviour.

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


Re: True of False

2007-09-27 Thread Marc Christiansen
Casey <[EMAIL PROTECTED]> wrote:
> I would recommend the OP try this:
> 
> run the (I)python shell and try the following:
> 
 a = [x for x in "abcdefg"]
 a
> ['a','b','c','d','e','f','g']
 "c" in a
> True
 "c" in a == True
> False
 ("c" in a) == True
> True
> 
> The reason your conditional failed is that it was interpreted as "c"
> in (a == True) which is False.

That was my first thought, too. But watch:
  >>> a = list("abcde")
  >>> a
  ['a', 'b', 'c', 'd', 'e']
  >>> "c" in (a == True)
  Traceback (most recent call last):
File "", line 1, in 
  TypeError: argument of type 'bool' is not iterable

Then it dawned on me (is this the right phrase?): It's the same situation
as e.g. x < y >= 1, which means the same as "x < y and y >= 1" (except
that y is only evaluated once). So '"c" in a == True' gets evaluated as
'"c" in a and a == True'.

> the "==" operator binds at a higher precedence level than the "in"
> operator, just as multiplication binds higher than addition

Operator precedence plays no role in this case. It is a case of
'chained' comparisons.

Hope that clears it up
Marc
-- 
http://mail.python.org/mailman/listinfo/python-list


HOT!!!PYTHON DEVELOPER REQUIRED @ ADOBE SYSTEMS

2007-09-27 Thread Recruiter-Adobe
Hi PYTHON DEVELOPERS,

ADOBE SYSTEMS is looking for a PYTHON DEVELOPER who can troubleshoot
Python based applet which makes data base queries and populates Excel
tables used to generate pivot charts, graphs and tables showing bug
metrics. Isolate problem which is causing reports to crash and
institute fix.

 This is a position through Manpower at our customer Adobe Systems,
you will be employed as a Manpower's contractor.

Job Responsibilities:

· Setup a new server (development environment)

· Install updated versions of both python and other plugins
used for our applet.

· Import Code/applet  instance.

· Remove code that uploads it to the Production Server
Instance

· Eventually move the entire Production Instance over to the
newer server.

· Update Code to comply with the latest Python standards

Knowledge & Skills:

· Expert in Python Programming

· Experience in COM Object programming speficially Excel COM
Objects

· Experience in using WebServices (SOAP)

· Win2k System Administration Experience a Plus

· Need to migrate from version 2.3 to latest version of Python

Hourly Pay rate: $85-$100/hr

If interested, please send a Word copy of your resumeto
[EMAIL PROTECTED] with your expected hourly rate, availability,
visa status, best time and phone # to contact you.

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


Re: True of False

2007-09-27 Thread Marc 'BlackJack' Rintsch
On Thu, 27 Sep 2007 17:06:30 +, Duncan Booth wrote:

> Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
> 
>> In [268]: 'c' in a == True
>> Out[268]: False
>> 
>> In [269]: ('c' in a) == True
>> Out[269]: True
>> 
>> In [270]: 'c' in (a == True)
>> ---
>>  
>> Traceback (most recent call
>>last) 
>> 
>> /home/bj/ in ()
>> 
>>: argument of type 'bool' is not iterable
>> 
>> 
>> What's going on there?
> 
> See http://docs.python.org/ref/comparisons.html
> 
>> Comparisons can be chained arbitrarily, e.g., x < y <= z is equivalent
>> to x < y and y <= z, except that y is evaluated only once (but in both
>> cases z is not evaluated at all when x < y is found to be false). 
> 
> In exactly the same way:
> 
>'c' in a == True
> 
> is equivalent to:
> 
>'c' in a and a == True
> 
> which is False.

Aaah *enlightenment*, I'm using this for range checks like in the docs,
but it wasn't obvious to me in this case.  Thanks.

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


Re: ValueError: too many values to unpack,>>>

2007-09-27 Thread Shawn Minisall
Marc 'BlackJack' Rintsch wrote:
> On Thu, 27 Sep 2007 12:36:58 -0400, Shawn Minisall wrote:
>
>   
>> With the multiple value lines, python says this "ValueError: too many 
>> values to unpack"
>>
>> I've googled it and it says that happens when you have too few or too 
>> many strings that don't match with the variables in number your trying 
>> to assign them too.  Below are the lines in reading in:
>>
>> line 3 - 19.1829.1578.75212.10
>> line 4 - 10020410.29   
>>
>> And this is the code I'm using:
>>
>> #read withdrawls from file on line3
>> line = infile.readline()
>>
>> #split withdrawls up
>> withdraw1, withdraw2, withdraw3, withdraw4 = string.split(line, "\t")
>>
>> #read deposits from file on line4
>> line = infile.readline()
>> #split deposits up
>> deposit1, deposit2, deposit3 = string.split(line, "\t")
>>
>> I have 4 strings to match line 3 and 3 to match the 3 on line 4...any 
>> thoughts?
>> 
>
> First thought is to find out which of the two lines triggers the
> exception.  This information is part of the full traceback.
>
> Ciao,
>   Marc 'BlackJack' Rintsch
>   

Sorry, it looks like it's on the fourth line with the 3 values on line 
4...its reading line 3 fine

Traceback (most recent call last):
  File "", line 1, in 
main()
  File "I:\COMPUTER PROGRAMMING CLASS\PROJECT #1\project1.py", line 33, 
in main
deposit1, deposit2, deposit3 = string.split(line, "\t")
ValueError: too many values to unpack

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


Re: How do I get the value out of a DOM Element

2007-09-27 Thread Stefan Behnel
kj7ny wrote:
> Forgot to mention I'm using Python 2.4.3.

You can install both lxml and ET on Python 2.4 (and 2.3). It's just that ET
went into the stdlib from 2.5 on.

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


Re: getopt with negative numbers?

2007-09-27 Thread Casey
On Sep 27, 1:34 pm, Peter Otten <[EMAIL PROTECTED]> wrote:
> optparse can handle options with a negative int value; "--" can be used to
> signal that no more options will follow:

Thanks, Peter.  getopt supports the POSIX "--" end of options
indicator as well, but that seems a little less elegant than being
able to simply set a value that tells the parser "I don't use any
numeric values as options, and I want to allow negative values as
arguments".  At the parser level implemening this would be trivial and
I frankly was hoping it had been implemented and it just wasn't
mentioned in the spares Python getopt library reference.

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


Re: True of False

2007-09-27 Thread Erik Jones

On Sep 27, 2007, at 12:29 PM, Erik Jones wrote:

>
> On Sep 27, 2007, at 11:47 AM, Marc 'BlackJack' Rintsch wrote:
>
>> On Thu, 27 Sep 2007 09:33:34 -0700, koutoo wrote:
>>
>>> I tried writing a true and false If statement and didn't get
>>> anything?  I read some previous posts, but I must be missing
>>> something.  I just tried something easy:
>>>
>>> a = ["a", "b", "c", "d", "e", "f"]
>>>
>>> if "c" in a == True:
>>>  Print "Yes"
>>>
>>> When I run this, it runs, but nothing prints.  What am I doing  
>>> wrong?
>>
>> Wow that's odd:
>>
>> In [265]: a = list('abcdef')
>>
>> In [266]: a
>> Out[266]: ['a', 'b', 'c', 'd', 'e', 'f']
>>
>> In [267]: 'c' in a
>> Out[267]: True
>>
>> In [268]: 'c' in a == True
>> Out[268]: False
>>
>> In [269]: ('c' in a) == True
>> Out[269]: True
>>
>> In [270]: 'c' in (a == True)
>> - 
>> -
>> -
>>  Traceback (most recent
>> call last)
>>
>> /home/bj/ in ()
>>
>> : argument of type 'bool' is not  
>> iterable
>>
>>
>> What's going on there?
>
> That is weird.  Given 270, what's happening in 268.
>
> Erik Jones

Cool, Richard Thomas answered this one for me.

Erik Jones

Software Developer | Emma®
[EMAIL PROTECTED]
800.595.4401 or 615.292.5888
615.292.0777 (fax)

Emma helps organizations everywhere communicate & market in style.
Visit us online at http://www.myemma.com


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


Re: getopt with negative numbers?

2007-09-27 Thread Peter Otten
Casey wrote:

> Is there an easy way to use getopt and still allow negative numbers as
> args?  I can easily write a workaround (pre-process the tail end of
> the arguments, stripping off any non-options including negative
> numbers into a separate sequence and ignore the (now empty) args list
> returned by getopt, but it would seem this is such a common
> requirement that there would be an option to treat a negative value as
> an argument.  Note that this is only a problem if the first non-option
> is a negative value, since getopt stops processing options as soon as
> it identifies the first argument value.
> 
> Alternatively, does optparse handle this?  I haven't used optparse (I
> know it is more powerful and OO, but you tend to stick with what you
> know, especially when it is part of my normal python programming
> template), but if it handles negative numbers I'm willing to learn it.

optparse can handle options with a negative int value; "--" can be used to
signal that no more options will follow:

>>> import optparse
>>> parser = optparse.OptionParser()
>>> parser.add_option("-a", type="int")

>>> options, args = parser.parse_args(["-a", "-42", "--", "-123"])
>>> options.a
-42
>>> args
['-123']

Without the "--" arg you will get an error:

>>> parser.parse_args(["-123"])
Usage:  [options]

: error: no such option: -1
$

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


Re: True of False

2007-09-27 Thread Gary Herron
Richard Thomas wrote:
> On 27/09/2007, Casey <[EMAIL PROTECTED]> wrote:
>   
>> On Sep 27, 12:48 pm, "Simon Brunning" <[EMAIL PROTECTED]>
>> wrote:
>> 
>>> On 9/27/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>>>
>>>   
 I tried writing a true and false If statement and didn't get
 anything?  I read some previous posts, but I must be missing
 something.  I just tried something easy:
 
 a = ["a", "b", "c", "d", "e", "f"]
 
 if "c" in a == True:
  Print "Yes"
 
 When I run this, it runs, but nothing prints.  What am I doing wrong?
 
>>> Just use
>>>
>>> if "c" in a:
>>>
>>> and all will be well. The True object isn't the only truthy value in
>>> Python - see .
>>>   
>> I would recommend the OP try this:
>>
>> run the (I)python shell and try the following:
>>
>> 
> a = [x for x in "abcdefg"]
> a
>   
>> ['a','b','c','d','e','f','g']
>> 
> "c" in a
>   
>> True
>> 
> "c" in a == True
>   
>> False
>> 
> ("c" in a) == True
>   
>> True
>>
>> The reason your conditional failed is that it was interpreted as "c"
>> in (a == True) which is False.
>> the "==" operator binds at a higher precedence level than the "in"
>> operator, just as multiplication
>> binds higher than addition
>>
>> 
>
> Actually it evaluates '("c" in a) and (a == True)'. You can check like so:
>
> import dis
> a = list("abcdef")
> dis.dis(lambda: "c" in a == True)
>
> And just follow the bytecode operations.
>   
Yikes.  So I did that and you're correct.   I've always looked at
chained comparisons with mild suspicion.  Now I guess that suspicion is
justified.  Interpreting
a -- Richard.
>
>   
>> --
>> http://mail.python.org/mailman/listinfo/python-list
>>
>> 

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


Re: True of False

2007-09-27 Thread Erik Jones

On Sep 27, 2007, at 11:47 AM, Marc 'BlackJack' Rintsch wrote:

> On Thu, 27 Sep 2007 09:33:34 -0700, koutoo wrote:
>
>> I tried writing a true and false If statement and didn't get
>> anything?  I read some previous posts, but I must be missing
>> something.  I just tried something easy:
>>
>> a = ["a", "b", "c", "d", "e", "f"]
>>
>> if "c" in a == True:
>>  Print "Yes"
>>
>> When I run this, it runs, but nothing prints.  What am I doing wrong?
>
> Wow that's odd:
>
> In [265]: a = list('abcdef')
>
> In [266]: a
> Out[266]: ['a', 'b', 'c', 'd', 'e', 'f']
>
> In [267]: 'c' in a
> Out[267]: True
>
> In [268]: 'c' in a == True
> Out[268]: False
>
> In [269]: ('c' in a) == True
> Out[269]: True
>
> In [270]: 'c' in (a == True)
> -- 
> -
>  Traceback (most recent  
> call last)
>
> /home/bj/ in ()
>
> : argument of type 'bool' is not iterable
>
>
> What's going on there?

That is weird.  Given 270, what's happening in 268.

Erik Jones

Software Developer | Emma®
[EMAIL PROTECTED]
800.595.4401 or 615.292.5888
615.292.0777 (fax)

Emma helps organizations everywhere communicate & market in style.
Visit us online at http://www.myemma.com


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


Re: True of False

2007-09-27 Thread Casey
On Sep 27, 1:12 pm, "Richard Thomas" <[EMAIL PROTECTED]> wrote:
> On 27/09/2007, Casey <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Sep 27, 12:48 pm, "Simon Brunning" <[EMAIL PROTECTED]>
> > wrote:
> > > On 9/27/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> > > > I tried writing a true and false If statement and didn't get
> > > > anything?  I read some previous posts, but I must be missing
> > > > something.  I just tried something easy:
>
> > > > a = ["a", "b", "c", "d", "e", "f"]
>
> > > > if "c" in a == True:
> > > >  Print "Yes"
>
> > > > When I run this, it runs, but nothing prints.  What am I doing wrong?
>
> > > Just use
>
> > > if "c" in a:
>
> > > and all will be well. The True object isn't the only truthy value in
> > > Python - see .
>
> > I would recommend the OP try this:
>
> > run the (I)python shell and try the following:
>
> > >>> a = [x for x in "abcdefg"]
> > >>> a
> > ['a','b','c','d','e','f','g']
> > >>> "c" in a
> > True
> > >>> "c" in a == True
> > False
> > >>> ("c" in a) == True
> > True
>
> > The reason your conditional failed is that it was interpreted as "c"
> > in (a == True) which is False.
> > the "==" operator binds at a higher precedence level than the "in"
> > operator, just as multiplication
> > binds higher than addition
>
> Actually it evaluates '("c" in a) and (a == True)'. You can check like so:
>
> import dis
> a = list("abcdef")
> dis.dis(lambda: "c" in a == True)
>
> And just follow the bytecode operations.
>
> -- Richard.
>
> > --
> >http://mail.python.org/mailman/listinfo/python-list

Doh, I forgot about operator chaining here.  I'm so used to just
seeing a < b < c that I forget about arbitrary operator chaining and
think like a C++ programmer!

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


getopt with negative numbers?

2007-09-27 Thread Casey
Is there an easy way to use getopt and still allow negative numbers as
args?  I can easily write a workaround (pre-process the tail end of
the arguments, stripping off any non-options including negative
numbers into a separate sequence and ignore the (now empty) args list
returned by getopt, but it would seem this is such a common
requirement that there would be an option to treat a negative value as
an argument.  Note that this is only a problem if the first non-option
is a negative value, since getopt stops processing options as soon as
it identifies the first argument value.

Alternatively, does optparse handle this?  I haven't used optparse (I
know it is more powerful and OO, but you tend to stick with what you
know, especially when it is part of my normal python programming
template), but if it handles negative numbers I'm willing to learn it.

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


Re: True of False

2007-09-27 Thread Carsten Haese
On Thu, 2007-09-27 at 16:47 +, Marc 'BlackJack' Rintsch wrote:
> On Thu, 27 Sep 2007 09:33:34 -0700, koutoo wrote:
> 
> > I tried writing a true and false If statement and didn't get
> > anything?  I read some previous posts, but I must be missing
> > something.  I just tried something easy:
> > 
> > a = ["a", "b", "c", "d", "e", "f"]
> > 
> > if "c" in a == True:
> >  Print "Yes"
> > 
> > When I run this, it runs, but nothing prints.  What am I doing wrong?
> 
> Wow that's odd:
> 
> In [265]: a = list('abcdef')
> 
> In [266]: a
> Out[266]: ['a', 'b', 'c', 'd', 'e', 'f']
> 
> In [267]: 'c' in a
> Out[267]: True
> 
> In [268]: 'c' in a == True
> Out[268]: False
> 
> In [269]: ('c' in a) == True
> Out[269]: True
> 
> In [270]: 'c' in (a == True)
> ---
>  Traceback (most recent call last)
> 
> /home/bj/ in ()
> 
> : argument of type 'bool' is not iterable
> 
> 
> What's going on there?

What's going on here is that both 'in' and '==' are comparison
operations, and Python allows you to chain comparisons. Just like "a < x
< b" is evaluated as "a < x and x < b", "'c' in a == True" is evaluated
as "'c' in a and a == True". Obviously, since a==True is false, the
chained comparison is False.

-- 
Carsten Haese
http://informixdb.sourceforge.net


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


Re: True of False

2007-09-27 Thread Richard Thomas
On 27/09/2007, Casey <[EMAIL PROTECTED]> wrote:
> On Sep 27, 12:48 pm, "Simon Brunning" <[EMAIL PROTECTED]>
> wrote:
> > On 9/27/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> >
> > > I tried writing a true and false If statement and didn't get
> > > anything?  I read some previous posts, but I must be missing
> > > something.  I just tried something easy:
> >
> > > a = ["a", "b", "c", "d", "e", "f"]
> >
> > > if "c" in a == True:
> > >  Print "Yes"
> >
> > > When I run this, it runs, but nothing prints.  What am I doing wrong?
> >
> > Just use
> >
> > if "c" in a:
> >
> > and all will be well. The True object isn't the only truthy value in
> > Python - see .
>
> I would recommend the OP try this:
>
> run the (I)python shell and try the following:
>
> >>> a = [x for x in "abcdefg"]
> >>> a
> ['a','b','c','d','e','f','g']
> >>> "c" in a
> True
> >>> "c" in a == True
> False
> >>> ("c" in a) == True
> True
>
> The reason your conditional failed is that it was interpreted as "c"
> in (a == True) which is False.
> the "==" operator binds at a higher precedence level than the "in"
> operator, just as multiplication
> binds higher than addition
>

Actually it evaluates '("c" in a) and (a == True)'. You can check like so:

import dis
a = list("abcdef")
dis.dis(lambda: "c" in a == True)

And just follow the bytecode operations.

-- Richard.

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


Re: True of False

2007-09-27 Thread Steve Holden
[EMAIL PROTECTED] wrote:
> I tried writing a true and false If statement and didn't get
> anything?  I read some previous posts, but I must be missing
> something.  I just tried something easy:
> 
> a = ["a", "b", "c", "d", "e", "f"]
> 
> if "c" in a == True:
>  Print "Yes"
> 
> When I run this, it runs, but nothing prints.  What am I doing wrong?
> Thanks.

You are unnecessarily adding a comparison with True. The correct way to 
write that is

if "c" in a:
   print "yes"

Bu of course you haven't actually told us what you really did, because 
the code you represent has syntax errors.

 >>> a = ["a", "b", "c", "d", "e", "f"]
 >>> "c" in a
True
 >>> if "c" in a == True:
...print "found it"
...
 >>> if ("c" in a) == True:
... print "At last!"
...
At last!
 >>>
-- 
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

Sorry, the dog ate my .sigline

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


Re: True of False

2007-09-27 Thread Duncan Booth
Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:

> In [268]: 'c' in a == True
> Out[268]: False
> 
> In [269]: ('c' in a) == True
> Out[269]: True
> 
> In [270]: 'c' in (a == True)
> ---
>  
> Traceback (most recent call
>last) 
> 
> /home/bj/ in ()
> 
>: argument of type 'bool' is not iterable
> 
> 
> What's going on there?

See http://docs.python.org/ref/comparisons.html

> Comparisons can be chained arbitrarily, e.g., x < y <= z is equivalent
> to x < y and y <= z, except that y is evaluated only once (but in both
> cases z is not evaluated at all when x < y is found to be false). 

In exactly the same way:

   'c' in a == True

is equivalent to:

   'c' in a and a == True

which is False.


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


Re: True of False

2007-09-27 Thread Casey
On Sep 27, 12:48 pm, "Simon Brunning" <[EMAIL PROTECTED]>
wrote:
> On 9/27/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> > I tried writing a true and false If statement and didn't get
> > anything?  I read some previous posts, but I must be missing
> > something.  I just tried something easy:
>
> > a = ["a", "b", "c", "d", "e", "f"]
>
> > if "c" in a == True:
> >  Print "Yes"
>
> > When I run this, it runs, but nothing prints.  What am I doing wrong?
>
> Just use
>
> if "c" in a:
>
> and all will be well. The True object isn't the only truthy value in
> Python - see .

I would recommend the OP try this:

run the (I)python shell and try the following:

>>> a = [x for x in "abcdefg"]
>>> a
['a','b','c','d','e','f','g']
>>> "c" in a
True
>>> "c" in a == True
False
>>> ("c" in a) == True
True

The reason your conditional failed is that it was interpreted as "c"
in (a == True) which is False.
the "==" operator binds at a higher precedence level than the "in"
operator, just as multiplication
binds higher than addition


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


Re: Implement file download using python

2007-09-27 Thread skulka3
On Sep 27, 11:39 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:
>  [EMAIL PROTECTED] wrote:
> > Hello,
>
> > I want to implement file downloads inside an authenticated web page,
> > such that when a user clicks a link, the server side python code
> > connects to a ftp server, downloads a relevant file and then streams
> > the file to the browser for the user to open it with the appropriate
> > application. In this case it will either be a pdf or a tiff file.
>
> > This function is quite similar to something like writing raw bytes to
> > a ServletOutputStream in java to be rendered directly to the user.
>
> > It would be nice if someone can provide guidance, examples on how such
> > a task may be accomplished using python.
>
> Fetching using ftplib is easy. But serving depends on what
> HTTP-server-environment you use. Please elaborate on that.
>
> Diez

Thanks Diez for your reply.
I am comfortable with using ftplib to fetch the file. As for the HTTP-
server environment,
I am using Apache 1.3 web server and python 2.1.3.

Salil.

Salil.

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


Re: comparing elements of a list with a string

2007-09-27 Thread Marc 'BlackJack' Rintsch
On Thu, 27 Sep 2007 08:16:59 -0400, Steve Holden wrote:

> Shriphani wrote:
>> Hello,
>> Would that mean that if I wanted to append all the (date, time) tuples
>> to a list, I should do something like:
>> 
>> for file in list_of_backup_files:
>> some_list.append(file)
> 
> That would be one way to do it (assuming you started with some_list as 
> an empty list). But a faster way would be to use a list comprehension 
> and say
> 
> some_list = [f for f in list_of_backup_files]

Or:

some_list = list(list_of_backup_files)

If `some_list` is not empty:

some_list.extend(list_of_backup_files)

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


Re: True of False

2007-09-27 Thread Shriphani

[EMAIL PROTECTED] wrote:
> I tried writing a true and false If statement and didn't get
> anything?  I read some previous posts, but I must be missing
> something.  I just tried something easy:
>
> a = ["a", "b", "c", "d", "e", "f"]
>
> if "c" in a == True:
>  Print "Yes"
>
> When I run this, it runs, but nothing prints.  What am I doing wrong?
> Thanks.
>
> Kou

Hello,
Just try :

a = ["a","b","c","d","e","f"]
if "c" in a:
print "yes"

That is going to work as the statement '"c" in a' itself is true. You
could try that by typing "c" in a at the interpreter.

regards,
Shriphani Palakodety

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


Re: True of False

2007-09-27 Thread Marc 'BlackJack' Rintsch
On Thu, 27 Sep 2007 09:33:34 -0700, koutoo wrote:

> I tried writing a true and false If statement and didn't get
> anything?  I read some previous posts, but I must be missing
> something.  I just tried something easy:
> 
> a = ["a", "b", "c", "d", "e", "f"]
> 
> if "c" in a == True:
>  Print "Yes"
> 
> When I run this, it runs, but nothing prints.  What am I doing wrong?

Wow that's odd:

In [265]: a = list('abcdef')

In [266]: a
Out[266]: ['a', 'b', 'c', 'd', 'e', 'f']

In [267]: 'c' in a
Out[267]: True

In [268]: 'c' in a == True
Out[268]: False

In [269]: ('c' in a) == True
Out[269]: True

In [270]: 'c' in (a == True)
---
 Traceback (most recent call last)

/home/bj/ in ()

: argument of type 'bool' is not iterable


What's going on there?

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


Re: True of False

2007-09-27 Thread skulka3
On Sep 27, 11:33 am, [EMAIL PROTECTED] wrote:
> I tried writing a true and false If statement and didn't get
> anything?  I read some previous posts, but I must be missing
> something.  I just tried something easy:
>
> a = ["a", "b", "c", "d", "e", "f"]
>
> if "c" in a == True:
>  Print "Yes"
>
> When I run this, it runs, but nothing prints.  What am I doing wrong?
> Thanks.
>
> Kou

,
You may want to include paren around ("c" in a) and a lower case p for
Print, i.e. print, and  it should work

so eg:
a = ["a", "b", "c", "d", "e", "f"]

 if ("c" in a) == True:
  print "Yes"

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


Re: True of False

2007-09-27 Thread Simon Brunning
On 9/27/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> I tried writing a true and false If statement and didn't get
> anything?  I read some previous posts, but I must be missing
> something.  I just tried something easy:
>
> a = ["a", "b", "c", "d", "e", "f"]
>
> if "c" in a == True:
>  Print "Yes"
>
> When I run this, it runs, but nothing prints.  What am I doing wrong?

Just use

if "c" in a:

and all will be well. The True object isn't the only truthy value in
Python - see .

-- 
Cheers,
Simon B.
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


ValueError: too many values to unpack

2007-09-27 Thread Shawn Minisall
I am trying to read a few lines of a file with multiple values, the rest 
are single and are reading in fine.

With the multiple value lines, python says this "ValueError: too many 
values to unpack"

I've googled it and it says that happens when you have too few or too 
many strings that don't match with the variables in number your trying 
to assign them too.  Below are the lines in reading in:

line 3 - 19.1829.1578.75212.10
line 4 - 10020410.29  
And this is the code I'm using:

   #read withdrawls from file on line3
   line = infile.readline()
 #split withdrawls up
   withdraw1, withdraw2, withdraw3, withdraw4 = string.split(line, "\t")

   #read deposits from file on line4
   line = infile.readline()
   #split deposits up
   deposit1, deposit2, deposit3 = string.split(line, "\t")

I have 4 strings to match line 3 and 3 to match the 3 on line 4...any 
thoughts?

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


Re: ValueError: too many values to unpack,>>>

2007-09-27 Thread Marc 'BlackJack' Rintsch
On Thu, 27 Sep 2007 12:36:58 -0400, Shawn Minisall wrote:

> With the multiple value lines, python says this "ValueError: too many 
> values to unpack"
> 
> I've googled it and it says that happens when you have too few or too 
> many strings that don't match with the variables in number your trying 
> to assign them too.  Below are the lines in reading in:
> 
> line 3 - 19.1829.1578.75212.10
> line 4 - 10020410.29   
> 
> And this is the code I'm using:
> 
> #read withdrawls from file on line3
> line = infile.readline()
>
> #split withdrawls up
> withdraw1, withdraw2, withdraw3, withdraw4 = string.split(line, "\t")
> 
> #read deposits from file on line4
> line = infile.readline()
> #split deposits up
> deposit1, deposit2, deposit3 = string.split(line, "\t")
> 
> I have 4 strings to match line 3 and 3 to match the 3 on line 4...any 
> thoughts?

First thought is to find out which of the two lines triggers the
exception.  This information is part of the full traceback.

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


RE: making run time changes..

2007-09-27 Thread Piyush Jain
Hi,
It seems that pyro provides remote access to object acting as middleware. My
requirement is a bit different. It need not be remote. But I need to make
run time changes at the running program, say changing it's functionality.
More in lines of dynamic modules, but triggered by messages from outside.

Regards,
Piyush

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Steve Holden
Sent: Thursday, September 27, 2007 9:05 PM
To: python-list@python.org
Subject: Re: making run time changes..

Piyush Jain wrote:
> Hi,
> 
> I am new(almost) to python. I wish to making a server in which I can 
> make changes at run time. For example , add a method to a 
> class/attribute to object etc. by sending it messages.
> 
> Can anyone help me with what features to look into and how to go about 
> it. Are there any similar projects?
> 
Take a look at Pyro (Python remote objects). It can almost certainly do 
what you want.

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

Sorry, the dog ate my .sigline

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

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


  1   2   >