NovelSpace Media, LLC announces the launch of their new online bookstore and web portal devoted to developers and programmers.

2006-05-13 Thread paquejd
NovelSpace Media, LLC has announced the launch of its new online
bookstore, NovelSpace.com.  Located at http://www.novelspace.com, it
features a wide and varied selection of books for computer aficionados,
developers, software engineers, and programmers.  In addition to low
prices and shipping fees, NovelSpace.com boasts an easily navigated
interface along with quick checkout and simple account management.
Proceeds from each purchase are donated in support of various open
source projects.

NovelSpace Media is also inaugurating Developer Haven, the first in a
series of web portals to be developed by the company.  Designed as an
online resource for programmers and software developers, Developer
Haven features a section devoted to industry news and a directory of
links to websites with code samples, tutorials, components, and
software packages.  Users can also test-drive a beta version of DH
Search, an internet search engine tasked exclusively to researching
material related to programming and software development.  Developer
Haven can be accessed from NovelSpace.com, or on its own at
http://developerhaven.novelspace.com.

About NovelSpace Media, LLC

NovelSpace Media is a development firm currently specializing in
e-commerce and portal websites.  The driving goal of the company is to
offer customers easy access to books and resources at competitive
prices, as well as building thriving online communities around rich
content offered through topic specific web-portals.

[EMAIL PROTECTED]

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

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


Re: distributing a app frozen by cx_freeze

2006-05-13 Thread Carl Banks
Flavio wrote:
 Traceback (most recent call last):
   File
 /home/fccoelho/Downloads/cx_Freeze-3.0.2/initscripts/Console.py, line
 26, in ?
   File epigrass.py, line 4, in ?
 ImportError: /home/flavio/freeze/qt.so: undefined symbol:
 _ZNK9QSGIStyle9classNameEv

 It is looking for the Original cx_freeze installation!!

I doubt it is.

Do you have the QT installed on the second system?  If you do, is it
the same version as on the original system?  Are you sure you copied
all the files over?  It looks like qt.so is trying to access a C++
symbol in another library (libqt.so perhaps?), but that other library
isn't installed.

cx_freeze probably only packages the Python module binding to the QT
library; not the library itself.  If so, you'll need to install QT on
the other system, or get cx_freeze to bundle up the QT shared library
(if the license allows it, of course), or rebuild the qt.so with the
static QT libraries.


Carl Banks

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


Tail Call Optimization Decorator?

2006-05-13 Thread Casey Hawthorne
Tail Call Optimization and Recursion are separate concepts!
--
Regards,
Casey
-- 
http://mail.python.org/mailman/listinfo/python-list


Amazing offers for Computers,Laptops

2006-05-13 Thread [EMAIL PROTECTED]
Hy every one. An amazing opportunity for all the people to buy and get
all the information related to the Laptops, Computer Systems,
registration for free trail and for rental basis. Effort less  thing,
just  make look over www.eazyrentals.com

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


Re: distributing a app frozen by cx_freeze

2006-05-13 Thread Flavio
Thanks for the hint. I'll try to get cx_freeze to bundle up other
shared libraries it may not be bundling such as qtcanvas, qtext, qtui,
etc. and see if it works.

I'll post back the results to help other poor souls like me.

Thanks

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


Slovenian Python User Group

2006-05-13 Thread Sebastjan Trepca
Hi!

just wanted to send a notice about a new portal/group for Slovenian
Python fans here :)

http://soup.zen.si (btw, it's in slovene lang)

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


Re: A critic of Guido's blog on Python's lambda

2006-05-13 Thread Duane Rettig
Alexander Schmolck [EMAIL PROTECTED] writes:

 I think that in most contexts lexical transparency is desirable so that
 deviations from lexical transparency ought to be well motivated. I also
 believe that a construct that is usually used to establish a lexically
 transparent binding shouldn't be equally used for dynamic bindings so that it
 isn't syntactically obvious what's going on. I've already provided some
 reasons why CL's design wrt. binding special and lexical variables seems bad
 to me. I don't think these reasons were terribly forceful but as I'm not aware
 of any strong motivation why the current behaviour would be useful I'm
 currently considering it a minor wart.

 To make things more concrete: What would be the downside of, instead of doing
 something like:

 (let ((*x* ...)) [(declare (special *x*))] ...) ; where [X] denotes maybe X

Let's start with this.  You seem to be saying that the above construct is 
inferior
to the alternatives you are about to suggest.  Why?  And since you are adding
an optional form, let's break it down into its separate situations:

1. (let ((*x* ...)) (declare (special *x*)) ...)

Here there is no question about the specialness of *x*; it is textually
obvious what the binding is - that it is not a lexical binding but a special
binding.

2. (let ((*x* ...)) ...)

[where there is no special declaration for *x* within the form]

Here, the issue is that it is not obvious that *x* is special (in this case,
it would have to already be a dynamic variable (what we internally call
globally special), because a special declaration within a lexical context
does not affect inner bindings.  Perhaps this form is the one you are really
having trouble with.

 doing any of the below:

 a) using a different construct e.g. (fluid-let ((*x* ...)) ...) for binding
special variables

Unless you also _remove_ the #2 case above, this seems no diferent than writing
a macro for the #1 case, above.

 b) having to use *...* (or some other syntax) for special variables

In fact, the spec does suggest precisely this (see
http://www.franz.com/support/documentation/8.0/ansicl/dictentr/defparam.htm,
in the Notes section), and to the extent that programmers obey the suggestion,
the textual prompting is present in the name.

 c) using (let ((q (special *x*) (,a ,b ,@c)) (values 1 2 '(3 4 5 6)))
   (list q ((lambda () (incf *x*))) a b c)) ; = (1 3 3 4 (5 6))

 (It's getting late, but hopefully this makes some vague sense)

Well, sort of; this seems simply like a sometimes-fluid-let, whose syntax could
easily be established by a macro (with destructurings whose form is (special X)
could be specially [sic] treated.

Now if in the above example you would have trouble with (a) and/or (c)
based on the absence of a lexical declaration (i.e. one that would undo
the effect of a globally special declaration), thus guaranteeing that a
fluid-let or a sometimes-fluid-let would work, you should know that while
I was working on the Environments Access module I theorized and demonstrated
that such a declaration could be easily done within a conforming Common Lisp.
I leave you with that demonstration here (though it really is only for
demonstration purposes only; I don't necessarily propose that CL should add
a lexical declaration to the language):

[This only works on Allegro CL 8.0]:

CL-USER(1): (defvar pie pi)
PIE
CL-USER(2): (compile (defun circ (rad) (* pie rad rad)))
CIRC
NIL
NIL
CL-USER(3): (circ 10)
314.1592653589793d0
CL-USER(4): (compile (defun foo (x) (let ((pie 22/7)) (circ x
FOO
NIL
NIL
CL-USER(5): (foo 10)
2200/7
CL-USER(6): (float *)
314.2857
CL-USER(7): (sys:define-declaration sys::lexical (rest vars)
  nil
  :variable
  (lambda (declaration env)
(declare (ignore env))
(let* ((spec '(lexical t))
   (res (mapcar #'(lambda (x) (cons x spec))
(cdr declaration
  (values :variable res
SYSTEM::LEXICAL
CL-USER(8): (compile (defun foo (x) (let ((pie 22/7)) (declare (sys::lexical 
pie)) (circ x
; While compiling FOO:
Warning: Variable PIE is never used.
FOO
T
NIL
CL-USER(9): (foo 10)
314.1592653589793d0
CL-USER(10): 

-- 
Duane Rettig[EMAIL PROTECTED]Franz Inc.  http://www.franz.com/
555 12th St., Suite 1450   http://www.555citycenter.com/
Oakland, Ca. 94607Phone: (510) 452-2000; Fax: (510) 452-0182   
-- 
http://mail.python.org/mailman/listinfo/python-list


plot data from Excel sheet by Matplotlib, how?

2006-05-13 Thread N/A
Hi all,

Can any1 please guide me how to plot data from Excel by Matplotlib?
Let's say, I have 78(rows) x 8(cols) data in an Excel sheet. I would 
like to plot data for all 78(rows) at 4th column against data for all 
78(rows) at 7th column. How to plot it? Thank u!
-- 
http://mail.python.org/mailman/listinfo/python-list


Sending mail with attachment...

2006-05-13 Thread Merrigan
Hi,

I have now eventually finished my newbie-backup script and I'm very
proud of the way it functions...

Anyways, I am looking for an easy way to use smtplib to send an email
with the output log of the script to multiple accounts. I need to use
it with a smtp server, and cannot pipe it directly to sendmail.

I have tried about 50 different ways that I have googled for in the
last 6 hours, but none of them work, I keep on getting errors.

The script runs on a Linux system.

Thanks for any help.

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


Re: getting rid of pass

2006-05-13 Thread Bruno Desthuilliers
David Murmann a écrit :
 Hi all!
 
 i just had this crazy idea:
 
 instead of
 
 while cond():
pass
 
 write
 
 while cond().

Yuck

 or
 
 try:
import xyz
 except ImportError:
pass
 
 compared to
 
 try:
import xyz
 except ImportError.

Yuck again

 i don't know whether this is syntactically unambiguous or replaces all
 uses of pass, but i find it quite nice to read.

I don't. I find it highly unreadable. I really find the pass statement 
to be a great idea, and to highly improve readability.

 also if something like this has been proposed before and rejected, i
 apologize for this late-in-the-night idea.
 
 what do you people think?

Please don't feel offended, but I think it would be a very bad thing to do.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: compiling module from string and put into namespace

2006-05-13 Thread Bruno Desthuilliers
glomde a écrit :
 Tanks but that isn't what I am looking for.
 I really want a function that you can call and imports
 the module into the calling functions namespace.

Please read the documentation of the __import__() *function*. (notice 
the double leading and ending underscores and the parenthesis).

 I dont want the caller to call import but a function.

Please read the documentation of the __import__() *function*. (notice 
the double leading and ending underscores and the parenthesis).



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


Is it possible to set the date/time of a directory in windows with Python? If so how?

2006-05-13 Thread ToddLMorgan
I'm trying to set any of the dates (create, modification, access) of a
directory under windows with python.

I'm trying to do this as I'm trying to write a unittest for a directory
cleaning script I'm writing (ie I need the test to set the create/mod
time for some of the directories so that I can be sure that the script
works properly - as it picks dirs based upon their age).

I've tried using the utime( path, times). That doesn't work as the doco
states
Whether a directory can be given for path depends on whether the
operating system implements directories as files (for example, Windows
does not).

So that doesn't work.

So I tried mark hammonds win32 extensions with something like this

import win32file, win32con, pywintypes
filehandle = win32file.CreateFile(file,
win32file.GENERIC_WRITE,win32file.FILE_SHARE_WRITE,
None,win32con.OPEN_ALWAYS, 0, None)
nowWin32=pywintypes.Time(theTime)
win32file.SetFileTime(filehandle, nowWin32, nowWin32, nowWin32)

which works fine for files but fails with Access Denied when I invoke
the CreateFile with a directory. This seems to occur no matter the
combination of READ or WRITE I choose for the parameters.

So does anyone have any useful suggestions (other than not using
windows)?

I've thought of a couple of reallly nasty solutions:
1. Temporarily alter the underlying system clock back to the required
time and create the directory then resetting it back again afterwards.
2. Create the required directory in some form of virtual filesystem -
eg Zip file, rar archive, tar etc. Then extract it to the real
filesystem and hope windows honors the timestamps (untested at this
point).

None of those is particularly appealing.

Thanks for listening.

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


Re: Is it possible to set the date/time of a directory in windows with Python? If so how?

2006-05-13 Thread Roger Upole
ToddLMorgan [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]
 I'm trying to set any of the dates (create, modification, access) of a
 directory under windows with python.

 I'm trying to do this as I'm trying to write a unittest for a directory
 cleaning script I'm writing (ie I need the test to set the create/mod
 time for some of the directories so that I can be sure that the script
 works properly - as it picks dirs based upon their age).

 I've tried using the utime( path, times). That doesn't work as the doco
 states
 Whether a directory can be given for path depends on whether the
 operating system implements directories as files (for example, Windows
 does not).

 So that doesn't work.

 So I tried mark hammonds win32 extensions with something like this

 import win32file, win32con, pywintypes
 filehandle = win32file.CreateFile(file,
 win32file.GENERIC_WRITE,win32file.FILE_SHARE_WRITE,
 None,win32con.OPEN_ALWAYS, 0, None)
 nowWin32=pywintypes.Time(theTime)
 win32file.SetFileTime(filehandle, nowWin32, nowWin32, nowWin32)

 which works fine for files but fails with Access Denied when I invoke
 the CreateFile with a directory. This seems to occur no matter the
 combination of READ or WRITE I choose for the parameters.

 So does anyone have any useful suggestions (other than not using
 windows)?

 I've thought of a couple of reallly nasty solutions:
 1. Temporarily alter the underlying system clock back to the required
 time and create the directory then resetting it back again afterwards.
 2. Create the required directory in some form of virtual filesystem -
 eg Zip file, rar archive, tar etc. Then extract it to the real
 filesystem and hope windows honors the timestamps (untested at this
 point).

 None of those is particularly appealing.

 Thanks for listening.

To create a handle to a directory, you have to use
FILE_FLAG_BACK_SEMANTICS.

 Roger


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


Named regexp variables, an extension proposal.

2006-05-13 Thread Paddy
Proposal: Named RE variables
==

The problem I have is that I am writing a 'good-enough' verilog tag
extractor as a long regular expression (with the 'x' flag for
readability), and find myself both
 1) Repeating sections of the RE, and
 2) Wanting to add '(?Psome_clarifier...) ' around sections
 because I know what the section does but don't really want
 the group.

If I could write:
 (?P/verilog_name/ [A-Za-z_][A-Za-z_0-9\$\.]* | \\\S+ )

...and have the RE parser extract the section of RE after the second
'/' and store it associated with its name that appears between the
first two '/'. The RE should NOT try and match against anything between
the outer '(' ')' pair at this point, just store.

Then the following code appearing later in the RE:
  (?P=verilog_name)

...should retrieve the RE snippet named and insert it into the RE
instead of the '(?P=...)' group before interpreting the RE 'as normal'

Instead of writing the following to search for event declarations:
  vlog_extract = r'''(?smx)
# Verilog event definition extraction
(?: event \s+ [A-Za-z_][A-Za-z_0-9\$\.]* \s* (?: , \s*
[A-Za-z_][A-Za-z_0-9\$\.]*)* )
  '''
I could write the following RE, which I think is clearer:
  vlog_extract = r'''(?smx)
# Verilog identifier definition
(?P/IDENT/ [A-Za-z_][A-Za-z_0-9\$\.]* (?!\.) )
# Verilog event definition extraction
(?: event \s+ (?P=IDENT) \s* (?: , \s* (?P=IDENT))* )
  '''

Extension; named RE variables, with arguments
===
In this, all group definitions in the body of the variable definition
reference the literal contents of groups appearing after the variable
name, (but within the variable reference),  when the variable is
referenced

So an RE variable definition like:
  defs = r'(?smx) (?P/GO/ go \s for \s \1 )'

Used like:
  rgexp = defs + r
(?P=GO (it) )
\s+
(?P=\GO (broke) )
  
Would match the string:
  go for it  go for broke

As would:
  defs2 = r'(?smx) (?P/GO/ go \s for \s (?P=subject) )'
  rgexp = defs2 + r
(?P=GO (?Psubject it) )
\s+
(?P=\GO (?Psubject broke) )
  

The above would allow me to factor out sections of REs and define
named, re-ussable RE snippets.


Please comment :-)

- Paddy.

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


Re: How to install pyTrix?

2006-05-13 Thread Claudio Grondi
DeepBlue wrote:
 Hi all,
 
 can any1 please tell me how to install pyTrix?
 
 thx!
The first step should be to get it, but how can it be got?

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


Re: Sending mail with attachment...

2006-05-13 Thread Merrigan
Hi Guys,

I just wanted to post the error, and then also the coda that causes
itI get this no matter what I do to this, and I don't understand
it. Any help would be welcome. Thank you

Error
::
Traceback (most recent call last):
  File /home/merrigan/projects/Backup Script/hobbitarchive.py, line
113, in ?
mailSender()
  File /home/merrigan/projects/Backup Script/hobbitarchive.py, line
74, in mailSender
s.sendmail(fromaddy, recievelist, mesg.as_string())
  File /usr/lib/python2.4/email/Message.py, line 129, in as_string
g.flatten(self, unixfrom=unixfrom)
  File /usr/lib/python2.4/email/Generator.py, line 82, in flatten
self._write(msg)
  File /usr/lib/python2.4/email/Generator.py, line 120, in _write
self._write_headers(msg)
  File /usr/lib/python2.4/email/Generator.py, line 166, in
_write_headers
header_name=h, continuation_ws='\t').encode()
  File /usr/lib/python2.4/email/Header.py, line 395, in encode
return self._encode_chunks(newchunks, maxlinelen)
  File /usr/lib/python2.4/email/Header.py, line 355, in
_encode_chunks
_max_append(chunks, s, maxlinelen, extra)
  File /usr/lib/python2.4/email/quopriMIME.py, line 79, in
_max_append
L.append(s.lstrip())
AttributeError: 'list' object has no attribute 'lstrip'

::

Code
::
def mailSender():
openlogmsg = open(completelog, 'rb')
mesg = MIMEText(openlogmsg.read())
openlogmsg.close()
mesg['Subject'] = subject
mesg['From'] = fromaddy
mesg['To'] = recievelist
s = smtplib.SMTP(smtpserver)
#   s.connect(smtpserver)
s.sendmail(fromaddy, recievelist, mesg.as_string())
s.quit()

::

Thanks a lot :)

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


Re: A critic of Guido's blog on Python's lambda

2006-05-13 Thread Marcin 'Qrczak' Kowalczyk
Ken Tilton [EMAIL PROTECTED] writes:

 I think the point is that, with the variable actually being just
 a string and with dedicated new explicit functions required as
 accessors, well, you could hack that up in any language with
 dictionaries. It is the beginnings of an interpreter, not Python
 itself even feigning special behavior.

If the semantics and the global structure of the code is right, only
you don't like the local concrete syntax, then the complaint is at
most as justified as complaints against Lisp parentheses.

-- 
   __( Marcin Kowalczyk
   \__/   [EMAIL PROTECTED]
^^ http://qrnik.knm.org.pl/~qrczak/
-- 
http://mail.python.org/mailman/listinfo/python-list


SystemError: ... cellobject.c:22: bad argument to internal ?

2006-05-13 Thread robert
 From the trace of a 2.3.5 software i got:

\'SystemError:
C:sfpythondist23srcObjectscellobject.c:22: bad 
argument to internal
function\\n\']


from the middle of normal function / or its call. What is this?

There is:

http://mail.python.org/pipermail/python-list/2005-January/260273.html

but seems to be something else. There is no dynamic addition of 
class-method. But the last function called is a callback function  in 
3rd level inner function of class method like:

class X:
def a():
  def b():
...
def c():...# breaks with systemerror
schedule_callback(c)   # - upon Windows WM_TIMER event
...


Will there be another bug-fix release of Python 2.3   ?

-robert


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


Re: A critic of Guido's blog on Python's lambda

2006-05-13 Thread Marcin 'Qrczak' Kowalczyk
Alexander Schmolck [EMAIL PROTECTED] writes:

 I'd like to see a demonstration that using the same binding syntax
 for special and lexical variables buys you something apart from bugs.

There are 3 fundamental operations related to plain mutable variables:

A1. Making a new mutable variable with an initial value.
A2. Getting the current value.
A3. Setting the new value.

and 4 operations related to dynamically scoped variables:

B1. Making a new dynamic variable with an initial value.
B2. Getting the current value.
B3. Setting the new value.
B4. Local rebinding with a new initial value.

If you don't ever use B4, dynamic variables behave exactly like plain
variables. For this reason I see no point in distinguishing A2 from B2,
or A3 from B3. Dynamic variables are a pure extension of plain variables
by providing an additional operation.

Distinguishing the syntax of A1 and B1 is natural: somehow it must be
indicated what kind of variable is created.

Mutability is orthogonal to dynamic scoping. It makes sense to have a
variable which is like a plain variable but without A3, and a variable
which is like a dynamic variable but without B3, although it doesn't
provide anything new, only allows to express more constraints with a
potential for optimization. I won't consider them here.

Common Lisp does something weird: it uses the same syntax for A1 and B4,
where the meaning is distinguished by a special declaration. Here is
its syntax:

Directly named plain variables:
A1. (let ((name value)) body) and other forms
A2. name
A3. (setq name value), (setf name value)

First-class dynamic variables:
B1. (gensym)
B2. (symbol-value variable)
B3. (set variable value), (setf (symbol-value variable) value)
B4. (progv `(variable) `(value) body)

Directly named dynamic variables:
B1. (defvar name value), (defparameter name value)
B2. name
B3. (setq name value), (setf name value)
B4. (let ((name value)) body) and other forms

Dynamic variables in Lisp come in two flavors: first-class variables
and directly named variables. Directly named variables are always
global. You can convert a direct name to a first-class variable by
(quote name).

Plain variables have only the directly named flavor and they are
always local. You can emulate the first-class flavor by wrapping a
variable in a pair of closures or a closure with dual getting/setting
interface (needs a helper macro in order to be convenient). You can
emulate a global plain variable by wrapping a dynamic variable in a
symbol macro, ignoring its potential for local rebinding. You can
emulate creation of a new first-class variable by using a dynamic
variable and ignoring its potential for local rebinding, but this
can't be used to refer to an existing directly named plain variable.

In order to create a plain variable, you must be sure that its name is
not already used by a dynamic variable in the same scope.

So any essential functionality is possible to obtain, but the syntax
is very irregular.

-- 
   __( Marcin Kowalczyk
   \__/   [EMAIL PROTECTED]
^^ http://qrnik.knm.org.pl/~qrczak/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: where do you run database scripts/where are DBs 'located'?

2006-05-13 Thread BartlebyScrivener
John,

Yep, different module. I'll watch the thread. Perhaps once you get
connected, we should make a mini-HOWTO for XP users while it's fresh in
your mind,  because this question seems to come up a lot, and beginners
would probably appreciate a short howto that would perhaps detail how
to set up either mysqldb, mxodbc, or both on XP and get Python talking
to MySQL.

I think no matter which you choose, you will benefit from downloading
the mysql connector and adding your mysql db to datasources on XP. Then
you can access the db just by using the name you gave it in the
datasources panel, e.g. driv=bbdatabank

rick

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


Re: where do you run database scripts/where are DBs 'located'?

2006-05-13 Thread BartlebyScrivener
 driv=bbdatabank

Oops, sorry, I meant,

driv='DSN=bbdatabank'

rick

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


Re: Named regexp variables, an extension proposal.

2006-05-13 Thread John Machin
On 13/05/2006 7:39 PM, Paddy wrote:
[snip]
 Extension; named RE variables, with arguments
 ===
 In this, all group definitions in the body of the variable definition
 reference the literal contents of groups appearing after the variable
 name, (but within the variable reference),  when the variable is
 referenced
 
 So an RE variable definition like:
   defs = r'(?smx) (?P/GO/ go \s for \s \1 )'
 
 Used like:
   rgexp = defs + r
 (?P=GO (it) )
 \s+
 (?P=\GO (broke) )
   
 Would match the string:
   go for it  go for broke
 
 As would:
   defs2 = r'(?smx) (?P/GO/ go \s for \s (?P=subject) )'
   rgexp = defs2 + r
 (?P=GO (?Psubject it) )
 \s+
 (?P=\GO (?Psubject broke) )
   
 
 The above would allow me to factor out sections of REs and define
 named, re-ussable RE snippets.
 
 
 Please comment :-)


1. Regex syntax is over-rich already.
2. You may be better off with a parser for this application instead of 
using regexes.
3. \\ is overloaded to the point of collapse already. Using it as an 
argument marker could make the universe implode.
4. You could always use Python to roll your own macro expansion gadget, 
like this:

C:\junktype paddy_rx.py
import re
flags = r'(?smx)'
GO = r'go \s for \s 1 2'
WS = r'\s+'

ARGMARK = 

# Can the comments about the style of
# this code; I've just translated it from
# a now-dead language with max 6 chars in variable names :-)
def macsub(tmplt, *infils):
wstr = tmplt
ostr = 
while wstr:
   lpos = wstr.find(ARGMARK)
   if lpos  0:
  return ostr + wstr
   ostr = ostr + wstr[:lpos]
   nch = wstr[lpos+1:lpos+2]
   if 1 = nch = 9:
  x = ord(nch)-ord(1)
  if x  len(infils):
 ostr = ostr + infils[x]
   elif nch == ARGMARK: # double  (or whatever)
  ostr = ostr + ARGMARK
   else:
  ostr = ostr + ARGMARK + nch
   wstr = wstr[lpos+2:]
return ostr

regexp =  .join([
 flags,
 macsub(GO, 'it,\s', 'Paddy'),
 WS,
 macsub(GO, 'broke'),
 ])
print regexp
text = go for it, Paddy  go for broke
m = re.match(regexp, text)
print len(text), m.end()

C:\junkpaddy_rx.py
(?smx) go \s for \s it,\s Paddy \s+ go \s for \s broke
30 30



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


Re: Is it possible to set the date/time of a directory in windows with Python? If so how?

2006-05-13 Thread ToddLMorgan
Thanks very much for that roger :-)

I changed my code to

filehandle = win32file.CreateFile(file, win32file.GENERIC_WRITE,
win32file.FILE_SHARE_WRITE, None, win32con.OPEN_ALWAYS,
win32con.FILE_FLAG_BACKUP_SEMANTICS, None)
nowWin32=pywintypes.Time(theTime)
win32file.SetFileTime(filehandle, nowWin32, nowWin32, nowWin32)

ie FILE_FLAG_BACKUP_SEMANTICS and everything works fine

Just for the sake of completeness ...

I'd just thought of another solution ... to have python determine the
modification date for the directory based upon the oldest contained
file (I'm guessing windows does the opposite - ie the newest file mod)
to give me the effect of having a directory with an older date.

The virtual file system idea didn't work either ... files had the
correct dates but the dirs didn't as doing the extraction with python
libs is subject to the same constraints ... and I didn't think that
altering the ZipInfo time entries would have any affect as they appear
to only represent files and not directories. I could have spawned a
command line to do the extraction but I lost interest at that point.

thanks again

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


Re: Tkinter: ability to delete widgets from Text and then re-add them

2006-05-13 Thread nholtz
I now see that I can accomplish what I want using the Canvas widget,
instead of the
Text widget (I.e., I can create a window on it, delete the window, then
re add it without
recreating the underlying widget object).

As I don't want the raw contents user-editable, I guess its better to
use a Canvas, rather
than a Text (slightly harder to use, though, I guess)

neal

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


Re: Sending mail with attachment...

2006-05-13 Thread Tim Williams
On 13 May 2006 03:13:33 -0700, Merrigan [EMAIL PROTECTED] wrote:

 ::

 Code
 ::
 def mailSender():
 openlogmsg = open(completelog, 'rb')
 mesg = MIMEText(openlogmsg.read())
 openlogmsg.close()
 mesg['Subject'] = subject
 mesg['From'] = fromaddy
 mesg['To'] = recievelist
 s = smtplib.SMTP(smtpserver)
 #   s.connect(smtpserver)
 s.sendmail(fromaddy, recievelist, mesg.as_string())
 s.quit()

You are passing a list to the To: header,  it should be a string.

The To header needs to be a text representation of some/all/None of
the recipients, or it can contain unrelated text,  its a field that
the mail client uses to display the email details, it is not related
to the sending of the email.

The recievelist used during the sendmail function should contain the
list of recipient address(es), which means all the TO , CC and BCC
addresses for that email - or it can be  a string of 1 address if you
are on a recent version of Python and there is only 1 recipient.

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


Re: reusing parts of a string in RE matches?

2006-05-13 Thread Mirco Wahab
Hi Fredrik

you brought up some terse and
somehow expressive lines with
their own beauty ...

 [this] is best done by a list comprehension:
l = [m[1] for m in re.findall(r, t)]
 
 or, [...] a generator expression:
g = (m[1] for m in re.findall(r, t))
 
 or
process(m[1] for m in re.findall(r, t))
 
 ... avoid creating the tuples, ... finditer instead:
 l = [m.group(2) for m in re.finditer(r, t)]
 g = (m.group(2) for m in re.finditer(r, t))
 
 finditer is also a good tool to use 
 for m in re.finditer(r, t):
 s = m.group(2)
 ... process s in some way ...

... which made me wish to internalize such wisdom too ;-)

This looks almost beautiful, it made me stand up and
go to some large book stores in order to grab a good
book on python.

Sadly, there were none (except one small 'dictionary',
ISBN: 3826615123). I live in a fairly large city
in Germany w/three large bookstores in the center,
where one can get loads of PHP and Java books, lots
of C/C++ and the like - even some Ruby books (some
Rails too) on display (WTF).

Not that I wouldn't order books (I do that all the
time for 'original versions') but it makes one
sad-faced to see the small impact of the Python
language here today on bookstore-tournarounds ...

Thanks  regards

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


Re: python soap web services

2006-05-13 Thread Butternut squash
Diez B. Roggisch wrote:

 Butternut squash wrote:
 
 Is there any reason why there isn't any python library that makes
 using soap as easy as how microsoft .net makes it.
 
 I mean I write rudimentary asmx files call them from a webbrowser.
 The WSDL is generated and then there is documentation and a form to
 invoke a function.
 
 The WSDL will never as easily be created as in .NET/JAVA, as Python lacks
 static typing annotations that are used by the WSDL-generators. So either
 someone defines his own type annotation theme for that purpose that can be
 used to infer the WSDL  - or you write WSDL yourself. Which is a major
 PITA, as the whole SOAP mess.
 
 Ravi OTH has pointed out _running_ a SOAP service is easy as cake.


I agree python soap is pretty easy to use.  Just a bit harder to use the c#
classic way to call a web service.


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


Re: Sending mail with attachment...

2006-05-13 Thread [EMAIL PROTECTED]
Replace:
mesg['To'] = recievelist 
By:
mesg['To'] = ', '.join(recievelist)

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


Re: How to pass variables between scripts

2006-05-13 Thread Jonathan Smith
Gross, Dorit (SDRN) wrote:
  [snip]
  for f in fileList:
  try:
  globvars = {'infile' : f}
  locvars = {}
  execfile('/scripts/second.py', globvars(), locvars)
  except IOError:
  exit(0)
  print locvars
 
 
  And this is what happens when calling test_exec.py
 
   ./test_exec.py
  Traceback (most recent call last):
File ./test_exec.py, line 19, in ?
  execfile('/scripts/second.py', vars(), results)
  TypeError: 'dict' object is not callable
 

Why do you try to call globevars as if it was a function? As the 
traceback states, dictionaries can't be called like that. Just take the 
() out and try again.

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


Package that imports with name of dependent package

2006-05-13 Thread David Pratt
Hi. I have code that currently depends on a particular package of a 
framework. I have decided I want to create my own package because I have 
made many changes and it is getting too difficult to maintain each time 
I retrieve an updated version of the framework from svn.

The problem is, that there are all sorts of imports to the dependent 
package throughout my code and I just want to replace this module with 
something that will provide a reference to my own package without 
changing the original imports. So it just needs to point to the new 
package so that the original imports in my code will continue to work.

For example, here is a package structure.

dependentpackage
|
+  __init__.py
+ somemodule.py
+ somefolder
  |
  +  __init__.py
  + somesubmodule.py
+ someotherfolder
etc 

I simply want the dependentpackage to point to the new package leaving 
no more than an init file or whatever would have to be minimally 
required to make this work

dependentpackage
|
+  __init__.py

mypackage
|
+  __init__.py
+ somemodule.py
+ somefolder
  |
  +  __init__.py
  + somesubmodule.py
+ someotherfolder
etc 

I my code I still need to have this work:

from dependentpackage.somemodule import something

- but I want the package to be getting the code from the new module.

I'd appreciate hearing of what I can do in an __init__ file or what 
other strategy could make this work. Many thanks.

Regards,
David

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


Re: python rounding problem.

2006-05-13 Thread Florian Diesch
Thomas Bartkus [EMAIL PROTECTED] wrote:

 Grant Edwards [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
 On 2006-05-08, Thomas Bartkus [EMAIL PROTECTED] wrote:

  does python support true rations, which means that 1/3 is a
  true one-third and not 0.3 rounded off at some
  arbitrary precision?
 
  At risk of being boring  ;-)
 
  - Python supports both rational and irrational numbers as
floating point numbers the way any language on any digital
computer does - imprecisely.
 
  A true (1/3) can only be expressed as a fraction.

 At the risk of being both boring and overly pedantic, that's
 not true.  In base 3, the value in question is precisely
 representable in floating point: 0.1

  As soon as you express it as a floating point - you are in a
  bit of trouble because that's impossible.

 It's not possible in base 2 or base 10.  It's perfectly
 possible in base 9 (used by the Nenets of Northern Russia) base
 12 (popular on planets where everybody has twelve toes) or base
 60 (used by th Sumerians).  [I don't know if any of those
 peoples used floating point in those bases -- I'm just pointing
 out that your prejudice towards base 10 notation is showing.]

  You can not express (1/3) as a floating point in Python any
  more than you can do it with pencil and paper.

 That's true assuming base 2 in Python and base 10 on paper. The
 base used by Python is pretty much etched in stone (silicon, to
 be precise).  There used to be articles about people working on
 base-3 logic gates, but base-3 logic never made it out of the
 lab. However, you can pick any base you want when using paper
 and pencil.

  You can be precise and write 1/3 or you can surrender to
  arithmetic convenience and settle for the imprecise by writing
  0.3, chopping it off at some arbitrary precision.

 Or you can write  0.1
  3

 :)

 Ahhh!
 But if I need to store the value 1/10 (decimal!), what kind of a precision
 pickle will I then find myself while working in base 3 ?  How much better
 for precision if we just learn our fractions and stick to storing integer
 numerators alongside integer denominators in big 128 bit double registers ?

 Even the Nenets might become more computationally precise by such means ;-)
 And how does a human culture come to decide on base 9 arithmetic anyway?

Just guessing: 
 * Use one thumb to point at one of the other 9 fingers
 * Every finger (except for the thumb) has 3 segments (and links), each
   of which can easily divided in three part (upper, middle, lower or left
   middle, right for the links) making 9 points for each finger.


 Even base 60 makes more sense if you like it when a lot of divisions come
 out nice and even.

You can count to 60 using two hands: Use the right thumb to point on
one of the 12 segments of the remaining 4 fingers and on the left hand
one finger for each dozen.


Of course this is wasting resources as you can count to 1023 with your
fingers. I never heard of a culture doing so, though.



   Florian
-- 
http://www.florian-diesch.de/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Package that imports with name of dependent package

2006-05-13 Thread Maric Michaud
Le Samedi 13 Mai 2006 16:05, David Pratt a écrit :
 I'd appreciate hearing of what I can do in an __init__ file or what
 other strategy could make this work. Many thanks.
you should leave the original package intact and patch it with new mehod and 
moddule; for example (A is the original package):
A/__init__.py
A/B/__init__.py
A/B/C.py
X/__init__.py
X/B/__init__.py
X/B/C.py

just write in X/__init__.py :
import A.B.C, B.C
A.B.C = B.C


and all from A.B import C following an import of X will return X.B.C. 

This is how we monkeypatch products in Zope.

-- 
_

Maric Michaud
_

Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Package that imports with name of dependent package

2006-05-13 Thread Peter Otten
David Pratt wrote:

 Hi. I have code that currently depends on a particular package of a
 framework. I have decided I want to create my own package because I have
 made many changes and it is getting too difficult to maintain each time
 I retrieve an updated version of the framework from svn.
 
 The problem is, that there are all sorts of imports to the dependent
 package throughout my code and I just want to replace this module with
 something that will provide a reference to my own package without
 changing the original imports. So it just needs to point to the new
 package so that the original imports in my code will continue to work.
 
 For example, here is a package structure.
 
 dependentpackage
 |
 +  __init__.py
 + somemodule.py
 + somefolder
   |
   +  __init__.py
   + somesubmodule.py
 + someotherfolder
 etc 
 
 I simply want the dependentpackage to point to the new package leaving
 no more than an init file or whatever would have to be minimally
 required to make this work
 
 dependentpackage
 |
 +  __init__.py
 
 mypackage
 |
 +  __init__.py
 + somemodule.py
 + somefolder
   |
   +  __init__.py
   + somesubmodule.py
 + someotherfolder
 etc 
 
 I my code I still need to have this work:
 
 from dependentpackage.somemodule import something
 
 - but I want the package to be getting the code from the new module.
 
 I'd appreciate hearing of what I can do in an __init__ file or what
 other strategy could make this work. Many thanks.

I think fixing the imports is the better long-term approach. But putting

from pkgutil import extend_path
import mypackage
__path__ = extend_path(mypackage.__path__, __name__)

into dependentpackage/__init__.py might work. 

Peter



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


Re: distributing a app frozen by cx_freeze

2006-05-13 Thread Flavio
Well I managed to get rid of the undefined symbol message by copying
all qt libs to the freeze directory, the problem is that now the
package is huge (83MB)!

So my question is: is there a way to find out exactly which lib is
missing ?

Thanks

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


Unicode ZSI interaction ??

2006-05-13 Thread Joakim Hove

Dear newsgroup,

I have written a cgi script in Python, and it has worked fine for some
time. Now the installed Python version has been upgraded to 2.4.1 and
I am having problems with non ascii characters.

The core of the problem I have is as follows:

  1. The webpage contains a text field where the user enters her/his
 name.

  2. My cgi script uses the 'cgi' class to extract the name the user
 has entered.

  3. The cgi script writes the name the user has given to a file.

Now, the webpage in question is in Norway; and many Norwegian names
are not 8bit clean, i.e. they contain characters which can not be
represented with a 7bit ascii encoding. As a consequence I get
*either* a UnicodeDecodeError *or* just blanks when writing it to
file.


Simplest case:
--

name = Åse
fileH = open(/tmp/namelist.txt,w)
fileH.write(name)

In this case the first character in the name variable is not in the
plain 7bit ascii encoding. The code written above runs without errors
or warnings, but the problematic character is simple replaced by a
space in the file '/tmp/namelist.txt'.



More complicated case:
--
The application uses the SOAP protocol via the ZSI module to
communicate with some other site. The SOAP call returns a variable,
and when this variable is combined with the name variable above I get
the UnicodeDecodeError:

name = ÅSE
ref  = SOAP_return_value()
fileH = open(/tmp/namelist.txt,a)
fileH.write(name:%s  ref:%s \n % (name,ref))
fileH.close()

This bombs with: 

   UnicodeEncodeError: 'ascii' codec can't encode character u'\xc5' in
   position 45: ordinal not in range(128) 

The variable 'ref' returned from the SOAP interaction is (seemingly
...) pure 7bit ascii.



Any suggestions greatly appreciated.

Joakim Hove



-- 
Joakim Hove
hove AT ntnu.no/
Tlf: +47 (73 5)9 34 27/ Stabburveien 18  
Fax: .   /  N-5231 Paradis   
http://www.ift.uib.no/~hove//   55 91 28 18 / 92 68 57 04
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: where do you run database scripts/where are DBs 'located'?

2006-05-13 Thread Lou Losee
On 5/13/06, Dennis Lee Bieber [EMAIL PROTECTED] wrote:
On Fri, 12 May 2006 21:00:49 -0400, John Salerno[EMAIL PROTECTED] declaimed the following in comp.lang.python: Latest development: I turned off my firewall and it worked. :)
Next step -- figure out what rule you need to define to the firewallto permit it to work...--WulfraedDennis Lee Bieber KD6MOG
[EMAIL PROTECTED] [EMAIL PROTECTED]HTTP://wlfraed.home.netcom.com/(Bestiaria Support Staff: 
[EMAIL PROTECTED])HTTP://www.bestiaria.com/--
http://mail.python.org/mailman/listinfo/python-listThe default port that the MySQL server listens on is 3306. This can be changed during install.-- Artificial Intelligence is no match for Natural Stupidity
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Package that imports with name of dependent package

2006-05-13 Thread Peter Otten
Peter Otten wrote:

 I'd appreciate hearing of what I can do in an __init__ file or what
 other strategy could make this work. Many thanks.
 
 I think fixing the imports is the better long-term approach. But putting
 
 from pkgutil import extend_path
 import mypackage
 __path__ = extend_path(mypackage.__path__, __name__)
 
 into dependentpackage/__init__.py might work.

One big caveat: If you are mixing both

import mypackage.somemodule

and

import dependentpackage.somemodule

in the same application, mypackage.somemodule and
dependentpackage.somemodule are *not* the same module instance. This may
have surprising effects when global variables in somemodule.py are
updated...

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


Re: Package that imports with name of dependent package

2006-05-13 Thread David Pratt
Hi Peter. I'd like to fix the imports, but this would impact the 
portability of portions of the code that currently work with the 
existing package from the framework.

This solution does the trick and allows me to create the package I want 
using a good amount of new material. I don't have to worry about adding 
to the original package each time a release comes out. I'll only have to 
monitor code changes for an impact on my classes, subclasses, etc. Still 
a pain, but a smaller one :-)  Many thanks.

Regards
David


Peter Otten wrote:
 from pkgutil import extend_path
 import mypackage
 __path__ = extend_path(mypackage.__path__, __name__)
 
 into dependentpackage/__init__.py might work. 
 
 Peter
 
 
 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Named regexp variables, an extension proposal.

2006-05-13 Thread Paul McGuire

Paddy [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Proposal: Named RE variables
 ==

 The problem I have is that I am writing a 'good-enough' verilog tag
 extractor as a long regular expression (with the 'x' flag for
 readability), and find myself both
  1) Repeating sections of the RE, and
  2) Wanting to add '(?Psome_clarifier...) ' around sections
  because I know what the section does but don't really want
  the group.

 If I could write:
  (?P/verilog_name/ [A-Za-z_][A-Za-z_0-9\$\.]* | \\\S+ )

 ...and have the RE parser extract the section of RE after the second
 '/' and store it associated with its name that appears between the
 first two '/'. The RE should NOT try and match against anything between
 the outer '(' ')' pair at this point, just store.

 Then the following code appearing later in the RE:
   (?P=verilog_name)

 ...should retrieve the RE snippet named and insert it into the RE
 instead of the '(?P=...)' group before interpreting the RE 'as normal'

 Instead of writing the following to search for event declarations:
   vlog_extract = r'''(?smx)
 # Verilog event definition extraction
 (?: event \s+ [A-Za-z_][A-Za-z_0-9\$\.]* \s* (?: , \s*
 [A-Za-z_][A-Za-z_0-9\$\.]*)* )
   '''
 I could write the following RE, which I think is clearer:
   vlog_extract = r'''(?smx)
 # Verilog identifier definition
 (?P/IDENT/ [A-Za-z_][A-Za-z_0-9\$\.]* (?!\.) )
 # Verilog event definition extraction
 (?: event \s+ (?P=IDENT) \s* (?: , \s* (?P=IDENT))* )
   '''


By contrast, the event declaration expression in the pyparsing Verilog
parser is:

identLead = alphas+$_
identBody = alphanums+$_
#~ identifier = Combine( Optional(.) +
#~   delimitedList( Word(identLead, identBody), .,
combine=True ) ).setName(baseIdent)
# replace pyparsing composition with Regex - improves performance ~10% for
this construct
identifier = Regex(
r\.?[+identLead+][+identBody+]*(\.[+identLead+][+identBody+]*)* ).
setName(baseIdent)

eventDecl = Group( event + delimitedList( identifier ) + semi )


But why do you need an update to RE to compose snippets?  Especially
snippets that you can only use in the same RE?  Just do string interp:

 I could write the following RE, which I think is clearer:
   vlog_extract = r'''(?smx)
 # Verilog identifier definition
 (?P/IDENT/ [A-Za-z_][A-Za-z_0-9\$\.]* (?!\.) )
 # Verilog event definition extraction
 (?: event \s+ (?P=IDENT) \s* (?: , \s* (?P=IDENT))* )
   '''
IDENT = [A-Za-z_][A-Za-z_0-9\$\.]* (?!\.)
vlog_extract = r'''(?smx)
  # Verilog event definition extraction
  (?: event \s+ %(IDENT)s \s* (?: , \s* %(IDENT)s)* )
  ''' % locals()

Yuk, this is a mess - which '%' signs are part of RE and which are for
string interp?  Maybe just plain old string concat is better:

IDENT = [A-Za-z_][A-Za-z_0-9\$\.]* (?!\.)
vlog_extract = r'''(?smx)
  # Verilog event definition extraction
  (?: event \s+ ''' + IDENT + ''' \s* (?: , \s* ''' + IDENT + ''')* )'''

By the way, your IDENT is not totally accurate - it does not permit a
leading ., and it does permit leading digits in identifier elements after
the first ..  So .goForIt would not be matched as a valid identifier
when it should, and go.4it would be matched as valid when it shouldn't (at
least as far as I read the Verilog grammar).

(Pyparsing (http://sourceforge.net/projects/pyparsing/) is open source under
the MIT license.  The Verilog grammar is not distributed with pyparsing, and
is only available free for noncommercial use.)

-- Paul


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


Factory pressed dvd movies, ps2, psp xbox backups for sale !!!

2006-05-13 Thread yuna77
We're offering all the latest factory pressed high quality dvd movies,
ps2, psp and xbox silvers with factory printed colour inserts at
fantastic prices, whether for personal use or reselling. We're shipping
worldwide with various shipping methods. For resellers, please contact
us for bulk discounts.

For a complete list and prices, please email us at
[EMAIL PROTECTED]

(Please state the type of list that you want and tell us your location
as the prices varies for different locations. If you're reseller,
please state the quantity you wish to order per shipment and we'll
quote you a wholesale price depending on the quantity ordered.)

* If you need references, we can provide them to you.

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


Re: Package that imports with name of dependent package

2006-05-13 Thread David Pratt
Hi Peter. Thank you for this warning. I'll document this in the code. I 
plan on importing only from dependentpackage for portability. Also, much 
in the framework relies upon it. This approach is primarily for 
maintenance purposes and would also allow me to package the modified 
dependentpackage (with just the __init__.py ) along with mypackage if I 
plan to distribute it. It allows it to be a drop in replacement.

I am hoping with packaging utilities, I can easily remove the 
dependentpackage if it is encountered in site-packages to replace it 
with my own.

Regards,
David


Peter Otten wrote:
 Peter Otten wrote:
 
 I'd appreciate hearing of what I can do in an __init__ file or what
 other strategy could make this work. Many thanks.
 I think fixing the imports is the better long-term approach. But putting

 from pkgutil import extend_path
 import mypackage
 __path__ = extend_path(mypackage.__path__, __name__)

 into dependentpackage/__init__.py might work.
 
 One big caveat: If you are mixing both
 
 import mypackage.somemodule
 
 and
 
 import dependentpackage.somemodule
 
 in the same application, mypackage.somemodule and
 dependentpackage.somemodule are *not* the same module instance. This may
 have surprising effects when global variables in somemodule.py are
 updated...
 
 Peter
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Slovenian Python User Group

2006-05-13 Thread [EMAIL PROTECTED]

Sebastjan Trepca wrote:
 Hi!

 just wanted to send a notice about a new portal/group for Slovenian
 Python fans here :)

 http://soup.zen.si (btw, it's in slovene lang)

But why is SOUP (Slovenski Ortodoksni Uporabniki Pythona)
used as an acronym?

Or is SOUP a word in Slovene also?


 
 Sebastjan

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


PyX on Windows

2006-05-13 Thread Tom Longridge
Hi,

I'm trying to use PyX to draw some diagrams with text in. I want to
change the font, so need to change the text mode from TeX to LaTeX.
However I get an error when I do so:

pyx.text.TexResultError: unhandled TeX response (might be an error)
The expression passed to TeX was:
  \documentclass{article}%
  \PyXInput{3}%
After parsing the return message from TeX, the following was left:
  *
  *(C:\Program Files\MiKTeX\tex\latex\base\article.cls
  Document Class: article 2004/02/16 v1.4f Standard LaTeX document
class
  (C:\Program Files\MiKTeX\tex\latex\base\size10.clo))

I'm using MikTek on Windows to run LaTeX; does anyone know if is this
likely to be the problem?

Many thanks,
Tom

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


Setting up InformixDb

2006-05-13 Thread The Shaffer s
I have an informix database on a unix machine which I want to access. I
downloaded InformixDb-2.2 and managed to get it built and installed and it
works fine with python.

My problem is I want to access the same database from a PC remotely. Yes, I
already have informix setup and configured on the unix machine to accept
connections remotely. And, I can connect to it fine from an ODBC interface
to Excel and Access.

But, to build the informix module requires the INFORMIXDIR environment
variable set to it which I don't believe I can set to a remote machine.

So, how can I get this module built without having an informix installed on
my PC?

Thanks.

Ken

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


Re: problemi con POST

2006-05-13 Thread Alex Martelli
Heavy [EMAIL PROTECTED] wrote:

 Sorry,
 you got reason, I thought I can write in my language, cause this is the
 first time that I post a question in this group... My problem is that I
 have to receive parameters from a POST method, i try to read them from
 the socket 'rfile', but this action is blocking, it never finish to
 read. Is there some existing method that can help me? Can you help me?
 thanks...

Post your question to it.comp.lang.python -- THAT is an Italian
newsgroup for Python.

Poni la domanda su it.comp.lang.python -- QUELLO e` un newsgroup
italiano per Python.


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


Re: compiling module from string and put into namespace

2006-05-13 Thread glomde
 I dont want the caller to call import but a function.

come again?

 type (__builtins__.__import__)

type 'builtin_function_or_method'

I didnt mean that  __import__ isnt a function, but that I want to
make a function called ImoprtFile that actually does something
very similar that what __import__.

So to rephrsase the questin how does __import__ load a module
into the callers namespace.

Example:

file1

def ImportFile(fileName):
parsedCode = Parser(fileName).Parse()
module = new.module(name)
exec parsedCode in module.__dict__
sys.modules[name] = module
import name #!!! This doesn't work. Imports in file1
namespace!

file2

import file1

file1.ImportFile(fileName)
fileName.function()  #This wont work because the import happened
locally in file1!

Now the import in file1 doesnt take effect in file2. So what do I have
to
do to make that work. And I dont want to do a custom hook to import.
So how does __import__ do?

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


Re: where do you run database scripts/where are DBs 'located'?

2006-05-13 Thread John Salerno
Dennis Lee Bieber wrote:
 On Fri, 12 May 2006 21:00:49 -0400, John Salerno
 [EMAIL PROTECTED] declaimed the following in comp.lang.python:
 
 Latest development: I turned off my firewall and it worked. :)
 
   Next step -- figure out what rule you need to define to the firewall
 to permit it to work...

Yeah, that's actually what I'm trying to do now. I'm not sure how to 
define it, but I assume it has something to do with 3306, since that's 
the default.

I remember when I first installed MySQL on my computer, it would never 
get past the configuration wizard, also because of a port/firewall 
issue. So I uninstalled it, and then reinstalled it with the firewall 
off and it worked fine. And this works fine too with the firewall off, I 
just need to figure out what the criteria are for the new rule I need.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: where do you run database scripts/where are DBs 'located'?

2006-05-13 Thread John Salerno
BartlebyScrivener wrote:
 John,
 
 Yep, different module. I'll watch the thread. Perhaps once you get
 connected, we should make a mini-HOWTO for XP users while it's fresh in
 your mind,  because this question seems to come up a lot, and beginners
 would probably appreciate a short howto that would perhaps detail how
 to set up either mysqldb, mxodbc, or both on XP and get Python talking
 to MySQL.
 
 I think no matter which you choose, you will benefit from downloading
 the mysql connector and adding your mysql db to datasources on XP. Then
 you can access the db just by using the name you gave it in the
 datasources panel, e.g. driv=bbdatabank
 
 rick
 

Well, I'm not too sure I need to do this now. The problem wasn't 
anything to do with mysqldb after all, it was just that my firewall 
wasn't allowing the connection. But with the firewall off, everything 
seems to work fine.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Sending mail with attachment...

2006-05-13 Thread John Salerno
Merrigan wrote:

   mesg['To'] = recievelist

It's already been pointed out that this is a problem, but I just wanted 
to mention also that 'recieve' is misspelled, in case that affects 
anything, or others who might read/use the code.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: where do you run database scripts/where are DBs 'located'?

2006-05-13 Thread BartlebyScrivener
 But with the firewall off, everything
 seems to work fine.

Whatever works. But I'm having trouble imagining how a firewall would
interfere with you accessing your own db on localhost.

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


Re: compiling module from string and put into namespace

2006-05-13 Thread glomde
Ok, now I think I know what I need to do.
I need to create a variable in the calling functions locals.
So how do I get access to the calles locals dictionary?
Is it possible?

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


Re: SystemError: ... cellobject.c:22: bad argument to internal ?

2006-05-13 Thread [EMAIL PROTECTED]
robert wrote:
 From the trace of a 2.3.5 software i got:

 \'SystemError:
 C:sfpythondist23srcObjectscellobject.c:22: bad
 argument to internal
 function\\n\']

...

 Will there be another bug-fix release of Python 2.3   ?

No, is this still a problem in 2.4?  2.4.4 is planned to be released
this summer.  Can you post the entire code (that doesn't reference
anything outside the stdlib) that causes this problem?

n

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


Re: compiling module from string and put into namespace

2006-05-13 Thread Edward Elliott
glomde wrote:

 I didnt mean that  __import__ isnt a function, but that I want to
 make a function called ImoprtFile that actually does something
 very similar that what __import__.
 
 So to rephrsase the questin how does __import__ load a module
 into the callers namespace.

Ok got it now.  I'm sure it's doable but it sounds tricky.  Wouldn't it be
easier to just have your function return a list of modules to the caller
and have the caller import them?

-- 
Edward Elliott
UC Berkeley School of Law (Boalt Hall)
complangpython at eddeye dot net
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: distributing a app frozen by cx_freeze

2006-05-13 Thread Carl Banks

Flavio wrote:
 Well I managed to get rid of the undefined symbol message by copying
 all qt libs to the freeze directory, the problem is that now the
 package is huge (83MB)!

 So my question is: is there a way to find out exactly which lib is
 missing ?

You know, if you're doing this on Linux, it's not all that unreasonable
to require QT to be installed on the target system.  Any reasonable
distribution has it nicely packaged.

But, if you must, ldd qt.so will list library dependencies of qt.so.


Carl Banks

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


Re: where do you run database scripts/where are DBs 'located'?

2006-05-13 Thread John Salerno
BartlebyScrivener wrote:
 But with the firewall off, everything
 seems to work fine.
 
 Whatever works. But I'm having trouble imagining how a firewall would
 interfere with you accessing your own db on localhost.
 

I don't know either. Something to do with the ports it's trying to use I 
guess.
-- 
http://mail.python.org/mailman/listinfo/python-list


[ANN] PanDAV on SourceForge.net

2006-05-13 Thread Ivan Voras
Around three weeks ago there was a thread about Python WebDAV servers, 
and I mentioned my PanDAV work (old homepage: 
http://ivoras.sharanet.org/projects/pandav.html). There was some 
interest in continuing the development and merging patches made by its 
users, so I requested a SourceForge project for it. Due to some internal 
delay in SourceForget it took a while until the project was created, but 
now it's there!

The project's home is http://sourceforge.net/projects/pandav/. If any of 
the thread's original posters (or anyone else) are interested, please 
create a SourceForge.net account and contact me.

The current version in CVS contains code and patches (for better 
compatibility with Windows XP) which is not present in the original package.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Slow network reading?

2006-05-13 Thread Andrew MacIntyre
Ivan Voras wrote:
 Andrew MacIntyre wrote:
 
 Comparative CPU  memory utilisation statistics, not to mention platform 
 and version of Python, would be useful hints...
 
 During benchmarking, all versions cause all CPU to be used, but Python 
 version has ~1.5x more CPU time allocated to it than PHP. Python is 2.4.1

A pretty fair indication of the Python interpreter doing a lot more work...

 Note that the file-like object returned by makefile() has significant
 portions of heavy lifting code in Python rather than C which can be a
 drag on ultimate performance...  If on a Unix platform, it may be worth
 experimenting with os.fdopen() on the socket's fileno() to see whether
 the core Python file object (implemented in C) can be used in place of
 the lookalike returned from the makefile method.

 That's only because I need the .readline() function. In C, I'm using 
 fgets() (with the expectation that iostream will buffer data).

The readline method of the file object lookalike returned by makefile
implements all of the line splitting logic in Python code, which is very
likely where the extra process CPU time is going.  Note that this code is
in Python for portability reasons, as Windows socket handles cannot be
used as file handles the way socket handles on Unix systems can be.

If you are running on Windows, a fair bit of work will be required to
improve performance as the line splitting logic needs to be moved to
native code - I wonder whether psyco could do anything with this?.

 Even without that, you are specifying a buffer size smaller than the
 default (8k - see Lib/socket.py). 16k might be even better.
 
 The benchmark is such that all of data is  200 bytes. I estimate that 
 in production almost all protocol data will be  4KB.

A matter of taste perhaps, but that seems to me like another reason not
to bother with a non-default buffer size.

 Although they're only micro-optimisations, I'd be interested in the
 relative performance of the query method re-written as:
 
 The change (for the better) is minor (3-5%).

Given your comments above about how much data is actually involved, I'm
a bit surprised that the tweaked version actually produced a measurable
gain.

-
Andrew I MacIntyre These thoughts are mine alone...
E-mail: [EMAIL PROTECTED]  (pref) | Snail: PO Box 370
[EMAIL PROTECTED] (alt) |Belconnen ACT 2616
Web:http://www.andymac.org/   |Australia
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: compiling module from string and put into namespace

2006-05-13 Thread Fuzzyman

glomde wrote:
 Ok, now I think I know what I need to do.
 I need to create a variable in the calling functions locals.
 So how do I get access to the calles locals dictionary?
 Is it possible?

If your import is used in the current namespace, just use the global
keyword.

Best is if your function just returns the module though, and then you
have bound your name to it exactly as if you had used import.

If you *really* want to poke it into the globals of whereever your
function is called from, you can use :

sys._getframe(1).globals['name'] = name

(or something like that, you will need to look up the semantics.)

This is a hack really though, just return the module object and bind
the right name to it where you call it from.

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

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


Re: unzip zip files

2006-05-13 Thread Jay Parlar

On May 12, 2006, at 5:45 PM, DataSmash wrote:

 I need to unzip all zip file(s) in the current directory
 into their own subdirectories.  The zip file name(s) always
 start with the string usa and end with .zip.
 The code below will make the subdirectory, move the zip
 file into the subdirectory, but unzips the contents into the
 root (current) directory.  I want the contents of the zip file
 unloaded into the newly created subdirectory where the zip file is.

 Any ideas?
 Thanks.
 R.D.

 import subprocess

 # Get all the zip files in the current directory.
 for zip in os.listdir(''):
 if zip.endswith(.zip):

 # Remove the first 3 and the last 4 characters
 # e.g. usa12345.zip becomes 12345
 zipBase = zip[3:-4]

 # Make directory for unzipping
 os.mkdir(zipBase)

 # Move the zip file to the subdirectory
 shutil.move(zip, zipBase)

 # Make system call unzip
 subprocess.Popen([unzip, zipBase + \\ + zip]).wait()



Ouch... Is there any reason that you're using subprocess+'unzip', as 
opposed to using the 'zipfile' module from the standard library?

Jay P.

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


Re: Slow network reading?

2006-05-13 Thread Ivan Voras
Andrew MacIntyre wrote:

 That's only because I need the .readline() function. In C, I'm using 
 fgets() (with the expectation that iostream will buffer data).
 
 The readline method of the file object lookalike returned by makefile
 implements all of the line splitting logic in Python code, which is very
 likely where the extra process CPU time is going.  Note that this code is

Heh, I didn't know that - you're probably right about this being a 
possible bottleneck.

 in Python for portability reasons, as Windows socket handles cannot be
 used as file handles the way socket handles on Unix systems can be.

I think they actually can in NT and above... but no, I'm doing it on Unix.

 Given your comments above about how much data is actually involved, I'm
 a bit surprised that the tweaked version actually produced a measurable
 gain.

I didn't do statistical analysis of the results so the difference 
actually could be negligable IRL.

Anyway, thanks for the advice - I'll leave it as it is, as the Python 
client is not used currently.

-- 
Things Mr Welch Cannot Do During An RPG:
274. I cannot commune with the Gods during peak hours.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Setting up InformixDb

2006-05-13 Thread Carsten Haese
On Sat, 13 May 2006 14:09:19 -0400, The Shaffer s wrote
 I have an informix database on a unix machine which I want to 
 access. I downloaded InformixDb-2.2 and managed to get it built and 
 installed and it works fine with python.
 
 My problem is I want to access the same database from a PC remotely. 
 Yes, I already have informix setup and configured on the unix 
 machine to accept connections remotely. And, I can connect to it 
 fine from an ODBC interface to Excel and Access.
 
 But, to build the informix module requires the INFORMIXDIR 
 environment variable set to it which I don't believe I can set to a 
 remote machine.
 
 So, how can I get this module built without having an informix 
 installed on my PC?

On the PC, you'll have to install either the Informix Client SDK
(http://www.ibm.com/software/data/informix/tools/csdk/) or Informix Connect
(http://www.ibm.com/software/data/informix/tools/connect/). Both are free
downloads.

If you plan on building InformixDB from source, you'll need CSDK. If you want
to simply use a pre-built binary, such as the one I provide at Sourceforge,
either CSDK or Informix Connect will do.

In either case, INFORMIXDIR on the PC should point to where you installed the
Informix client software, and INFORMIXSERVER points to the server instance
you're connecting to.

Hope this helps,

Carsten.

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


Iterating generator from C

2006-05-13 Thread Sven Suursoho
Hi,


I am working on project that has embedded python interpreter to run  
user-specified python procedures. Those procedures might return any  
iterable object with set of result data -- basically everything for which  
iter() returns valid object (list, tuple, dict, iterator etc)

It works ok, except generator under Python 2.4 with debugging enabled (see  
http://sourceforge.net/tracker/index.php?func=detailaid=1483133group_id=5470atid=105470).

Is there any way to rewrite following program to handle returned generator  
without hitting this bug?
Error handling is omitted for clarity.

#include Python.h

const char *py_source =
 def fn():\n
yield 1\n;

int main ()
{
   Py_Initialize();

   PyObject *globals = PyDict_New();

   // insert function code into interpreter
   PyObject *code = PyRun_String(py_source, Py_file_input, globals, NULL);
   Py_DECREF(code);

   // do call
   code = Py_CompileString(fn(), string, Py_eval_input);
   PyObject *gen = PyEval_EvalCode((PyCodeObject *)code, globals, NULL);

   // iterate result
   PyObject *item;
   while ((item = PyIter_Next(gen))) {
   printf( %ld\n, PyInt_AsLong(item));
   Py_DECREF(item);
   }

   Py_DECREF(gen);
   Py_DECREF(code);
   Py_DECREF(globals);

   Py_Finalize();
   return 0;
}


Br,
-- 
Sven Suursoho
-- 
http://mail.python.org/mailman/listinfo/python-list


LocaWapp 09 - localhost web applications

2006-05-13 Thread .
http://daviderognoni.blogspot.com?locawapp


- MAIN NEWS
===

* add thread
* add Request object
* new locawapp_main function
* fixed files.py
* ...


http://daviderognoni.blogspot.com?locawapp

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


Re: distributing a app frozen by cx_freeze

2006-05-13 Thread Flavio
I know,  but the whole point of cx_freeze is to generate standalone
executables, so asking for an installation of an specific version of Qt
is just a little better than asking the end user to install from
source...

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


retain values between fun calls

2006-05-13 Thread Gary Wessle
Hi

the second argument in the functions below suppose to retain its value
between function calls, the first does, the second does not and I
would like to know why it doesn't? and how to make it so it does?

thanks

# it does
def f(a, L=[]):
L.append(a)
return L
print f('a')
print f('b')


# it does not
def f(a, b=1):
b = a + b
return b
print f(1)
print f(2)
-- 
http://mail.python.org/mailman/listinfo/python-list


cx_freeze and matplotlib

2006-05-13 Thread Flavio

I am trying to freeze an application which imports matplotlib. It all
works fine on the machine where it was frozen. The executable runs
without a glitch.

But when I move the directory containing the frozen executable and
other libs to a new machine, I get the following error:

Traceback (most recent call last):
 File
/home/fccoelho/Downloads/cx_Freeze-3.0.2/initscripts/Console.py,
line 26, in ?
 File epigrass.py, line 5, in ?
 File Epigrass/manager.py, line 7, in ?
 File Epigrass/simobj.py, line 4, in ?
 File /usr/lib/python2.4/site-packages/matplotlib/__init__.py, line
457, in ?
   try: return float(s)
 File /usr/lib/python2.4/site-packages/matplotlib/__init__.py, line
245, in wrapper
   if level not in self.levels:
 File /usr/lib/python2.4/site-packages/matplotlib/__init__.py, line
319, in _get_data_path
   Return the string representing the configuration dir.  If s is the
RuntimeError: Could not find the matplotlib data files

Matplotlib can't find its data files.
Apparently this problem comes up in py2exe as well and it is handled
like this:

from distutils.core import setup
import glob
import py2exe

data = glob.glob(r'C:\Python23\share\matplotlib\*')
data.append(r'C:\Python23\share\matplotlib\matplotlibrc')

setup( console= [simple_plot.py],
  data_files = [(matplotlibdata, data)],
 )

This is the only thing I need to solve before I can distribute my
frozen package, so please help me here. There must be a way since the
frozen works in the original machine but not on the new Which also has
the same version of matplotib installed.

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


Cellular automata and image manipulation

2006-05-13 Thread defcon8
Hello. I have recently been experimenting with cellular automata and I
would like to know how I could convert a 2d list of 0's and 1's into
white and black squares on an image. I have tried to install matplotlib
and also NumTut but both to no avail. There seem to be bugs in their
installation and I have not been able to figure out how to resolve
them. I would be happy for someone to suggest a library and maybe give
a simple example of how to do what I want to do.

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


Re: Cellular automata and image manipulation

2006-05-13 Thread Robert Kern
[EMAIL PROTECTED] wrote:
 Hello. I have recently been experimenting with cellular automata and I
 would like to know how I could convert a 2d list of 0's and 1's into
 white and black squares on an image. I have tried to install matplotlib
 and also NumTut but both to no avail. There seem to be bugs in their
 installation and I have not been able to figure out how to resolve
 them. I would be happy for someone to suggest a library and maybe give
 a simple example of how to do what I want to do.

Why don't you explain your problems with installing numpy (the Numeric Tutorial
is out of date; don't bother with NumTut) or matplotlib on the appropriate
mailing lists?

  http://lists.sourceforge.net/lists/listinfo/numpy-discussion
  http://lists.sourceforge.net/lists/listinfo/matplotlib-users

-- 
Robert Kern

I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth.
  -- Umberto Eco

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


Re: distributing a app frozen by cx_freeze

2006-05-13 Thread Edward Elliott
Flavio wrote:

 ImportError: /home/flavio/freeze/qt.so: undefined symbol:
 _ZNK9QSGIStyle9classNameEv

 So my question is: is there a way to find out exactly which lib is
 missing ?

yes - find the one with that symbol.  wash, rinse, repeat. ;)

-- 
Edward Elliott
UC Berkeley School of Law (Boalt Hall)
complangpython at eddeye dot net
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Cellular automata and image manipulation

2006-05-13 Thread John Bauman

[EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Hello. I have recently been experimenting with cellular automata and I
 would like to know how I could convert a 2d list of 0's and 1's into
 white and black squares on an image. I have tried to install matplotlib
 and also NumTut but both to no avail. There seem to be bugs in their
 installation and I have not been able to figure out how to resolve
 them. I would be happy for someone to suggest a library and maybe give
 a simple example of how to do what I want to do.

In my 1d cellular automaton, I used the python image library and
import Image
nim = Image.new(1, (height * 2, height))
nim.putdata(bimg)
nim.resize((400,200)).save(output.png)

where bimg is a 2d list of 0's and 1's. You could probably remove the 
resize. 


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


distutils and binding a script to a file extension on windows

2006-05-13 Thread Alexandre Guimond
Hi.

I built a little installer on windows XP using distutils for my
package. In there i add a few files to the python script directory. I
would like one of these scripts to be the default program to be used by
files with a given extention (e.g. i have an image viewer and would
like it to be used when ever i click on a .gif file). I can do this
manually (through Tools-Folder Options-File Types), but it would be
nicer if the installer could configure this.

It seems this may be possible through the postinstallation script of
distutils, but i have no clue how to do this. does any have experience
with this? i assume i need to edit the registry entries, but i dont
know how or which ones.

thx for any help

alex.

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


Re: having trouble importing a module from local directory

2006-05-13 Thread vduber6er
newbie reply, but how do i go about doing that?  thanks!

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


Question regarding checksuming of a file

2006-05-13 Thread Andrew Robert
Good evening,

I need to generate checksums of a file, store the value in a variable,
and pass it along for later comparison.

The MD5 module would seem to do the trick but I'm sketchy on implementation.


The nearest I can see would be

import md5

m=md5.new()
contents = open(self.file_name,rb).read()
check=md5.update(contents)

However this does not appear to be actually returning the checksum.

Does anyone have insight into where I am going wrong?

Any help you can provide would be greatly appreciated.

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


Re: Question regarding checksuming of a file

2006-05-13 Thread Edward Elliott
Andrew Robert wrote:

 m=md5.new()
 contents = open(self.file_name,rb).read()
 check=md5.update(contents)
 
 However this does not appear to be actually returning the checksum.

the docs are your friend, use them.  hint: first you eat, then you...
http://docs.python.org/lib/module-md5.html

-- 
Edward Elliott
UC Berkeley School of Law (Boalt Hall)
complangpython at eddeye dot net
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Question regarding checksuming of a file

2006-05-13 Thread Andrew Robert
Actually, I think I got it but would like to confirm this looks right.

import md5
checksum = md5.new()
mfn = open(self.file_name, 'r')
for line in mfn.readlines():
checksum.update(line)
mfn.close()
cs = checksum.hexdigest()
print cs

The value cs should contain the MD5 checksum or did I miss something?

Any help you can provide would be greatly appreciated.

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


Re: Question regarding checksuming of a file

2006-05-13 Thread Roy Smith
In article [EMAIL PROTECTED],
 Andrew Robert [EMAIL PROTECTED] wrote:

 Good evening,
 
 I need to generate checksums of a file, store the value in a variable,
 and pass it along for later comparison.
 
 The MD5 module would seem to do the trick but I'm sketchy on implementation.
 
 
 The nearest I can see would be
 
 import md5
 
 m=md5.new()
 contents = open(self.file_name,rb).read()
 check=md5.update(contents)
 
 However this does not appear to be actually returning the checksum.
 
 Does anyone have insight into where I am going wrong?

After calling update(), you need to call digest().  Update() only updates 
the internal state of the md5 state machine; digest() returns the hash.  
Also, for the code above, it's m.update(), not md5.update().  Update() is a 
method of an md5 instance object, not the md5 module itself.

Lastly, the md5 algorithm is known to be weak.  If you're doing md5 to 
maintain compatability with some pre-existing implementation, that's one 
thing.  But, if you're starting something new from scratch, I would suggest 
using SHA-1 instead (see the sha module).  SHA-1 is much stronger 
cryptographically than md5.  The Python API is virtually identical, so it's 
no added work to switch to the stronger algorithm.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Question regarding checksuming of a file

2006-05-13 Thread Andrew Robert
Roy Smith wrote:

 However this does not appear to be actually returning the checksum.

 Does anyone have insight into where I am going wrong?
 
 After calling update(), you need to call digest().  Update() only updates 
 the internal state of the md5 state machine; digest() returns the hash.  
 Also, for the code above, it's m.update(), not md5.update().  Update() is a 
 method of an md5 instance object, not the md5 module itself.
 
 Lastly, the md5 algorithm is known to be weak.  If you're doing md5 to 
 maintain compatability with some pre-existing implementation, that's one 
 thing.  But, if you're starting something new from scratch, I would suggest 
 using SHA-1 instead (see the sha module).  SHA-1 is much stronger 
 cryptographically than md5.  The Python API is virtually identical, so it's 
 no added work to switch to the stronger algorithm.

Hi Roy,

This is strictly for checking if a file was corrupted during transit
over an MQSeries channel.

The check is not intended to be used for crypto purposes.
-- 
http://mail.python.org/mailman/listinfo/python-list


Aggregate funuctions broken in MySQLdb?

2006-05-13 Thread Lorenzo
I'm trying to use some of the agg functions in MySQLdb (avg, min, max), 
but they're just not working as I would expect. They all return the 
value 1 when executed as part of Python scripts, but work as expected 
when used in mysql 4.1. Does anyone have any experience using Python 
with MySQLdb? Quite frankly, the more I use it, the more MySQLdb seems 
to be not quite ready for prime time.

-- 
My Break-Dancing days are over, but there's always the Funky Chicken
--The Full Monty
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to install pyTrix?

2006-05-13 Thread DeepBlue
Hi,

PyTrix can be obtained from http://www.american.edu/econ/pytrix/pytrix.htm

cheers!


Claudio Grondi wrote:
 DeepBlue wrote:
 Hi all,

 can any1 please tell me how to install pyTrix?

 thx!
 The first step should be to get it, but how can it be got?
 
 Claudio
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: distributing a app frozen by cx_freeze

2006-05-13 Thread Serge Orlov
Flavio wrote:
 Well I managed to get rid of the undefined symbol message by copying
 all qt libs to the freeze directory, the problem is that now the
 package is huge (83MB)!

 So my question is: is there a way to find out exactly which lib is
 missing ?

I haven't done that myself, but I've had an idea of discovering
dependances for dynamic languages: run your test suite and register
which files are loaded (byte code, dlls, datafiles), then remove from
the list all files your know they were used only for testing, that's
it, now you know all the files that you need to run your application.

On linux you can find you which .so files are loaded by looking at file
/proc/self/maps at the end of running your test suite. To find out
which python bytecode files were loaded you can use -v option of
python, it will print all files that were loaded to stderr, to separate
its output from other stderr stuff, you can redirect sys.stderr to some
other file.

After you've done all that work, I'm not sure if you need cx_freeze.
You just need to write little startup script that will set
LD_LIBRARY_PATH, PYTHONPATH and start your main script.

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


Re: cx_freeze and matplotlib

2006-05-13 Thread Serge Orlov
Flavio wrote:
 I am trying to freeze an application which imports matplotlib. It all
 works fine on the machine where it was frozen. The executable runs
 without a glitch.

 But when I move the directory containing the frozen executable and
 other libs to a new machine, I get the following error:

 Traceback (most recent call last):
  File
 /home/fccoelho/Downloads/cx_Freeze-3.0.2/initscripts/Console.py,
 line 26, in ?
  File epigrass.py, line 5, in ?
  File Epigrass/manager.py, line 7, in ?
  File Epigrass/simobj.py, line 4, in ?
  File /usr/lib/python2.4/site-packages/matplotlib/__init__.py, line
 457, in ?
try: return float(s)
  File /usr/lib/python2.4/site-packages/matplotlib/__init__.py, line
 245, in wrapper
if level not in self.levels:
  File /usr/lib/python2.4/site-packages/matplotlib/__init__.py, line
 319, in _get_data_path
Return the string representing the configuration dir.  If s is the
 RuntimeError: Could not find the matplotlib data files

 Matplotlib can't find its data files.

I'm not familiar with cx_freeze, but have you told cx_freeze that you
don't want to bundle matplotlib or cx_freeze has decided that
matplotlib is not going to be bundled? That fact that matplotlib is
loaded from site-package is pretty strange, standalone application are
not supposed to depend on non-system packages.

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


Re: where do you run database scripts/where are DBs 'located'?

2006-05-13 Thread John Salerno
Dennis Lee Bieber wrote:
 On Sat, 13 May 2006 14:49:06 -0400, John Salerno
 [EMAIL PROTECTED] declaimed the following in comp.lang.python:
 
 Yeah, that's actually what I'm trying to do now. I'm not sure how to 
 define it, but I assume it has something to do with 3306, since that's 
 the default.

   What firewall application?
 
   Zone Alarm, that I use, pops up a warning that xyz is trying to
 act as a server -- I just had to configure it to allow server for local
 and block internet.

Norton Internet Security. Usually it will pop up a warning and I can 
accept or decline it, but it doesn't do it in this case. It just won't 
connect to the database unless it's disabled.
-- 
http://mail.python.org/mailman/listinfo/python-list


any plans to make pprint() a builtin?

2006-05-13 Thread John Salerno
Just wondering if this will ever happen, maybe in 3.0 when print becomes 
a function too? It would be a nice option to have it available without 
importing it every time, but maybe making it a builtin violates some 
kind of pythonic ideal?
-- 
http://mail.python.org/mailman/listinfo/python-list


copying files into one

2006-05-13 Thread Gary Wessle
Hi

I am looping through a directory and appending all the files in one
huge file, the codes below should give the same end results but are
not, I don't understand why the first code is not doing it.

thanks


combined = open(outputFile, 'wb')

for name in flist:
if os.path.isdir(file): continue

infile = open(os.path.join(file), 'rb')

# CODE 1 this does not work
tx = infile.read(1000)
if tx == : break
combined.write(tx)
infile.close()

# CODE 2 but this works fine 
for line in infile:
combined.write(line)
infile.close()

combined.close()
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: retain values between fun calls

2006-05-13 Thread George Sakkis
Gary Wessle wrote:
 Hi

 the second argument in the functions below suppose to retain its value
 between function calls, the first does, the second does not and I
 would like to know why it doesn't? and how to make it so it does?

 thanks

 # it does
 def f(a, L=[]):
 L.append(a)
 return L
 print f('a')
 print f('b')


 # it does not
 def f(a, b=1):
 b = a + b
 return b
 print f(1)
 print f(2)

It's a FAQ:
http://www.python.org/doc/faq/general/#why-are-default-values-shared-between-objects.

Whenever you want to control one or more objects beyond the lifetime of
a single function call, your first thought should be to use a class to
couple behaviour with state:

class SomeFancyClassName(object):
def __init__(self, b=1):
self.b = b
def f(self, a):
self.b += a
return self.b

x = SomeFancyClassName()
print x.f(1)
print x.f(2)


HTH,
George

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


count items in generator

2006-05-13 Thread BartlebyScrivener
Still new. I am trying to make a simple word count script.

I found this in the great Python Cookbook, which allows me to process
every word in a file. But how do I use it to count the items generated?

def words_of_file(thefilepath, line_to_words=str.split):
the_file = open(thefilepath)
for line in the_file:
for word in line_to_words(line):
yield word
the_file.close()
for word in words_of_file(thefilepath):
dosomethingwith(word)

The best I could come up with:

def words_of_file(thefilepath, line_to_words=str.split):
the_file = open(thefilepath)
for line in the_file:
for word in line_to_words(line):
yield word
the_file.close()
len(list(words_of_file(thefilepath)))

But that seems clunky.

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


Re: copying files into one

2006-05-13 Thread Edward Elliott
Gary Wessle wrote:

 I am looping through a directory and appending all the files in one
 huge file, the codes below should give the same end results but are
 not, I don't understand why the first code is not doing it.
 
 combined = open(outputFile, 'wb')
 for name in flist:
 if os.path.isdir(file): continue
 infile = open(os.path.join(file), 'rb')

this shouldn't work.  'file' is a type object, not a filename.  did you
rebind 'file' without showing us?  or should those 'file's be 'name's
instead?  in either case, calling os.path.join with one argument is
pointless.

 
 # CODE 1 this does not work
 tx = infile.read(1000)
 if tx == : break
 combined.write(tx)
 infile.close()

hint: where will break take you?  therein lies your answer.


-- 
Edward Elliott
UC Berkeley School of Law (Boalt Hall)
complangpython at eddeye dot net
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: copying files into one

2006-05-13 Thread Edward Elliott
Gary Wessle wrote:

 I am looping through a directory and appending all the files in one
 huge file, the codes below should give the same end results but are
 not, I don't understand why the first code is not doing it.

another bit of friendly advice (for others as well): learn to use pdb before
posting your code for the group to debug.  this type of error is easily
catchable with a little effort.  you'll learn more by investigating your
problems yourself before feeding them to the great distributed debugger
known as comp.lang.python.

-- 
Edward Elliott
UC Berkeley School of Law (Boalt Hall)
complangpython at eddeye dot net
-- 
http://mail.python.org/mailman/listinfo/python-list


do/while structure needed

2006-05-13 Thread John Salerno
1 random.shuffle(letters)
2 trans_letters = ''.join(letters)[:len(original_set)]
3 trans_table = string.maketrans(original_set, trans_letters)

So what I'd like to do is have lines 1 and 2 run once, then I want to do 
some comparison between original_set and trans_letters before running 
line 3. If the comparison passes, line 3 runs; otherwise, lines 1 and 2 
run again.

A do/while would be good for this, but perhaps I'm looking at it in the 
wrong way? Or is there some kind of do/while type of idiom that I could use?

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


Re: count items in generator

2006-05-13 Thread Alex Martelli
BartlebyScrivener [EMAIL PROTECTED] wrote:

 Still new. I am trying to make a simple word count script.
 
 I found this in the great Python Cookbook, which allows me to process
 every word in a file. But how do I use it to count the items generated?
 
 def words_of_file(thefilepath, line_to_words=str.split):
 the_file = open(thefilepath)
 for line in the_file:
 for word in line_to_words(line):
 yield word
 the_file.close()
 for word in words_of_file(thefilepath):
 dosomethingwith(word)
 
 The best I could come up with:
 
 def words_of_file(thefilepath, line_to_words=str.split):
 the_file = open(thefilepath)
 for line in the_file:
 for word in line_to_words(line):
 yield word
 the_file.close()
 len(list(words_of_file(thefilepath)))
 
 But that seems clunky.

My preference would be (with the original definition for
words_of_the_file) to code

   numwords = sum(1 for w in words_of_the_file(thefilepath))


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


Re: count items in generator

2006-05-13 Thread George Sakkis
BartlebyScrivener wrote:

 Still new. I am trying to make a simple word count script.

 I found this in the great Python Cookbook, which allows me to process
 every word in a file. But how do I use it to count the items generated?

 def words_of_file(thefilepath, line_to_words=str.split):
 the_file = open(thefilepath)
 for line in the_file:
 for word in line_to_words(line):
 yield word
 the_file.close()
 for word in words_of_file(thefilepath):
 dosomethingwith(word)

 The best I could come up with:

 def words_of_file(thefilepath, line_to_words=str.split):
 the_file = open(thefilepath)
 for line in the_file:
 for word in line_to_words(line):
 yield word
 the_file.close()
 len(list(words_of_file(thefilepath)))

 But that seems clunky.

As clunky as it seems, I don't think you can beat it in terms of
brevity; if you care about memory efficiency though, here's what I use:

def length(iterable):
try: return len(iterable)
except:
i = 0
for x in iterable: i += 1
return i

You can even shadow the builtin len() if you prefer:

import __builtin__

def len(iterable):
try: return __builtin__.len(iterable)
except:
i = 0
for x in iterable: i += 1
return i


HTH,
George

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


Re: count items in generator

2006-05-13 Thread BartlebyScrivener
Thanks! And thanks for the Cookbook.

rd

There is no abstract art. You must always start with something.
Afterward you can remove all traces of reality.--Pablo Picasso

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


Re: do/while structure needed

2006-05-13 Thread George Sakkis
John Salerno wrote:

 1 random.shuffle(letters)
 2 trans_letters = ''.join(letters)[:len(original_set)]
 3 trans_table = string.maketrans(original_set, trans_letters)

 So what I'd like to do is have lines 1 and 2 run once, then I want to do
 some comparison between original_set and trans_letters before running
 line 3. If the comparison passes, line 3 runs; otherwise, lines 1 and 2
 run again.

 A do/while would be good for this, but perhaps I'm looking at it in the
 wrong way? Or is there some kind of do/while type of idiom that I could use?

 Thanks.

I guess you want something like:

while True:
random.shuffle(letters)
trans_letters = ''.join(letters)[:len(original_set)]
if some_compatison(original_set,trans_letters):
trans_table = string.maketrans(original_set, trans_letters)
break


HTH,
George

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


Re: count items in generator

2006-05-13 Thread Paul Rubin
George Sakkis [EMAIL PROTECTED] writes:
 As clunky as it seems, I don't think you can beat it in terms of
 brevity; if you care about memory efficiency though, here's what I use:
 
 def length(iterable):
 try: return len(iterable)
 except:
 i = 0
 for x in iterable: i += 1
 return i

Alex's example amounted to something like that, for the generator
case.  Notice that the argument to sum() was a generator
comprehension.  The sum function then iterated through it.
-- 
http://mail.python.org/mailman/listinfo/python-list


[ python-Feature Requests-1487389 ] datetime.time and datetime.timedelta

2006-05-13 Thread SourceForge.net
Feature Requests item #1487389, was opened at 2006-05-12 13:13
Message generated for change (Comment added) made by fresh
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=355470aid=1487389group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Chris Withers (fresh)
Assigned to: Nobody/Anonymous (nobody)
Summary: datetime.time and datetime.timedelta

Initial Comment:
print datetime.time(hour=0)+datetime.timedelta(hours=1) 

...gives...

TypeError: unsupported operand type(s) for +:
'datetime.time' and 'datetime.timedelta'

Which is a bit frustrating :-/

Does it really need to be this way?

Chris

--

Comment By: Chris Withers (fresh)
Date: 2006-05-13 15:49

Message:
Logged In: YES 
user_id=24723

Well, I think the OverflowError is perfectly correct, and
lets the software author handle that situation in any way
they want.

That said, you could add a keyword option to the
datetime.time constructor to allow it either to wrap round,
or raise OverflowError, with the overflow being the default.

If I resulted up patches for these, how would I get them
into a python release?

--

Comment By: Tim Peters (tim_one)
Date: 2006-05-12 16:15

Message:
Logged In: YES 
user_id=31435

Since the lack of arithmetic on `time` objects is both
intended and documented, this isn't a bug.  I moved this
to the Feature Requests tracker.

The problem with arithmetic on time objects is that it's not
obvious what to do in case of overflow or underflow:  wrap
around or raise OverflowError?  Either way violates _some_
reasonable expectation.  Embed your time in a `datetime`
object and then you can decide what you want to do.  For
example, if you want to wrap around,

 print (datetime.combine(date.today(), time(hour=0)) -
timedelta(hours=1)).time()
23:00:00


--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=355470aid=1487389group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1487966 ] SystemError with conditional expression in assignment

2006-05-13 Thread SourceForge.net
Bugs item #1487966, was opened at 2006-05-13 18:25
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1487966group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Parser/Compiler
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Submitted By: Žiga Seilnacht (zseil)
Assigned to: Nobody/Anonymous (nobody)
Summary: SystemError with conditional expression in assignment

Initial Comment:
When a conditional expression appears on the left
side of an assignment, SystemError is raised instead
of SyntaxError. Example:

Python 2.5a2 (trunk:45989M, May 13 2006, 15:40:42)
[MSC v.1310 32 bit (Intel)] on win32

 a if True else b = 3
SystemError: unexpected expression in assignment 5 (line 1)


--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1487966group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-944394 ] No examples or usage docs for urllib2

2006-05-13 Thread SourceForge.net
Bugs item #944394, was opened at 2004-04-29 13:02
Message generated for change (Comment added) made by loewis
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=944394group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: None
Status: Closed
Resolution: Works For Me
Priority: 5
Submitted By: Chris Withers (fresh)
Assigned to: Nobody/Anonymous (nobody)
Summary: No examples or usage docs for urllib2

Initial Comment:
Hi there,

I'm sure I reported this before, but it's a couple of
major releases later, and there's still no usage docs
for urllib2.

The examples given are too trivial to be helpful, but
I'm guessing people are using the module so there must
be some examples out there somewhere ;-)

With a bit o fhelp from Moshez, I found the docstring
in the module source. At the very least, it'd be handy
if that appeared somewhere at:

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

But really, mroe extensive and helpful documentation on
this cool new module would be very handy.

Chris

--

Comment By: Martin v. Löwis (loewis)
Date: 2006-05-13 18:33

Message:
Logged In: YES 
user_id=21627

fresh, you haven't responded to jjlee's questions from
2006-04-17 16:26, so it is unclear what precisely it is that
you want. In absence of a specific problem description, I'm
closing this as works for me.

--

Comment By: Chris Withers (fresh)
Date: 2006-05-13 17:51

Message:
Logged In: YES 
user_id=24723

wtf?

--

Comment By: SourceForge Robot (sf-robot)
Date: 2006-05-12 04:21

Message:
Logged In: YES 
user_id=1312539

This Tracker item was closed automatically by the system. It was
previously set to a Pending status, and the original submitter
did not respond within 14 days (the time period specified by
the administrator of this Tracker).

--

Comment By: Georg Brandl (gbrandl)
Date: 2006-04-27 15:06

Message:
Logged In: YES 
user_id=849994

Chris, I concur with jjlee that suggesting examples is the
best way to get something done. Perhaps, if you're using
urllib2, you could flesh out some examples from your code?

--

Comment By: John J Lee (jjlee)
Date: 2006-04-17 16:26

Message:
Logged In: YES 
user_id=261020

Do you have any specific suggestions for what is unhelpful
and/or missing?

Otherwise, nothing is likely to change.

Note that a little was added at the bottom of this page in
2.4, explaining how OpenerDirector uses the handlers to open
URLs:

http://docs.python.org/lib/opener-director-objects.html

Looking at the top-level page, I guess an introduction /
overview would help?  Did you have other stuff in mind too?


--

Comment By: Chris Withers (fresh)
Date: 2006-04-17 16:19

Message:
Logged In: YES 
user_id=24723

I still feel there could be more.

I guess the best course, for me, would be to leave this open
but at a really low priority.

However, I probably wouldn't scream too much if the issue
was closed.

--

Comment By: John J Lee (jjlee)
Date: 2006-04-15 20:49

Message:
Logged In: YES 
user_id=261020

They are here: http://docs.python.org/lib/urllib2-examples.html

--

Comment By: Chris Withers (fresh)
Date: 2006-04-15 20:07

Message:
Logged In: YES 
user_id=24723

Where are these examples you're referring to?

I don't see any at:
http://docs.python.org/lib/module-urllib2.html

I've already commented that the existing ones in the
docstring would be a start but still don't really much help
in taking full advantage of this module.

--

Comment By: John J Lee (jjlee)
Date: 2006-04-15 19:34

Message:
Logged In: YES 
user_id=261020

Examples for urllib2 were added some time ago, so I suggest
this bug is closed.

--

Comment By: Chris Withers (fresh)
Date: 2004-06-01 10:17

Message:
Logged In: YES 
user_id=24723

I'm certainly willing, but I am totally incapable :-S

The reason I opened this issue is because it would seem that
urllib2 is better the urllib, but seems to be severely
underdocumented, and hence I don't understand how to use it
and so can't provide examples.

As I said in the original submission, including the module's
docstring in the Python module documentation would be a
start, but doesn't cover what appears to be the full
potential of a 

[ python-Bugs-1487481 ] Could BIND_FIRST be removed on HP-UX?

2006-05-13 Thread SourceForge.net
Bugs item #1487481, was opened at 2006-05-12 17:32
Message generated for change (Comment added) made by loewis
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1487481group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Interpreter Core
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Göran Uddeborg (goeran)
Assigned to: Guido van Rossum (gvanrossum)
Summary: Could BIND_FIRST be removed on HP-UX?

Initial Comment:
I'm trying to build Python 2.4.3 on HP-UX 11.  I need
tkinter, so I have first built Tcl and Tk 8.4.13.

During the build, the python interpreter crashes.  When
running the setup.py script, just after making the
_tkinter.sl module, it crashes with a memory fault.

I've tried to investigate this, and it seems that
malloc and friends gets confused by the dynamic
loading.  I've filed a support request with HP about this.

One observation I made is that this malloc bug seems to
be connected with the use of BIND_FIRST in
dynload_hpux.c.  If I just remove this flag (in two
places) it appears as if Python works normally.

I'm hesitant if this is a good idea.  BIND_FIRST is
there as an explicit, non-default, flag.  Somebody must
have choosen to do so for some reason.  What was that
reason?  And is it still valid?  If not, maybe the flag
could be removed, and this problem in HP-UX be avoided?

--

Comment By: Martin v. Löwis (loewis)
Date: 2006-05-13 18:38

Message:
Logged In: YES 
user_id=21627

BIND_FIRST was added with this commit:


r7068 | guido | 1996-12-06 00:15:35 +0100 (Fr, 06 Dez 1996)
| 2 lines
Geänderte Pfade:
   M /python/trunk/Python/importdl.c

Some extra flags that an HPUX user wants me to add.



Guido, do you have any records on which user that was
and why he wanted these flags to be added?

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1487481group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-944394 ] No examples or usage docs for urllib2

2006-05-13 Thread SourceForge.net
Bugs item #944394, was opened at 2004-04-29 12:02
Message generated for change (Comment added) made by jjlee
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=944394group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: None
Status: Closed
Resolution: Works For Me
Priority: 5
Submitted By: Chris Withers (fresh)
Assigned to: Nobody/Anonymous (nobody)
Summary: No examples or usage docs for urllib2

Initial Comment:
Hi there,

I'm sure I reported this before, but it's a couple of
major releases later, and there's still no usage docs
for urllib2.

The examples given are too trivial to be helpful, but
I'm guessing people are using the module so there must
be some examples out there somewhere ;-)

With a bit o fhelp from Moshez, I found the docstring
in the module source. At the very least, it'd be handy
if that appeared somewhere at:

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

But really, mroe extensive and helpful documentation on
this cool new module would be very handy.

Chris

--

Comment By: John J Lee (jjlee)
Date: 2006-05-13 19:09

Message:
Logged In: YES 
user_id=261020

Is this helpful, Chris?

http://svn.python.org/view/python/trunk/Doc/howto/urllib2.rst?view=markup


--

Comment By: Martin v. Löwis (loewis)
Date: 2006-05-13 17:33

Message:
Logged In: YES 
user_id=21627

fresh, you haven't responded to jjlee's questions from
2006-04-17 16:26, so it is unclear what precisely it is that
you want. In absence of a specific problem description, I'm
closing this as works for me.

--

Comment By: Chris Withers (fresh)
Date: 2006-05-13 16:51

Message:
Logged In: YES 
user_id=24723

wtf?

--

Comment By: SourceForge Robot (sf-robot)
Date: 2006-05-12 03:21

Message:
Logged In: YES 
user_id=1312539

This Tracker item was closed automatically by the system. It was
previously set to a Pending status, and the original submitter
did not respond within 14 days (the time period specified by
the administrator of this Tracker).

--

Comment By: Georg Brandl (gbrandl)
Date: 2006-04-27 14:06

Message:
Logged In: YES 
user_id=849994

Chris, I concur with jjlee that suggesting examples is the
best way to get something done. Perhaps, if you're using
urllib2, you could flesh out some examples from your code?

--

Comment By: John J Lee (jjlee)
Date: 2006-04-17 15:26

Message:
Logged In: YES 
user_id=261020

Do you have any specific suggestions for what is unhelpful
and/or missing?

Otherwise, nothing is likely to change.

Note that a little was added at the bottom of this page in
2.4, explaining how OpenerDirector uses the handlers to open
URLs:

http://docs.python.org/lib/opener-director-objects.html

Looking at the top-level page, I guess an introduction /
overview would help?  Did you have other stuff in mind too?


--

Comment By: Chris Withers (fresh)
Date: 2006-04-17 15:19

Message:
Logged In: YES 
user_id=24723

I still feel there could be more.

I guess the best course, for me, would be to leave this open
but at a really low priority.

However, I probably wouldn't scream too much if the issue
was closed.

--

Comment By: John J Lee (jjlee)
Date: 2006-04-15 19:49

Message:
Logged In: YES 
user_id=261020

They are here: http://docs.python.org/lib/urllib2-examples.html

--

Comment By: Chris Withers (fresh)
Date: 2006-04-15 19:07

Message:
Logged In: YES 
user_id=24723

Where are these examples you're referring to?

I don't see any at:
http://docs.python.org/lib/module-urllib2.html

I've already commented that the existing ones in the
docstring would be a start but still don't really much help
in taking full advantage of this module.

--

Comment By: John J Lee (jjlee)
Date: 2006-04-15 18:34

Message:
Logged In: YES 
user_id=261020

Examples for urllib2 were added some time ago, so I suggest
this bug is closed.

--

Comment By: Chris Withers (fresh)
Date: 2004-06-01 09:17

Message:
Logged In: YES 
user_id=24723

I'm certainly willing, but I am totally incapable :-S

The reason I opened this issue is because it would seem that
urllib2 is better the urllib, but seems to be severely

[ python-Bugs-1487966 ] SystemError with conditional expression in assignment

2006-05-13 Thread SourceForge.net
Bugs item #1487966, was opened at 2006-05-13 18:25
Message generated for change (Comment added) made by zseil
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1487966group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Parser/Compiler
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Submitted By: Žiga Seilnacht (zseil)
Assigned to: Nobody/Anonymous (nobody)
Summary: SystemError with conditional expression in assignment

Initial Comment:
When a conditional expression appears on the left
side of an assignment, SystemError is raised instead
of SyntaxError. Example:

Python 2.5a2 (trunk:45989M, May 13 2006, 15:40:42)
[MSC v.1310 32 bit (Intel)] on win32

 a if True else b = 3
SystemError: unexpected expression in assignment 5 (line 1)


--

Comment By: Žiga Seilnacht (zseil)
Date: 2006-05-13 22:50

Message:
Logged In: YES 
user_id=1326842

Attaching a patch. Most of the changes
in test_syntax are due to error renumbering.
All tests passed with this patch applied.

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1487966group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



  1   2   >