Re: 2**2**2**2**2 wrong? Bug?

2007-07-10 Thread Erik Max Francis
Jim Langston wrote:

> Gah!  Python goes right to left?  Dang, I haven't seen that since APL.

For the ** operator, and with good reason:  Left-associative ** doesn't 
really serve much useful purpose, since (a**b)**c == a**(b*c), so if one 
writes a**b**c, one usually means a**(b**c), or they would have written 
it more efficiently and clearly.

-- 
Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/
  San Jose, CA, USA && 37 20 N 121 53 W && AIM, Y!M erikmaxfrancis
   Men with empires in their purpose / And new eras in their brains
-- Lamya
-- 
http://mail.python.org/mailman/listinfo/python-list


standalone executables

2007-07-10 Thread Navid Parvini
  Dear All,
 
I need a reference to get all the programs which used to package Python 
programs into standalone executables files.
 Would you help me?
 
Thank you in advance.
  Navid
  
  
-
Park yourself in front of a world of choices in alternative vehicles.
Visit the Yahoo! Auto Green Center.-- 
http://mail.python.org/mailman/listinfo/python-list

Re: What is the most efficient way to test for False in a list?

2007-07-10 Thread Duncan Booth
Paul Rubin  wrote:

> "Diez B. Roggisch" <[EMAIL PROTECTED]> writes:
>> >> status = all(list)
>> > 
>> > Am I mistaken, or is this no identity test for False at all?
>> 
>> You are mistaken. all take an iterable and returns if each value of
>> it is true.
> 
> all(list) does what the OP's code did, tests for the presence of a
> false value in the list.  If you want an identity test, use 
> 
>   status = not (False in list)

That is an equality test, not an identity test:

>>> False in [0]
True

as others have said, if you need an identity test use:

 any(x is False for x in theList)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Error when trying to write unicode xml to zipfile

2007-07-10 Thread Stefan Behnel
Gabriel Genellina wrote:
> En Mon, 09 Jul 2007 20:11:24 -0300, Martin <[EMAIL PROTECTED]>
> escribió:
> 
>> I get below error when trying to write unicode xml to a zipfile.
>>
>> zip.writestr('content.xml', content.toxml())
>>   File "/usr/lib/python2.4/zipfile.py", line 460, in writestr
>> zinfo.CRC = binascii.crc32(bytes)   # CRC-32 checksum
>> UnicodeEncodeError: 'ascii' codec can't encode character u'\u25cf' in
>> position 2848: ordinal not in range(128)
>>
>> Any ideas?
> 
> Encode before writing. Assuming you want to use utf-8:
> zip.writestr('content.xml', content.toxml().encode('utf-8'))

Unless, obviously, you were serialising to a non-utf8 encoding. But since the
"toxml()" method seems to return unicode here (which sounds surprising), I
expect it a) to provide no XML declaration at all or b) to be broken anyway.

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


Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-07-10 Thread Diez B. Roggisch
Paul Rubin schrieb:
> "Diez B. Roggisch" <[EMAIL PROTECTED]> writes:
>>> Which implies that even in ADA, runtime type errors are in fact
>>> expected - else there would be no handler for such a case.
>> Well, yes, runtime errors occur - in statically typed languages as
>> well. That's essentially the halting-problem.
> 
> Well, no, it's quite possible for a language to reject every program
> that has any possibility of throwing a runtime type error.  The
> halting problem implies that no algorithm can tell EXACTLY which
> programs throw errors and which do not.  So the language cannot accept
> all programs that are free of runtime type errors and reject all
> programs that definitely have runtime type errors, with no uncertain
> cases.  But it's fine for a language to reject uncertain cases and
> accept only those which it can rigorously demonstrate have no type
> errors.

Sure. But which class of programs are decidable? There's lot's of 
research going on with model checking and the like. But AFAIK, the 
consensus is that the very moment you allow recursive types, the 
type-checking is either incomplete, or possibly non-deterministic. Which 
makes then the compiler hang.

Diez

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


Re: What is the most efficient way to test for False in a list?

2007-07-10 Thread Paul Rubin
Duncan Booth <[EMAIL PROTECTED]> writes:
> >   status = not (False in list)
> 
> That is an equality test, not an identity test:
> 
> >>> False in [0]
> True

Arrh!  Strongly typed language, my eye ;-)  Thanks.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Error when trying to write unicode xml to zipfile

2007-07-10 Thread Martin v. Löwis
> Unless, obviously, you were serialising to a non-utf8 encoding. But since the
> "toxml()" method seems to return unicode here (which sounds surprising), I
> expect it a) to provide no XML declaration at all or b) to be broken anyway.

Or c) the user forgot to specify the encoding= parameter in toxml().

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


Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-07-10 Thread Paul Rubin
"Diez B. Roggisch" <[EMAIL PROTECTED]> writes:
> Sure. But which class of programs are decidable? There's lot's of
> research going on with model checking and the like. But AFAIK, the
> consensus is that the very moment you allow recursive types, the
> type-checking is either incomplete, or possibly
> non-deterministic. Which makes then the compiler hang.

Type checking is already undecidable in many mainstream languages
including C++.  Nonetheless people manage to use those languages.

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


Re: Should I use Python for these programs?

2007-07-10 Thread Hendrik van Rooyen
 "CC" <[EMAIL PROTECTED]> wrote:

> 
> I have considerable C and assembly language experience.  However, these 
> are mostly on embedded microcontrollers since I moved away from PC 
> programming all the way back in 1988 :-O

Your experience parallels mine, except that mine has a surfeit of assembler...

> 
> I wish to accomplish a few PC programming tasks, and am considering to 
> learn Python:

go for it - you will be delighted with the simplicity of the complex stuff,
and irritated at the hoops that you have to jump through to do low level stuff,
but the trade off is worth the pain.

> 
> 1.  Develop a simple GUI program to run on Linux and Windows which can 
> send parameters and small blocks of data to an embedded microcontroller 
> device via RS-232 or USB.  Also display simple data (probably single 
> numbers) sent from the device.

If you spend a bit of money on a Lantronix Xport, you can use ethernet,
and then the linux/windows problems goes away - as sockets seem to 
"just work"

> 
> Note, if it is USB, then the client will be implemented by me using FTDI 
> chips that appear to the PC as a serial port.
> 
> 2.  Develop a simple vector drawing program that will allow one to 
> freehand draw a sketch composed of a few lines, or perhaps render text 
> in a vector form.  Then sample the lines with a certain (user 
> configurable) spacing, and use the mouse to move the sample points along 
> the lines to tweak the sample locations if desired.  Then output a file 
> of X,Y coordinates for the samples.
> 
> What is this crazy thing for?  It's to develop simple lasershow vector 
> frames.  I am also designing a DSP-based lasershow output device, so the 
> same capabilities of delivering a data payload over serial/USB to a 
> target device will be needed here as well.
> 
> I would prefer to be able to write a program that is cross-platform 
> between Linux and Windows.  I realize this might be especially 
> problematic with the serial comms.

true - its not quite the same.

> 
> I am also confused by the plethora of Python GUI extensions, though 
> Tkinter seems like a likely candidate.  I am uncertain if I will have 
> difficulty learning how to use this if I don't know Tcl/Tk.

No - there are excellent examples and docs available on the web.
Unless you are doing something very fancy, you dont "need" to know Tcl.

The development cycle is fast, and if you get stuck you can get help
here - this is a super group of people (said he modestly...   :- )  )

> 
> Do you think Python is the right language for these projects?

Yes - I am in the process of finishing an Injection Moulding Machine 
Controller, with the GUI in tkinter (cos its in the standard library),
with some crude animation of the machine functions - and it all "just works"

In my case, the OS is linux, and the interface is serial - but then I am not 
trying for cross platform compatibility. - I have implemented a sliding
window full duplex reliable protocol, so it is possible to use Python to 
talk to a serial device. (at 115200, so its not "that" slow)

> 
> Any input will be appreciated.
> 

hth - Hendrik



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


Re: Where is the syntax for the dict() constructor ?! (OT)

2007-07-10 Thread Hendrik van Rooyen
 "Steve Holden" <[EMAIL PROTECTED]> wrote:

> Sorry - dreadful joke. Since teeth chew, I wondered whether esteeth 
> might eschew. [Graon ...]
> 

*grin* 

*Wonders if he can extend this troll to get Steve to explain what "teeth" are.*

; - ) 

- Hendrik

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


Re: S2K DTS and Python

2007-07-10 Thread Tim Golden
Phil Runciman wrote:
> I am a Python newbie so please be gentle on me.

Welcome to Python.

> I have created a program that takes text files within a directory and it
> successfully parses the information from them to create 3 CSV files.

Good so far.

> However, I now want to update some tables in MSAccess, and it occurred
> to me that because Sequel Server 2000 DTS can interface with scripting
> languages that maybe I could call my first Python program from within
> DTS and then update the tables using DTS. (I am learning DTS hence the
> idea).

Unless you *really* wanted to learn DTS (and I don't find it
that useful myself) then simply do this through Python... and
have some fun at the same time :)

> My questions are:
> 
> Has anyone used Python within DTS?

Haven't, but I wouldn't even try. Unless I were constrained
by some kind of contractual binding, I wouldn't even *start*
using DTS if I could use Python. I find it far too opaque.

> Am I off the wall trying such a thing?

No, but I think it's easier to use the csv module, pyodbc [1]
and either code the SQL directly, which is what I tend to do, or
use one of the several SQL-ORM-style wrappers around: SQLObject[2],
sqlalchemy[3] and its friend Elixir[4], or the newly-advertised
Storm[5] from Canonical.

Feel free to post back with questions or progress.

TJG

[1] http://pyodbc.sf.net
[2] http://www.sqlobject.org/
[3] http://sqlalchemy.org
[4] http://elixir.ematia.de/
[5] https://storm.canonical.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Simple operator associativity and precedence rules (was: 2**2**2**2**2 wrong? Bug?)

2007-07-10 Thread Ben Finney
"Jim Langston" <[EMAIL PROTECTED]> writes:

> 2**2 = 4
> 4**2 = 16
> 16**2 = 256
> 256**2 = 65536
> 65536**2 = 4294967296
>
> In fact, if I put (2**2)**2**2**2
> it comes up with the correct answer, 4294967296

I have never gone wrong with mathematical expressions since I reduced
the set of operator associativity and precedence rules to these:

  1. Addition and subtraction have the same precedence, and are
 left-to-right associative

  2. Multiplication and division have the same precedence, and are
 left-to-right associative

  3. Use parentheses to make explicit all other precedence and
 associativity

The specific programming language I use at any given moment might
follow more complex rules, but I ignore them in favour of the above
set. I thus spend less time uselessly thinking about tasks I should be
delegating to explicit expression syntax, and am never surprised by a
misunderstood mathematical associativity or precedence rule.

-- 
 \"A hundred times every day I remind myself that [...] I must |
  `\   exert myself in order to give in the same measure as I have |
_o__) received and am still receiving"  -- Albert Einstein |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Comparing modified elements in Sets

2007-07-10 Thread Asun Friere
On Jul 10, 5:57 am, [EMAIL PROTECTED] wrote:
> I'd like to be able to compare set 1 with set 2 and have it match
> filename1 and filename3, or compare set 1 with 3 and get back
> filename1, filename2.  etc.
>
> Is there a way for me to do this inside the compare function, rather
> than having to make duplicate copies of each set?

Is there a will?
Inevitably there is a way! Whether you should take it is another
question entirely. ;)

Assuming by 'compare' function you mean such methods as 'difference,'
'symetric_difference', 'intersection' and the like... here's a nasty
little hack (using the old-school Set from sets.py)  It's not to spec
(you get the tails back in the result, but that's easily fixed), and
it only implements a replacement method for 'difference' (called
'tailess_difference).

I apologise if the google groups mailer kludges the indentation ...
-
from sets import Set
from itertools import ifilterfalse
from os.path import splitext

class BodgySet (Set) :

def tailess_difference (self, other) :
"""Return, as a new BodgySet, the difference of two
sets, where element identity ignores all characters
from the last stop (period).

NOTE: As currently implemented all elements of said
sets must be strings (fix this in self.has_key)!!!

"""
assert other.__class__ is self.__class__
result = self.__class__()
data = result._data
value = True
for elt in ifilterfalse(other.has_key, self) :
data[elt] = value
return result

def has_key (self, target) :
thead, ttail = splitext(target)
for key in self._data.keys() :
khead, ktail = splitext(key)
if thead == khead :
return True
-

Using this hacked set:
>>> a = BodgySet(['a1.txt', 'a2.txt'])
>>> b = BodgySet(['a1.xml', 'a2.xml', 'a3.xml'])
>>> b.tailess_difference(a)
BodgySet(['a3.xml'])

Is that the kind of thing you had in mind?

While it can be done, I would prefer to make copies of the sets, with
a cast list comprehension something like:  set([os.path.splitext(x)[0]
for x in orig_set]).  Much better readibility and probably greater
efficiency (I haven't bothered timing or dissing it mind).

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


Re: Simple operator associativity and precedence rules (was: 2**2**2**2**2 wrong? Bug?)

2007-07-10 Thread Steven D'Aprano
On Tue, 10 Jul 2007 18:05:49 +1000, Ben Finney wrote:

> I have never gone wrong with mathematical expressions since I reduced
> the set of operator associativity and precedence rules to these:
> 
>   1. Addition and subtraction have the same precedence, and are
>  left-to-right associative
> 
>   2. Multiplication and division have the same precedence, and are
>  left-to-right associative
> 
>   3. Use parentheses to make explicit all other precedence and
>  associativity
> 
> The specific programming language I use at any given moment might follow
> more complex rules, but I ignore them in favour of the above set. I thus
> spend less time uselessly thinking about tasks I should be delegating to
> explicit expression syntax, and am never surprised by a misunderstood
> mathematical associativity or precedence rule.


However... floating point issues can still bite you. _Neither_ floating 
point addition nor multiplication are associative, or rather, they are 
not *always* associative. And it doesn't take weird examples, complicated 
formulae, or wildly differing numbers to find examples:


>>> 0.1*(0.2*0.3) == (0.1*0.2)*0.3
False
>>> 0.1+(0.2+0.3) == (0.1+0.2)+0.3
False

(Depending on the version of Python, operating system, chip set, 
underlying C libraries and solar tides, your millage may vary.)


The difference between the left and right hand sides are small, but real. 
Or rather, float. *wink*


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


Re: Building a Python app with Mozilla

2007-07-10 Thread greg
[EMAIL PROTECTED] wrote:
> Last I looked (3.1-ish), Qt didn't use the Aqua widgets but rather
> tried to write their own widgets that looked (kinda) like the MacOS
> widgets.

That might be so, but even if it had used real Aqua widgets,
the same problem would have occurred.

My point was that using native widgets is not in itself
enough to ensure a native experience. There are conventions
about *how* the widgets are used, and other things about
the behaviour that don't relate to widgets at all.

Native widgets are certainly a better thing to start
from, though.

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


Transfer folders to ftp

2007-07-10 Thread Laurentiu
hi!

i am new to python and i made some digging about how
to send files and folders to ftp server.

i manage to send a file, but i don't know how to send
folders with subfolders in it.

please, can someone help me to accomplish this tasks:

1. send a folder with subfolders to ftp server.
2. make the program invisible... running hide
3. send only folder that is different to the host

i know that this tasks can be easily accomplish with a
sync program, but i want to make this in python.

thanks a lot





___ 
New Yahoo! Mail is the ultimate force in competitive emailing. Find out more at 
the Yahoo! Mail Championships. Plus: play games and win prizes. 
http://uk.rd.yahoo.com/evt=44106/*http://mail.yahoo.net/uk 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: standalone executables

2007-07-10 Thread Daniel Nogradi
> I need a reference to get all the programs which used to package Python
> programs into standalone executables files.
>  Would you help me?


windows: http://www.py2exe.org/
mac: http://cheeseshop.python.org/pypi/py2app/
linux: http://wiki.python.org/moin/Freeze
linux/windows: http://python.net/crew/atuining/cx_Freeze/

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


Re: trouble controlling vim with subprocess on windows machine

2007-07-10 Thread agc
Hi Josiah,

> >> This recipe for asynchronous communication usingsubprocesscould be
> >> used to write an expect-like tool:
> >>http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440554

I have played with the above recipe and it is excellent,
but could you please go into some more detail about what is needed
to make a cross platform [p]expect like (non-pty based) tool?

Specifically, could you describe how you would connect to
*another* interactive Python process with your subclass of
subprocess.Popen?
i.e:

a = Popen('python', stdin=?, stdout=?, stderr=?)
#now run an interactive session with 'a'

I have tried several combinations of the above and I seem
to be stuck on the fact that python is interacting with a
'tty', not 'std*'.  Maybe I'm missing a basic piece?

Thanks for any input,
Alex


> >> It works on both Windows and *nix.
>
> >>   - Josiah
>
> > I had the original dir work but when I tried to trade it out with vim
> > it isn't clear
> > how I should call it..  vim filename and it doesn't find filename for
> > some reason.
> > I called it pipe and then
>
> > inport pipe
>
> > def load_instrument3(instr_name, csd_name):
> >   if sys.platform == 'win32':
> > shell, commands, tail = ('gvim' + csd_name, (csd_name,
> > csd_name), '\r\n')
> >   else:
> > shell, commands, tail = ('sh', ('ls', 'echo HELLO WORLD'),
> > '\n')
>
> >   a = pipe.Popen(shell, stdin=pipe.PIPE, stdout=pipe.PIPE)
> >   print pipe.recv_some(a),
> >   for cmd in commands:
> > pipe.send_all(a, csd_name)
> > print pipe.recv_some(a),
> >   pipe.send_all(a, csd_name)
> >   print pipe.recv_some(a, e=0)
> >   a.wait()
>
> The example uses a platform-specific shell in order to use the
> environment variable PATH to discover the executable to run.  If you
> know the exact path to your binary ('gvim' for you), it should work.
> As-is, your program would require a binary with the name 'gvim'+csd_name
> in the same path as the script you are executing.
>
>   - Josiah


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


Re: Portable general timestamp format, not 2038-limited

2007-07-10 Thread greg
Ilya Zakharevich wrote:
> In pedantic mode: negative timestamps make sense with Big Bang as the
> epoch as well.  (AFAIU, the current way of thinking is that it was
> "just too hot" before the big bang, it is not that "there was
> nothing".)

If Stephen Hawking is right, the shape of the universe
is such that there isn't any time "before" the big bang
at all. It's like asking what's north of the North Pole.

Of course, this may have been replaced with some other
equally bizarre idea by now...

Another thought: If the cosmologists ever decide if
and when the Big Crunch is going to happen, we may be
able to figure out once and for all how many bits we
need in the timestamp.

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


Re: xmlrpclib hangs execution

2007-07-10 Thread Arno Stienen
Hi Andy,

Your patches solves the problem too. Thanks!

One thing: if I use the unpatched xmlrpclib.py, the printed output of 
xml calls look like:

{'state': 0, 'str': 'Info_RT'}

But if I use your patch, they look like:

state0strInfo_RT

I prefer the former, as it is easier to extract the info. Why did this 
change with your patch?

Bye,
Arno.



itkovian wrote:
> I think a better fix than the one I posted below is using the
> HTTPConnection library, as opposed to the HTTP library from httplib.
> 
> A patch can be found below:
> 
> --- /sw/lib/python2.5/xmlrpclib.py  2006-11-29 02:46:38.0
> +0100
> +++ xmlrpclib.py2007-06-15 16:03:17.0 +0200
> @@ -1182,23 +1182,13 @@
>  self.send_user_agent(h)
>  self.send_content(h, request_body)
> 
> -errcode, errmsg, headers = h.getreply()
> +response = h.getresponse()
> +
> +if response.status != 200:
> +  raise ProtocolError(host + handler, response.status,
> response.reason, response.msg.headers)
> 
> -if errcode != 200:
> -raise ProtocolError(
> -host + handler,
> -errcode, errmsg,
> -headers
> -)
> -
> -self.verbose = verbose
> -
> -try:
> -sock = h._conn.sock
> -except AttributeError:
> -sock = None
> -
> -return self._parse_response(h.getfile(), sock)
> +payload = response.read()
> +return payload
> 
>  ##
>  # Create parser.
> @@ -1250,7 +1240,7 @@
>  # create a HTTP connection object from a host descriptor
>  import httplib
>  host, extra_headers, x509 = self.get_host_info(host)
> -return httplib.HTTP(host)
> +return httplib.HTTPConnection(host)
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Get a filename list of a web site

2007-07-10 Thread aidechamp
Hi all,
is it possible to get a filename directory list of a website (possibly
with full path indication)?
Using python & possibly wget?

Bye.

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


Re: object references/memory access

2007-07-10 Thread greg
Dennis Lee Bieber wrote:

>   If a process is known to be CPU bound, I think it is typical
> practice to "nice" the process... Lowering its priority by direct
> action.

Yes, but one usually only bothers with this for long-running
tasks. It's a nicety, not an absolute requirement.

It seems like this would have been an even more important
issue in the timesharing environments where unix originated.
You wouldn't want everyone's text editors suddenly starting
to take half a second to respond to keystrokes just because
someone launched "cc -O4 foo.c" without nicing it.

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


Re: "Empty" text

2007-07-10 Thread Nick Craig-Wood
Miles <[EMAIL PROTECTED]> wrote:
>  On Jul 9, 4:30 am, Nick Craig-Wood <[EMAIL PROTECTED]> wrote:
> > Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
> > >  On Sun, 08 Jul 2007 22:23:20 +0200, Jan Danielsson wrote:
> > > >Firefox is very unhappy about the textarea not having separate
> > > > opening and a closing tags. i.e. I need this:
> > >
> > >  Then either Firefox is broken or you don't declare your XHTML properly 
> > > and
> > >  Firefox thinks it's HTML.
> >
> > I suspect the former - we noticed exactly the same thing (can't
> > remember which tags we were having problems with), using the
> > declaration :-
> >
> >   
> >>   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
> >
> > I haven't tested this again recently though.
> 
>  Firefox is not broken.  The XML prolog and DOCTYPE do not affect HTML
>  vs. XHTML interpretation--only the Content-Type does.  If you are
>  serving a page as "text/html", which you almost certainly are, then
>  all browsers will parse it as HTML, regardless of prolog and doctype,
>  and HTML does not support self-closing tags.  You need to serve the
>  page as "application/xhtml+xml", or avoid self-closing tags on
>  elements other than , , , etc.
> 
>  http://www.w3.org/TR/xhtml1/#C_3

Ah very good - that solves that mystery - thank you!

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


Can I Redirect debug output from HTTPConnection to a file?

2007-07-10 Thread Harel
I'm using httplib.HTTPConnection to perform http connections and
during the beta period of the application I wanted to log its verbose
output [set_debuglevel(5)]. However, raising the debuglevel just
outputs it to stdout. can I redirect that to a file? My app uses the
logging module for logging and I'd like to use that to log into the
standard log it generates.

Any ideas?
Thanks,
Harel

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


Your message to Pyro-users awaits moderator approval

2007-07-10 Thread pyro-users-bounces
Your mail to 'Pyro-users' with the subject

test

Is being held until the list moderator can review it for approval.

The reason it is being held:

Post by non-member to a members-only list

Either the message will get posted to the list, or you will receive
notification of the moderator's decision.  If you would like to cancel
this posting, please visit the following URL:


http://emergent.brynmawr.edu/mailman/confirm/pyro-users/b516bf2af8963d4ecb9bf5598ad61f36f94235f3

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


Re: "Empty" text

2007-07-10 Thread André
On Jul 8, 5:23 pm, Jan Danielsson <[EMAIL PROTECTED]> wrote:
> Hello all,
>
>I'm using mod_python+ElementTree to build XHTML pages. But I stumbled
> across this problem:
>
> 
> def foo(req, desc = None):
>
>...
>
>tr = ET.SubElement(tbl, "tr")
>th = ET.SubElement(tr, "th")
>th.text = "Description"
>td = ET.SubElement(tr, "td")
>ta = ET.SubElement(td, "textarea", name="desc", rows="8",
> cols="64")
>if desc is None:
>   desc = ''
>ta.text = desc
> 
>
>The problem is that this generates the following code:
>
>   
> Description
> 
>   
> 
>   
>
>Firefox is very unhappy about the textarea not having separate
> opening and a closing tags. i.e. I need this:
>
>   
>
>I understand the opitmization ElementTree is performing; but it seems
> there are cases when it is not the proper thing to do. Is it possible to
>  force ElementTree to output the XHTML code I need it to?
>
> --
> Kind regards,
> Jan Danielsson

I ran into the same problem and a workaround I found was to use either
ta.text = " "   or ta.text = "\n" instead of ta.text = ''.
For my application, it did the right thing; your mileage may vary.

André

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

Professional Grant Proposal Writing Workshop (September 2007: Simon Fraser University)

2007-07-10 Thread Anthony Jones


The Grant Institute's Grants 101: Professional Grant Proposal Writing Workshop will be held at Simon Fraser University at Harbour Centre, September 12 - 14
, 2007. Interested development professionals, researchers, faculty, and graduate students should register as soon as possible, as demand means that seats will fill up quickly. Please forward, post, and distribute this e-mail to your colleagues and listservs. 
 
All participants will receive certification in professional grant writing from the Institute. For more information call (213) 817 - 5308 or visit The Grant Institute at www.thegrantinstitute.com.
 
Please find the program description below:
 
The Grant Institute
Grants 101: Professional Grant Proposal Writing Workshop
will be held at
Simon Fraser University at Harbour Centre
Vancouver,  British Columbia
September 12 - 14, 2007
8:00 AM - 5:00 PM
 

The Grant Institute's Grants 101 course is an intensive and detailed introduction to the process, structure, and skill of professional proposal writing. This course is characterized by its ability to act as a thorough overview, introduction, and refresher at the same time. In this course, participants will learn the entire proposal writing process and complete the course with a solid understanding of not only the ideal proposal structure, but a holistic understanding of the essential factors, 
which determine whether or not a program gets funded. Through the completion of interactive exercises and activities, participants will complement expert lectures by putting proven techniques into practice. This course is designed for both the beginner looking for a thorough introduction and the intermediate looking for a refresher course that will strengthen their grant acquisition skills. This class, simply put, is designed to get results by creating professional grant proposal writers. 

 
Participants will become competent program planning and proposal writing professionals after successful completion of the Grants 101 course. In three active and informative days, students will be exposed to the art of successful grant writing practices, and led on a journey that ends with a masterful grant proposal. 
 
Grants 101 consists of three (3) courses that will be completed during the three-day workshop. 
 
(1) Fundamentals of Program Planning
 
This course is centered on the belief that "it's all about the program." This intensive course will teach professional program development essentials and program evaluation. While most grant writing "workshops" treat program development and evaluation as separate from the writing of a proposal, this class will teach students the relationship between overall program planning and grant writing. 
 
(2) Professional Grant Writing
 

Designed for both the novice and experienced grant writer, this course will make each student an overall proposal writing specialist. In addition to teaching the basic components of a grant proposal, successful approaches, and the do's and don'ts of grant writing, this course is infused with expert principles that will lead to a mastery of the process. Strategy resides at the forefront of this course's intent to illustrate grant writing as an integrated, multidimensional, and dynamic endeavor. 
Each student will learn to stop writing the grant and to start writing the story. Ultimately, this class will illustrate how each component of the grant proposal represents an opportunity to use proven techniques for generating support.
 
(3) Grant Research
 

At its foundation, this course will address the basics of foundation, corporation, and government grant research. However, this course will teach a strategic funding research approach that encourages students to see research not as something they do before they write a proposal, but as an integrated part of the grant seeking process. Students will be exposed to online and database research tools, as well as publications and directories that contain information about foundation, corporation, and 
government grant opportunities. Focusing on funding sources and basic social science research, this course teaches students how to use research as part of a strategic grant acquisition effort.
 
Registration
$597.00 USD tuition includes all materials and certificates.
 
Each student will receive:
*The Grant Institute Certificate in Professional Grant Writing
*The Grant Institute's Guide to Successful Grant Writing
*The Grant Institute Grant Writer's Workbook with sample proposals, forms, and outlines
 
Registration Methods
 
1) On-Line - Complete the online registration form at www.thegrantinstitute.com under Register Now. We'll send your confirmation by e-mail. 
 
2) By Phone - Call (213) 817 - 5308 to register by phone. Our friendly Program Coordinators will be happy to assist you and answer your questions. 
 
3) By E-mail - Send an e-mail with your name, organization, and basic contact information to [EMAIL PROTECTED] and we will reserve your slot and send you

Re: highly einteractive editor for python

2007-07-10 Thread Atul Bhingarde
What I want to see is that it is possible to create a python based 
application in a environment where I can see the results as I am creating 
it, specifically gui widgets (from say TK). This will provide a robust 
mechanism to see gui layout as well.

Thanks

Atul
"Josiah Carlson" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Atul Bhingarde wrote:
>> Does anybody know an editor that facilitates, interactive python 
>> development. Where GUI etc developed will be possible to see in real time 
>> mode.
>
> Boa Constructor?  wxGlade embedded in some other software (SPE?)  XRCed? 
> What do you mean by "real time mode"?
>
>  - Josiah 


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


Re: Choosing Tkinter over wxPython...

2007-07-10 Thread Eric Brunel
On Mon, 09 Jul 2007 23:08:20 +0200, Kevin Walzer <[EMAIL PROTECTED]>  
wrote:
> I've spent some time playing with both, and while wxPython is nice,  
> Tkinter just seems to fit my head better, and with appropriate selection  
> of widgets and interface design, seems to yield up perfectly usable  
> GUI's.
>
> Can anyone else who finds Tkinter better for them than wxPython (or the  
> other toolkits) explain why it works for them?

I am, for more or less the same reasons as you. At the time I started -  
which is quite some time ago -, there was also no serious alternative to  
Tkinter's Canvas and Text widgets in the other toolkits. This has changed  
today, at least for the Text widget. But now, I'm used to Tkinter's way of  
doing things and I find working with other toolkits weird...
-- 
python -c "print ''.join([chr(154 - ord(c)) for c in  
'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])"
-- 
http://mail.python.org/mailman/listinfo/python-list


stripping the first byte from a binary file

2007-07-10 Thread rvr
Would someone mind showing me how to strip the first byte from a
binary file? For some reason I can't figure this out from the binary
file editing examples I've read. Thanks.

~rvr

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


Re: highly einteractive editor for python

2007-07-10 Thread Atul Bhingarde
I liked what the Wing IDE provides, one question though will it provide 
facility like creating the GUI widgets (say using TK) and facilitaate layout 
for the same and then run the script ?

Thanks

Atul
"Steve Holden" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Atul Bhingarde wrote:
>> Does anybody know an editor that facilitates, interactive python 
>> development. Where GUI etc developed will be possible to see in real time 
>> mode.
>>
>> Thanks
>>
>> Atul
> Wind IDE is great for debugging GUI-based programs - you can set 
> breakpoints in event-handling routines and see them activate when your 
> program responds to mouse clicks and so on.
>
>   http://wingware.com/
>
> 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
> --- Asciimercial --
> Get on the web: Blog, lens and tag the Internet
> Many services currently offer free registration
> --- Thank You for Reading -
> 


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


Re: The best platform and editor for Python

2007-07-10 Thread greg
Nicola Musatti wrote:
> It's in *commercial* projects that
> features nobody really needs are not implemented. Profit is
> fundamental in convincing you that you really need the features.

In Soviet Russia, you don't need features, features need *you*.

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


Re: stripping the first byte from a binary file

2007-07-10 Thread Jeremy Sanders
rvr wrote:

> Would someone mind showing me how to strip the first byte from a
> binary file? For some reason I can't figure this out from the binary
> file editing examples I've read. Thanks.

Do you mean something like this?

f = open('test.dat', 'rb')
f.read(1)  # read 1st byte and ignore it
rest = f.read()  # read rest

or

data = f.read()
data = data[1:] # skip 1st byte

?

-- 
Jeremy Sanders
http://www.jeremysanders.net/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: accessing an object instance by only having one of its attribute values

2007-07-10 Thread Bruno Desthuilliers
mshiltonj a écrit :
> On Jul 8, 8:29 pm, Paul McGuire <[EMAIL PROTECTED]> wrote:
>> On Jul 8, 2:11 pm, mshiltonj <[EMAIL PROTECTED]> wrote:
> 
>> I have some comments on the Pythonicity of your suggestions.  Same
>> assumption, object attr is a unique key of some sort.  How to create
>> the dict of objects, and how to retrieve an object by key.
>>
>> -- Paul
> 
> I was probably being overly helpful, in a bad way. I'm new to python,
> I'm not very pythonic yet, and still learning the python idioms.
> 
> Not sure why I slipped into the habit of testing for None, though. :-(
> 
> Probably a perl thing, where I'm regularly testing for defined-ness.
> "if ($foo)" is different than "if (defined $foo)"

I'm not sure about the exact meaning of "defined-ness" in Perl, but in 
Python, trying to access a non-existing name - which is not the same 
thing as a name bound to None - will raise a NameError.

And while we're at it, you definitively don't need the parens around the 
test.

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


Re: How would I write this C code in Python?

2007-07-10 Thread Bruno Desthuilliers
Marc 'BlackJack' Rintsch a écrit :
> On Fri, 06 Jul 2007 17:31:50 +, DeveloperX wrote:
> 
>> I am trying to figure out how to rewrite the following chunk of code
>> in Python:
>>
>> C source
>> [code]
>> typedef struct PF
>> {
>>   int flags;
>>   long user;
>>   char*filename;
>>   unsigned char buffer[MAXBUFFERSIZE];
>> } PF;
>>
>> typedef BLOCK
>> {
>>   PF * packdata;
>> } BLOCK;
>>
>> BLOCK* blocks;
>> [/code]
>>
>> My first idea was to create a class for PF and a class for BLOCK, but
>> I got lost somewhere along the lines. :\
>>
>> Python Attempt: Please note that since I can't type TABs online
>> easily, I am using the @ character to represent TABs in the following
>> Python code.
>> [code]
>> class PF:
>> @def __init__(self):
>> @@self.flags, self.user = 0, 0
>> @@self.filename = ''
>> @@self.buffer = []
>>
>> class BLOCK:
>> @def __init__(self):
>> @@self.packdata = []
>>
>> blocks = []
>> [/code]
>>
>> Any Python Gurus out there that can help me?
> 
> At a first glance it looks okay but unless we know what you are going to
> do with these data structures it's hard to tell if it is really the best
> "translation".
> 
> `PF.buffer` might be better a string

Mmm... We can't tell for sure since we have no use case, but I'm not 
sure that the OP wants an immutable object here.

> or an `array.array`.

or a StringIO.

>  And is `BLOCK`
> really just a structure with *one* member?  Looks a bit odd IMHO.

+1


Unless you have behaviours attached to this type, you may as well just 
use lists.


And while we're at it, Python's conventions are that ALL_UPPER names 
denotes (pseudo) constants. For types, the conventions is to use 
CantRememberIfItsCamelOrMixedCaseButYouShouldGetTheIdeaByNow.

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

Re: Choosing Tkinter over wxPython...

2007-07-10 Thread martin . laloux
me to because of the problem of the new versions of wxpython not
compatible with the old ones (try to run a script done with wxpython
3, 4, 5 even 6 with wxpython 2.8.x). Each time, I must re-examine all
my old scripts. Tkinter, although less beautiful, is more stable

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


Re: Should I use Python for these programs?

2007-07-10 Thread Bjoern Schliessmann
Grant Edwards wrote:

> Most of the graphics I do with Python is with Gnuplot (not
> really appropriate for what you want to do.
> wxWidgets/Floatcanvas might be worth looking into.

Agreed (I'm quite sure you mean wxPython though). Also, in "wxPython
in Action" (the official book) a simple drawing app is constructed.
It could help to start from there.

Regards,


Björn

-- 
BOFH excuse #211:

Lightning strikes.

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


Re: "Empty" text

2007-07-10 Thread Jan Danielsson
André wrote:
[---]
>>I understand the opitmization ElementTree is performing; but it seems
>> there are cases when it is not the proper thing to do. Is it possible to
>>  force ElementTree to output the XHTML code I need it to?
> 
> I ran into the same problem and a workaround I found was to use either
> ta.text = " "   or ta.text = "\n" instead of ta.text = ''.
> For my application, it did the right thing; your mileage may vary.

   The problem was actually as indicated by others, that the document
was not being served as application/xml+xhtml. The _real_ problem was
the fact that I know too little about http/html. I put a meta tag in the
head, indicating that it had the content type "application/xml+xhtml",
and thought that would do it. Which is obviously didn't.

   Once I added req.content_type = "application/xml+xhtml" to my
mod_python application, it worked properly. In the future, I'll be sure
to use the "View Page Info" feature in Firefox to actually check what
type my documents are being served as.

   I was surprised to find that some pages render quite differently,
just by changing content type from text/html to application/xml+xhtml.
(Quite a positive surprise, to me)


   A big "Thank you!" goes to those who helped me find the source of the
problem.

-- 
Kind regards,
Jan Danielsson
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: highly einteractive editor for python

2007-07-10 Thread Bjoern Schliessmann
Atul Bhingarde wrote:

> What I want to see is that it is possible to create a python based
> application in a environment where I can see the results as I am
> creating it, specifically gui widgets (from say TK). This will
> provide a robust mechanism to see gui layout as well.

Py is an IDE for Python/wxPython that, AFAICS, does what you look
for.

http://www.wxpython.org/py.php

Regards,


Björn

-- 
BOFH excuse #318:

Your EMAIL is now being delivered by the USPS.

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


Re: Error when trying to write unicode xml to zipfile

2007-07-10 Thread Stefan Behnel
Martin v. Löwis wrote:
>> Unless, obviously, you were serialising to a non-utf8 encoding. But since the
>> "toxml()" method seems to return unicode here (which sounds surprising), I
>> expect it a) to provide no XML declaration at all or b) to be broken anyway.
> 
> Or c) the user forgot to specify the encoding= parameter in toxml().

Then I would expect it a) to serialise to a UTF-8 compatible encoding that
does not require a declaration (which excludes Python unicode) or b) to be
broken. :)

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


Re: 2**2**2**2**2 wrong? Bug?

2007-07-10 Thread Christian Tismer


On 10.07.2007, at 07:21, Jim Langston wrote:


In Python 2.5 on intel, the statement
2**2**2**2**2
evaluates to

2**2**2**2**2
2003529930406846464979072351560255750447825475569751419265016973710894 
0595563114

...

533753975582208506072339445587895905719156736L




Yes, also on 2.4.4
What's wrong about it?

ciao - chris

--
Christian Tismer :^)   
tismerysoft GmbH : Have a break! Take a ride on Python's
Johannes-Niemeyer-Weg 9A :*Starship* http://starship.python.net/
14109 Berlin : PGP key -> http://wwwkeys.pgp.net/
work +49 30 802 86 56  mobile +49 173 24 18 776  fax +49 30 80 90 57 05
PGP 0x57F3BF04   9064 F4E1 D754 C2FF 1619  305B C09C 5A3B 57F3 BF04
  whom do you want to sponsor today?   http://www.stackless.com/





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

Re: xmlrpclib hangs execution

2007-07-10 Thread itkovian
Arno,

> Your patches solves the problem too. Thanks!
>
> One thing: if I use the unpatched xmlrpclib.py, the printed output of
> xml calls look like:
>
> {'state': 0, 'str': 'Info_RT'}
>
> But if I use your patch, they look like:
>
> state0strInfo_RT
>
> I prefer the former, as it is easier to extract the info. Why did this
> change with your patch?

I've no idea, I'll look into this as soon as possible. Thanks for
letting me know.

I want to point you to another possible solution, which is using a
derived
transport class. I've posted this on my blog, see

http://www.itkovian.net/base/transport-class-pythons-xml-rpc-lib

I'm not sure if this might solve the problem you pointed out.

-- Andy

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


Re: path backslash escaping trouble

2007-07-10 Thread Sion Arrowsmith
placid  <[EMAIL PROTECTED]> wrote:
>I have these files; [ ... ]
>
>MergeTypecodefromlabel
>BLnameBUILDMODS
>OldLname
>BaseVersion6.9.1.24A
>RequiredRelease6.10.1.3
>Description
>FixRelation
>Dependencies
>LpAffectedNo
>CodeReviewFirstName LastName
>TestingCompile/Build;Designer;Smoketests;
>OtherTesting
>Vobsipsupport;
>Elements\ipsupport\ipbuild\Wizard\build.pl@@\main\buildmods\3
>
>i read this whole file into a string so i can search for the value of
>Elements which is
>\ipsupport\ipbuild\Wizard\build.pl@@\main\buildmods\3
>
>but this path is escaped
>\\ipsupport\\ipbuild\\Wizard\\build.pl@@\\main\\buildmods\\3

How are you reading the file in? Are you absolutely sure that the
escaping appears *in the string*, and isn't being done by whatever
you're using to inspect it?

Consider:
>>> s = open('/tmp/Elements').read()
>>> s
'Elements\\ipsupport\\ipbuild\\Wizard\\build.pl@@\\main\\buildmods\\3\n'
>>> len(s)
70

Now, if those backslashes had *really* been escaped, the string would be
length 77, wouldn't it?

>>> s.find('')
-1

And find() can't find any double-backslashes in there.

-- 
\S -- [EMAIL PROTECTED] -- http://www.chaos.org.uk/~sion/
   "Frankly I have no feelings towards penguins one way or the other"
-- Arthur C. Clarke
   her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump
-- 
http://mail.python.org/mailman/listinfo/python-list

Dynamic method

2007-07-10 Thread Gabor Urban

Hi guys.

I have an issue I think Python could handle. But I do not have the knowledge
to do it.

Suppose I have a class 'myClass' and instance 'var'. There is function
'myFunc(..)'. I have to add (or bind) somehow the function to the class, or
the instance. Any help, info or point of reference is wellcome

Thx in advance,
G
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Get a filename list of a web site

2007-07-10 Thread faulkner
On Jul 10, 5:12 am, [EMAIL PROTECTED] wrote:
> Hi all,
> is it possible to get a filename directory list of a website (possibly
> with full path indication)?
> Using python & possibly wget?
>
> Bye.

HTTP does not provide a command for this.
you need to acquire a shell account on the specific server you're
interested in. generally, this requires emailing the addresses in the
whois database, explaining why you need a shell account. generally,
they will deny your request.
then you can say `ssh [EMAIL PROTECTED] ls DIRECTORY`.
a few directories on a few servers are configured such that they list
themselves when queried. iirc, there's a google trick to let you find
these directories.

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


Re: Building a Python app with Mozilla

2007-07-10 Thread Damjan
> Last I looked (3.1-ish), Qt didn't use the Aqua widgets

Qt is now up to 4.3 and they use native Aqua

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


Re: Get a filename list of a web site

2007-07-10 Thread aidechamp
Thanks, faulkner,
years ago I used on Windows Teleport, which had the possibilty to
download
only the file list. I hoped that in Linux with the aid of python &
wget

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


Re: xmlrpclib hangs execution

2007-07-10 Thread Arno Stienen
Thanks! I'll try that one too to find the easiest solution. For 
portability, it is easier to use a new transport class and not have to 
patch files of the Python distribution.

Using a similar strategy, I used this class just before I read about 
your patch, which works fine too:
http://mail.python.org/pipermail/python-list/2004-April/256360.html

Could you comment on the difference between this class and yours?

You might want to include on your site how to use the class in a 
reallife example, i.e. like the other class does:

import httplib, xmlrpclib
s = xmlrpclib.ServerProxy('http://SOMEURL', 
transport=PersistTransport())

I agree with you on xmlrpclib needed an upgrade, but in the past could 
not find anybody 'responsible' and knowledgeable enough to do this. 
Although I do feel responsible for open source development, I do not 
have the python knowledge to propose a fix myself!

Bye,
Arno.


itkovian wrote:
> Arno,
> 
>> Your patches solves the problem too. Thanks!
>>
>> One thing: if I use the unpatched xmlrpclib.py, the printed output of
>> xml calls look like:
>>
>> {'state': 0, 'str': 'Info_RT'}
>>
>> But if I use your patch, they look like:
>>
>> state0strInfo_RT
>>
>> I prefer the former, as it is easier to extract the info. Why did this
>> change with your patch?
> 
> I've no idea, I'll look into this as soon as possible. Thanks for
> letting me know.
> 
> I want to point you to another possible solution, which is using a
> derived
> transport class. I've posted this on my blog, see
> 
> http://www.itkovian.net/base/transport-class-pythons-xml-rpc-lib
> 
> I'm not sure if this might solve the problem you pointed out.
> 
> -- Andy
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Should I use Python for these programs?

2007-07-10 Thread Nick Craig-Wood
CC <[EMAIL PROTECTED]> wrote:
>  I have considerable C and assembly language experience.  However, these 
>  are mostly on embedded microcontrollers since I moved away from PC 
>  programming all the way back in 1988 :-O
> 
>  I wish to accomplish a few PC programming tasks, and am considering to 
>  learn Python:
> 
>  1.  Develop a simple GUI program to run on Linux and Windows which can 
>  send parameters and small blocks of data to an embedded microcontroller 
>  device via RS-232 or USB.  Also display simple data (probably single 
>  numbers) sent from the device.
> 
>  Note, if it is USB, then the client will be implemented by me using FTDI 
>  chips that appear to the PC as a serial port.

No problems - pyserial, wxPython work fine cross platform. You can
also use libusb from python from windows and linux also for low level
USB stuff.  I've managed to use all those things successfully.

>  I would prefer to be able to write a program that is cross-platform 
>  between Linux and Windows.  I realize this might be especially 
>  problematic with the serial comms.

On the contrary, pyserial does a very good job of abstracting the
serial port away.

>  I am also confused by the plethora of Python GUI extensions, though 
>  Tkinter seems like a likely candidate.  I am uncertain if I will have 
>  difficulty learning how to use this if I don't know Tcl/Tk.

Use wxPython would be my advice.  tk is OK, but a bit clunky.  it does
have the advantage that it is built into the language though.

>  Do you think Python is the right language for these projects?

Yes!

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


Re: highly einteractive editor for python

2007-07-10 Thread Peter Decker
On 7/10/07, Atul Bhingarde <[EMAIL PROTECTED]> wrote:
> What I want to see is that it is possible to create a python based
> application in a environment where I can see the results as I am creating
> it, specifically gui widgets (from say TK). This will provide a robust
> mechanism to see gui layout as well.

This isn't for Tk, but for wxPython-based development, but you might
want to look at Dabo's visual tools. Their Class Designer allows you
to visually develop your application's windows, allowing you to focus
on coding the logic instead of having to guess how what your UI will
look like.

Check out the screencasts (hey, how else can you see the advantage of
a visual tool?) at http://dabodev.com/documentation. The best ones to
start with are the two on 'Building a Database App in the Class
Designer'. They show some of the database connectivity stuff, too, but
that's not required. I create apps without databases all the time with
Dabo.
-- 

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


Re: Dynamic method

2007-07-10 Thread Daniel Nogradi
> I have an issue I think Python could handle. But I do not have the knowledge
> to do it.
>
> Suppose I have a class 'myClass' and instance 'var'. There is function
> 'myFunc(..)'. I have to add (or bind) somehow the function to the class, or
> the instance. Any help, info or point of reference is wellcome

How about this (note the first argument 'self' which is the instance
itself in the second case):



def method_for_instance( message ):
print message

def method_for_class( self, message ):
print message

class myClass( object ):
pass

inst = myClass( )
inst.method = method_for_instance

inst.method( 'hello' )

myClass.method = method_for_class

inst = myClass( )
inst.method( 'hello' )
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Distributing python apps

2007-07-10 Thread Wildemar Wildenburger
Robert Dailey wrote:
> Thanks a ton guys. You both gave me the exact answers I was looking
> for.
>
>   
Uhm, late entry here, but you might want to consider PyInstaller 
. Not sure if the project is 
still alive as I see no mention of Python 2.5 on their site but you 
never know.

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


Best architecture for proxy?

2007-07-10 Thread Andrew Warkentin
I am going to write a general-purpose modular proxy in Python. It will
consist of a simple core and several modules for things like filtering
and caching. I am not sure whether it is better to use multithreading,
or to use an event-driven networking library like Twisted or Medusa/
Asyncore. Which would be the better architecture to use?

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


Re: Get a filename list of a web site

2007-07-10 Thread Diez B. Roggisch
 [EMAIL PROTECTED] wrote:

> Thanks, faulkner,
> years ago I used on Windows Teleport, which had the possibilty to
> download
> only the file list. I hoped that in Linux with the aid of python &
> wget

ssh. Runs on nearly all linuxes.

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


Re: Can I Redirect debug output from HTTPConnection to a file?

2007-07-10 Thread Harel
I'll answer myself then:

import os
ioLogFile = file(LOG_FILE_PATH + IO_LOG_FILE, "w") #get a log file
created
os.dup2(config.ioLogFile.fileno(), 1)  #route stdout (file descriptor
1) to the log file's one

Thanks
Harel

On Jul 10, 10:32 am, Harel <[EMAIL PROTECTED]> wrote:
> I'm using httplib.HTTPConnection to perform http connections and
> during the beta period of the application I wanted to log its verbose
> output [set_debuglevel(5)]. However, raising the debuglevel just
> outputs it to stdout. can I redirect that to a file? My app uses the
> logging module for logging and I'd like to use that to log into the
> standard log it generates.
>
> Any ideas?
> Thanks,
> Harel


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


Re: Dynamic method

2007-07-10 Thread Alex Popescu
On Jul 10, 5:07 pm, "Daniel Nogradi" <[EMAIL PROTECTED]> wrote:
> > I have an issue I think Python could handle. But I do not have the knowledge
> > to do it.
>
> > Suppose I have a class 'myClass' and instance 'var'. There is function
> > 'myFunc(..)'. I have to add (or bind) somehow the function to the class, or
> > the instance. Any help, info or point of reference is wellcome
>
> How about this (note the first argument 'self' which is the instance
> itself in the second case):
>
> def method_for_instance( message ):
> print message
>
> def method_for_class( self, message ):
> print message
>
> class myClass( object ):
> pass
>
> inst = myClass( )
> inst.method = method_for_instance
>
> inst.method( 'hello' )
>
> myClass.method = method_for_class
>
> inst = myClass( )
> inst.method( 'hello' )

I think a solution may be using the new module and the function
instancemethod:

instancemethod(function, instance, class)
This function will return a method object, bound to instance, or
unbound if instance is None. function must be callable.

./alex
--
.w( the_mindstorm )p.


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


Parsing Help

2007-07-10 Thread Robert Rawlins - Think Blue
Hello Guys,

 

I'm looking for some help building a function which can parse some XML for
me using ElementTree. The document is of a very consistent format and I've
copied an example of the document below.

 



 









 











 







 





























 











 

















 







 





















 

Now, the piece of information I'm looking to retrieve is inside the
 element and is, in this example , however I want the function to return the standard integer value and not
the unit8 encoded version, so instead of my function returning '0x05' it
just needs to return '5' which is the standard integer version.

 

I will be passing this XML into the function as a string, so the function
will be formed something like this:

 

Def myFunction(XmlAsString):

Pass the xml and exract my value



Return the value as an integer...

 

I'm not sure on the best method to do this, I just want something nice and
quick, lightweight and that's not resource hungry. Can anyone offer some
advice on this?

 

Thanks guys,

 

Rob

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

Re: Dynamic method

2007-07-10 Thread Bruno Desthuilliers
Daniel Nogradi a écrit :
>> I have an issue I think Python could handle. But I do not have the 
>> knowledge
>> to do it.
>>
>> Suppose I have a class 'myClass' and instance 'var'. There is function
>> 'myFunc(..)'. I have to add (or bind) somehow the function to the 
>> class, or
>> the instance. Any help, info or point of reference is wellcome
> 
> How about this (note the first argument 'self' which is the instance
> itself in the second case):
> 
> 
> 
> def method_for_instance( message ):
>print message
> 
> def method_for_class( self, message ):
>print message
> 
> class myClass( object ):
>pass
> 
> inst = myClass( )
> inst.method = method_for_instance
> 
> inst.method( 'hello' )

This won't work as expected:

class Bidule(object):
   def __init__(self, name):
 self.name = name

def greet(self, who):
   print "hello %s, my name is %s" % (who, self.name)

b = Bidule('Bruno')
b.greet = greet
b.greet('Daniel')

=>
Traceback (most recent call last):
   File "", line 1, in 
   File "/tmp/python-23258Nq5.py", line 10, in 
 b.greet('Daniel')
TypeError: greet() takes exactly 2 arguments (1 given)


The point is that Python functions are descriptor objects that, when 
looked up, return a (bound or unbound) method object wrapping 
themselves. So to attach functions as method *on a per-instance basis*, 
you either need to use new.instancemethod (as explained by Alex), or 
directly use the descriptor protocol, ie:

b.greet = greet.__get__(b)
b.greet('Daniel')
=> hello Daniel, my name is Bruno

Note that you don't need this to attach a function as method to a class 
- the descriptor protocol will then JustWork(tm).

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


Re: Building a Python app with Mozilla

2007-07-10 Thread Bruno Desthuilliers
Thorsten Kampe a écrit :
> Hi,
> 
> I've already sent this to the Komodo mailing list (which seemed to me 
> the more appropriate place) but unfortunately I got no response.
> 
> I'd like to build a Python GUI app. Neither Tkinter nor Wxpython nor 
> PyQT are actually what I want (because the lack of GUI builders and 
> they don't really look good on Windows and Linux).

Err... Actually, there are GUI builders for wxWidget (the C++ lib behind 
wxPython). And since wxWidgets relies on the platform's GUI libs (native 
on Windows, GTK or Metal on unices), I don't get the "don't look good" 
point ?

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

Re: Shed Skin Python-to-C++ Compiler 0.0.21, Help needed

2007-07-10 Thread mark . dufour
hi mike,

> Great work.  You might want to advertise this on the main site
> (currently it states that this is impossible).

yes, thank you for reminding me.

> You've said somewhere that you didn't/don't plan on working on this
> aspect, but it is surely the "killer feature" of shed skin needed to
> for it to be able to be used as pyrex is currently (optimizing bits of
> larger projects).

no I agree it is a very useful feature :-) I was just waiting for
someone to step in and help out. when that happened I was motivated
enough to fill in the details.

> I wish I had time to help,

I know it's a bit boring, but I'm always glad to receive bug
reports :) A few hours of help looking into adding custom classes to
the extension module support, or implementing some library functions,
can be very useful too.. (I'm currently getting practically no help at
all).

>But there is such a large gap betwixt the
>twain that such dreaming is but an excercise in fantasy (there's
>always pypy).

yes, pypy will solve all problems, including world hunger ^^


thanks,
mark dufour - shed skin author

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


How to check if file is in use?

2007-07-10 Thread loial
Is there anyway in pythn to check whether a file is being used/written
to by another process, e.g like the fuser command?

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


Need Help

2007-07-10 Thread pycraze
Hi ,

  I need some info about the following snippet  .

---
  protocol = 'NTLMSSP\000'#name
type = '\001\000'   #type 1
zeros1 = '\000\000'

   zeros2 = '\000\000\000\000\000\000\000\000\000'
zeros3 = '\000\000\000\000\000\000\000\000\000\000\000'
smthg1 = '0\000\000\000\000\000\000\000'# something with
chr(48) length?
smthg2 = '0\000\000\000'# something with
chr(48) lenght?


  msg1 = protocol + type + zeros1 + flags + zeros2 + zeros3 +
smthg1 + smthg2
msg1 = base64.encodestring(msg1)
msg1 = string.replace(msg1, '\012', '')
---

   In the above code what does "
000\000\000\000\000\000\000\000\000 " signify ?  Which form of
representation is this ?

 This code is from the NTLM APS python code from sourceforge 0.98
version .

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


Re: How to check if file is in use?

2007-07-10 Thread Gerhard Häring
loial wrote:
> Is there anyway in pythn to check whether a file is being used/written
> to by another process, e.g like the fuser command?

No, you'll have to use platform-specific methods (like calling fuser 
etc. with the subprocess module).

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


Re: trouble controlling vim with subprocess on windows machine

2007-07-10 Thread [EMAIL PROTECTED]
On Jul 10, 4:00 am, agc <[EMAIL PROTECTED]> wrote:
> Hi Josiah,
>
> > >> This recipe for asynchronous communication usingsubprocesscould be
> > >> used to write an expect-like tool:
> > >>http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440554
>
> I have played with the above recipe and it is excellent,
> but could you please go into some more detail about what is needed
> to make a cross platform [p]expect like (non-pty based) tool?
>
> Specifically, could you describe how you would connect to
> *another* interactive Python process with your subclass of
> subprocess.Popen?
> i.e:
>
> a = Popen('python', stdin=?, stdout=?, stderr=?)
> #now run an interactive session with 'a'
>
> I have tried several combinations of the above and I seem
> to be stuck on the fact that python is interacting with a
> 'tty', not 'std*'.  Maybe I'm missing a basic piece?
>
> Thanks for any input,
> Alex
>
>
>
> > >> It works on both Windows and *nix.
>
> > >>   - Josiah
>
> > > I had the original dir work but when I tried to trade it out withvim
> > > it isn't clear
> > > how I should call it..  vimfilename and it doesn't find filename for
> > > some reason.
> > > I called it pipe and then
>
> > > inport pipe
>
> > > def load_instrument3(instr_name, csd_name):
> > >   if sys.platform == 'win32':
> > > shell, commands, tail = ('gvim' + csd_name, (csd_name,
> > > csd_name), '\r\n')
> > >   else:
> > > shell, commands, tail = ('sh', ('ls', 'echo HELLO WORLD'),
> > > '\n')
>
> > >   a = pipe.Popen(shell, stdin=pipe.PIPE, stdout=pipe.PIPE)
> > >   print pipe.recv_some(a),
> > >   for cmd in commands:
> > > pipe.send_all(a, csd_name)
> > > print pipe.recv_some(a),
> > >   pipe.send_all(a, csd_name)
> > >   print pipe.recv_some(a, e=0)
> > >   a.wait()
>
> > The example uses a platform-specific shell in order to use the
> > environment variable PATH to discover the executable to run.  If you
> > know the exact path to your binary ('gvim' for you), it should work.
> > As-is, your program would require a binary with the name 'gvim'+csd_name
> > in the same path as the script you are executing.
>
> >   - Josiah- Hide quoted text -
>
> - Show quoted text -


I gave this a shot with a windows batch file (although I am not sure I
am doing it right)

path c:\program files\vim\vim71
path c:\dex tracker
gvim bay-at-night.csd
echo \intsr | gvim
echo \ | gvim
echo :r strings.orc | gvim
pause


and it just pulls up gvim bay-at-night.csd and never does the two
searches or pulls up the file.  I do have a windows version of sh if
that works better.

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


Re: Need Help

2007-07-10 Thread Marc 'BlackJack' Rintsch
On Tue, 10 Jul 2007 08:28:05 -0700, pycraze wrote:

>In the above code what does "
> 000\000\000\000\000\000\000\000\000 " signify ?  Which form of
> representation is this ?

\nnn is the octal representation of a byte.  The snippet you've shown
contains mostly zero bytes:

In [10]: a = '\000'

In [11]: a
Out[11]: '\x00'

In [12]: ord(a)
Out[12]: 0

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


bool behavior in Python 3000?

2007-07-10 Thread Alan Isaac
Is there any discussion of having real booleans
in Python 3000?  Say something along the line
of the numpy implementation for arrays of type 'bool'?

Hoping the bool type will be fixed will be fixed,
Alan Isaac
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: allow scripts to use .pth files?

2007-07-10 Thread Alan Isaac
John Machin wrote:
> I got the impression that the OP was suggesting that the interpreter
> look in the directory in which it found the script.

Right.

 
> I got the impression that the problem was that the package was not
> only not on sys.path but also not in the same directory as the script
> that wanted to import it.

Right.


> I'm curious whether you think that the OP's use of ".pth" was a typo,
> and whether you have read this:
> http://docs.python.org/lib/module-site.html

You seem to understand what I'm getting at.
Thanks John.

Alan Isaac (the OP above)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: bool behavior in Python 3000?

2007-07-10 Thread Michael Hoffman
Alan Isaac wrote:
> Is there any discussion of having real booleans
> in Python 3000?

I'm not sure how the bools we have now are not "real."

 > Say something along the line of the numpy implementation for arrays 
of > type 'bool'?

What aspect of this do you want? A bool typecode for the stdlib array 
module?

I can guess a number of things that you might mean, but it would be best 
if you explained with an example of what current behavior is and what 
you would like it to be.
-- 
Michael Hoffman
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: bool behavior in Python 3000?

2007-07-10 Thread Peter Otten
Alan Isaac wrote:

> Is there any discussion of having real booleans
> in Python 3000?  

The last I have seen is

http://mail.python.org/pipermail/python-3000/2007-January/005284.html

> Hoping the bool type will be fixed will be fixed,

Do you care to explain what is broken?

Peter

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


serializing datetime object

2007-07-10 Thread [EMAIL PROTECTED]

Hi
I want to serialize datetime.datetime.now() object . I could convert it to
string but how do I get a datetime object back from the string?
Any suggestions?
thanks
mark
-- 
http://mail.python.org/mailman/listinfo/python-list

win32com ppt embedded object

2007-07-10 Thread Lance Hoffmeyer
Hey all,

I am trying to create some python code to edit embedded ppt slides and need 
some help.

import win32com.client
from win32com.client import constants
import re
import codecs,win32com.client
import time
import datetime
import win32com.client.dynamic
##
 VARIOUS VARIABLES TO SET 
path = "C:\temp/"
##
##


PPT=win32com.client.Dispatch("PowerPoint.Application")
WB=PPT.Presentations.Open(path + "File.ppt")
PPT.Visible=1
PPTSLIDE= 29

for Z in WB.Slides(29).Shapes:
if (Z.Type== 7):
ZZ=Z.OLEFormat.Object
WSHEET = ZZ.Worksheets(1)
WSHEET.Range("A1").Value = .50
WSHEET.Range("A1").NumberFormat="0%"

Gives error:

Traceback (most recent call last):
  File "P:\Burke\TRACKERS\Ortho-McNeil\04 2007, 04-10 WAVE 
4\Automation\Document1.py", line 23, in ?
WSHEET = ZZ.Worksheets(1)
  File "C:\Program Files\Python\lib\site-packages\win32com\client\dynamic.py", 
line 489, in __getattr__
raise AttributeError, "%s.%s" % (self._username_, attr)
AttributeError: .Worksheets

Tool completed with exit code 1



Why is ZZ unknown and how to I correct this?




Thanks in advance,

Lance


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


subprocess popen trouble

2007-07-10 Thread nik
I am having trouble using subprocess popen and stdin/stdout

I have the following simple test application written in C++, that just
echoes back the stdin. It works fine running from the command line:

#include 
#include 

int main (int argc, char * const argv[]) {
int currenttemp = 0;
int settemp = 0;
char* str;

while(currenttemp < 500){
gets(str);
sscanf(str, ">%d", &settemp);
currenttemp = settemp;
printf("<%d\n", currenttemp++);
}
return 0;
}

##
Then I have the following python code. A listener thread that waits
for the output of test and the main part that creates the subprocess
Popen object, passes it to the thread and then sends user input to the
subprocess test.


import subprocess
import os, sys
from threading import *
import time

class TempXListen(Thread):
""" thread to listen for incomming
messages and put them onto a
shared queue, no time lost processing incoming lines
"""
def __init__(self, channel):
""" connect internal response queue
to external queue
"""
Thread.__init__(self)
self.setDaemon(True)
self._channel = channel
self.start()

def run(self):
""" listening loop
reads line off of input source
puts the line into the response Q shared with parent
thread
sets event that parent is waiting for to indicate Q has at
least 1 element
"""
while 1:
try:
response = self._channel.stdout.readline() #
read input line
print response
except Exception, e:
print 'Listener Exception: ' + str(e)


print "Temp Monitor Test"
tempx = subprocess.Popen('/Users/engineeringadmin/Documents/test/build/
Debug/test', \
 bufsize=1, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, \
 stderr=subprocess.PIPE)

print tempx.stderr.readline()

listener = TempXListen(tempx)
while 1:
data = sys.stdin.readline()
if data != '':
data = '>' + data + '\n'
tempx.stdin.write(data)
print data
time.sleep(1)


###
When I run it this is the output:

Temp Monitor Test
warning: this program uses gets(), which is unsafe.

45
>45


The subprocess is opened, because the warning is coming off of the
test applications stderr, but nothing else seems to go in or out. I've
been looking at a lot of examples and a lot of different postings, and
can't see any mistakes in my use of subprocess. I would really
appreciate it if somebody could see where I am going wrong.

Thank you,
Nik

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


xml yml and dependency hell

2007-07-10 Thread Rustom Mody
yaml by its indent-orientation is quite pythonic.  In comparison xml
is cumbersome and laborious.

Strangely ruby supports yaml out of the box but python requires a
third party package PyYAML.

Now this may not seem like a big deal for us -- installing pyYAML
takes all of one minute -- but it may not be so to others as I
recently learned.

I conducted a python training for a corporate in which I showed among
other things that yaml is much neater than xml.  They agreed that it
was neat but were reluctant to consider it because it adds dependency
headaches at a later point with their customers.



So is it likely that yaml will make it to the standard python library
at some point??
-- 
http://mail.python.org/mailman/listinfo/python-list


Abort trap - Fatal Python error: GC object already tracked

2007-07-10 Thread p . lavarre
Is this interesting Python output?

$ gc-object-already-tracked.py

**
File "/Users/admin/Desktop/lxio/gc-object-already-tracked.py", line
770, in __main__.REDACTED
Failed example:
nqzhexes(self.send())
Expected:
'... [redacted] ...'z
Got:
'... [redacted] ...'
Fatal Python error: GC object already tracked
Abort trap
$
$ /usr/bin/env python --version
Python 2.5.1
$ uname
Darwin
$

I can just avoid it, I don't need to solve it, but tell me I can help
by solving it, and I'll look more closely.

I can't just share all this source with you - I wrote a simulation for
pay under c*nfidentiality - but if I find I can throw away most of the
source and still produce the error, I could share that.

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


REALLY!

2007-07-10 Thread [EMAIL PROTECTED]

Is this for reals man!
I hope this is not one of those rip-off emails.




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

Re: 2**2**2**2**2 wrong? Bug?

2007-07-10 Thread fynali

>
> 19729
>
> Did you count the 'L'?
>

(-:

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


Re: How do I remotely access Scheduled Tasks from Windows XP to Windows Server 2003?

2007-07-10 Thread fynali
On Jul 10, 4:51 am, kj7ny <[EMAIL PROTECTED]> wrote:
> On Jun 30, 10:55 am, "Roger Upole" <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > "kj7ny" wrote:
> > > How can I access and manipulateScheduledTasksin Windows using
> > > Python?
>
> > > I have a Windows XP workstation running Python 2.4.4 using the
> > > win32all modules to control the windows services on multiple Windows
> > > 2003 servers.  It works great.
>
> > > However, I also need to remotely collect the settings for the
> > >scheduledtasks(on those same Windows 2003 servers) and then
> > > manipulate those task settings.
>
> > > At the very least, I need to find out which ones are enabled and then
> > > be able to disable and re-enable thosetasksat will.  It would be
> > > better to be able to also detect the account each task runs as so that
> > > I could only disable selectedtasks, but I'll any help I can get.
>
> > > Thanks,
>
> > Pywin32 comes with a module that lets you do this, win32com.taskscheduler.
> > You can use PyITaskScheduler.SetTargetComputer to accesstaskson remote
> > machines.
>
> >Roger
>
> > == Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet 
> > News==http://www.newsfeeds.comThe#1 Newsgroup Service in the World! 
> > >100,000 Newsgroups
> > ---= East/West-Coast Server Farms - Total Privacy via Encryption =---
>
> I FINALLY found taskscheduler (with the help of your post).  I found
> it under
>
> ...\Python243\Lib\site-packages\win32comext\taskscheduler
>
> ... and, there seems to be a /test/ directory with some examples.
> Haven't tried them yet, but they should get me started.
>
> Thanks,- Hide quoted text -
>
> - Show quoted text -

kj7ny, could you post back here to learn from?

Thanks.

s|a fynali

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


Re: The best platform and editor for Python

2007-07-10 Thread Douglas Alan
[EMAIL PROTECTED] (Alex Martelli) writes:

> Kay Schluehr <[EMAIL PROTECTED]> wrote:

>> half of the community is happy with Emacs and the other half wants to
>> program in a VS-like environment, neither consensus nor progress has

> Calling all vi/vim users (and we'll heartily appreciate the support
> of TextMate fans, BBEdit ones, etc, etc) -- we're at risk being
> defined out of existence, since we're neither happy with Emacs

That's because the Emacs users are the only ones who matter.

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


Re: Phoenix-iTorrent: iTunes Bit Torrent client v 0.3 release

2007-07-10 Thread Danyelle Gragsone
How is this related to python?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Abort trap - Fatal Python error: GC object already tracked

2007-07-10 Thread p . lavarre
> Is this interesting Python output? ...
>
> Fatal Python error: GC object already tracked
> Abort trap
>
> ... tell me I can help by solving it, and
> I'll look more closely.

Sorry, never mind, not interesting after all.

Newbie me did somehow forget the fact that ctypes.memmove doesn't
bounds-check, e.g. there is no error raised by overwriting memory not
owned, which then naturally degrades the stability of the GC etc.

>>> import ctypes
>>>
>>> bytes = (3 * ctypes.c_ubyte)()
>>> bytes[0], bytes[1], bytes[2]
(0, 0, 0)
>>> CP = ctypes.POINTER
>>> ctypes.cast(ctypes.addressof(bytes) + 3, CP(ctypes.c_ubyte)).contents.value
0
>>>
>>> result = ctypes.memmove(ctypes.addressof(bytes), '\1\3\5\7', 4)
>>> bytes[0], bytes[1], bytes[2]
(1, 3, 5)
>>> ctypes.cast(ctypes.addressof(bytes) + 3, CP(ctypes.c_ubyte)).contents.value
7
>>>

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


C Extension Seg Faults

2007-07-10 Thread Daryl
I'm having trouble tracking down some segmentation faults with a C
extension.  I can see where it's failing but don't know how to fix
it.  Basically, my python programme builds a pair of large tuples of
tuples.  I want to unpack these tuples and process them.  The code in
question looks something like:

... snip ...

SizeN = PyTuple_Size(PlacementN);
SizeP = PyTuple_Size(PlacementP);
for(ixN = 0; ixN < SizeN; ixN++) {
LenN = (int) PyTuple_Size(PyList_GetItem(PlacementN, ixN));
for(Count = 0; Count < LenN; Count++)
*(GatesN+Count) = (int)
PyInt_AsLong(PyTuple_GetItem(PyTuple_GetItem(PyList_GetItem(PlacementN,
ixN), Count), GATE));
for(ixP = 0; ixP < SizeP; ixP++) {
printf("I feel lucky (%d)...", ixP); fflush(stdout);
LenP = (int) PyTuple_Size(PyList_GetItem(PlacementP,
ixP));
printf("Ta-Da!\n"); fflush(stdout);
for(Count = 0; Count < LenP; Count++)
*(GatesP+Count) = (int)
PyInt_AsLong(PyTuple_GetItem(PyTuple_GetItem(PyList_GetItem(PlacementP,
ixP), Count), GATE));
[ MUCH PROCESSING ]
... snip ...

The inner loop runs a few hundred times (263) then fails with a
segmentation fault.  I've trolled through the documentation online and
in the various .h files but can't seem to find anything.

Anybody have an idea what really obvious foolish thing I'm doing?

Thanks,
-Daryl

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


Re: C Extension Seg Faults

2007-07-10 Thread Paul Rubin
Daryl <[EMAIL PROTECTED]> writes:
> The inner loop runs a few hundred times (263) then fails with a
> segmentation fault.  I've trolled through the documentation online and
> in the various .h files but can't seem to find anything.
> 
> Anybody have an idea what really obvious foolish thing I'm doing?

It's not worth staring at code to try to figure out things like that.
Run it under gdb, examine the relevant data objects when it crashes
and see what's broken (e.g. some pointer is unexpectedly null), then
set a conditional breakpoint that stops execution when that incorrect
condition happens (e.g. the pointer gets set to null), run the program
til the breakpoint triggers, see what other condition X caused the
condition that caused the crash, set another breakpoint that triggers
when X occurs, etc.  Work backwards systematically til you find the bug.

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


Re: C Extension Seg Faults

2007-07-10 Thread Daryl
> It's not worth staring at code to try to figure out things like that.
> Run it under gdb, examine the relevant data objects when it crashes
> and see what's broken (e.g. some pointer is unexpectedly null), then
> set a conditional breakpoint that stops execution when that incorrect
> condition happens (e.g. the pointer gets set to null), run the program
> til the breakpoint triggers, see what other condition X caused the
> condition that caused the crash, set another breakpoint that triggers
> when X occurs, etc.  Work backwards systematically til you find the bug.

Yeah, not 30 seconds after I posted it I found the problem.  Under
some (funny) conditions the extension would be called with a list
instead of a tuple.  My debug case (of course) worked fine but the
full test would fail.

Sorry for the noise,
-Daryl

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


Re: win32com ppt embedded object

2007-07-10 Thread fynali
On Jul 10, 8:40 pm, Lance Hoffmeyer <[EMAIL PROTECTED]> wrote:
> Hey all,
>
> I am trying to create some python code to edit embedded ppt slides and need 
> some help.
>
> import win32com.client
> from win32com.client import constants
> import re
> import codecs,win32com.client
> import time
> import datetime
> import win32com.client.dynamic
> ##
>  VARIOUS VARIABLES TO SET 
> path = "C:\temp/"
> ##
> ##
>
> PPT=win32com.client.Dispatch("PowerPoint.Application")
> WB=PPT.Presentations.Open(path + "File.ppt")
> PPT.Visible=1
> PPTSLIDE= 29
>
> for Z in WB.Slides(29).Shapes:
> if (Z.Type== 7):
> ZZ=Z.OLEFormat.Object
> WSHEET = ZZ.Worksheets(1)
> WSHEET.Range("A1").Value = .50
> WSHEET.Range("A1").NumberFormat="0%"
>
> Gives error:
>
> Traceback (most recent call last):
>   File "P:\Burke\TRACKERS\Ortho-McNeil\04 2007, 04-10 WAVE 
> 4\Automation\Document1.py", line 23, in ?
> WSHEET = ZZ.Worksheets(1)
>   File "C:\Program 
> Files\Python\lib\site-packages\win32com\client\dynamic.py", line 489, in 
> __getattr__
> raise AttributeError, "%s.%s" % (self._username_, attr)
> AttributeError: .Worksheets
>
> Tool completed with exit code 1
>
> Why is ZZ unknown and how to I correct this?
>
> Thanks in advance,
>
> Lance


"""
How do I know which methods and properties are available?
Good question. This is hard! You need to use the documentation with
the products, or possibly a COM browser. Note however that COM
browsers typically rely on these objects registering themselves in
certain ways, and many objects to not do this. You are just expected
to know.

The Python COM browser
PythonCOM comes with a basic COM browser that may show you the
information you need. Note that this package requires Pythonwin (ie,
the MFC GUI environment) to be installed for this to work.

There are far better COM browsers available - I tend to use the one
that comes with MSVC, or this one!

To run the browser, simply select it from the Pythonwin Tools menu, or
double-click on the file win32com\client\combrowse.py

"""

--
s|a fynali

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


Re: xml yml and dependency hell

2007-07-10 Thread Stefan Behnel
Rustom Mody wrote:
> yaml by its indent-orientation is quite pythonic.  In comparison xml
> is cumbersome and laborious.
> 
> Strangely ruby supports yaml out of the box but python requires a
> third party package PyYAML.
> 
> Now this may not seem like a big deal for us -- installing pyYAML
> takes all of one minute -- but it may not be so to others as I
> recently learned.
> 
> I conducted a python training for a corporate in which I showed among
> other things that yaml is much neater than xml.  They agreed that it
> was neat but were reluctant to consider it because it adds dependency
> headaches at a later point with their customers.
> 
> 
> 
> So is it likely that yaml will make it to the standard python library
> at some point??

That's up to the maintainers of PyYAML. If they want to get it in, there will
be ways to get there. If they do not want to - unlikely, unless someone else
takes up the work. But it's definitely easier if the authors decide to put it 
in.

Besides, why would you assume any dependency headaches? There's EasyInstall
and setuptools if you need them.

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


Re: S2K DTS and Python

2007-07-10 Thread stefaan
> > However, I now want to update some tables in MSAccess, and it occurred
> > to me that because Sequel Server 2000 DTS can interface with scripting
> > languages that maybe I could call my first Python program from within
> > DTS and then update the tables using DTS. (I am learning DTS hence the
> > idea).

I have never heard about DTS, so I cannot advise you on that.
But since you mentioned MsAccess, I want to mention that I have
successfully used the DejaVu object relational mapper[1] to access
MsAccess
databases. Other ORMs like SqlObject and SqlAlchemy - to the best of
my knowledge -
do not support MsAccess out of the box (yet?).

[1] http://projects.amor.org/docs/dejavu/1.5.0RC1/

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


Re: xml yml and dependency hell

2007-07-10 Thread Rustom Mody
On 7/11/07, Stefan Behnel <[EMAIL PROTECTED]> wrote:
> Rustom Mody wrote:

> > So is it likely that yaml will make it to the standard python library
> > at some point??
>
> That's up to the maintainers of PyYAML. If they want to get it in, there will
> be ways to get there. If they do not want to - unlikely, unless someone else
> takes up the work. But it's definitely easier if the authors decide to put it 
> in.

Is this a general comment or specific to yaml?  I mean can anyone add
anything they please to the python standard library?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Need Help

2007-07-10 Thread Paul McGuire
On Jul 10, 10:28 am, pycraze <[EMAIL PROTECTED]> wrote:
> Hi ,
>
>   I need some info about the following snippet  .
>
> ---
>   protocol = 'NTLMSSP\000'#name
> type = '\001\000'   #type 1
> zeros1 = '\000\000'
>
>zeros2 = '\000\000\000\000\000\000\000\000\000'
> zeros3 = '\000\000\000\000\000\000\000\000\000\000\000'
> smthg1 = '0\000\000\000\000\000\000\000'# something with
> chr(48) length?
> smthg2 = '0\000\000\000'# something with
> chr(48) lenght?
>
>   msg1 = protocol + type + zeros1 + flags + zeros2 + zeros3 +
> smthg1 + smthg2
> msg1 = base64.encodestring(msg1)
> msg1 = string.replace(msg1, '\012', '')
> ---
>
>In the above code what does "
> 000\000\000\000\000\000\000\000\000 " signify ?  Which form of
> representation is this ?
>
>  This code is from the NTLM APS python code from sourceforge 0.98
> version .

I think redoing this code using the struct module would make the
behavior and intent clearer, rather than trying to encode binary data
directly into strings.

-- Paul

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


Re: bool behavior in Python 3000?

2007-07-10 Thread Alan G Isaac
Peter Otten wrote:
 > The last I have seen is
 > http://mail.python.org/pipermail/python-3000/2007-January/005284.html

OK.  Thanks.


 > Do you care to explain what is broken?

I suppose one either finds coercion of arithmetic operations to int
to be odd/broken or does not.  But that's all I meant.

My preference would be for the arithmetic operations *,+,-
to be given the standard interpretation for a two element
boolean algebra:
http://en.wikipedia.org/wiki/Two-element_Boolean_algebra

In contrast with the link above,
it does not bother me that arithmetic with ints and bools
produces ints.

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


Re: xml yml and dependency hell

2007-07-10 Thread Bruno Desthuilliers
Rustom Mody a écrit :
> yaml by its indent-orientation is quite pythonic.  In comparison xml
> is cumbersome and laborious.
> 
> Strangely ruby supports yaml out of the box but python requires a
> third party package PyYAML.
> 
> Now this may not seem like a big deal for us -- installing pyYAML
> takes all of one minute -- but it may not be so to others as I
> recently learned.
> 
> I conducted a python training for a corporate in which I showed among
> other things that yaml is much neater than xml.  They agreed that it
> was neat but were reluctant to consider it because it adds dependency
> headaches at a later point with their customers.
> 
> So is it likely that yaml will make it to the standard python library
> at some point??

"dependency headaches" ? AFAICT from the project's site, pyYAML is a 
pure Python package, and the only requirement mentioned is Python 2.3. 
Compared to some products often in use in "corporate" environment, I 
wouldn't call this a "dependency headaches".

Not that I disagree with the idea of including pyYAML in the standard 
lib - this would be in pahse with the "batteries included" philosophie 
IMHO - but then, what about python-json ? FWIW, JSON being another 
pretty good alternative to XML, and probably more used than YAML, thanks 
to the Ajax/Web2.0 madness.

But anyway, the inclusion of a package in the standard lib is a somehow 
formalized process (cf pep 0002 [1]), supposed to be initiated by the 
package's maintainers. So if you want this to happen for pyYAML, you'll 
  first have to talk about it with the project's leaders.

[1] http://python.org/dev/peps/pep-0002/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Embedding Matplotlib in wxpython wx.Panel problem

2007-07-10 Thread abakshi11

I was wondering if you ever got to create a small GUI program that did plots
using Matplotlib
I am gettin an error where its saying "WXagg's accelerator requires the
wxPython headers-the wxpython header files can not be located in any of the
standard include directories reported by 'wx-config --cppflags'
Do you think you can help?



Soren-3 wrote:
> 
> Hi,
> 
> I'm trying to create a small GUI program where I can do plots using
> Matplotlib. I've been trying to borrow code from the examples at the
> matplotlib website, but I can't get it to work.
> 
> I want to be able to create a wx.Panel that contains an axis for
> plotting. Around it i want other panels containing various settings,
> buttons etc. to control the plot. So far I can't even get the program
> to actually show a plot in a panel.
> 
> Does anyone here have experience in making a wxpython GUI with
> matplotlib?
> 
> Any help would be appreciated!
> 
> Thanks,
> Soren
> 
> My code shows a frame, and I'm trying to set up two panels.. one with
> a plot and one with a button.. The plotpanel is just a little square
> in the corner when I run it.. ???
> 
> My code is as follows:
> 
> import wx
> import pylab
> from matplotlib.numerix import arange, sin, cos, pi
> import matplotlib
> 
> matplotlib.use('WXAgg')
> from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg
> from matplotlib.backends.backend_wx import NavigationToolbar2Wx
> from matplotlib.figure import Figure
> matplotlib.interactive(False)
> 
> class App(wx.App):
> 
> def OnInit(self):
> self.frame = MainFrame("Autoplotter", (50,60), (700,700))
> self.frame.Show()
> 
> return True
> 
> class MainFrame(wx.Frame):
> 
> def __init__(self, title, pos, size):
> wx.Frame.__init__(self, None, -1, title, pos, size)
> 
> pPanel = PlotPanel(self, -1)# Plot panel
> 
> bPanel = ButtonPanel(self, 100,500, (200,100))# button
> panel
> 
> sizer = wx.BoxSizer(wx.VERTICAL)
> 
> sizer.Add(pPanel,0)
> sizer.Add(bPanel,0)
> 
> self.SetSizer(sizer)
> 
> class ButtonPanel(wx.Panel):
> 
> def __init__(self, Parent, xPos, yPos, insize):
> 
> pos = (xPos, yPos)
> wx.Panel.__init__(self, Parent, -1, pos, style =
> wx.RAISED_BORDER, size = insize)
> 
> button = wx.Button(self, -1, 'HELLO!!', (10,10), (150,50))
> 
> class NoRepaintCanvas(FigureCanvasWxAgg):
> """We subclass FigureCanvasWxAgg, overriding the _onPaint method,
> so that
> the draw method is only called for the first two paint events.
> After that,
> the canvas will only be redrawn when it is resized.
> """
> def __init__(self, *args, **kwargs):
> FigureCanvasWxAgg.__init__(self, *args, **kwargs)
> self._drawn = 0
> 
> def _onPaint(self, evt):
> """
> Called when wxPaintEvt is generated
> """
> if not self._isRealized:
> self.realize()
> 
> if self._drawn < 2:
> self.draw(repaint = False)
> self._drawn += 1
> 
> self.gui_repaint(drawDC=wx.PaintDC(self))
> 
> 
> class PlotPanel(wx.Panel):
> 
> def __init__(self, parent, id = -1, color = None,\
>  dpi = None, style = wx.NO_FULL_REPAINT_ON_RESIZE,
> **kwargs):
> 
> wx.Panel.__init__(self, parent, id = id, style = style,
> **kwargs)
> 
> self.figure = Figure(None, dpi)
> self.canvas = NoRepaintCanvas(self, -1, self.figure)
> self._resizeflag = True
> 
> self.Bind(wx.EVT_IDLE, self._onIdle)
> self.Bind(wx.EVT_SIZE, self._onSize)
> 
> self._SetSize()
> 
> def draw(self):   # just draw something!
> if not hasattr(self, 'subplot'):
> self.subplot = self.figure.add_subplot(111)
> theta = arange(0, 45*2*pi, 0.02)
> rad = (0.8*theta/(2*pi)+1)
> r = rad*(8 + sin(theta*7+rad/1.8))
> x = r*cos(theta)
> y = r*sin(theta)
> #Now draw it
> self.subplot.plot(x,y, '-r')
> 
> def _onSize(self, event):
> self._resizeflag = True
> 
> def _onIdle(self, evt):
>  if self._resizeflag:
>  self._resizeflag = False
>  self._SetSize()
>  self.draw()
> 
> def _SetSize(self, pixels = None):
> """
> This method can be called to force the Plot to be a desired
> size, which defaults to
> the ClientSize of the panel
> """
> if not pixels:
> pixels = self.GetClientSize()
> self.canvas.SetSize(pixels)
> self.figure.set_figsize_inches(pixels[0]/
> self.figure.get_dpi(),
> pixels[1]/self.figure.get_dpi())
> 
> 
> if __name__ == "__main__":
> 
> app = App(0)
> app.MainLoop()
> 
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Embedding-Matplotlib-in-wxpython-wx.

Re: xml yml and dependency hell

2007-07-10 Thread Bruno Desthuilliers
Rustom Mody a écrit :
> On 7/11/07, Stefan Behnel <[EMAIL PROTECTED]> wrote:
> 
>> Rustom Mody wrote:
> 
> 
>> > So is it likely that yaml will make it to the standard python library
>> > at some point??
>>
>> That's up to the maintainers of PyYAML. If they want to get it in, 
>> there will
>> be ways to get there. If they do not want to - unlikely, unless 
>> someone else
>> takes up the work. But it's definitely easier if the authors decide to 
>> put it in.
> 
> 
> Is this a general comment or specific to yaml?  I mean can anyone add
> anything they please to the python standard library?

No, definitively. But the process is supposed to be initiated by the 
maintainers. Have a look at pep 0002 for more informations.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: bool behavior in Python 3000?

2007-07-10 Thread Steven Bethard
Alan G Isaac wrote:
>  > Do you care to explain what is broken?
> 
> I suppose one either finds coercion of arithmetic operations to int
> to be odd/broken or does not.  But that's all I meant.
> 
> My preference would be for the arithmetic operations *,+,-
> to be given the standard interpretation for a two element
> boolean algebra:
> http://en.wikipedia.org/wiki/Two-element_Boolean_algebra

If I understand this right, the biggest difference from the current 
implementation would be that::

 True + True == True

instead of:

 True + True == 2

What's the advantage of that? Could you give some use cases where that 
would be more useful than the current behavior?

It's much easier to explain to newcomers that *, + and - work on True 
and False as if they were 1 and 0 than it is to introduce them to a two 
element boolean algebra. So making this kind of change needs a pretty 
strong motivation from real-world code.

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


Re: bool behavior in Python 3000?

2007-07-10 Thread Daniel
>>  > Do you care to explain what is broken?
>>  My preference would be for the arithmetic operations *,+,-
>> to be given the standard interpretation for a two element
>> boolean algebra:
>> http://en.wikipedia.org/wiki/Two-element_Boolean_algebra
>
> If I understand this right, the biggest difference from the current  
> implementation would be that::
>
>  True + True == True
>
> instead of:
>
>  True + True == 2
>
> What's the advantage of that? Could you give some use cases where that  
> would be more useful than the current behavior?
>

I prefer the use of 'and' and 'or', and they feel more pythonic than & and  
+

-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-07-10 Thread Bruno Desthuilliers
Paul Rubin a écrit :
> Bruno Desthuilliers <[EMAIL PROTECTED]> writes:
> 
>>>If the assertion is wrong, the compiler signals an error.  In
>>>that sense it's like a unit test; it makes sure the function does what
>>>the user expects.
>>
>>It still boils down to the same problem : possibly valid types are
>>rejected based on a declaration.
> 
> 
> I'm not sure what you mean.  If the programmer intended for the
> function to compute an integer, then it's invalid for the function to
> return (say) a string, whether there is a static typecheck or not.

I was mostly thinking of inputs, but it's the same thing for outputs - 
in most cases the concrete "type" (=> class) of the object returned by a 
function is no more significant than the concrete type(s) of it's 
input(s). What is important is that these objects supports the 
(implicit) protocols expected by either the function itself (for inputs) 
or the caller (for output(s)). And FWIW, in Python, it's not unusual for 
a function or method to be able to return objects of any type - cf the 
dict.get(key, default=None) method.

(snip)

>>>However, that may be a self-fulfilling prophecy since maybe I'm
>>>cultivating a coding style that doesn't use the dynamism,
>>
>>Perhaps is this coding style not making the best use of Python's
>>features ? To me, it sounds like doing procedural programming in OCaml -
>>it's of course possible, but probably not the best way to use the language.
>  
> This is in principle possible, though I feel like I'm coding more
> effectively since gravitating to this style. 

> Anton van Straaten (a
> dynamic typing proponent) wrote of static checks
> (http://lambda-the-ultimate.org/node/2216#comment-31954):
> 
> In most cases, the correctness proof itself is not the most important
> advantage of static checking of a program. Rather, it's the type
> discipline that must be followed in order to achieve that correctness
> proof. The final proof is like the certificate you get when you
> graduate from college: it's not that important by itself, but to have
> obtained it you must have done a lot of work, at least some of which
> is important and necessary. You can do the work without getting the
> certificate, but many people don't, and in the programming case they
> may pay a price for that in terms of programs with poor type
> discipline, which can have consequences for reasoning and the
> "ilities".
> 
> I coded a fair amount of Lisp before starting with Python though, so
> even before, I tended to code Python in a Lisp-like style, ignoring
> Python's more dynamic features such as metaclasses.

While my knowledge of Lisp is somewhat limited - I played with Common 
Lisp and Scheme (and Emacs Lisp) but never seriously used any Lisp 
dialect - it also had some influence on my coding style. But Python's 
support for "hi-level" programming - including the restricted support 
for functional approach - mostly comes from it's object model, and I 
prefer to take advantage of this object model instead of trying to write 
Lisp (or Haskell or whatever other FPL) in Python. A good example could 
be partial application - which in Python is better implemented as a 
class than using closures.

> I'd also compare the situation with Forth, where functions can consume
> and insert arbitrary numbers of values to the stack, but programmers
> in practice maintain careful stack discipline (making sure to pop and
> push a constant number of values, and documenting the meaning of each
> one) in order to avoid going crazy.  Just because the language offers
> you rope, doesn't mean you can't decline to hang yourself with it.

Indeed. But this doesn't mean you should not use the rope at all - 
specially when it happens to be the RightThing(tm) to do. Compare an old 
framework like Zope 2.x, and new ones (internally) making heavy use of 
metaclasses, descriptors etc, and you may find out that these features 
not only greatly help wrt/ both robustness (less boilerplate) and 
readability (less boilerplate), but also tend to encourage a more 
declarative style (.

> Finally, this article about "gradual typing" (you can write your code
> dynamically and then later add static annotations resulting in type
> safety) might be of interest:

I have too few problems with type errors to feel a need for more "type 
safety" than what Python actually provides, and I don't see the point of 
adding arbitrary restrictions. What's appropriate for language X is not 
necessarily appropriate for language Y, and I know where to find smart 
statically typed languages if and when I do need them.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Portable general timestamp format, not 2038-limited

2007-07-10 Thread Ilya Zakharevich
[A complimentary Cc of this posting was sent to
greg 
<[EMAIL PROTECTED]>], who wrote in article <[EMAIL PROTECTED]>:
> Ilya Zakharevich wrote:
> > In pedantic mode: negative timestamps make sense with Big Bang as the
> > epoch as well.  (AFAIU, the current way of thinking is that it was
> > "just too hot" before the big bang, it is not that "there was
> > nothing".)
> 
> If Stephen Hawking is right, the shape of the universe
> is such that there isn't any time "before" the big bang
> at all. It's like asking what's north of the North Pole.

I do not remember any statement like this - even from 70s...  Could
you provide a reference?  There were conjectures about "initial
singularity", but I do not recollect them related to SH.

> Of course, this may have been replaced with some other
> equally bizarre idea by now...

Nothing as bizzare as the "initial singularity".  There was a hot soup
not very far from a phase transition point; stochastically, some
micro-regions (bubbles) cool a little bit, and are subject to a phase
transition; due to transition, the metric in them grows (inflation),
so the "size" after transition [as seen from inside] is (hundreds?
thousands? millions? - I do not remember) orders of magnitude larger
than before transition - you get the universe-as-we-know-it as what sits
inside a "visible horizon" in such a babble.  Wiki for "inflation".

> Another thought: If the cosmologists ever decide if
> and when the Big Crunch is going to happen, we may be
> able to figure out once and for all how many bits we
> need in the timestamp.

In the "hot soup", it is very hard to construct a watch.  There may be
even some quantum-mechanical restrictions on bit storage in so hot a
matter (but I do not recollect seeing this).  If so, then indeed,
"nothing measurable" happens before and after inflation/collapse of
the universe-as-we-know-it; so timestamp would be restricted to the
interval between the bangs.

Hope this helps,
Ilya
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: bool behavior in Python 3000?

2007-07-10 Thread Bjoern Schliessmann
Alan Isaac wrote:

> Hoping the bool type will be fixed will be fixed,

Is there any type named "bool" in standard Python?

Regards,


Björn

-- 
BOFH excuse #207:

We are currently trying a new concept of using a live mouse. 
Unfortunately, one has yet to survive being hooked up to the
computer.please bear with us.

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


Re: bool behavior in Python 3000?

2007-07-10 Thread Bjoern Schliessmann
Alan G Isaac wrote:

> My preference would be for the arithmetic operations *,+,-
> to be given the standard interpretation for a two element
> boolean algebra:
> http://en.wikipedia.org/wiki/Two-element_Boolean_algebra

>>> [bool(True+True), bool(True+False)]
[True, True]

Works for me, or did I misunderstand you?

If you don't want explicitly to write bool, you could define your
own True and False classes.

Regards,


Björn

-- 
BOFH excuse #184:

loop found in loop in redundant loopback

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


Re: Best architecture for proxy?

2007-07-10 Thread Bjoern Schliessmann
Andrew Warkentin wrote:

> I am going to write a general-purpose modular proxy in Python. It
> will consist of a simple core and several modules for things like
> filtering and caching. I am not sure whether it is better to use
> multithreading, or to use an event-driven networking library like
> Twisted or Medusa/ Asyncore. Which would be the better
> architecture to use?

I'd definitely use an event-driven approach with Twisted. 

Generally, multithreading is less performant than multiplexing. High
performance servers mostly use a combination of both, though.

Regards,


Björn

-- 
BOFH excuse #306:

CPU-angle has to be adjusted because of vibrations coming from the
nearby road

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


Re: subprocess popen trouble

2007-07-10 Thread Gal Diskin

Your code seems correct to me.

Just as a long shot - have you tried setting  bufsize=0 ?


nik wrote:


I am having trouble using subprocess popen and stdin/stdout

I have the following simple test application written in C++, that just
echoes back the stdin. It works fine running from the command line:

#include 
#include 

int main (int argc, char * const argv[]) {
int currenttemp = 0;
int settemp = 0;
char* str;

while(currenttemp < 500){
gets(str);
sscanf(str, ">%d", &settemp);
currenttemp = settemp;
printf("<%d\n", currenttemp++);
}
return 0;
}

##
Then I have the following python code. A listener thread that waits
for the output of test and the main part that creates the subprocess
Popen object, passes it to the thread and then sends user input to the
subprocess test.


import subprocess
import os, sys
from threading import *
import time

class TempXListen(Thread):
""" thread to listen for incomming
messages and put them onto a
shared queue, no time lost processing incoming lines
"""
def __init__(self, channel):
""" connect internal response queue
to external queue
"""
Thread.__init__(self)
self.setDaemon(True)
self._channel = channel
self.start()

def run(self):
""" listening loop
reads line off of input source
puts the line into the response Q shared with parent
thread
sets event that parent is waiting for to indicate Q has at
least 1 element
"""
while 1:
try:
response = self._channel.stdout.readline() #
read input line
print response
except Exception, e:
print 'Listener Exception: ' + str(e)


print "Temp Monitor Test"
tempx = subprocess.Popen('/Users/engineeringadmin/Documents/test/build/
Debug/test', \
 bufsize=1, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, \
 stderr=subprocess.PIPE)

print tempx.stderr.readline()

listener = TempXListen(tempx)
while 1:
data = sys.stdin.readline()
if data != '':
data = '>' + data + '\n'
tempx.stdin.write(data)
print data
time.sleep(1)


###
When I run it this is the output:

Temp Monitor Test
warning: this program uses gets(), which is unsafe.

45
  

45




The subprocess is opened, because the warning is coming off of the
test applications stderr, but nothing else seems to go in or out. I've
been looking at a lot of examples and a lot of different postings, and
can't see any mistakes in my use of subprocess. I would really
appreciate it if somebody could see where I am going wrong.

Thank you,
Nik

  

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

  1   2   >