Re: MS SQL Server: NT Authentication. Possible?

2006-08-22 Thread Dirk Hagemann
>   You have a user named "null"?
>
>   Off-hand, it looks very much like the CGI script is still running
> with the privileges of the web-server, and /that/ is set up in a locked
> down account that doesn't have connection rights.

I also thought this might be the reason, but when I include
username = os.environ.get('REMOTE_USER')
in this script and print the username, it's my NT-username and not a
webserver user.
By the way - the webserver is an IIS.
I once before had the problem that some code worked fine when I
directly executed it, but didn't work when executed by this webserver
(both again with the same user-account).
May be it has something to do with the IIS. I will try to find a
solution by reading these sites:
http://www.google.de/search?hl=de&q=%22Login+failed+for+user+'(null)'%22+%22Not+associated+with+a+trusted+SQL+Server+connection%22&btnG=Suche&meta=

Dirk

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


Re: Modules... paths... newbie confusion

2006-08-22 Thread MrBlueSky
Thanks for the suggestions, folks..

site-packages
~~
OK, I'm been trying to get MSSQL into c:\Python24\lib\site-packages.
MSSQL comes (as a tar'd, zip'd file) with a folder hierarchy with
MSSQL.py at the top level and then bin\python2.3\mssqldb.pyd.   If I
try and copy this folder hierarchy into site-packages and "import
MSSQL" then it recognises MSSQL.py but fails to import mssqldb, as
that's imported from MSSQL.py.

I've noticed a setup.py in the MSSQL folder, but it looks like it has
odd hard-coded paths in it (D:\...) and anyway when I tried to run it,
I found the Usage message less than helpful!

I really apologise if this is Bleeding Obvious to everyone else - is
there a web page that will explain all this so the lightbulb will go on
over my head?!

John

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


Re: Loading module via full path

2006-08-22 Thread Andre Poenitz
Gary Herron <[EMAIL PROTECTED]> wrote:
> Andre Poenitz wrote:
>> Hi all.
>>
>> Is there a way to load a module given a full path to the module
>> without extending sys.path first?
>
> The standard module named "imp" can help you with this.

Thank you. I got stuck on http://docs.python.org/api/importing.html
(as I need it to be called from C(++)) and found no way to specify a path there
[and there aren't too many cross references in the python docs *sigh*]

I have now something similar to

class CPyObject
{
public:
  explicit CPyObject(PyObject * pObject) : m_pObject(pObject) { /*Check();*/ }
  ~CPyObject() { Py_XDECREF(m_pObject); }
  operator PyObject *() { return m_pObject; }
private:
  CPyObject(const CPyObject &);  // intentionally not implemented
  void operator=(const CPyObject &); // intentionally not implemented
  PyObject * m_pObject;
};

static PyObject * LoadModule(const char * mod, const char * path)
{
  CPyObject pyImpModule ( PyImport_Import(PyString_FromString("imp")) ); 

  CPyObject pyImpFindModuleFunc ( PyObject_GetAttrString(pyImpModule, 
"find_module") ); 
  CPyObject pyImpFindModuleArgs ( Py_BuildValue("s[s]", mod, path) );
  CPyObject pyImpFindModuleRes  ( PyObject_CallObject(pyImpFindModuleFunc, 
pyImpFindModuleArgs) ); 

  CPyObject pyImpLoadModuleFunc ( PyObject_GetAttrString(pyImpModule, 
"load_module") ); 
  CPyObject pyImpLoadModuleArgs ( Py_BuildValue("sOOO",
mod,
PyTuple_GetItem(pyImpFindModuleRes, 0),
PyTuple_GetItem(pyImpFindModuleRes, 1),
PyTuple_GetItem(pyImpFindModuleRes, 2)
  )); 
  return PyObject_CallObject(pyImpLoadModuleFunc, pyImpLoadModuleArgs);
}

which seems to do what I want even if it looks a bit too verbose for my taste 
and I
don't know whether I go the reference counting right.

Thanks for the hint,
Andre'
-- 
http://mail.python.org/mailman/listinfo/python-list


How can I enumerate all windows services and disable some of them?

2006-08-22 Thread could . net
I know that Module win32service has some functions on manipulating
win32 services.
But I still have 2 questions:
1. how to enumerate all services?
2. how to disable a certain one?

Thanks in advance!

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


Re: How to decode a string

2006-08-22 Thread Fredrik Lundh
Lad wrote:

> for
> print repr(RealName)  command
> I will get
> 
> P?ibylov\xe1 Ludmila
> where instead of  ? should be also a character

that's not very likely; repr() always includes quotes, always escapes 
non-ASCII characters, and optionally includes a Unicode prefix.

please try this

   print "*", repr(RealName), type(RealName), "*"

and post the entire output; that is, *everything* between the asterisks.



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


Re: how do you get the name of a dictionary?

2006-08-22 Thread Duncan Booth
jojoba wrote:

> However, does it not seem reasonable to ask python:
> 
> Given a dicitionary, Banana = {}
> return one or more strings,
> where each string is the name(s) of the reference(s) to Banana.
> 
> why is this not sane?!?!
> what am i missing here?

Some time back I posted some code which would do exactly that, but it is 
not nice, and it is buggy, but if you want to play with it:
http://groups.google.co.uk/group/comp.lang.python/tree/browse_frm/thread/394ba5b48f83ebfb/237dc92f3629dd9a

>>> import varname
>>> Banana = {}
>>> class C:
...classFruit = [{}, Banana]
...
>>> def names(x):
... for s in varname.object_info(x):
... print s
...
>>> names(Banana)
__main__.C.classFruit[1]
__main__.Banana
__main__.names()x

The problem as others have said is that there are a lot of namespaces in 
Python (module globals, classes, instances, local variables of active 
functions, ...), and the only way to find which names refers to an object 
is to search the relevant namespaces.

There is some information which can help: for any object you can get a list 
of all objects that refer to it, and that can be used to trace backwards 
until you find a namespace at which point you still have to search the 
namespace to find out which name refers to the object. Of course doing all 
this creates lots of new references and infinite loops both of which you 
have to ignore.

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


RE: Add users to directory/folder and set permissions in Windows

2006-08-22 Thread Tim Golden
[Adam Jones]
| 
| Gallagher, Tim (NE) wrote:
| > I was wondering if there was a way to add a user in active 
| directory to
| > a folder and set the permissions.
| 
| It should be possible. If you can use VBScript or JScript it will be
| easier to find resources for those. You will probably need, at the
| least, the win32 extension for Python, which you can find here:
| http://www.python.net/crew/mhammond/win32/
| 
| A quick google search for "python active directory" turned up the
| following page, which would probably also prove helpful:
| http://tgolden.sc.sabren.com/python/ad_cookbook.html

I must shamefacedly admit that the active_directory module
which that page represents is a little stale. It does work,
but I haven't even added in the one or two patches people
have sent. Welcome to use it, but YMMV.

Try searching the python-win32 archives for posts by Roger Upole
(or anyone else) on the subject of AD and/or security.

TJG


This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk

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


Re: text editor suggestion?

2006-08-22 Thread [EMAIL PROTECTED]
John Salerno wrote:
>
> The thing I liked about UltraEdit is that you can define your own groups
> of words and put whatever words you want in there, so my file had a
> group called '__builtins__' and it listed all the Python built-in
> methods, and those would be highlighted. Most editors I see don't seem
> to allow this...they just figure out what a function or method is on
> their own somehow.

In vim, you can just put "let python_highlight_builtins=1" in your
.vimrc for this particular example (other python syntax settings
include python_highlight_numbers, python_highlight_space_errors,
python_highlight_exceptions).

Use python_highlight_all to turn them all on.

To do it by hand and have it automatically come on in all .py buffers,
you could do:
au BufEnter *.py syntax keyword pythonFunction abs apply basestring
bool
au BufEnter *.py syntax keyword pythonFunction buffer callable chr

etc.  Put as many as you want on one line.  Use other syntax groups if
you want them highlighted as something other than functions.

Or, with vim's builtin python interpreter you could grab the list of
builtins directly, for instance have this in your vimrc:
pyf ~/.vim/vimrc.py

And have this in ~/.vim/vimrc.py:

import vim
# Might want to trim out exceptions/leading underscores/etc from
this...
builtins = ' '.join( [ b for b in dir(__builtins__)] )
vim.command('au BufEnter *.py syn keyword pythonFunction '+builtins)

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


Re: What do you want in a new web framework?

2006-08-22 Thread Tim Roberts
"Paul Boddie" <[EMAIL PROTECTED]> wrote:
>Marc 'BlackJack' Rintsch wrote:
>> emrahayanoglu wrote:
>> >
>> > Now i want to listen all of you. What do you want in that web
>> > framework(Easy use of Database, Easy use of XML, GUI Designer, etc...)?
>>
>> Don't think that yet another Python web framework is really needed.
>
>Why not? I know that some people are probably basking in the glory of
>supposedly having their favourite framework recently blessed by the
>BDFL, whilst others lament the almost unfair rejection of their own
>framework on possibly dubious grounds by the very same person (thus
>seeing their "winner takes all" strategy backfire totally), but open
>source and various other network-effect movements benefit from lots of
>people trying different things (the "scratch your own itch"
>observation) rather than everyone gathering together for one big
>strategy meeting.

Ordinarily, I think the "do it yourself" nature of Python is a great thing,
and I would never try to dissuade someone from reinventing something
themselves.  However, in the case of web frameworks, I believe Marc is
fundamentally correct: the web framework proliferation in Python is
actually doing the language a huge disservice.

Consider Ruby.  If someone asks, "I'd like to do a web site with Ruby, what
should I use?", the answer comes back loud, clear, and unanimous: Ruby on
Rails.  If someone asks, "I'd like to do a web site with Python, what
should I use?", she gets 25 different answers.  "Look at HTMLGen, Cheetah,
WebWare, CherryPy, Karrigell, Django, Pylons, Plone, Zope, TurboGears,
etc., etc.", none of which are pre-installed in the typical Linux
distribution.  To the non-programming decision maker, that kind of response
makes Python look unprofessional -- a toy.

Now, please do not send me ugly emails accusing me of running down Python.
I've been a Python believer since 1.52.  I've done web sites in at least 5
of the frameworks, and I even wrote one of the wiki pages that compares web
frameworks.  However, it is only the fact that I *AM* a true Python
believer that gave me the patience and incentive to try 5 different
frameworks.  If a corporate decision maker were involved, that would never
happen.  Python would simply fall off of the list of options, and the job
would get done in PHP or Ruby on Rails.

I agree with Marc.  PLEASE do not create "yet another Python web
framework."  Let's pick one, and join together to turn it into the One,
True, Unquestioned Web Solution.
-- 
- Tim Roberts, [EMAIL PROTECTED]
  Providenza & Boekelheide, Inc.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Unclear on argument passing to "sendmail'

2006-08-22 Thread Tim Roberts
John Draper <[EMAIL PROTECTED]> wrote:
>
>In "smtplib" module, the "sendmail" method of function is to be passed a 
>host, but it is the Domain name
>for the SMTP Server as gotten from the "dig" command?   IE:   dig -tMX 
>would give me the SMTP
>server.   In my code I have:
>
>try:
>print "Sending message to host: %s" % mailHost
>server=smtplib.SMTP(mailHost)
>server.sendmail(reply_email,email,body)
>server.quit()
>except:
>print "Uunable to send"
>
>Is mailHost like "mail.t-mobile.com" which I get from the MX record for 
>a given domain?
>But also,  is the "email" just the mail account,  ie:  the username?   
>without the @?

Tim William's answer is not exactly correct.  The host you specify in the
smtplib.SMTP constructor should NOT be the MX record for any of the
recipients.  You should never have to look up MX records yourself.

Instead, you should specify your ISP's outgoing mail host.  In your
particular case, you should specify "mail.webcrunchers.com".  That server
will do the MX record lookups, and distribute the message to all of the
places it needs to go, using as many SMTP conversations as are required.

Remember that a single call to smtplib.SMTP.sendmail can send to multiple
recipients.  Each of them has to have its own SMTP connection.  That's the
job of mail.webcrunchers.com: it queues your message, and sends it to each
recipient individually.

If your message is being sent to exactly one person, then you CAN look up
the MX host and send it directly, but there are more and more cases where
that won't work.  Many corporate SMTP servers are now rejecting mail that
comes from DSL and cable modem IP addresses, as an anti-spam measure.
-- 
- Tim Roberts, [EMAIL PROTECTED]
  Providenza & Boekelheide, Inc.
-- 
http://mail.python.org/mailman/listinfo/python-list


wxWindow GetPosition() bug???

2006-08-22 Thread mardif
Hi,
I've found a strange behavior in method GetPosition() of wxWindow class

( and derived ).
On windows, if you create a window object

frame = wx.Frame(None, -1, "TESTING")

and you set the position to:
frame.SetPosition( (300, 45000) )

If you call method GetPosition, the result will be:
frame.GetPosition()
 >>> (300, 32767)

32767 is the integer limit. Why GetPosition() returns this value??? and

why on Unix Platform this problem was not found??

thx very much!

bye

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


Re: Python and STL efficiency

2006-08-22 Thread Ray

Fredrik Lundh wrote:
> Ray wrote:
>
> >> in the C++ example, you're creating 4 string objects.
> >
> > In which case, Licheng, you should try using the /GF switch. This will
> > tell Microsoft C++ compiler to pool identical string literals together.
>
> in what way does that change the implementation of C++'s string type ?

Ah, yes what was I thinking? The fact that it stores std::string
objects escaped my mind somehow. /GF just pools the string literals.
Thanks for the correction.

> 
> 

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


Re: Python and STL efficiency

2006-08-22 Thread Ray

Tim N. van der Leeuw wrote:
> > In which case, Licheng, you should try using the /GF switch. This will
> > tell Microsoft C++ compiler to pool identical string literals together.
> >
> >
> > :)
>
> The code still creates a new string - instance each time it tries to
> append a const char* to the vector ...

Yeah, you're right... I've been programming Java too long :)

> You should instead create the string-objects ahead of time, outside of
> the loop.
> 
> Regards,
> 
> --Tim

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


Re: Problem of function calls from map()

2006-08-22 Thread Peter Otten
Dasn wrote:

> # size of 'dict.txt' is about 3.6M, 154563 lines
> f = open('dict.txt', 'r')

> lines = f.readlines()
 
> def sp0(lines):
> """> sp0() -- Normal 'for' loop"""
> l = []
> for line in lines:
> l.append(line.split('\t'))
> return l

Where do you get the data from in the "real world"? If it's a file you might
get the best overall performance if you skip the readlines() call:

sp0(f)

Anyway, here's another variant you can try:

from itertools import izip, starmap, repeat

def splitlines(lines):
return list(starmap(str.split, izip(lines, repeat("\t"

Peter

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


Re: Python and STL efficiency

2006-08-22 Thread Tim N. van der Leeuw

Ray wrote:
> Tim N. van der Leeuw wrote:
> > > In which case, Licheng, you should try using the /GF switch. This will
> > > tell Microsoft C++ compiler to pool identical string literals together.
> > >
> > >
> > > :)
> >
> > The code still creates a new string - instance each time it tries to
> > append a const char* to the vector ...
>
> Yeah, you're right... I've been programming Java too long :)
>

Took me a while to see that too! Have been programming too much Java /
Python as well. Anyways, when changing the Python version so that it
adds 40.000 unique strings to the list (and proving that there are
indeed 40.000 unique ids in the list, by making a set of all id()s in
the list and taking the len() of that set), it still takes at most a
second. I cannot test the speed of the c++ version on my computer, so
nothing scientific here.

I'm curious though, if on the OP's machine the slowed-down Python
version is still faster than the C++ version.


Cheers,

--Tim

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


RE: How can I enumerate all windows services and disable some of them?

2006-08-22 Thread Tim Golden
[EMAIL PROTECTED]

| I know that Module win32service has some functions on manipulating
| win32 services.
| But I still have 2 questions:
| 1. how to enumerate all services?
| 2. how to disable a certain one?

You can use WMI to do this if you want.

Have a look at this example:

http://tgolden.sc.sabren.com/python/wmi_cookbook.html#automatic_services

and then at the Win32_Service WMI class:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/
wmi/win32_service.asp

and in particular at the StartService method

TJG


This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk

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


RE: How can I enumerate all windows services and disable some of them?

2006-08-22 Thread Tim Golden
[Tim Golden]

| [EMAIL PROTECTED]
| 
| | I know that Module win32service has some functions on manipulating
| | win32 services.
| | But I still have 2 questions:
| | 1. how to enumerate all services?
| | 2. how to disable a certain one?
| 
| You can use WMI to do this if you want.

... or I could actually read the question before answering.
I don't know if you can actually *disable* a service
from WMI. You can certainly stop it, but the status appears
to be a read-only option.

Sorry
TJG


This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk

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


Re: Regular Expression question

2006-08-22 Thread Anthra Norell
Steve,
   I thought Fredrik Lundh's proposal was perfect. Are you now saying it 
doesn't solve your problem because your description of the
problem was incomplete? If so, could you post a worst case piece of htm, one 
that contains all possible complications, or a
collection of different cases all of which you need to handle?

Frederic

- Original Message -
From: <[EMAIL PROTECTED]>
Newsgroups: comp.lang.python
To: 
Sent: Monday, August 21, 2006 11:35 PM
Subject: Re: Regular Expression question


> Hi, thanks everyone for the information! Still going through it :)
>
> The reason I did not match on tag2 in my original expression (and I
> apologize because I should have mentioned this before) is that other
> tags could also have an attribute with the value of "adj__" and the
> attribute name may not be the same for the other tags. The only thing I
> can be sure of is that the value will begin with "adj__".
>
> I need to match the "adj__" value with the closest preceding tag1
> irrespective of what tag the "adj__" is in, or what the attribute
> holding it is called, or the order of the attributes (there may be
> others). This data will be inside an html page and so there will be
> plenty of html tags in the middle all of which I need to ignore.
>
> Thanks very much!
> Steve
>
> --
> http://mail.python.org/mailman/listinfo/python-list

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


Re: idutils and Python

2006-08-22 Thread Ramon Diaz-Uriarte
On 21 Aug 2006 22:56:13 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

> What exactly are you trying to accomplish?  If you want to index
> function/class names, variables, etc then you should take a look at
> "exuberant ctags" http://ctags.sourceforge.net53 --although it started
> off as a C indexer, it has excellent Python support, it's free, and as
> a bonus its indices are well supported from inside major editors (vim,
> emacs, etc) so you can easily follow code flow, find function/class
> definitions, etc.


Sorry for not being clear enough. I want the following:

a) have my editor go to the point where a function/whatever is defined

b) see all places where a function/whatever is used.

I've tried exuberant ctags and I do like it a lot. a) is done
wonderfully (within emacs, the editor I use, but also in other
editros, from what I've read).  However, b) does not work exactly as
I'd like:

1.  With Emacs and tags: using "tags-search" I can visit, one by one,
all places where a function is called, but I'd like to see where it is
called before visting that file and know, before visiting each file in
turn, whether I'll visit 1 or 20 files (or, to put it in another way,
I'd like to see like a poor-mans static callgraph).

2. From what I understand, there is a deeper difference than just how
results are shown: the tags file contains the places where, say, a
function is defined, but finding where it is used requires running
grep on every file looking for the tag. (I believe that is what
"tags-search" does in emacs).  In contrast, ID utils does not do any
grep, but directly goes to the ID file, where all that is already
pre-stored, which also means that it will be a lot faster than
grepping for the tags.

A tool similar to IDutils is Global
http://www.gnu.no/software/global/, but it also does not incorporate
Python support. (Though defining other parsers might be simple; I
haven't looked at it closely).

I think the wish "do not use grep, just look at the index file, and
immediately display all matches"  is reasonable and probably other
Python coders had thought about it before. But I am wondering if I am
missing something obvious, as most people seem to be very happy with
exuberant ctags.


Thanks,

R.

On 21 Aug 2006 22:56:13 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Ramon Diaz-Uriarte wrote:
> > Dear All,
> >
> > Has anybody tried to use ID Utils
> > (http://www.gnu.org/software/idutils/4652) with Python?
>
> What exactly are you trying to accomplish?  If you want to index
> function/class names, variables, etc then you should take a look at
> "exuberant ctags" http://ctags.sourceforge.net53 --although it started
> off as a C indexer, it has excellent Python support, it's free, and as
> a bonus its indices are well supported from inside major editors (vim,
> emacs, etc) so you can easily follow code flow, find function/class
> definitions, etc.
>
> --
> http://mail.python.org/mailman/listinfo/python-list54
>


-- 
Ramon Diaz-Uriarte
Bioinformatics Unit
Spanish National Cancer Centre (CNIO)
http://ligarto.org/rdiaz
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: convert a long string in binary

2006-08-22 Thread Maric Michaud
Le dimanche 20 août 2006 13:55, [EMAIL PROTECTED] a écrit :
> bussiere maillist:
> > i've got a very long string
> > and i wanted to convert it in binary
>
> Not much tested:
>
> _nibbles = {"0":"", "1":"0001", "2":"0010", "3":"0011",
> "4":"0100", "5":"0101", "6":"0110", "7":"0111",
> "8":"1000", "9":"1001", "A":"1010", "B":"1011",
> "C":"1100", "D":"1101", "E":"1110", "F":""}
>
> def toBase2(number):
> if number < 16:
> return "" + _nibbles["%X" % number]
> else:
> d1, d2 = "%X" % number
> return _nibbles[d1] + _nibbles[d2]
>
> convbin = dict((chr(i), toBase2(i)) for i in xrange(256))
>
> def binary(s):
> return "".join(convbin[c] for c in s)
>
> print binary("testing string")
>
> Surely there are ways to make it shorter (But it's fast enough).
>

Maybe this one is more elegant :

In [305]: trans = {}

In [306]: for i in range(256) :
   .: trans[chr(i)] = ''.join(i & 2**j and '1' or '0'
   .: for j in reversed(range(8)))
   .:

In [307]: trans['a']
Out[307]: '0111'

In [308]: trans['\xee']
Out[308]: '11101110'

In [309]: print ''.join(trans[e] for e in 'test string')
01110100011001010111001101110110011100110111010001110010011010010110111001100111


> Bye,
> bearophile

-- 
_

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: What do you want in a new web framework?

2006-08-22 Thread Paul Boddie
Tim Roberts wrote:
>
> Consider Ruby.  If someone asks, "I'd like to do a web site with Ruby, what
> should I use?", the answer comes back loud, clear, and unanimous: Ruby on
> Rails.

I actually believe that people in most buzzword shortlist situations
see Rails as being the name in the list of candidates, not Ruby - it's
somewhat like Zope being in the list rather than Python, or
Struts/Tapestry/Apache-project-of-the-month being in the list rather
than Java (albeit with a fairly warm corporate feeling that Java is
there underneath).

> If someone asks, "I'd like to do a web site with Python, what
> should I use?", she gets 25 different answers.  "Look at HTMLGen, Cheetah,
> WebWare, CherryPy, Karrigell, Django, Pylons, Plone, Zope, TurboGears,
> etc., etc.", none of which are pre-installed in the typical Linux
> distribution.  To the non-programming decision maker, that kind of response
> makes Python look unprofessional -- a toy.

Indeed. That's why, after enumerating the uncontrollably expanding list
of solutions for a time [1], I wanted to concentrate on showing the
viable options with all their differentiating features in the Python
Web Frameworks Overview [2]. Ultimately, that content was moved to the
python.org Wiki [3] and everyone got their chance to hype their pet
project - it became like a random set of links. Sure, everyone wants
everyone else to see their work, but there's a role in the community
for objective education about the right tool for the job rather than
either graphically showing the little fish tear each other apart, or
jumping on the bandwagon with the most momentum and hyping it to the
exclusion of everything else. In the latter case, the end result is to
promote the big fish to the bigger pool (that stuff about Rails, Zope,
Struts & friends above), creating another generation of "agile
frameworks".

[...]

> I agree with Marc.  PLEASE do not create "yet another Python web
> framework."  Let's pick one, and join together to turn it into the One,
> True, Unquestioned Web Solution.

Let's say we go for front-runner "du jour", Django. I've looked at
Django, and I'll admit that parts of the core API are fairly well done
when compared to certain other frameworks. However, let's say that we
want to "do it right" whilst expressing our dissatisfaction with the
templating, noting that when doing XML-oriented templating (that's
HTML, XHTML, XML and so on) I prefer something which upsets my Web page
editor less than it already is. So we unplug the templating somehow and
offer other options which plug into whatever magic that exists in
Django to make everything work smoothly. Let's say we unplug the
database abstraction layer because it doesn't do everything we want,
either, noting that I don't have any strong opinions about Django's
object-relational mapper, but I am wary of Web frameworks which
apparently encourage a database installation just for "hello world"
even if it isn't strictly required from a technical perspective.
Ultimately, we end up in a situation that is described far better in
the following article:

http://www.cmlenz.net/blog/2006/08/the_python_web_.html

In my opinion, what has damaged the Python Web frameworks scene has
been the continual hype and land-grabbing, the refusal to cede ground
on even the most basic stuff ("my magic form request variables are
better than yours", even though the majority of such magic solutions
are lacklustre at best), and that continual sighting of a grand prize
that at best gives you a ticket to Zopeworld - you get your own
"business ecosystem" while everyone else starts working on the next
thing to undo you.

I'd like to hear suggestions on how some cooperation can be encouraged
above the WSGI level, which despite the fanfare didn't really give so
many good answers to those confused users looking for a solution. As
I've said often enough before, the abstract "paper comparison" of Web
frameworks evolved into WebStack [4] which was originally an exercise
in seeing just how different many frameworks are at the lower levels:
the answer, given that you can paper over them in that way, is
"different only in unhelpful ways but not irreconcilably so". One day,
the Python Web frameworks scene may grow up and realise this fact.

Paul

[1]
http://web.archive.org/web/20041011015154/http://thor.prohosting.com/~pboddie/Python/web_modules.html
[2] http://www.boddie.org.uk/python/web_frameworks.html
[3] http://wiki.python.org/moin/WebProgramming
[4] http://www.python.org/pypi/WebStack

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


Re: Problem of function calls from map()

2006-08-22 Thread Georg Brandl
Paul McGuire wrote:
> "Dasn" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
>>
>> Hi, there.
>>
>> 'lines' is a large list of strings each of which is seperated by '\t'
>> >>> lines = ['bla\tbla\tblah', 'bh\tb\tb', ... ]
>>
>> I wanna split each string into a list. For speed, using map() instead
>> of 'for' loop.
> 
> Try this.  Not sure how it stacks up for speed, though.  (As others have
> suggested, if 'for' loop is giving you speed heartburn, use a list
> comprehension.)
> 
> In this case, splitUsing is called only once, to create the embedded
> function tmp.  tmp is the function that split will call once per list item,
> using whatever characters were specified in the call to splitUsing.
> 
> -- Paul
> 
> 
> 
> data = [
> "sldjflsdfj\tlsjdlj\tlkjsdlkfj",
> "lsdjflsjd\tlsjdlfdj\tlskjdflkj",
> "lskdjfl\tlskdjflj\tlskdlfkjsd",
> ]
> 
> def splitUsing(chars):
> def tmp(s):
> return s.split(chars)
> return tmp
> 
> for d in map(splitUsing('\t'), data):
> print d

And why is this better than

map(lambda t: t.split('\t'), data)

?

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


Re: How can I enumerate all windows services and disable some of them?

2006-08-22 Thread Roger Upole

<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
>I know that Module win32service has some functions on manipulating
> win32 services.
> But I still have 2 questions:
> 1. how to enumerate all services?
> 2. how to disable a certain one?
>
> Thanks in advance!
>

win32service.EnumServicesStatus lists services, and ChangeServiceConfig
lets you change the start type to disabled.

import win32service
hscm=win32service.OpenSCManager(None,None,win32service.SC_MANAGER_ALL_ACCESS)
svcs=win32service.EnumServicesStatus(hscm)
for svc in svcs:
if svc[0]=='PyPipeTestService':
hsvc=win32service.OpenService(hscm, svc[0], 
win32service.SERVICE_CHANGE_CONFIG)
win32service.ChangeServiceConfig(hsvc, win32service.SERVICE_NO_CHANGE,
win32service.SERVICE_DISABLED, win32service.SERVICE_NO_CHANGE, 
None, None,0,
None,None,None,None)
win32service.CloseServiceHandle(hsvc)
win32service.CloseServiceHandle(hscm)


 Roger



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


Re: Python and STL efficiency

2006-08-22 Thread Mc Osten
Jeremy Sanders <[EMAIL PROTECTED]> wrote:

> It must be the debugging, the compiler or a poor STL implementation. With
> gcc 4 it runs instantly on my computer (using -O2), even with 10x the
> number of values.

$ gcc --version
i686-apple-darwin8-gcc-4.0.1 (GCC) 4.0.1 (Apple Computer, Inc. build
5363)

I adapted original poster's code and made a function that did not create
strings each time. The NoisyString is a class we can use to actually
track copying.

In fact Python here is faster. Suppose it has a really optimized set
class...


Here some results (I know that the fpoint optimizations are useless...
it's is my "prebuilt" full optimization macro :) ):




$ g++ -O3 -pipe -O2 -march=pentium-m -msse3 -fomit-frame-pointer
-mfpmath=sse  -o set_impl set_impl.cpp 
$ ./set_impl 
What do you know?
chicken crosses road
fool
so long...
What do you know?
chicken crosses road
fool
so long...
Elapsed 5.8
Elapsed 1.71

$ g++ -Os -pipe -O2 -march=pentium-m -msse3 -fomit-frame-pointer
-mfpmath=sse  -o set_impl set_impl.cpp 
$ ./set_impl 

What do you know?
chicken crosses road
fool
so long...
What do you know?
chicken crosses road
fool
so long...
Elapsed 5.8
Elapsed 1.71

$ g++ -O3 -o set_impl set_impl.cpp 
$ ./set_impl 
What do you know?
chicken crosses road
fool
so long...
What do you know?
chicken crosses road
fool
so long...
Elapsed 0.47
Elapsed 0.18

$ g++ -o set_impl set_impl.cpp 
$ ./set_impl 
What do you know?
chicken crosses road
fool
so long...
What do you know?
chicken crosses road
fool
so long...
Elapsed 0.63
Elapsed 0.33

$ python -O set_impl.py 
so long...
What do you know
fool
chicken crosses road
so long...
What do you know
fool
chicken crosses road
Elapsed: 1.37 seconds
Elapsed: 3.81 seconds



--- PYTHON CODE -
#python

global size 
size = 100

def f():
a = []
for i in range(size):
a.append('What do you know')
a.append('so long...')
a.append('chicken crosses road')
a.append('fool')
b = set(a)
for s in b:
print s

def slow_f():
a = []
for i in range(size):
a.append('%s' % 'What do you know')
a.append('%s' % 'so long...')
a.append('%s' % 'chicken crosses road')
a.append('%s' % 'fool')
b = set(a)
for s in b:
print s

import time
from time import clock

f_start = clock()
f()
f_end   = clock()

slow_f_start = clock()
slow_f()
slow_f_end   = clock()

print "Elapsed: %f seconds" % (f_end - f_start)
print "Elapsed: %f seconds" % (slow_f_end - slow_f_start)

--


- CPP CODE -
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
using namespace std;


#define SIZE 100

class NoisyString : public std::string {
  public:
  NoisyString(const string& cp) 
  : string(cp) 
  {
  cout << "Fuck I got copied!" << endl;
  }
  
  NoisyString(const char* s ) : string(s) {

  }
  
  
  
};


void f(){
  vector a;
for (long int i=0; i b(a.begin(), a.end());
copy(b.begin(), b.end(), ostream_iterator(cout, "\n"));
}

void fast_f(){
  vector a;
  string s1  =  "What do you know?"   ;
  string s2  =  "so long..."  ;
  string s3  =  "chicken crosses road";
  string s4  =  "fool";
for (long int i=0; i b(a.begin(), a.end());
copy(b.begin(), b.end(), ostream_iterator(cout, "\n"));
}


int main(){
  clock_t f_start, 
  f_end,
  faster_f_start, 
  faster_f_end,
  fast_f_start,
  fast_f_end;
 
  f_start = clock();
  f();
  f_end   = clock();
  
  fast_f_start = clock();
  fast_f();
  fast_f_end   = clock();
  

  cout << "Elapsed " << (f_end - f_start) / double(CLOCKS_PER_SEC) <<
endl;
  cout << "Elapsed " << (fast_f_end - fast_f_start) /
double(CLOCKS_PER_SEC) << endl;
  
}

---




-- 
blog:  http://www.akropolix.net/rik0/blogs | Uccidete i filosofi,
site:  http://www.akropolix.net/rik0/  | tenetevi riso e
forum: http://www.akropolix.net/forum/ | bacchette per voi.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python and STL efficiency

2006-08-22 Thread Mc Osten
Tim N. van der Leeuw <[EMAIL PROTECTED]> wrote:

> I'm curious though, if on the OP's machine the slowed-down Python
> version is still faster than the C++ version.

I tested both on my machine (my other post in the thread)

-- 
blog:  http://www.akropolix.net/rik0/blogs | Uccidete i filosofi,
site:  http://www.akropolix.net/rik0/  | tenetevi riso e
forum: http://www.akropolix.net/forum/ | bacchette per voi.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to decode a string

2006-08-22 Thread Lad
Fredrik Lundh wrote:
> Lad wrote:
>
> > for
> > print repr(RealName)  command
> > I will get
> >
> > P?ibylov\xe1 Ludmila
> > where instead of  ? should be also a character
>
> that's not very likely; repr() always includes quotes, always escapes
> non-ASCII characters, and optionally includes a Unicode prefix.
>
> please try this
>
>print "*", repr(RealName), type(RealName), "*"
>
> and post the entire output; that is, *everything* between the asterisks.
>
The result of print "*", repr(RealName), type(RealName), "*" is

* 'Fritschov\xe1 Laura'  *


Best regards,
L

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


Configure python2.5 on Gentoo

2006-08-22 Thread Norman Khine
Hello,
I have a strange result on a Gentoo machine in that, after I run 
./configure and then type make, the make goes in circles.

checking for c++... c++
configure: WARNING:

  By default, distutils will build C++ extension modules with "c++".
  If this is not intended, then set CXX on the configure command line.
 
checking how to run the C preprocessor... cc -E
checking for egrep... grep -E


and then it starts again...

How can I correct this and what is this due to. I am compiling Python-2.5b3

Many thanks

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


Re: Python and STL efficiency

2006-08-22 Thread Fredrik Lundh
"Mc Osten" wrote:

> In fact Python here is faster. Suppose it has a really optimized set
> class...

Python's memory allocator is also quite fast, compared to most generic
allocators...

 



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


How to get database metadata information (i.e. existing tables and columns in tables)

2006-08-22 Thread Chris Brat
Hi,

Is it possible to retrieve details about the database, specifically a
list of the tables in the database; and then to retrieve the columns
and their types for the tables?

Is this dependant on the database? 

Thanks
Chris

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


RE: How to get database metadata information (i.e. existing tables andcolumns in tables)

2006-08-22 Thread Tim Golden
[Chris Brat]

| Is it possible to retrieve details about the database, specifically a
| list of the tables in the database; and then to retrieve the columns
| and their types for the tables?
| 
| Is this dependant on the database? 

In effect it's dependent on the database. We're assuming you're
talking about a relational databases for a start, since other
databases don't necessarily even have tables. The major databases
may support the INFORMATION_SCHEMA standard (random link:
http://www.devx.com/getHelpOn/10MinuteSolution/20561) but they
may not -- I don't think sqlite does, for example -- and their 
implementations may well vary etc.

In short, try INFORMATION_SCHEMA first. Failing that, look
at the specific db docs for the gen.

TJG


This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk

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


Re: How to get database metadata information (i.e. existing tables and columns in tables)

2006-08-22 Thread Mathias Waack
Chris Brat wrote:

> Is it possible to retrieve details about the database, specifically a
> list of the tables in the database; and then to retrieve the columns
> and their types for the tables?

Yes. 

> Is this dependant on the database?

Yes. 

Real databases usually store meta-data (list of tables, list of columns,
list of indexes aso...) in system tables which can be queried in the same
manner as common tables or view. Just read your database handbook...

HTH
Mathias

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


Re: wxWindow GetPosition() bug???

2006-08-22 Thread Andre Poenitz
mardif <[EMAIL PROTECTED]> wrote:
> Hi,
> I've found a strange behavior in method GetPosition() of wxWindow class
> 
> ( and derived ).
> On windows, if you create a window object
> 
> frame = wx.Frame(None, -1, "TESTING")
> 
> and you set the position to:
> frame.SetPosition( (300, 45000) )
> 
> If you call method GetPosition, the result will be:
> frame.GetPosition()
> >>> (300, 32767)
> 
> 32767 is the integer limit. Why GetPosition() returns this value??? and
> 
> why on Unix Platform this problem was not found??
> 
> thx very much!

Traditionally, there was a 16(15?) bit limit for coordinates on X Window
systems.

Maybe the wx implementations tries to be smarter than X itself and
restricts the positions artificially. Maybe Windows has sch a limit 
itself...

I don't really know, other than 'never try to access coordinates
that are 'much' bigger than what is actually visible'...

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


Re: Python and STL efficiency

2006-08-22 Thread Mc Osten
Fredrik Lundh <[EMAIL PROTECTED]> wrote:

> Python's memory allocator is also quite fast, compared to most generic
> allocators...

In fact also in the two "slow" versions Python outperforms C++.
I didn't notice it in the first place.

-- 
blog:  http://www.akropolix.net/rik0/blogs | Uccidete i filosofi,
site:  http://www.akropolix.net/rik0/  | tenetevi riso e
forum: http://www.akropolix.net/forum/ | bacchette per voi.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python and STL efficiency

2006-08-22 Thread Tim N. van der Leeuw

Mc Osten wrote:
> Fredrik Lundh <[EMAIL PROTECTED]> wrote:
>
> > Python's memory allocator is also quite fast, compared to most generic
> > allocators...
>
> In fact also in the two "slow" versions Python outperforms C++.
> I didn't notice it in the first place.
>

But your C++ program outputs times in seconds, right? So all
compilations except for the first two give results in less than a
second, right? (meaning the optimizations of your standard-compilation
give worst results than -O3?)

BTW, I don't quite understand your gcc optimizations for the first 2
compiles anyways: two -O options with different values. Doesn't that
mean the 2nd -O takes preference, and the compilation is at -O2 instead
of -O3?

Why both -O3 and -O2 at the command-line?

Cheers,

--Tim


> --
> blog:  http://www.akropolix.net/rik0/blogs | Uccidete i filosofi,
> site:  http://www.akropolix.net/rik0/  | tenetevi riso e
> forum: http://www.akropolix.net/forum/ | bacchette per voi.

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


Re: How to get database metadata information (i.e. existing tables and columns in tables)

2006-08-22 Thread Miki
Hello Chris,

> Is it possible to retrieve details about the database, specifically a
> list of the tables in the database; and then to retrieve the columns
> and their types for the tables?
>
> Is this dependant on the database?
Yes and Yes. However some toolkits like SQLObject
(http://www.sqlobject.org/) and SQLAlchemy (http://www.sqlalchemy.org/)
can do this work for you (IIRC).

HTH,
Miki
http://pythonwise.blogspot.com/

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


Re: Python and STL efficiency

2006-08-22 Thread Tim N. van der Leeuw

Mc Osten wrote:
> Fredrik Lundh <[EMAIL PROTECTED]> wrote:
>
> > Python's memory allocator is also quite fast, compared to most generic
> > allocators...
>
> In fact also in the two "slow" versions Python outperforms C++.
> I didn't notice it in the first place.
>
> --
> blog:  http://www.akropolix.net/rik0/blogs | Uccidete i filosofi,
> site:  http://www.akropolix.net/rik0/  | tenetevi riso e
> forum: http://www.akropolix.net/forum/ | bacchette per voi.

Well, I guess I'm getting really obsessed with this. But anyways. I
installed MinGW on my Windows-XP (sp2) laptop. It is g++ version 3.4.5
-- ancient, yes, but on windows it's the latest available.

I compiled Mc Osten's C++ program (tweaked the output a little) and ran
it; ran his version of the python code too.
Oh boy; yes indeed the slow python is faster than the fast C++
version... Must be something really awful happening in the STL
implementation that comes with GCC 3.4!

Here's the output from my console:

[EMAIL PROTECTED] ~/My Documents/Python
$ g++ -O3 -march=pentium-m -o SpeedTest SpeedTest.cpp

[EMAIL PROTECTED] ~/My Documents/Python
$ ./SpeedTest.py
Begin Test
Number of unique string objects: 4
so long...
What do you know
fool
chicken crosses road
Number of unique string objects: 4
so long...
What do you know
fool
chicken crosses road
Fast - Elapsed: 0.037574 seconds
Slow - Elapsed: 0.081520 seconds

[EMAIL PROTECTED] ~/My Documents/Python
$ ./SpeedTest.exe
Begin Test
What do you know?
chicken crosses road
fool
so long...
What do you know?
chicken crosses road
fool
so long...
Fast - Elapsed: 2.089 seconds
Slow - Elapsed: 6.303 seconds

[EMAIL PROTECTED] ~/My Documents/Python


Cheers,

--Tim

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


unicode "table of character" implementation in python

2006-08-22 Thread Nicolas Pontoizeau
Hi,

I am handling a mixed languages text file encoded in UTF-8. Theres is
mainly French, English and Asian languages. I need to detect every
asian characters in order to enclose it by a special tag for latex.
Does anybody know if there is a unicode "table of character"
implementation in python? I mean, I give a character and python replys
me with the language in which the character occurs.

Thanks in advance

-- 
http://www.nicolas.pontoizeau.org/
Nicolas Pontoizeau - Promotion EFREI 2005
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to get database metadata information (i.e. existing tables and columns in tables)

2006-08-22 Thread Chris Brat
Thanks for the great feedback.

Chris.


Chris Brat wrote:
> Hi,
>
> Is it possible to retrieve details about the database, specifically a
> list of the tables in the database; and then to retrieve the columns
> and their types for the tables?
> 
> Is this dependant on the database? 
> 
> Thanks
> Chris

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


CONSTRUCT - Module Attributes and Execution Environment

2006-08-22 Thread lazaridis_com
I would like to change the construct:

if __name__ == '__main__':

to something like:

if exec.isMain():

My (OO thought) is to place a class in an separate code module and to
instantiate an singleton instance which would keep th something like
this:

class ExecutionEnv:
def isMain(self)
if CALLING_MODULE.__name__ == '__main__':
return true
else
return false

exec = ExecutionEnv()

How to I get access to the CALLING_MODULE ?

-

Are ther alternative constructs/mechanism available, which could be
used to add this functionality possiby directly to a code-module?

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


Re: Modules... paths... newbie confusion

2006-08-22 Thread Steve Holden
MrBlueSky wrote:
> Thanks for the suggestions, folks..
> 
> site-packages
> ~~
> OK, I'm been trying to get MSSQL into c:\Python24\lib\site-packages.
> MSSQL comes (as a tar'd, zip'd file) with a folder hierarchy with
> MSSQL.py at the top level and then bin\python2.3\mssqldb.pyd.   If I
> try and copy this folder hierarchy into site-packages and "import
> MSSQL" then it recognises MSSQL.py but fails to import mssqldb, as
> that's imported from MSSQL.py.
> 
> I've noticed a setup.py in the MSSQL folder, but it looks like it has
> odd hard-coded paths in it (D:\...) and anyway when I tried to run it,
> I found the Usage message less than helpful!
> 
> I really apologise if this is Bleeding Obvious to everyone else - is
> there a web page that will explain all this so the lightbulb will go on
> over my head?!
> 
It's usually considered acceptable to tweak the setup.py file if it has 
to know where specific things like libraries exist on your machine. 
Usually the file will be setup up to find them in the most obvious 
places (so I don't know what D:... paths are doing in there).

In other words, it's OK to fix setup.py so it runs!

You won;t get MySQLdb to run without running the setup.py since IIRC 
there's a compile step for a C library (and it's that compile step that 
needs to be able to find the MySQL client libraries).

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

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


Re: CONSTRUCT - Module Attributes and Execution Environment

2006-08-22 Thread Fuzzyman

lazaridis_com wrote:
> I would like to change the construct:
>
> if __name__ == '__main__':
>
> to something like:
>
> if exec.isMain():
>
> My (OO thought) is to place a class in an separate code module and to
> instantiate an singleton instance which would keep th something like
> this:
>
> class ExecutionEnv:
> def isMain(self)
> if CALLING_MODULE.__name__ == '__main__':
> return true
> else
> return false
>
> exec = ExecutionEnv()
>
> How to I get access to the CALLING_MODULE ?

sys._getframe(1).f_globals['__name__']

All the best,

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

>
> -
>
> Are ther alternative constructs/mechanism available, which could be
> used to add this functionality possiby directly to a code-module?

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


Re: How to get database metadata information (i.e. existing tables and columns in tables)

2006-08-22 Thread Steve Holden
Chris Brat wrote:
> Hi,
> 
> Is it possible to retrieve details about the database, specifically a
> list of the tables in the database; and then to retrieve the columns
> and their types for the tables?
> 
> Is this dependant on the database? 
> 
As far as locating the field names goes, this should work with most 
DBAPI modules:

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/81189

thought hat doesn't help wiht getting the table names ...

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

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


Re: Problem installing Python 2.4.3 on FreeBSD 5.3-RELEASE-p31

2006-08-22 Thread [EMAIL PROTECTED]

jamesuh wrote:
> Martin v. Löwis wrote:
> > [EMAIL PROTECTED] schrieb:
> > > I assume this is related to the configure warning... ?  Same error with
> > > just a standard "./configure" and "make".
> > >
> > > Any help would be great :)
> >
> > If you don't need the curses module, go on with the installation.
> > It's a known bug in FreeBSD's curses header file.
> >
> > Regards,
> > Martin
>
> But I cannot continue because it seg faults and does not continue the
> make - Forgive my ignorance, but how do I prevent the curses module
> from being included?

There is some severe problem here. I have this very version of Python
on a FreeBSD 5.3 system (I'm typing on it now) and didn't have this
problem. I think you may have some conflict in your object libs.

If you don't need tkinter you can go to one of the FreeBSD ftp sites
and download the packaged binary version.

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


Re: How to decode a string

2006-08-22 Thread Fredrik Lundh
"Lad" wrote:

> The result of print "*", repr(RealName), type(RealName), "*" is
>
> * 'Fritschov\xe1 Laura'  *

looks like the MySQL interface is returning 8-bit strings using ISO-8859-1
encoding (or some variation of that; \xE1 is "LATIN SMALL LETTER A
WITH ACUTE" in 8859-1).

have you tried passing "use_unicode=True" to the connect() call ?

 



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


Re: Python and STL efficiency

2006-08-22 Thread Jeremy Sanders
Mc Osten wrote:

> Here some results (I know that the fpoint optimizations are useless...
> it's is my "prebuilt" full optimization macro :) ):

Interesting. The opimisation makes no difference to the speed of the C++ one
for me. I just get

xpc17:~> g++4 -O2 test2.cpp
xpc17:~> ./a.out
What do you know?
chicken crosses road
fool
so long...
What do you know?
chicken crosses road
fool
so long...
Elapsed 2.11
Elapsed 1.11

(This is with an Althon 64 4600+ running Linux).

Unfortunately the Python on this computer doesn't have set as it is too old,
so I can't compare it.

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


Re: Problem of function calls from map()

2006-08-22 Thread Sion Arrowsmith
Dasn  <[EMAIL PROTECTED]> wrote:
># size of 'dict.txt' is about 3.6M, 154563 lines
>f = open('dict.txt', 'r')
>print "Reading lines..."
>lines = f.readlines()
>print "Done."
 [ ... ]
>def sp1(lines):
>   """> sp1() -- List-comprehension"""
>   return [s.split('\t') for s in lines]
 [ ... ]
>def sp4(lines):
>   """> sp4() -- Not correct, but very fast"""
>   return map(str.split, lines)
>
>for num in xrange(5):
>   fname = 'sp%(num)s' % locals()
>   print eval(fname).__doc__
>   profile.run(fname+'(lines)')

>> sp1() -- List-comprehension
> 154567 function calls in 12.240 CPU seconds
 [ ... ]
>> sp4() -- Not correct, but very fast
> 5 function calls in 3.090 CPU seconds
 [ ... ]
>The problem is the default behavior of str.split should be more complex
>than str.split('\t'). If we could use the str.split('\t') in map(), the
>result would be witty. What do u guys think?

I think there's something weird going on -- sp4 should be making
154563 calls to str.split. So no wonder it goes faster -- it's
not doing any work.

How does [s.split() for s in lines] compare to sp2's
[s.split('\t') for s in lines] ?

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

Re: IDLE with python 2.5

2006-08-22 Thread Miki
Hello Emmanuel,
> I've just read in Python 2.5 description that IDLE 'executes code in a
> separate process', using a TCP connection on port 127.0.0.1 to
> communicate.
This is older than 2.5 (for sure it's in 2.4, can't remember if it was
in 2.3)

> Does it mean that we can now debug embedded python with IDLE ?
I don't think so, it just open a new "python.exe" process and
communicates with it via TCP.

HTH,
Miki
http://pythonwise.blogspot.com/

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


Re: CONSTRUCT - Module Attributes and Execution Environment

2006-08-22 Thread Duncan Booth
lazaridis_com wrote:

> Are ther alternative constructs/mechanism available, which could be
> used to add this functionality possiby directly to a code-module?

How about something along these lines:

-- auto.py -
import sys, atexit

def main_body(f):
if f.func_globals['__name__']=='__main__':
atexit.register(f, sys.argv)
return f

@main_body
def auto(args):
print "auto run", args


If you run auto.py as a script then the decorated function executes. If you 
import it then the decorated function doesn't execute. In your own script 
you just need an import statement and to put the decorator on your main 
function.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Modules... paths... newbie confusion

2006-08-22 Thread Sibylle Koczian
Steve Holden schrieb:
> You won;t get MySQLdb to run without running the setup.py since IIRC
> there's a compile step for a C library (and it's that compile step that
> needs to be able to find the MySQL client libraries).
> 
But MySQLdb comes with a windows installer. No need to tweak anything.
Sometimes you've got to choose between a slightly older version without
install worries and the newest source, but not at the moment.

-- 
Dr. Sibylle Koczian
Universitaetsbibliothek, Abt. Naturwiss.
D-86135 Augsburg
e-mail : [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Problem of function calls from map()

2006-08-22 Thread Paul McGuire
"Georg Brandl" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Paul McGuire wrote:
> > "Dasn" <[EMAIL PROTECTED]> wrote in message
> > news:[EMAIL PROTECTED]
> >>
> >> Hi, there.
> >>
> >> 'lines' is a large list of strings each of which is seperated by '\t'
> >> >>> lines = ['bla\tbla\tblah', 'bh\tb\tb', ... ]
> >>
> >> I wanna split each string into a list. For speed, using map() instead
> >> of 'for' loop.
> >

> >
> > def splitUsing(chars):
> > def tmp(s):
> > return s.split(chars)
> > return tmp
> >
> > for d in map(splitUsing('\t'), data):
> > print d
>
> And why is this better than
>
> map(lambda t: t.split('\t'), data)
>
> ?
>
> Georg

Hmm, "better" is a funny word.  My posting was definitely more verbose, but
verbosity isn't always bad.

In defense of brevity:
- often (but not always) runs faster
- usually easier to understand as a single gestalt (i.e., you don't have to
jump around in the code, or grasp the intent of a dozen or more lines, when
one or a few lines do all the work), but this can be overdone

In defense of verbosity:
- usually more explicit, as individual bits of logic are exposed as separate
functions or statements, and anonymous functions can be given more
descriptive names
- usually easier to understand, especially for language newcomers
- separate functions can be compiled by psyco

Of course, such generalizations invite obvious extremes and counterexamples.
Prime number algorithms compacted into one-liners are anything but quick to
understand; conversely, I've seen a 40-line database function exploded into
>100 classes (this was in Java, so each was also a separate file!) in
pursuit of implementing a developer's favorite GOF pattern.

This idiom (as used in the splitUsing case) of returning a callable from a
function whose purpose is to be a factory for callables seems to be a common
one in Python, I think I've seen it go by different names: currying, and
closures being most common, and decorators are another flavor of this idea.
Perhaps these idioms ("idia"?) emerged when "lambda" was on Guido's Py3K
chopping block.

So I wouldn't really hold these two routines up for "betterness" - the OP's
performance test shows them to be about the same.  To summarize his
performance results (times in CPU secs):
- explicit "for" loop - 20.510  (309130 total function calls; 154563 to
split and 154563 to append)
- list comprehension - 12.240 (154567 total function calls; 154563 to split)
- map+lambda - 20.480   (309130 total function calls; 154563 to  and
154563 to split)
- map+splitUsing - 21.900  (309130 total function calls; 154563 to tmp and
154563 to split)

The big winner here is the list comprehension, and it would seem it outdoes
the others by halving the number of function calls.  Unfortunately, most of
our currying/closure/decorator idioms are implemented using some sort of
"function-calls-an-embedded-function" form, and function calls are poison to
performance in Python (and other languages, too, but perhaps easier to
observe in Python).  Even the anonymous lambda implementation has this same
issue.

So the interesting point here is to go back to the OP's OP, in which he
states, "For speed, [I'm] using map() instead of 'for' loop."  As it turns
out, map() isn't much of a win in this case.  The real, "best" solution is
the list comprehension, not only for speed, but also for ease of readability
and understanding.  It's tough to beat this:

return [s.split('\t') for s in lines]

for clarity, explicity, brevity, and as it happens, also for speed.

-- Paul


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


a question to run a Python program using PMW

2006-08-22 Thread Agathe Sørflaten
Title: Message



Hi
 
I found your questio 
regarding "I am new to Python and I am trying to run an old 
program. I do notknow what version this old program was running back in 2001 
( I knowit was run successfully). I got the source codes from the office and 
Idownloaded Python 2.3 and Pmw 1.2. when ran the program I got 
thefollowing messageTraceback (most recent call last):File 
"BidderUI.py", line 12, in ?import os.path, string, PmwFile 
"C:\Python23\Pmw\__init__.py", line 35, in 
?__import__(_loader)ImportError: No module named 
Pmw_1_2.lib.PmwLoaderI did create Pmw.py by running bunddlepmw.py. I 
also find PmwLoader.pyunder the PMW_1_2/lib directory. Does anyone know how 
to fix this? didI miss any steps ?"
I have the sma 
problem. Did you ever resolve this issue? 
How? 

 
thanks, 

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

Re: What do you want in a new web framework?

2006-08-22 Thread Alex Martelli
Tim Roberts <[EMAIL PROTECTED]> wrote:
   ...
> themselves.  However, in the case of web frameworks, I believe Marc is
> fundamentally correct: the web framework proliferation in Python is
> actually doing the language a huge disservice.

Indeed, it has been truthfully observed that Python's the only language
with more web frameworks than keywords.

I have already suggested to the BDFL that he can remedy this situation
in Py3k: all he has to do, of course, is to add a LOT more keywords.


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


bit-torrent client code open source in Python written

2006-08-22 Thread thomasasta
Hey

there is a new python written open source bit-torrent client out.
Don´t mit it up with brams c++ bittorrent, in python it is bit-torrent.sf.net

Don´t forget the minus -

http://bit-torrent.sourceforge.net/

It´s out till 10 days and the code is open source, so you can add it to any 
other application in python like CyberSpace or any other app !

;-))

Btw: does anyone know a pyhton written kedamlia client for the emule network or 
any other kademlia function ?

Kind regards...
-- 


"Feel free" – 10 GB Mailbox, 100 FreeSMS/Monat ...
Jetzt GMX TopMail testen: http://www.gmx.net/de/go/topmail
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: How to decode a string

2006-08-22 Thread Lad

Fredrik Lundh wrote:
> "Lad" wrote:
>
> > The result of print "*", repr(RealName), type(RealName), "*" is
> >
> > * 'Fritschov\xe1 Laura'  *
>
> looks like the MySQL interface is returning 8-bit strings using ISO-8859-1
> encoding (or some variation of that; \xE1 is "LATIN SMALL LETTER A
> WITH ACUTE" in 8859-1).
>
> have you tried passing "use_unicode=True" to the connect() call ?
>
> 

Frederik,
Thank you for your reply.
I found out that if I do not decode the string at all, it looks
correct. But I do not know  why it is ok without decoding.
I use Django and I do not use use_unicode=True" to the connect() call.

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


Re: What do you want in a new web framework?

2006-08-22 Thread Fredrik Lundh
Alex Martelli wrote:

> Indeed, it has been truthfully observed that Python's the only language
> with more web frameworks than keywords.

recent research indicates that it has more web frameworks than comments
in the source code.

 



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


Re: Problem of function calls from map()

2006-08-22 Thread Fredrik Lundh
Sion Arrowsmith wrote:

> I think there's something weird going on -- sp4 should be making
> 154563 calls to str.split. So no wonder it goes faster -- it's not doing
> any work.

of course it does:

>>> lines = ["line\tone", "line\ttwo"]
>>> [s.split("\t") for s in lines]
[['line', 'one'], ['line', 'two']]
>>> map(str.split, lines)
[['line', 'one'], ['line', 'two']]

the problem is that he's using a Python-level profiler to benchmark things 
written
in C.

(you cannot really use "profile" to *benchmark* things written in Python 
either; the
profiler tells you where a given program spends the time, not how fast it is in 
com-
parision with other programs)

 



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


Re: Python and STL efficiency

2006-08-22 Thread Mc Osten
Tim N. van der Leeuw <[EMAIL PROTECTED]> wrote:


> But your C++ program outputs times in seconds, right? So all
> compilations except for the first two give results in less than a
> second, right? (meaning the optimizations of your standard-compilation
> give worst results than -O3?)

Yes. It's in seconds but the benchmark that are one order of magnitudo
less than the others have of a different "size" (10 instead of
100).  That is cut and paste from my terminal... I think it's a
mess. I do it all again from scratch.

> BTW, I don't quite understand your gcc optimizations for the first 2
> compiles anyways: two -O options with different values. Doesn't that
> mean the 2nd -O takes preference, and the compilation is at -O2 instead
> of -O3?
> Why both -O3 and -O2 at the command-line?

I forgot I put -O2 in my $FAST_FLAGS. I don't know what I was thinking
about.

This the correct version

$ g++ -Os -pipe -march=pentium-m -msse3 -fomit-frame-pointer
-mfpmath=sse  -o set_impl set_impl.cpp 

$ ./set_impl 
What do you know?
chicken crosses road
fool
so long...
What do you know?
chicken crosses road
fool
so long...
Elapsed 6.3
Elapsed 2.1

$ g++ -O2 -pipe -march=pentium-m -msse3 -fomit-frame-pointer
-mfpmath=sse  -o set_impl set_impl.cpp 
$ ./set_impl 
What do you know?
chicken crosses road
fool
so long...
What do you know?
chicken crosses road
fool
so long...
Elapsed 5.8
Elapsed 1.7

$ g++ -O3 -pipe -march=pentium-m -msse3 -fomit-frame-pointer
-mfpmath=sse  -o set_impl set_impl.cpp 
$ ./set_impl  
What do you know?
chicken crosses road
fool
so long...
What do you know?
chicken crosses road
fool
so long...
Elapsed 5.79
Elapsed 1.72

$ g++ -pipe -march=pentium-m -msse3 -fomit-frame-pointer -mfpmath=sse
-o set_impl set_impl.cpp 
$ ./set_impl
What do you know?
chicken crosses road
fool
so long...
What do you know?
chicken crosses road
fool
so long...
Elapsed 7.12
Elapsed 2.98

$ python -O set_impl.py 
so long...
What do you know
fool
chicken crosses road
so long...
What do you know
fool
chicken crosses road
Elapsed: 1.37 seconds
Elapsed: 3.80 seconds

-- 
blog:  http://www.akropolix.net/rik0/blogs | Uccidete i filosofi,
site:  http://www.akropolix.net/rik0/  | tenetevi riso e
forum: http://www.akropolix.net/forum/ | bacchette per voi.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python and STL efficiency

2006-08-22 Thread Mc Osten
Tim N. van der Leeuw <[EMAIL PROTECTED]> wrote:

> Oh boy; yes indeed the slow python is faster than the fast C++
> version... Must be something really awful happening in the STL
> implementation that comes with GCC 3.4!

And the Python version does the very same number of iterations than the
C++ one? I suppose they are looping on arrays of different sizes, just
like my "first version".

-- 
blog:  http://www.akropolix.net/rik0/blogs | Uccidete i filosofi,
site:  http://www.akropolix.net/rik0/  | tenetevi riso e
forum: http://www.akropolix.net/forum/ | bacchette per voi.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: text editor suggestion?

2006-08-22 Thread John Salerno
Ravi Teja wrote:

> Stick to SciTE. It takes almost no learning effort and meets everyone
> of those requirements. As far as customerization goes, SciTE can be
> customerized quite well. In fact, it can even be scripted with Lua. You
> seem to be using the single file executable which does not come with
> the configuration files. Otherwise, I cannot see how you could be
> missing this ability.

I really like Scite, but I find it's syntax highlighting abilities to be 
quite limited. You can't specify your own groups of words, you can only 
use what is already preset in the lexer files.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: unicode "table of character" implementation in python

2006-08-22 Thread Brian Beck
Nicolas Pontoizeau wrote:
> I am handling a mixed languages text file encoded in UTF-8. Theres is
> mainly French, English and Asian languages. I need to detect every
> asian characters in order to enclose it by a special tag for latex.
> Does anybody know if there is a unicode "table of character"
> implementation in python? I mean, I give a character and python replys
> me with the language in which the character occurs.

Nicolas, check out the unicodedata module:
http://docs.python.org/lib/module-unicodedata.html

Find "import unicodedata" on this page for how to use it:
http://www.amk.ca/python/howto/unicode

I'm not sure if it has built-in support for finding which language block a
character is in, but a table like this might help you:
http://www.unicode.org/Public/UNIDATA/Blocks.txt

-- 
Brian Beck
Adventurer of the First Order
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: unicode "table of character" implementation in python

2006-08-22 Thread Nicolas Pontoizeau
2006/8/22, Brian Beck <[EMAIL PROTECTED]>:
> Nicolas, check out the unicodedata module:
> http://docs.python.org/lib/module-unicodedata.html
>
> Find "import unicodedata" on this page for how to use it:
> http://www.amk.ca/python/howto/unicode
>
> I'm not sure if it has built-in support for finding which language block a
> character is in, but a table like this might help you:
> http://www.unicode.org/Public/UNIDATA/Blocks.txt

As usual, Python has a solution that goes beyond my needs!
Thanks for the links I will dive into it.

Nicolas

-- 
http://www.nicolas.pontoizeau.org/
Nicolas Pontoizeau - Promotion EFREI 2005
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: CONSTRUCT - Module Attributes and Execution Environment

2006-08-22 Thread Larry Bates
lazaridis_com wrote:
> I would like to change the construct:
> 
> if __name__ == '__main__':
> 
> to something like:
> 
> if exec.isMain():
> 
> My (OO thought) is to place a class in an separate code module and to
> instantiate an singleton instance which would keep th something like
> this:
> 
> class ExecutionEnv:
> def isMain(self)
> if CALLING_MODULE.__name__ == '__main__':
> return true
> else
> return false
> 
> exec = ExecutionEnv()
> 
> How to I get access to the CALLING_MODULE ?
> 
> -
> 
> Are ther alternative constructs/mechanism available, which could be
> used to add this functionality possiby directly to a code-module?
> 
Two thoughts:

1) Don't call a class instance exec, it will mask the built-in
exec statement.

2) IMHO all the suggestions are way more complicated than
if __name__ == "__main__" and are not SOP for most pythoneers.
I know what the former construct means/does.  I have to
decipher your class to figure our what the latter does and it
doesn't really save you any code or provide a performance
enhancement.

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


Re: CONSTRUCT - Module Attributes and Execution Environment

2006-08-22 Thread Georg Brandl
Larry Bates wrote:
> lazaridis_com wrote:
>> I would like to change the construct:
>> 
>> if __name__ == '__main__':
>> 
>> to something like:
>> 
>> if exec.isMain():
>> 
>> My (OO thought) is to place a class in an separate code module and to
>> instantiate an singleton instance which would keep th something like
>> this:
>> 
>> class ExecutionEnv:
>> def isMain(self)
>> if CALLING_MODULE.__name__ == '__main__':
>> return true
>> else
>> return false
>> 
>> exec = ExecutionEnv()
>> 
>> How to I get access to the CALLING_MODULE ?
>> 
>> -
>> 
>> Are ther alternative constructs/mechanism available, which could be
>> used to add this functionality possiby directly to a code-module?
>> 
> Two thoughts:
> 
> 1) Don't call a class instance exec, it will mask the built-in
> exec statement.

He won't be able to ;)

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


Re: Problem of function calls from map()

2006-08-22 Thread Sion Arrowsmith
Fredrik Lundh <[EMAIL PROTECTED]> wrote:
>Sion Arrowsmith wrote:
>> I think there's something weird going on -- sp4 should be making
>> 154563 calls to str.split. So no wonder it goes faster -- it's not doing
>> any work.
>the problem is that he's using a Python-level profiler to benchmark things 
>written
>in C.
>
>(you cannot really use "profile" to *benchmark* things written in Python 
>either; the
>profiler tells you where a given program spends the time, not how fast it is 
>in com-
>parision with other programs)

Hmm. Playing around with timeit suggests that although split() *is*
faster than split("\t"), it's fractional, rather than the OP's four
times faster. Is the overhead of profile keeping track of calls in
Python getting in the way? (Not having used profile -- hence my
confusion.) And why can map() keep everything at the C level when
the list comprehension can't?

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

Translating Javascript programs to python.

2006-08-22 Thread Vyz
Hi,
I have a script with hundreds of lines of javascript spread accross 7
files. Is there any tool out there to automatically or
semi-automatically translate the code into python. 

Thanks
Vyz

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


Re: how do you get the name of a dictionary?

2006-08-22 Thread jojoba
Hello again,

Fredrick said:

> Python's object model.  an object has a value, a type, and an identity,
> but no name.

I say:

Thank you Fredrick for the reply!
However, although python's object model does not currently support what
i am asking for, how difficult would it be to assign a string name(s)
to an object upon creation (and upon referencing)?

please note:
i don't want to do anything sophisticated with this, i am really only
looking for a TITLE for my dictionary when i throw it in a tree editor
that i have built. And i do realize that its not possible now. I am
just pressing a point here.

Sorry to ruffle everyone's feathers, but this is a fairly curious
problem.

Thanks to all,
jojoba

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


Re: Translating Javascript programs to python.

2006-08-22 Thread Diez B. Roggisch
Vyz schrieb:
> Hi,
> I have a script with hundreds of lines of javascript spread accross 7
> files. Is there any tool out there to automatically or
> semi-automatically translate the code into python. 

Nope. Besides: in which environment does that script run - a browser? 
Then it would be difficult if not impossible to execute even a 
hypothetic result.

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


Re: Python and STL efficiency

2006-08-22 Thread Tim N. van der Leeuw

Mc Osten wrote:
> Tim N. van der Leeuw <[EMAIL PROTECTED]> wrote:
>
> > Oh boy; yes indeed the slow python is faster than the fast C++
> > version... Must be something really awful happening in the STL
> > implementation that comes with GCC 3.4!
>
> And the Python version does the very same number of iterations than the
> C++ one? I suppose they are looping on arrays of different sizes, just
> like my "first version".
>

Hmmm.. You're quite right. The C++ version had an array size 100.000
(your version), the Python version still had an array size 10.000 (as
in my modified copy of the original version).

When fixing the Python version to have 100.000 items, like the C++
version, the Python timings are:

Begin Test
Number of unique string objects: 4
so long...
What do you know
fool
chicken crosses road
Number of unique string objects: 40
so long...
What do you know
fool
chicken crosses road
Fast - Elapsed: 0.512088 seconds
Slow - Elapsed: 1.139370 seconds

Still twice as fast as the fastest GCC 3.4.5 compiled version!

Incidentally, I also have a version compiled with VC++ 6 now... (not
yet w/VC++ 7) .. Compiled with release-flags and maximum optimization
for speed, here's the result of VC++ 6:

[EMAIL PROTECTED] ~/My Documents/Python
$ ./SpeedTest_VC.exe
Begin Test
What do you know?
chicken crosses road
fool
so long...
What do you know?
chicken crosses road
fool
so long...
Fast - Elapsed: 4.481 seconds
Slow - Elapsed: 4.842 seconds

So you can see that it's 'slow' version of the code is faster than the
'slow' version compiled with GCC, but the 'fast' code is barely faster
than the 'slow' code! And the 'fast' version compiled with GCC is much
faster than the 'fast' version compiled with VC++ 6!

My conclusion from that is, that the vector<> or set<> implementations
of GCC are far superior to those of VC++ 6, but that memory allocation
for GCC 3.4.5 (MinGW version) is far worse than that of MSCRT / VC++ 6.
(And Python still smokes them both).

Cheers,

--Tim



> --
> blog:  http://www.akropolix.net/rik0/blogs | Uccidete i filosofi,
> site:  http://www.akropolix.net/rik0/  | tenetevi riso e
> forum: http://www.akropolix.net/forum/ | bacchette per voi.

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


Re: idutils and Python

2006-08-22 Thread [EMAIL PROTECTED]
Ramon Diaz-Uriarte wrote:
> On 21 Aug 2006 22:56:13 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> > What exactly are you trying to accomplish?  If you want to index
> > function/class names, variables, etc then you should take a look at
> > "exuberant ctags" http://ctags.sourceforge.net53 --although it started
> > off as a C indexer, it has excellent Python support, it's free, and as
> > a bonus its indices are well supported from inside major editors (vim,
> > emacs, etc) so you can easily follow code flow, find function/class
> > definitions, etc.
>
>
> Sorry for not being clear enough. I want the following:
>
> a) have my editor go to the point where a function/whatever is defined

That's usually ctags/etags

> b) see all places where a function/whatever is used.

That's usually cscope  http://cscope.sourceforge.net/ but I've not
tried to use it with Python before; from the web page it looks like it
may be worth a spin:
"The fuzzy parser supports C, but is flexible enough to be useful for
C++ and Java, and for use as a generalized 'grep database' (use it to
browse large text documents!"

The vim integration is very nice.  It has emacs integration too, but I
haven't used it and can't comment on how good it is.

> I think the wish "do not use grep, just look at the index file, and
> immediately display all matches"  is reasonable and probably other
> Python coders had thought about it before. But I am wondering if I am
> missing something obvious, as most people seem to be very happy with
> exuberant ctags.

I am usually happy with grep, but we only have a medium-large size
project (320,000 lines of Python code); I can imagine on very large
codebases that would be too slow to be practical.

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


Re: how do you get the name of a dictionary?

2006-08-22 Thread Georg Brandl
jojoba wrote:
> Hello again,
> 
> Fredrick said:
> 
>> Python's object model.  an object has a value, a type, and an identity,
>> but no name.
> 
> I say:
> 
> Thank you Fredrick for the reply!
> However, although python's object model does not currently support what
> i am asking for, how difficult would it be to assign a string name(s)
> to an object upon creation (and upon referencing)?
> 
> please note:
> i don't want to do anything sophisticated with this, i am really only
> looking for a TITLE for my dictionary when i throw it in a tree editor
> that i have built. And i do realize that its not possible now. I am
> just pressing a point here.
> 
> Sorry to ruffle everyone's feathers, but this is a fairly curious
> problem.

Why not add a "name" attribute to your objects? e.g.

class NamedDict(dict):
 def __init__(self, _name_, *args, **kwargs):
 self.name = _name_
 dict.__init__(self, *args, **kwargs)

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


Re: Need advice on how to improve this function

2006-08-22 Thread Gabriel Genellina

At Monday 21/8/2006 12:03, Larry Bates wrote:


> I wrote a function that converts a tuple of tuples into html.  For
> example:
> I'd like to know ways to make it better (more efficient, able to deal
> with enormous-size arguments, etc).  How would I write this as a
> generator?
Before you put too much work into this you might want to take a look
at HTMLgen:  http://www.python.net/crew/friedrich/HTMLgen/html/main.html


Another very good library is 
(Don't be afraid of the date - it's just that HTML standards haven't 
changed very much lately :) )




Gabriel Genellina
Softlab SRL 






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


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

Re: how do you get the name of a dictionary?

2006-08-22 Thread BartlebyScrivener
>> how difficult would it be to assign a string name(s)
>> to an object upon creation (and upon referencing)?

Exactly the point that's being made. It's so easy just do it yourself:

banana={"name":"banana"}

Hey what is the name of my dictionary?

banana["name"]

But why build it into Python and force everyone else to do it, when
most of the time nobody cares what the name is, or they already know?

It's like forcing everybody everywhere always and forever to wear
"Hello My Name Is" tags.

rd

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


Re: Unclear on argument passing to "sendmail'

2006-08-22 Thread John Draper
Tim Williams wrote:

> On 21/08/06, John Draper <[EMAIL PROTECTED]> wrote:
>
>> In "smtplib" module, the "sendmail" method of function is to be  passed
>
> > host, but it is the Domain name
>
>> for the SMTP Server as gotten from the "dig" command?   IE:   dig -tMX
>> would give me the SMTP
>> server.   In my code I have:
>
> >
>
>> try:
>> print "Sending message to host: %s" % mailHost
>> server=smtplib.SMTP(mailHost)
>> server.sendmail(reply_email,email,body)
>> server.quit()
>> except:
>> print "Uunable to send"
>>
>> Is mailHost like "mail.t-mobile.com" which I get from the MX record for
>> a given domain?
>> But also,  is the "email" just the mail account,  ie:  the username?
>> without the @?
>>
>> I need to be able to query the mail server?   Also,  I want to be able
>> to handle
>> the "SMTPRecipientsRefused" exception.   What is the proper syntax for
>> handling
>> this?
>>
>> Do I do it like this?
>>
>> try:
>> print "Sending message to host: %s" % mailHost
>> server=smtplib.SMTP(mailHost)
>> server.sendmail(reply_email,email,body)
>> server.quit()
>> except SMTPRecipientsRefused:
>> print "Recipient refused"
>>
>> Is that the right syntax?   I have severe problems with not enough
>> example code.
>>
>
> mailHost is the name of the mail server server you are sending the
> email to/via,  for internet mail this will be a server from the
> recipient's domain's mx records (or your ISP server).

Ok,  that's what I thought,  I wasn't sure if I were to put the MAIN host
name or the MX host name.

>
> reply_email is the full email address of the sender, or the email
> address you wish to appear as the sender. It does not have to be the
> same address as used in the body headers

OK

>
> email is a bad choice for a variable name,  try something like
> to_email,  in your case it should contain the full email address of
> the recipeint or a list of recipients.  

Ok,   so If I already have a MX hostname of "mail.myhost.com",  then
I would put into my "to_email"...@myhost.com for
my user name,  is that right?   And not just  without the
@myhost.com,   right?

> The address(es)  do not have
> to be the same address as used in the body headers

OK

>
> server.sendmail returns a list of failed recipient email addresses if
> only some failed,   if all the recipients failed you get an exception.

Hmmm - the problem I have is if I knowingly put in a bad recipient,  and
try to send to a unknown user,  I get all appearances that the mail went 
through.
I never got any kind of failed recipient (Which for me,  is a total 
bummer), because
now I cannot know if the mail was sucessfully sent.  Is this normal 
behaviour for
an SMTP server?   I know in SOME instances,  in the case the SMTP server has
to "relay" the mail to another server,  I wouldn't get this exception 
and it would
appear the mail went through,  but will the "sendmail" method also return
the failed recipient's Email address in this case as well?

By the way,  I'm sending this mail to a "sms" gateway to a cellular 
provider,
so the username is their phone number.   But (sigh),  these providers don't
appear to tell me if I put in a bogus phone number.

>
> Apologies for the bad formatting below,  its untested but should show
> you the structure for managing an SMTP msg send.  You could tidy it up
> without too much effort
>
> import sys
>
> for mailHost in MX_records:
> try:
>print "Sending message to host: %s" % mailHost
>server=smtplib.SMTP(mailHost)
>failed = server.sendmail(reply_email,email,body)
>server.quit()
>break
> except smtplib.SMTPRecipientsRefused, x :  #all recips failed
>for recip in x.recipients:
>print recip
>server.quit()
>break
> except smtplib.SMTPDataError, x: # an error at the end of the
> # message body =  MSG Failed
> # all recips failed
>print x[0], x[1]
>server.quit()
>break
> except smtplib.SMTPSenderRefused, x : # the sender was refused = #MSG 
> failed
> # all recips failed
>print x[0], x[1]
>server.quit()
>break
> except: #can't connect so continue to next MX server - don't fail !!!
>e_error = str(sys.exc_info()[0])
>print e_error
>server.quit()
>continue
>
> for recip in failed:  # some failed, some didn't
>print recip

Hmmm - so THAT's how I use the exceptions.  What is "x"?  Is that the 
error code,
or is that the returned dictionary.I thought I had to do it this way

   d = server.sendmail(reply_email,email,body)

Where "d" is the dictionary.   But in your above code,  you return a 
"failed",  but
you are not using it in any other part of the code.  Is this because "x" 
when used
in the "except" clause is what I'm to use?   Is "x" and "failed" the 
same dictionary?

Ok,  I got one more question...  in the docs on the smtplib class,  a 
"sendmail"
method also has other arguments,   such as mail_options,  and rcpt_options.
What are they,  and could you give me an example 

Re: How to get database metadata information (i.e. existing tables and columns in tables)

2006-08-22 Thread Luis M. González
If you want to know the names of the fields on a recordset, you can use
cursor.description.
For example, lets say you have a connection to a MySQL database:

con = MySQLdb.connect('localhost','root','','mydb')
cur = con.cursor()
cur.execute('select * from customers')
result = cur.fetchall()

fields = [i[0] for i in cur.description]
...
Description gives a list with information about your recordset, being
the first item the name of the field.

Hope this helps...
Luis



Chris Brat wrote:
> Hi,
>
> Is it possible to retrieve details about the database, specifically a
> list of the tables in the database; and then to retrieve the columns
> and their types for the tables?
> 
> Is this dependant on the database? 
> 
> Thanks
> Chris

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


Re: Create a Multilanguage PDF in Python

2006-08-22 Thread Perseo
Thanks I will try it.

Diez B. Roggisch wrote:
> Perseo wrote:
>
> > I can't upload in the PYTHONPATH but in a normal folder of our site.
> > Exist another way to do it?
>
> PYTHONPATH is an environment variable. You can set it to arbitrary paths,
> and python will look for module there, too. Or you modify sys.path before
> you try the import.
> 
> Diez

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


Re: Input from the same file as the script

2006-08-22 Thread Dieter Maurer
Georg Brandl <[EMAIL PROTECTED]> writes on Sun, 20 Aug 2006 20:08:38 +0200:
> [EMAIL PROTECTED] wrote:
> > Can the input to the python script be given from the same file as the
> > script itself. e.g., when we execute a python script with the command
> > 'python  > When I ran the below the python interpreter gave an error.

The easiest way would be:

 data = '''\
 here comes your data
 ...
 '''

 # and now you use it
 ... data ...

 # you can even wrap it into a file
 from StringIO import StringIO
 data_as_file = StringIO(data)
 ... data_as_file.readline() ...

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


Unicode Error

2006-08-22 Thread Gallagher, Tim (NE)









Hey all I am learning Python
and having a fun time doing so.  I have a question for y'all, it has to do with
active directory.

 

I want to get the last login
for a computer from Active Directory.  I am using the active_directory module
and here is my code.

 

[START]

 

import active_directory

 

computer =
active_directory.root()

for cpu in computer.search
("cn='Computer_Name'"): 

    print cpu.samAccountName    ←---
Works find

    print
cpu.operatingSystem   ←--- Works find

    print cpu.lastLogon ←---
Getting Error

 

[END]

 

 

I get an error that I am not sure what to do with,
the error is TypeError: coercing to Unicode: need string or buffer, instance
found in my line Do I have to change the output to meet Unicode formation?

 

Thanks,

-T






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

Re: how do you get the name of a dictionary?

2006-08-22 Thread jojoba
> Exactly the point that's being made. It's so easy just do it yourself:
> banana={"name":"banana"}
> Hey what is the name of my dictionary?
> banana["name"]
> But why build it into Python and force everyone else to do it, when
> most of the time nobody cares what the name is, or they already know?


Aha.
my problem, (which as i said before, is not really an important
problem) is to take any dictionary and load it into a tree viewer AND
get the name(s) of that dictionary (if they exist, and if not, so be
it).
Now, that means that a given dictionary might not have the admittedly
super simple method of binding a name to itself (i.e. the
banana={"name":"banana"}).
This has been my issue. And there is no GENERAL solution that currently
exists.
I completely agree with everybody that a draconian solution is not
necessarily optimal, but i havent been convinced that it would
drastically, deleteriously affect python performance.
However, since i am not one of the wonderful people who commit time to
actually coding python, i dont really have a say.  =)
I know i am harping on this, but no one of yet has really proven why
having such a feature would seriously affect python speed.
Any ideas?
jojoba

o(-_-)o

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


Re: how do you get the name of a dictionary?

2006-08-22 Thread Carsten Haese
On Tue, 2006-08-22 at 12:34, jojoba wrote:
> Hello again,
> 
> Fredrick said:
> 
> > Python's object model.  an object has a value, a type, and an identity,
> > but no name.
> 
> I say:
> 
> Thank you Fredrick for the reply!
> However, although python's object model does not currently support what
> i am asking for, how difficult would it be to assign a string name(s)
> to an object upon creation (and upon referencing)?
> 
> please note:
> i don't want to do anything sophisticated with this, i am really only
> looking for a TITLE for my dictionary when i throw it in a tree editor
> that i have built. And i do realize that its not possible now. I am
> just pressing a point here.

At the risk of stating the obvious, why don't you simply add a parameter
for the title in the invocation of the tree editor? I.e. instead of

invoke_tree_editor(somedict)

do

invoke_tree_editor(somedict, "somedict")

HTH,

Carsten.


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


Re: text editor suggestion?

2006-08-22 Thread Ravi Teja

John Salerno wrote:
> Ravi Teja wrote:
>
> > Stick to SciTE. It takes almost no learning effort and meets everyone
> > of those requirements. As far as customerization goes, SciTE can be
> > customerized quite well. In fact, it can even be scripted with Lua. You
> > seem to be using the single file executable which does not come with
> > the configuration files. Otherwise, I cannot see how you could be
> > missing this ability.
>
> I really like Scite, but I find it's syntax highlighting abilities to be
> quite limited. You can't specify your own groups of words, you can only
> use what is already preset in the lexer files.

???

In the same file, near the top.

keywordclass.python=and assert break class continue def del elif \
else except exec finally for from global if import in is lambda None \
not or pass print raise return try while yield

I could add my own keywords to it.

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


Re: how do you get the name of a dictionary?

2006-08-22 Thread Gabriel Genellina

At Tuesday 22/8/2006 13:34, jojoba wrote:


i don't want to do anything sophisticated with this, i am really only
looking for a TITLE for my dictionary when i throw it in a tree editor
that i have built. And i do realize that its not possible now. I am
just pressing a point here.

Sorry to ruffle everyone's feathers, but this is a fairly curious
problem.


It's no problem at all: do you need a TITLE for your dictionary? Add 
a "title" attribute and you're done. Do you want a class? Inherit 
from dict and add your title attribute there.
That's pretty standard OO, and there is no need to modify the Python 
language...




Gabriel Genellina
Softlab SRL 




p4.vert.ukl.yahoo.com uncompressed Tue Aug 22 17:27:05 GMT 2006 
	


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

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

Re: Problem of function calls from map()

2006-08-22 Thread Fredrik Lundh
Sion Arrowsmith wrote:

>> (you cannot really use "profile" to *benchmark* things written in Python 
>> either; the
>> profiler tells you where a given program spends the time, not how fast it is 
>> in com-
>> parision with other programs)
> 
> Hmm. Playing around with timeit suggests that although split() *is*
> faster than split("\t"), it's fractional, rather than the OP's four
> times faster. Is the overhead of profile keeping track of calls in
> Python getting in the way?

correct.

> And why can map() keep everything at the C level when the list com-
 > prehension can't?

map is called with two Python objects (the str.split callable and the 
sequence object), while the list comprehension is turned into a byte-
code loop that evaluates s.split for each item in the sequence; compare 
and contrast:

 >>> def func(a):
... return map(str.split, a)
...
 >>> dis.dis(func)
   2   0 LOAD_GLOBAL  0 (map)
   3 LOAD_GLOBAL  1 (str)
   6 LOAD_ATTR2 (split)
   9 LOAD_FAST0 (a)
  12 CALL_FUNCTION2
  15 RETURN_VALUE

 >>> def func(a):
... return [s.split() for s in a]
...
 >>> dis.dis(func)
   2   0 BUILD_LIST   0
   3 DUP_TOP
   4 STORE_FAST   1 (_[1])
   7 LOAD_FAST0 (a)
  10 GET_ITER
 >>   11 FOR_ITER19 (to 33)
  14 STORE_FAST   2 (s)
  17 LOAD_FAST1 (_[1])
  20 LOAD_FAST2 (s)
  23 LOAD_ATTR0 (split)
  26 CALL_FUNCTION0
  29 LIST_APPEND
  30 JUMP_ABSOLUTE   11
 >>   33 DELETE_FAST  1 (_[1])
  36 RETURN_VALUE

(LOAD_GLOBAL and LOAD_ATTR does full name lookups, while LOAD_FAST loads 
a local variable using an integer index)



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


Job Jar

2006-08-22 Thread D
Hello, I apologize in advance for the vague description, but as of now
I only have an idea of what I'd like to do, and need some guidance as
to if it is feasible, and where to begin.  Basically, I'd like to
create a web-based "job jar", that users in my office can access in
order to view, and "take ownership" of, misc. office tasks.  One idea I
had was that when users select a task (i.e. by selecting a check box
and clicking an UPDATE button), tasks are automatically put in an In
Progress list (which identifies the task and the user who took
ownership of it) - then, when the action is complete, the user updates
it again which puts it in a Completed list (again, with the task
description and the user who completed it).  However, only certain
users should be able to add and modify task descriptions.

Is this something that would be extremely lengthy to write in Python,
or are there applications already out there that would make more sense
to use (I've played around with Twiki, but believe it to be overkill).
If it makes sense to design it from scratch, where can I begin in terms
of which libraries to use, etc.? Thanks in advance.

Steve

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


Re: how do you get the name of a dictionary?

2006-08-22 Thread jojoba



> At the risk of stating the obvious, why don't you simply add a parameter
> for the title in the invocation of the tree editor? I.e. instead of
> invoke_tree_editor(somedict)
> do
> invoke_tree_editor(somedict, "somedict")
> HTH,
> Carsten.


Thanks Carsten.
This would indeed allow me to assign a title for my dicitonaries, but i
am looking for something more general..
specfically:
given any dictionary, get a name for it.

But yeah, your way would totally work!
Thanks,
jojoba

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


Re: how do you get the name of a dictionary?

2006-08-22 Thread Fredrik Lundh
jojoba wrote:

> However, although python's object model does not currently support what
> i am asking for, how difficult would it be to assign a string name(s)
> to an object upon creation (and upon referencing)?

if you want to add additional behaviour to an object, wrap it in custom 
class, or use a subclass.

here's an example:

 >>> class dict_with_title(dict):
... title = None
...
 >>> d = dict_with_title()
 >>> d.title = "this is the title"
 >>> d["a"] = "hello"
 >>> d
{'a': 'hello'}
 >>> d.title
'this is the title'



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


Re: https on ActiveState Python 2.4?

2006-08-22 Thread Jack
Thanks for the reply.

I found some openSSL patches for earlier versions of ActiveState Python.
It involves .pyd files and they look for earlier versions of Python DLLs and 
don't
run on ActiveState Python 2.4. I suspect the regular Python solution would
have the same problem or even more problems because it's not a pure .py
patch.

"Dennis Lee Bieber" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> On Mon, 21 Aug 2006 15:31:20 -0700, "Jack" <[EMAIL PROTECTED]>
> declaimed the following in comp.lang.python:
>
>> I'm trying to use urllib to retrieve an https page but I am
>> getting an "unknown url type: https"
>>
>> It seems that ActiveState Python doesn't have SSL support.
>> Any advice?
>>
>
> I've not tried, but it may be that the "regular" Python (of the same
> language level) may have SSL as a DLL/PYD & .py set and you could just
> copy them into the ActiveState install directory...
> -- 
> Wulfraed Dennis 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-list


Re: Job Jar

2006-08-22 Thread Fredrik Lundh
D wrote:

> Hello, I apologize in advance for the vague description, but as of now
> I only have an idea of what I'd like to do, and need some guidance as
> to if it is feasible, and where to begin.  Basically, I'd like to
> create a web-based "job jar", that users in my office can access in
> order to view, and "take ownership" of, misc. office tasks.  One idea I
> had was that when users select a task (i.e. by selecting a check box
> and clicking an UPDATE button), tasks are automatically put in an In
> Progress list (which identifies the task and the user who took
> ownership of it) - then, when the action is complete, the user updates
> it again which puts it in a Completed list (again, with the task
> description and the user who completed it).  However, only certain
> users should be able to add and modify task descriptions.

why not use an issue tracker?

 http://roundup.sourceforge.net/
 http://trac.edgewall.org/
 https://launchpad.net/

(etc)



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


Re: https on ActiveState Python 2.4?

2006-08-22 Thread Fredrik Lundh
Jack wrote:
> Thanks for the reply.
> 
> I found some openSSL patches for earlier versions of ActiveState Python.
> It involves .pyd files and they look for earlier versions of Python DLLs and 
> don't run on ActiveState Python 2.4. I suspect the regular Python solution 
> would
> have the same problem or even more problems because it's not a pure .py
> patch.

huh?  the "regular Python solution" ships with a perfectly working SSL 
library (in DLLs/_ssl.pyd), which look for the appropriate version of 
the Python DLL:

 > dumpbin /imports "\python24\DLLs\_ssl.pyd"
Microsoft (R) COFF Binary File Dumper Version 6.00.8168
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

Dump of file \python24\DLLs\_ssl.pyd

File Type: DLL

   Section contains the following imports:

 WSOCK32.dll
 ...
 python24.dll
 ...

(what's the point in using ActiveState's crippled distribution if you 
need stuff that's shipped with the standard distro, btw?  why not just 
use the standard version, and install win32all on top of that?)



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


Re: Job Jar

2006-08-22 Thread D
Thanks, Fredrik - but could I adapt them so that, instead of using them
for bug tracking (don't need version control, etc.), they're just used
for keeping track of simple tasks?

Fredrik Lundh wrote:
> D wrote:
>
> > Hello, I apologize in advance for the vague description, but as of now
> > I only have an idea of what I'd like to do, and need some guidance as
> > to if it is feasible, and where to begin.  Basically, I'd like to
> > create a web-based "job jar", that users in my office can access in
> > order to view, and "take ownership" of, misc. office tasks.  One idea I
> > had was that when users select a task (i.e. by selecting a check box
> > and clicking an UPDATE button), tasks are automatically put in an In
> > Progress list (which identifies the task and the user who took
> > ownership of it) - then, when the action is complete, the user updates
> > it again which puts it in a Completed list (again, with the task
> > description and the user who completed it).  However, only certain
> > users should be able to add and modify task descriptions.
>
> why not use an issue tracker?
>
>  http://roundup.sourceforge.net/
>  http://trac.edgewall.org/
>  https://launchpad.net/
> 
> (etc)
> 
> 

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


Re: Create a Multilanguage PDF in Python

2006-08-22 Thread Perseo
Nothing to do!
I enable test2.py and the folder with 777 permission and I write at the
top of the file the PYTHONPATH "#!/usr/bin/python" as you told me but
it doesn't works as well.

this is my organization:
www.domain.com/python/reportlab/ [all files]
www.domain.com/python/test2.py


#!/usr/bin/python

print "Content-Type: text/html\n\n"
print "Hello World"

from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont
from reportlab.pdfgen import canvas

pdfmetrics.registerFont(TTFont('Verdana', 'Verdana.ttf'))
c = canvas.Canvas("pl.pdf")
c.setFont("Verdana", 12)
c.drawString(100, 600, "Witaj,
¶wiecie!".decode("iso-8859-2").encode("utf-8"))
c.showPage()
c.save()


The verdana font doesn't exist in the reportlab fonts folder. I try to
delete the rows where it is called like (registerFont, setFont) but
nothing to do.

any suggestion?!



Diez B. Roggisch wrote:
> Perseo wrote:
>
> > I can't upload in the PYTHONPATH but in a normal folder of our site.
> > Exist another way to do it?
>
> PYTHONPATH is an environment variable. You can set it to arbitrary paths,
> and python will look for module there, too. Or you modify sys.path before
> you try the import.
> 
> Diez

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


key not found in dictionary

2006-08-22 Thread KraftDiner
I have a dictionary and sometime the lookup fails...
it seems to raise an exception when this happens.
What should I do to fix/catch this problem?

desc = self.numericDict[k][2]
KeyError: 589824   < This is the error that is being produced,
because there is no key
589824.

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


Re: key not found in dictionary

2006-08-22 Thread hiaips

KraftDiner wrote:
> I have a dictionary and sometime the lookup fails...
> it seems to raise an exception when this happens.
> What should I do to fix/catch this problem?
>
> desc = self.numericDict[k][2]
> KeyError: 589824   < This is the error that is being produced,
> because there is no key
> 589824.

It raises a KeyError, as you are seeing. Just use a try/except
construction and handle the error as required by your application:

try:
desc = self.numericDict[k][2]
except KeyError, ke:


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


Re: text editor suggestion?

2006-08-22 Thread John Salerno
Ravi Teja wrote:

> ???
> 
> In the same file, near the top.
> 
> keywordclass.python=and assert break class continue def del elif \
> else except exec finally for from global if import in is lambda None \
> not or pass print raise return try while yield
> 
> I could add my own keywords to it.
> 

But I don't want all my keywords to be highlighted in the same way. I 
have different colors for Python keywords, functions and methods, 
exceptions, other words like 'self', etc. and there's no way to do this 
without rewriting the lexer file (which is in C++) and recompiling Scite 
to build the changes into it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: key not found in dictionary

2006-08-22 Thread [EMAIL PROTECTED]
KraftDiner wrote:
> I have a dictionary and sometime the lookup fails...
> it seems to raise an exception when this happens.
> What should I do to fix/catch this problem?
>
> desc = self.numericDict[k][2]
> KeyError: 589824   < This is the error that is being produced,
> because there is no key
> 589824.

Given the information provided the simplest answer would be:

try:
desc = self.numericDict[k][2]
except KeyError:
desc = ''

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


Re: key not found in dictionary

2006-08-22 Thread Chaz Ginger
KraftDiner wrote:
> I have a dictionary and sometime the lookup fails...
> it seems to raise an exception when this happens.
> What should I do to fix/catch this problem?
> 
> desc = self.numericDict[k][2]
> KeyError: 589824   < This is the error that is being produced,
> because there is no key
> 589824.
> 

As stated you can wrap the access in the try - except - else statement, 
as in

try:
  foo['bar']
except :
  # Handle the error.
  pass
else :
  # We have it, so use it...
  print foo['bar']

Or you can use the has_key() and test it first. For example

  if foo.has_key('bar'):
print 'we have it'
  else :
print 'we don't have bar.'

That'll do it for me.

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


Re: Job Jar

2006-08-22 Thread Gabriel Genellina

At Tuesday 22/8/2006 15:47, D wrote:


Thanks, Fredrik - but could I adapt them so that, instead of using them
for bug tracking (don't need version control, etc.), they're just used
for keeping track of simple tasks?


Roundup  is generic enough to be 
used for almost anything...

It has nothing to do with version control.



Gabriel Genellina
Softlab SRL 




p5.vert.ukl.yahoo.com uncompressed Tue Aug 22 18:27:05 GMT 2006 
	


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

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

Re: key not found in dictionary

2006-08-22 Thread Philippe Martin
KraftDiner wrote:

> I have a dictionary and sometime the lookup fails...
> it seems to raise an exception when this happens.
> What should I do to fix/catch this problem?
> 
> desc = self.numericDict[k][2]
> KeyError: 589824   < This is the error that is being produced,
> because there is no key
> 589824.

If you agree that the key is not there, then just catch the exception
(try ... except)

Philippe

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


Re: key not found in dictionary

2006-08-22 Thread Pierre Quentel
Depending on what you want to do if the key doesn't exist, you might
want to use the dictionary method get() :

value = some_dict.get(key,default)

sets value to some_dict[key] if the key exists, and to default
otherwise

Regards,
Pierre

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


Re: radio buttons in curses

2006-08-22 Thread Fabian Braennstroem
Sorry, me again...
Does nobody have an idea or is it to stupid?

* Fabian Braennstroem <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I want to add some radio and check buttons to my curses
> script. As I understand it, there are no buttons in the
> 'basic' curses module. Now, I found the curses-extra module,
> but I not able to download and install it.
>
> Does anybody have an idea, where I can download the module
> or, even better, how I can create radio and check buttons
> with the 'ordinary' curses module? Would be nice...
>
> Greetings!
>  Fabian
>
> -- 
> http://mail.python.org/mailman/listinfo/python-list
>

Greetings!
 Fabian

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


Re: how do you get the name of a dictionary?

2006-08-22 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, jojoba wrote:

> Aha.
> my problem, (which as i said before, is not really an important
> problem) is to take any dictionary and load it into a tree viewer AND
> get the name(s) of that dictionary (if they exist, and if not, so be
> it).

How do you take "any" dictionary?  Don't you have to know a name to refer
to it?  Just pass this very name as additional argument to your tree
viewer.

> I know i am harping on this, but no one of yet has really proven why
> having such a feature would seriously affect python speed.
> Any ideas?

You have to attach a name to a dict every time it's assigned to a name and
delete a name from the dictionary every time such a name is deleted or
rebound to some other object.  And all this is unnecessary extra work and
memory consumption in 99.99% of most programs.

And why do you want to special case dictionaries?  If Python is doing it
for dictionaries, sooner or later someone will ask for the names of lists
or any arbitrary object.

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


  1   2   >