Re: porting vc++ project to python?

2007-08-23 Thread Diez B. Roggisch
marco Starglider schrieb:
> hi,
> 
> i have a very large project in visual studio2005->visual c++ in windowsxp.
> i'd like to port it, or my next project,  over to python.
> is this possible without rewriting all my code?
> are there multiple options to do this?
> my project is so large, that entirely rewriting it
> is actually no option.
> 
> regards,
> 
> m
> 
> ps i guess, it's an option to transform my current code into one or more
> python extensions/modules, and then calling them from a python core
> module?

It is. I personally prefer SIP, which is a C++ wrapper generator used to 
wrap the Qt toolkit. But there are other options as well, e.g. SWIG and 
Boost::Python.

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


Re: How do I get the current path of my python file that is currently running.

2007-08-23 Thread Arnau Sanchez
Lamonte Harris escribió:

> Say I start i click on a python file on my desktop, how could I return 
> the path of the current python file thats running?

http://docs.python.org/lib/module-sys.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Xah's Edu Corner: Under the spell of Leibniz's dream

2007-08-23 Thread Matthias Buelow
In comp.lang.lisp Bikal KC <[EMAIL PROTECTED]> wrote:

> I used usenet years ago then stopped for couple of years. I remember
> seeing him/her on c.l.perl I believe doing the same thing he/she is
> doing atm. I'd say the ultimate usenet superstar. Wow!

I think it's some (probably mild) form of autism.
No offense intended, Xah.
-- 
http://mail.python.org/mailman/listinfo/python-list


[ANN] Python courses this Fall

2007-08-23 Thread wesley chun
Folks, I'd like to announce my final Python courses for 2007:

Need to get up-to-speed with Python as quickly as possible? Come join
me, Wesley Chun, author of Prentice-Hall's well-received "Core Python
Programming," for another set of courses this Fall in beautiful
Northern California! This will be the final set for 2007... if you
miss these, you'll have to wait until next year. I look forward to
meeting you!
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(COMPREHENSIVE) INTRODUCTION TO PYTHON: Mon-Wed, 2007 Oct 8-10

This is course is meant for those new to Python and/or want to get
more in-depth formal training. We will immerse you in the world of
Python in only a few days.  We will show you more than just its syntax
(which you don't really need a book to learn, right?). Knowing more
about how Python works under the covers, including the relationship
between data objects and memory management, will make you a much more
effective Python programmer coming out of the gate.  3 hands-on labs
each day will help hammer the concepts home.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
INTERNET PROGRAMMING WITH PYTHON: Sat, 2007 Oct 13

This 1-day course will introduce current Python programmers to 3
distinct areas of Internet programming, each in self-contained modules
with a set of lab exercises following each lecture topic:

Network Programming using Sockets -- Underneath all of today's network
protocols, i.e., HTTP, FTP, RDBMS, IM, e-mail, etc., lies the main
communication mechanism, sockets. Here, we introduce client/server
architecture and how to program sockets using Python.

Internet Client Programming -- One level above the socket layer are
well-known Internet protocols such as FTP, NNTP, POP3, and SMTP.  In
this section, we learn how to create Internet clients of these
protocols to transfer files, send and receive e-mail, and read Usenet
newsgroup postings.

Web/CGI Programming -- Yes, pure CGI is "sooo yesterday," but before
you jump on all the web framework bandwagons, it's a good idea to
learn basics and the basis of how all web servers deliver dynamic
content back to the client browser so that you can appreciate all the
work that is done on your behalf by a more fully-featured frame- work.
Time-permitting, we will also give a high-level overview of one of the
more popular Python web frameworks, Django.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

WHERE: near the San Francisco Airport (SFO/San Bruno), CA, USA

WEB:   http://cyberwebconsulting.com (click "Python Training")

LOCALS: easy freeway (101/280/380) with lots of parking plus public
transit (BART and CalTrain) access via the San Bruno stations, easily
accessible from all parts of the Bay Area

VISITORS: free shuttle to/from the airport, free high-speed internet,
free breakfast and regular evening receptions; fully-equipped suites

See website for costs, venue info, and registration.  Discounts are
available for multiple registrations as well as for teachers/students.

Hope to see you there!
-- wesley
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"Core Python Programming", Prentice Hall, (c)2007,2001
http://corepython.com

wesley.j.chun :: wescpy-at-gmail.com
python training and technical consulting
cyberweb.consulting : silicon valley, ca
http://cyberwebconsulting.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Are there precompiled python for sgi ?

2007-08-23 Thread [EMAIL PROTECTED]
Hi,

Are there precompiled python for sgi(IRIX6.5) to download? Several 
packages(_socket, Tkinter, ...) always failed when I tried to build python 
from source on our machine running IRIX6.5.

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


Re: How would I go about making a file open. Not the way you might think.

2007-08-23 Thread Hendrik van Rooyen

Lamonte Harris  wrote:

>Basically you can open a file by double clicking, and by default it would open
w/ what every program you have it set >to.  Most text files would open in
notepad.  How can I make a txt open so that notepad opens w/ the content in it
by >using just python.

I asked this question just yesterday - and Tim Golden answered:

os.startfile()

- Hendrik

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


Re: What Are These Import/From Statements about?

2007-08-23 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Robert
Kern wrote:

> os.path. It's a sub-module of the standard os module.

Actually, there are no such things as sub-modules (as you'll find out if you
try to define one). What it really is is a variable in that module, which
points to another module (e.g. posixpath).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Raw strings to normal strings conversion?

2007-08-23 Thread James Stroud
Nagarajan wrote:
> Is there a way by which I could obtain normal string form of a raw
> string.
> XML CDATA is returned as raw string. But I need the string to actually
> escape special chars.
> 
> Any idea?
> 

This doesn't seem clear. Perhaps an example of what you get and what you 
want it converted to.

In the meantime, see if urllib.unquote() doesn't do what you need.

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


Re: [ANN] Python courses this Fall

2007-08-23 Thread Jeff Pang
Sounds good.How about the costs for those lessons?thanks.

-- "wesley chun" <[EMAIL PROTECTED]> wrote:
Folks, I'd like to announce my final Python courses for 2007:

Need to get up-to-speed with Python as quickly as possible? Come join
me, Wesley Chun, author of Prentice-Hall's well-received "Core Python
Programming," for another set of courses this Fall in beautiful
Northern California! This will be the final set for 2007... if you
miss these, you'll have to wait until next year. I look forward to
meeting you!
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(COMPREHENSIVE) INTRODUCTION TO PYTHON: Mon-Wed, 2007 Oct 8-10

This is course is meant for those new to Python and/or want to get
more in-depth formal training. We will immerse you in the world of
Python in only a few days.  We will show you more than just its syntax
(which you don't really need a book to learn, right?). Knowing more
about how Python works under the covers, including the relationship
between data objects and memory management, will make you a much more
effective Python programmer coming out of the gate.  3 hands-on labs
each day will help hammer the concepts home.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
INTERNET PROGRAMMING WITH PYTHON: Sat, 2007 Oct 13

This 1-day course will introduce current Python programmers to 3
distinct areas of Internet programming, each in self-contained modules
with a set of lab exercises following each lecture topic:

Network Programming using Sockets -- Underneath all of today's network
protocols, i.e., HTTP, FTP, RDBMS, IM, e-mail, etc., lies the main
communication mechanism, sockets. Here, we introduce client/server
architecture and how to program sockets using Python.

Internet Client Programming -- One level above the socket layer are
well-known Internet protocols such as FTP, NNTP, POP3, and SMTP.  In
this section, we learn how to create Internet clients of these
protocols to transfer files, send and receive e-mail, and read Usenet
newsgroup postings.

Web/CGI Programming -- Yes, pure CGI is "sooo yesterday," but before
you jump on all the web framework bandwagons, it's a good idea to
learn basics and the basis of how all web servers deliver dynamic
content back to the client browser so that you can appreciate all the
work that is done on your behalf by a more fully-featured frame- work.
Time-permitting, we will also give a high-level overview of one of the
more popular Python web frameworks, Django.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

WHERE: near the San Francisco Airport (SFO/San Bruno), CA, USA

WEB:   http://cyberwebconsulting.com (click "Python Training")

LOCALS: easy freeway (101/280/380) with lots of parking plus public
transit (BART and CalTrain) access via the San Bruno stations, easily
accessible from all parts of the Bay Area

VISITORS: free shuttle to/from the airport, free high-speed internet,
free breakfast and regular evening receptions; fully-equipped suites

See website for costs, venue info, and registration.  Discounts are
available for multiple registrations as well as for teachers/students.

Hope to see you there!
-- wesley
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"Core Python Programming", Prentice Hall, (c)2007,2001
http://corepython.com

wesley.j.chun :: wescpy-at-gmail.com
python training and technical consulting
cyberweb.consulting : silicon valley, ca
http://cyberwebconsulting.com
-- 
http://mail.python.org/mailman/listinfo/python-list




Send your friends personalized video messages!
Sign up for a FREE Juno account and start sending Video Mail today!
http://track.juno.com/s/lc?u=http://ads.addynamix.com/click/2-2130421-177


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


Re: Impersonate another user temporarily (Unix and Windows)

2007-08-23 Thread Tim Golden
billiejoex wrote:
> Hi there. I'm writing a modification for a FTP server library I'm
> maintaining.
> Depending on the system I'd want to temporarily impersonate the logged
> user to perform actions on filesystem.
> Something like:
> 
> try:
> change_user('user', 'password')
> os.rmdir('dir')
> except:
> print "some error"
> finally:
> change_user('old_user', 'password')
> 
> On Unix I took at look at os.seteuid() and os.setegid() functions and
> I noticed they could be useful for my purpose.
> On Windows I have no idea about how could I emulate a similar
> behaviour.
> Could someone please point me in the right direction?

(Warning: not tried, but at least gives you the things to Google for!)

You need the win32security module from the pywin32 extensions. [1]
In particular, you want to look at the LogonUser and
ImpersonateLoggedOnUser functions.

TJG

[1] http://pywin32.sf.net
-- 
http://mail.python.org/mailman/listinfo/python-list


Question: wxpython and 3d engine example with model load ?

2007-08-23 Thread OpenPavilion
Hello,

did anyone succeed in combining wxpython and a 3d engine (pyogre,
crystalblend, panda3d, soya etc.) ?

I would like to create an application, which uses wxpython tree, menu
and grid elements and embedds a 3d view of some of the listed objects
in an own detail window, so showing the object as a 3d model.
I know there is PyOpenGL as well, but I need to load complete models
(meshes done with cinema4d or blender) into the 3d view.

So it would be very nice, if someone could post me a link to an
example, where someone has successfully glued wxpython UI and a 3d
engine view loading meshes into the 3d view.

Regards
Bernd

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


Re: Raw strings to normal strings conversion?

2007-08-23 Thread Nagarajan
On Aug 23, 1:21 pm, James Stroud <[EMAIL PROTECTED]> wrote:
> Nagarajan wrote:
> > Is there a way by which I could obtain normal string form of a raw
> > string.
> > XML CDATA is returned as raw string. But I need the string to actually
> > escape special chars.
>
> > Any idea?
>
> This doesn't seem clear. Perhaps an example of what you get and what you
> want it converted to.

Here is an example:
>> rawstr = r'a\nb'
>> print rawstr
a\nb

Now I need this newstr to actually interpret '\n', in other words, to
behave like a normal string.
>
> In the meantime, see if urllib.unquote() doesn't do what you need.
>
> James

And yes, unquote doesn't help.

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


Re: python debugging under emacs?

2007-08-23 Thread Alberto Griggio
> Is there a debugging mode in emacs that works well with python?
> 
> I tried gud, but it was giving me errors, so I thought I'd ask before I
> try to get it to work: Is there an emacs mode (perhaps gud) that'll give a
> view of the python source, and currenly executing line, the ability
> inspect datastructures, etc.?  You know, like a modern debugger?  :)
> 
> I also looked at ddd, but it was cranky too, and apparently hasn't seen a
> new release in years.
> 
> I'm really more of a vim person than an emacs person, but if emacs will
> do what I want, I'd happily use it - for this.  :)

You can try pydb (http://bashdb.sourceforge.net/pydb/), has a GUD interface
that in my experience works better than pdb...

HTH,
Alberto


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


Re: Raw strings to normal strings conversion?

2007-08-23 Thread Marc 'BlackJack' Rintsch
On Thu, 23 Aug 2007 09:21:40 +, Nagarajan wrote:

> On Aug 23, 1:21 pm, James Stroud <[EMAIL PROTECTED]> wrote:
>> Nagarajan wrote:
>> > Is there a way by which I could obtain normal string form of a raw
>> > string.
>> > XML CDATA is returned as raw string. But I need the string to actually
>> > escape special chars.
>>
>> > Any idea?
>>
>> This doesn't seem clear. Perhaps an example of what you get and what you
>> want it converted to.
> 
> Here is an example:
>>> rawstr = r'a\nb'
>>> print rawstr
> a\nb
> 
> Now I need this newstr to actually interpret '\n', in other words, to
> behave like a normal string.

So you get a string with Newlines as two character sequence \n.  You don't
get "raw" strings.  That is a concept in Python source code.  When the
program is running there is no such distinction between "raw" and "normal"
strings.  Here's a solution:

In [87]: print r'a\nb'
a\nb

In [88]: print r'a\nb'.decode('string-escape')
a
b

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


Re: Baby Steps, optionDB

2007-08-23 Thread Padraig
On Aug 23, 4:41 am, "W. Watson" <[EMAIL PROTECTED]> wrote:
> root.option_readfile('optionDB')

Just leave out the line which tries to read in the non-existent config
file...

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


Joining elements in a list to 1 element

2007-08-23 Thread dimitri pater
Dear all,
I am having trouble joining elements in a list into 1 element.
e.g. ['a','b','c'] into ['abc'] so that len(list) returns 1

I have tried the following:
myList = ['a','b','c']
print myList
>>>['a', 'b', 'c']
# get type
print type(myList)
>>>
# get length
print len(myList)
>>>3

myList2 = ''.join(myList)
print myList2
>>>abc
# get type
print type(myList2)
>>>
# get length
print len(myList2)
>>>3

As you can see, the type 'list' turns into 'str' after .join. Doing
something like list(''.join(myList)) returns the type 'list' but still has 3
elements.

thanks,
Dimitri

-- 
---
You can't have everything. Where would you put it? -- Steven Wright
---
please visit www.serpia.org
-- 
http://mail.python.org/mailman/listinfo/python-list

beginner, idiomatic python

2007-08-23 Thread bambam
Would someone like to suggest a replacement for this? It works ok,
but it doesn't look like any of the other code:

tempList = ['1','2','3','4','5','6','7','8']
sampleList=[]
for port in tempList:
pagefound = False
for i in range(self.parent.GetPageCount()):
page=self.parent.GetPage(i)
if hasattr(page, "port"):
if page.port == int(port):
pagefound=True
if not pagefound:
sampleList.append(port)

Thanks!


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


Socket recv(1) seems to block instead of returning end of file.

2007-08-23 Thread Hendrik van Rooyen

While doing a netstring implementation I noticed that if you
build a record up using socket's recv(1), then when you close
the remote end down, the recv(1) hangs, despite having a short
time out of  0.1 set.

If however, you try to receive more than one char, (I tested with 3,
did not try 2), then when you shut the remote end down you do not
get a time out, but an empty string - the normal end of file, I suppose.

Has anybody else seen this behaviour?

The transmit side seems to give a broken pipe error, which is fine.

I am using stock standard SuSe 10, Python 2.4, out of the box.

- Hendrik


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


Re: Raw strings to normal strings conversion?

2007-08-23 Thread Nagarajan
On Aug 23, 2:42 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
> On Thu, 23 Aug 2007 09:21:40 +, Nagarajan wrote:
> > On Aug 23, 1:21 pm, James Stroud <[EMAIL PROTECTED]> wrote:
> >> Nagarajan wrote:
> >> > Is there a way by which I could obtain normal string form of a raw
> >> > string.
> >> > XML CDATA is returned as raw string. But I need the string to actually
> >> > escape special chars.
>
> >> > Any idea?
>
> >> This doesn't seem clear. Perhaps an example of what you get and what you
> >> want it converted to.
>
> > Here is an example:
> >>> rawstr = r'a\nb'
> >>> print rawstr
> > a\nb
>
> > Now I need this newstr to actually interpret '\n', in other words, to
> > behave like a normal string.
>
> So you get a string with Newlines as two character sequence \n.  You don't
> get "raw" strings.  That is a concept in Python source code.  When the
> program is running there is no such distinction between "raw" and "normal"
> strings.  Here's a solution:
>
> In [87]: print r'a\nb'
> a\nb
>
> In [88]: print r'a\nb'.decode('string-escape')
> a
> b
>
> Ciao,
> Marc 'BlackJack' Rintsch

Thanks a lot.

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


Re: Joining elements in a list to 1 element

2007-08-23 Thread Francesco Guerrieri
On 8/23/07, dimitri pater <[EMAIL PROTECTED]> wrote:
>
> Dear all,
> I am having trouble joining elements in a list into 1 element.
> e.g. ['a','b','c'] into ['abc'] so that len(list) returns 1
>
>
You need to append the joined string to your new list.
For instance
my_list = ["a", "b", "c"]
my_second_list = []
my_second_list.append("".join(my_list))

bye,
Francesco
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Impersonate another user temporarily (Unix and Windows)

2007-08-23 Thread billiejoex
On 23 Ago, 10:38, Tim Golden <[EMAIL PROTECTED]> wrote:
> billiejoex wrote:
> > Hi there. I'm writing a modification for a FTP server library I'm
> > maintaining.
> > Depending on the system I'd want to temporarily impersonate the logged
> > user to perform actions on filesystem.
> > Something like:
>
> > try:
> > change_user('user', 'password')
> > os.rmdir('dir')
> > except:
> > print "some error"
> > finally:
> > change_user('old_user', 'password')
>
> > On Unix I took at look at os.seteuid() and os.setegid() functions and
> > I noticed they could be useful for my purpose.
> > On Windows I have no idea about how could I emulate a similar
> > behaviour.
> > Could someone please point me in the right direction?
>
> (Warning: not tried, but at least gives you the things to Google for!)
>
> You need the win32security module from the pywin32 extensions. [1]
> In particular, you want to look at the LogonUser and
> ImpersonateLoggedOnUser functions.
>
> TJG
>
> [1]http://pywin32.sf.net- Nascondi testo tra virgolette -
>
> - Mostra testo tra virgolette -

Thanks for suggestion.
I made it.

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


Re: Impersonate another user temporarily (Unix and Windows)

2007-08-23 Thread Chris Mellon
On 8/23/07, billiejoex <[EMAIL PROTECTED]> wrote:
> On 23 Ago, 10:38, Tim Golden <[EMAIL PROTECTED]> wrote:
> > billiejoex wrote:
> > > Hi there. I'm writing a modification for a FTP server library I'm
> > > maintaining.
> > > Depending on the system I'd want to temporarily impersonate the logged
> > > user to perform actions on filesystem.
> > > Something like:
> >
> > > try:
> > > change_user('user', 'password')
> > > os.rmdir('dir')
> > > except:
> > > print "some error"
> > > finally:
> > > change_user('old_user', 'password')
> >
> > > On Unix I took at look at os.seteuid() and os.setegid() functions and
> > > I noticed they could be useful for my purpose.
> > > On Windows I have no idea about how could I emulate a similar
> > > behaviour.
> > > Could someone please point me in the right direction?
> >
> > (Warning: not tried, but at least gives you the things to Google for!)
> >
> > You need the win32security module from the pywin32 extensions. [1]
> > In particular, you want to look at the LogonUser and
> > ImpersonateLoggedOnUser functions.
> >
> > TJG
> >
> > [1]http://pywin32.sf.net- Nascondi testo tra virgolette -
> >
> > - Mostra testo tra virgolette -
>
> Thanks for suggestion.
> I made it.
>


Note that running your process as a user with enough priviledges to
impersonate another user pretty much eliminates all the benefits of
running as a low-priviledged user in the first place. Consider
re-thinking your application model and having an "ftp" user instead.
-- 
http://mail.python.org/mailman/listinfo/python-list


sentance containg the string or symbol Ω

2007-08-23 Thread yadin
how can i print a sentance containg the string or symbol Ω in python
and also lambda?

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

Re: Baby Steps, optionDB

2007-08-23 Thread W. Watson
That got things moving. Thanks. It looks like I have some typos to deal with 
now. I used to program in C++, and there's one thing I've never liked about 
OOP. Too much typing!

Padraig wrote:
> On Aug 23, 4:41 am, "W. Watson" <[EMAIL PROTECTED]> wrote:
>> root.option_readfile('optionDB')
> 
> Just leave out the line which tries to read in the non-existent config
> file...
> 

-- 
  Wayne Watson (Nevada City, CA)

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


Re: Baby Steps, optionDB

2007-08-23 Thread W. Watson
Thanks. I think I agree about the book comment. I used to dabble with Tcl/Tk 
many years ago. About a year ago, I sold my only book on it. I thought I'd 
never need it again! I wonder if Grayson's (e-book on his site) has improved.

After spending about 90 minutes with IDLE, I'm not real impressed. Is there 
something better?

Dennis Lee Bieber wrote:
> On Wed, 22 Aug 2007 20:41:11 -0700, "W. Watson"
> <[EMAIL PROTECTED]> declaimed the following in comp.lang.python:
> 
>> I'm just playing with Python. It's my first outing. The program is below. I 
>> thought I'd fuss with numbers, and then get bold and try some Tkinter stuff.
>>   I copied the root stuff from a book (Grayson), and get stopped at the 
>> optionDB statement. What's wrong? I get
>> clError: couldn't open "optionDB": no such file or directory
>> from Idle. Does the Tk code need to be up higher? The book is dated 2000, so 
>> maybe that item no longer exists.
>>
>   More likely, you need to create a file with standard Tk
> configuration options in the directory you are running from...
> 
>   A google search on "tk optiondb" brings up a page full of RUBY
> stuff...
> 
> 
> {That wasn't the easiest book to understand either... It seems to have
> been written on the basis that one already knew tcl/tk, and how it
> linked together}

-- 
  Wayne Watson (Nevada City, CA)

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


Re: sentance containg the string or symbol ?

2007-08-23 Thread Peter Otten
yadin wrote:

> how can i print a sentance containg the string or symbol ? in python
> and also lambda?

The most robust way is to use unicode strings:

>>> print u"? and also \N{GREEK CAPITAL LETTER LAMDA}"
? and also ?

If you use literals like the omega above you also have to specify the
encoding of your script in the first or second line, typically

# -*- coding: utf-8 -*-

Only 8-bit encodings are allowed.

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


Re: sentance containg the string or symbol Ω

2007-08-23 Thread Bill Scherer
yadin wrote:
> how can i print a sentance containg the string or symbol Ω in python
> and also lambda?
>
>   
>>> "Ω"
'\xce\xa9'
>>> print '\xce\xa9'
Ω
>>>


...works on my terminal anyway.
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: sentance containg the string or symbol Ω

2007-08-23 Thread Peter Otten
Oops, forgot to switch the encoding to utf-8.

>>> print u"Ω and also \N{GREEK CAPITAL LETTER LAMDA}"
Ω and also Λ

Peter

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

Re: advice about `correct' use of decorator

2007-08-23 Thread BJörn Lindqvist
On 8/22/07, Gabriel Genellina <[EMAIL PROTECTED]> wrote:
> On 22 ago, 10:00, "BJörn Lindqvist" <[EMAIL PROTECTED]> wrote:
> > As I said, you can accomplish the exact same thing by calling a
> > function from within the function that requires the user to be logged
> > in.
> >
> > def change_pass():
> > check_user_logged_in()
> > ... more stuff here...
> >
> > is less complex (and therefore preferable) than:
> >
> > @check_user_logged_in
> > def change_pass():
> > ... more stuff here...
> >
> > An important principle in engineering is that you should always strive
> > to make your design as simple as possible. If you have two equal
> > designs, you should always choose the one that is simpler because
> > simple things are easier to understand than complex things.
>
> I don't see the complexity in this case - both are a single line of
> code. Any internal complexity is hidden by the language. In fact, I

"Hiding" doesn't reduce complexity, quite the opposite.

> consider the decorated function simpler than the other: its body
> represents exactly what the function does, without any distracting
> precondition calls.

Think about how the decorator is implemented. It is a high order
function, taking a function and returning a new function. Something
like this:

def check_user_logged_in(func):
def f(*args, **kwargs):
if global_state.the_user.is_logged_in:
return func(*args, **kwargs)
return show_login_page()
return f

@check_user_logged_in
def change_pass():
... more stuff here...

or:

def check_user_logged_in():
return global_state.the_user.is_logged_in

def change_pass():
if not check_user_logged_in():
return show_login_page()
... more stuff here ...

or even:

def change_pass():
if not global_state.the_user.is_logged_in:
return show_login_page()
... more stuff here ...

> The decorator has some advantages: can have syntax support on your
> editor, can perform some registering/logging, it's even easier to
> quickly check visually if it's here.

The decorator has just as many disadvantages. For example, what if you
want to redirect back to the change_pass page once the user has
pressed the Login button on the login_page? Or if you want to show
different login pages depending on user properties? How much control
flow do you really want to "hide" in your decorator?

-- 
mvh Björn
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: sentance containg the string or symbol Ω

2007-08-23 Thread Bart Ogryczak
On 23 ago, 13:20, yadin <[EMAIL PROTECTED]> wrote:
> how can i print a sentance containg the string or symbol Ω in python
> and also lambda?

Well, you can use this dictionary to find out its unicode code point:
from htmlentitydefs import name2codepoint
unichr(name2codepoint['Omega'])
u'\u03a9'
unichr(name2codepoint['Lambda'])
u'\u039b'

print u'this is upper case omega: \u03a9, and this is upper case
lambda: \u039b'

See http://www.digitalmediaminute.com/reference/entity/ for entity
names.

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

Re: beginner, idiomatic python

2007-08-23 Thread Scott David Daniels
bambam wrote:
> Would someone like to suggest a replacement for this? It works ok,
> but it doesn't look like any of the other code:
> 
> tempList = ['1','2','3','4','5','6','7','8']
> sampleList=[]
> for port in tempList:
> pagefound = False
> for i in range(self.parent.GetPageCount()):
> page=self.parent.GetPage(i)
> if hasattr(page, "port"):
> if page.port == int(port):
> pagefound=True
> if not pagefound:
> sampleList.append(port)
> 
> Thanks!
> 
> 
Look at good questions.  This is a _very_ underspecified question.

One stab at mindreading:

 def ported_pages(self):
 for i in range(self.parent.GetPageCount()):
 if hasattr(page, 'port'):
 yield page

 ...
 tempList = ['1','2','3','4','5','6','7','8']
 missing = dict((int(v), v) for v in tempList)
 for page in self.ported_pages():
 if page.port in missing:
 missing.pop(page.port)
 if not missing:
 break
 sampleList = missing.values()
 ...

-Scott David Daniels
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Baby Steps, optionDB

2007-08-23 Thread Carsten Haese
On Thu, 2007-08-23 at 04:30 -0700, W. Watson wrote:
> I used to program in C++, and there's one thing I've never liked about 
> OOP. Too much typing!

Blame C++, not OOP. In time, you will find that Python's approach to OOP
in particular and to programming in general allows you to express your
ideas more concisely than you could in other programming languages.

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


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


Problems Connecting to Crystal Reports table and changing field values

2007-08-23 Thread Michael Dorrian
Below  is the my code so far. I have one table with 7 fields in my report
and i want to clear these fields and then save the report as a different
name and then print. The saving and printing part seem fine but i cannot
seem to access the connection properties at all. I have the
ConnectionProperties lines commented out because they give an error and
there is no password or user name so thats not the problem it just gives an
error saying connection properties was not recognized function name which it
should be??. Also finally how can i change these field names inside the
"tbl" table below.


import sys
from win32com.client import Dispatch

server="C:\\xx" #only an example

app = Dispatch('CrystalRunTime.Application')
rep = app.OpenReport('C:\\testers.rpt')
rep.ReadRecords()
tbl = rep.Database.Tables.Item(1)
#prop = tbl.ConnectionProperties('Data Source')
#prop.Value = 'server'

rep.ExportOptions.FormatType = 1
rep.ExportOptions.DestinationType = 1
rep.ExportOptions.DiskFileName = "C:\\Testerss.rpt"
rep.Export(False)
rep.PrintOut(promptUser=False)
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Question: wxpython and 3d engine example with model load ?

2007-08-23 Thread kyosohma
On Aug 23, 4:11 am, OpenPavilion <[EMAIL PROTECTED]> wrote:
> Hello,
>
> did anyone succeed in combining wxpython and a 3d engine (pyogre,
> crystalblend, panda3d, soya etc.) ?
>
> I would like to create an application, which uses wxpython tree, menu
> and grid elements and embedds a 3d view of some of the listed objects
> in an own detail window, so showing the object as a 3d model.
> I know there is PyOpenGL as well, but I need to load complete models
> (meshes done with cinema4d or blender) into the 3d view.
>
> So it would be very nice, if someone could post me a link to an
> example, where someone has successfully glued wxpython UI and a 3d
> engine view loading meshes into the 3d view.
>
> Regards
> Bernd

I recommend that you post this question to the wxPython group. If it's
been done, they should know.
http://www.wxpython.org/maillist.php

Mike

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


Re: How would I go about making a file open. Not the way you might think.

2007-08-23 Thread kyosohma
On Aug 23, 2:09 am, "Hendrik van Rooyen" <[EMAIL PROTECTED]> wrote:
> Lamonte Harris  wrote:
> >Basically you can open a file by double clicking, and by default it would 
> >open
>
> w/ what every program you have it set >to.  Most text files would open in
> notepad.  How can I make a txt open so that notepad opens w/ the content in it
> by >using just python.
>
> I asked this question just yesterday - and Tim Golden answered:
>
> os.startfile()
>
> - Hendrik

Golden knows a lot. That's a good way to do it. I recommend it too!

Mike

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


Simple Python Spider

2007-08-23 Thread luca bertini
Hi everybody, i'm new to the forum so: hello everybody (should I say  
"world"?) ^_^
I'm trying to do a simple spider in python which:

1) ask google a query
2) parse the data

I'm a python newbie so *any* help would be very, very welcommed.
Thanks in advice!

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


simple spider in python

2007-08-23 Thread gmcalendar
Hi everybody, i'm new to the forum so: hello everybody (should I say
"world"?) ^_^
I'm trying to do a simple spider in python which:

1) ask google a query
2) parse the data

I'm a python newbie so *any* help would be very, very welcommed.
Thanks in advice!

cheers!

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


Re: MsiLib

2007-08-23 Thread Charlie
Thank you everybody for your help. It finally runs without errors and  
I should be able to use this as I figure out more of it. I am curios  
if there is any idea as to when GetString will be implemented?

Charlie

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


Re: Joining elements in a list to 1 element

2007-08-23 Thread Francesco Guerrieri
On 8/23/07, J. Cliff Dyer <[EMAIL PROTECTED]> wrote:
>
>  What do you want to have happen in this case?
>
> my_list = [ 'a', 4, 'c' ]
>


It depends on the requirements of the OP.
A possible solution could be:

my_second_list = []
try:
my_second_list.append("".join(my_list))
except TypeError:
my_second_list.append("".join(str(item) for item in my_list) )


But it depends on the the actual requirements, maybe it isn't meaningful for
the original list to contain numbers (think for instance of nucleotide
sequences...?)

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

Re: Socket recv(1) seems to block instead of returning end of file.

2007-08-23 Thread Grant Edwards
On 2007-08-23, Hendrik van Rooyen <[EMAIL PROTECTED]> wrote:

> While doing a netstring implementation I noticed that if you
> build a record up using socket's recv(1), then when you close
> the remote end down, the recv(1) hangs,

I don't see that behavior running 2.4 on Gentoo.

> despite having a short time out of 0.1 set.

What time out?  A socket's recv method doesn't do timeouts.

> If however, you try to receive more than one char, (I tested
> with 3, did not try 2), then when you shut the remote end down
> you do not get a time out, but an empty string - the normal
> end of file, I suppose.
>
> Has anybody else seen this behaviour?

No.  recv(1) works fine for me (Python 2.4 under Gentoo).
Perhaps you could post a minimal example that doesn't work for
you?


#!/usr/bin/python

#reader
import socket

HOST = '' # Symbolic name meaning the local host
PORT = 8765   # Arbitrary non-privileged port
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((HOST, PORT))
s.listen(1)
conn, addr = s.accept()
print 'Connected by', addr
while 1:
data = conn.recv(1)
print "rx:",len(data)
if not data: break
conn.close()




#!/usr/bin/python

# writer
import socket,random

HOST = '' # Symbolic name meaning the local host
PORT = 8765   # Arbitrary non-privileged port
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))
print 'Connected to',((HOST,PORT))
for i in range(10):
data = "abcdefghijklmnopqrstuvwxyz"[:random.randint(1,20)]
s.send(data)
print "tx:",len(data)
conn.close()


-- 
Grant Edwards   grante Yow! Loni Anderson's hair
  at   should be LEGALIZED!!
   visi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Question: wxpython and 3d engine example with model load ?

2007-08-23 Thread Mike C. Fletcher
OpenPavilion wrote:
...
> I would like to create an application, which uses wxpython tree, menu
> and grid elements and embedds a 3d view of some of the listed objects
> in an own detail window, so showing the object as a 3d model.
> I know there is PyOpenGL as well, but I need to load complete models
> (meshes done with cinema4d or blender) into the 3d view.
>   
There's a bit of sample code in OpenGLContext/bin (yes, yes, I know, 
part of PyOpenGL, which you don't want) that does a 
VRML-97-scenegraph-rendering window + a shell (you'll need the latest 
CVS version to work with modern wxPythons).  There's commented out code 
that inserted a tree (to show the scenegraph as a tree, but I haven't 
got that finished).

Other options:

* I think Pivy (Coin/Inventor wrapper) could likely be embedded in
  PyQt (it has a Qt-based window operation IIRC) if that's an
  acceptable compromise.
* http://www.python-ogre.org/wiki/DownloadsPage seems to suggest
  there's an example for using Ogre with wxPython/wxWidgets.
* http://panda3d.org/phpbb2/viewtopic.php?=&p=11555 suggests there's
  a way to get panda3d and wxPython working together

I don't see a soya + wxPython page in a few seconds of googling, so I 
guess finding that is left as an exercise for the reader.

HTH,
Mike

-- 

  Mike C. Fletcher
  Designer, VR Plumber, Coder
  http://www.vrplumber.com
  http://blog.vrplumber.com

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


Re: simple spider in python

2007-08-23 Thread Frederick Polgardy
On Aug 23, 8:33 am, [EMAIL PROTECTED] wrote:
> Hi everybody, i'm new to the forum so: hello everybody (should I say
> "world"?) ^_^
> I'm trying to do a simple spider in python which:
>
> 1) ask google a query
> 2) parse the data
>
> I'm a python newbie so *any* help would be very, very welcommed.
> Thanks in advice!
>
> cheers!

Take a look at the docs for urllib2.urlopen().  The examples should
give you most of what you need.


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


Python submodules and name imports

2007-08-23 Thread Frank Aune
Hi,

First take a look at:

http://www.network-theory.co.uk/docs/pytut/Packages.html

as I will use this module file layout as an example.

If I want to do the following:

from Sound import Effects
...
Effects.echo.echofilte(bla bla)

What will Sound/Effects/__init__.py need to contain then? I tried to define 
the __all__ = ['echo','surround','reverse']  parameter in the init file, but 
this only seems to be effective for " .. import *" statements.

Is the correct way of accomplishing this to explicitly import the submodules 
in sound/Effects/__init__.py? I'm looking for the "official" way of doing 
this.

Thank you,
Frank Aune
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Symbolic Link

2007-08-23 Thread mosscliffe
On 22 Aug, 00:05, Ian Clark <[EMAIL PROTECTED]> wrote:
> Hyuga wrote:
> > On Aug 19, 4:29 pm,mosscliffe<[EMAIL PROTECTED]> wrote:
> >> The source file is in an area which python can see, but not the
> >> browser.  I am trying to make a link in a browser friendly area so I
> >> can use it to display an image file.
>
> > You might want to try using an .htaccess file.  Place a file
> > called .htaccess in the "browser friendly area" and place in it the
> > line:
>
> > Options +FollowSymLinks
>
> > Assuming your hosting service will allow that, then it should work.
> > If not, then why not just copy the image files?  Storage is cheap
> > these days.
>
> > Hyuga
>
> My question would be why a symbolic link? Why not a hard link? Are the
> two directories on different mount points? After the script finishes
> does python need to see that image file again? Why not just move it?
>
> Ian

I just imagined a symbolic link would be quicker.

I have tested a hard link now and it seems to work fine.  I am
deleting the link/s at the end of the session/s.

I think a link is better than a move, because there is always a
possibility I might somehow delete the moved file and then I would
lose the original one.

Thanks for your help.

Richard

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


Re: simple spider in python

2007-08-23 Thread samushack
> I'm trying to do a simple spider in python which:
>
> 1) ask google a query
> 2) parse the data

While you could use urllib2.urlopen() as Frederick mentioned, there is
actually a Python module built JUST for getting info from Google
queries! So check out PyGoogle: http://pygoogle.sourceforge.net/

After you install and import it like a normal Python module, you can
do things like:
doGoogleSearch("thing to query") and get results! Very easy to use.

One thing that might throw you at first: You need to get an API key
from Google, and use that when you setup the classes. The link I
pasted above has all the details.

Good luck!

-Sam

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


Re: Baby Steps, optionDB

2007-08-23 Thread W. Watson
VBasic is the same. Longish. The ultimate in conciseness was APL.

Carsten Haese wrote:
> On Thu, 2007-08-23 at 04:30 -0700, W. Watson wrote:
>> I used to program in C++, and there's one thing I've never liked about 
>> OOP. Too much typing!
> 
> Blame C++, not OOP. In time, you will find that Python's approach to OOP
> in particular and to programming in general allows you to express your
> ideas more concisely than you could in other programming languages.
> 

-- 
  Wayne Watson (Nevada City, CA)

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


Re: Baby Steps, optionDB

2007-08-23 Thread Carsten Haese
On Thu, 2007-08-23 at 14:38 +, W. Watson wrote:
>  The ultimate in conciseness was APL.

I think you are mistaking terseness for conciseness.

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


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


Re: simple spider in python

2007-08-23 Thread gmcalendar
thanks everybody, s kind. I'll take a look at booth.
have a nice day/night (depending on your latitude!) ^_^

ciao!

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


Re: How do I get the current path of my python file that is currently running.

2007-08-23 Thread rasmus
On Aug 23, 3:33 am, Arnau Sanchez <[EMAIL PROTECTED]> wrote:
> Lamonte Harris escribió:
>
> > Say I start i click on a python file on my desktop, how could I return
> > the path of the current python file thats running?
>
> http://docs.python.org/lib/module-sys.html

Try this:

import sys
import os
print sys.argv[0]
print os.getcwd()

-
sys.argv[0] should contain the name of the script as it was called.
os.getcwd() will return the current working directory, which may also
find helpful.

hope this helps.

Matt



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


expat error, help to debug?

2007-08-23 Thread Andreas Lobinger
Aloha,

i'm trying to write an xml filter, that extracts some info about
an .xml document (with external entities), esp. start elements and
external entities. The document is a DOCBOOK xml and afacs
well formed and passes our docbook toolchain (dblatex etc.).

My parser is (very simple):
[115] scylla(scylla)> more pbxml.py

class xmlhandle:
 def __init__(self):
 self.parser_stack = [];
 self.parser = None;

 def se(self,name,attr):
 print "s", self.parser.CurrentLineNumber, name, attr

 def ex(self,context,baseid,n1,n2):
 print "x",context,n1,n2

def fromxml(fname):
 import xml.parsers.expat
 p = xml.parsers.expat.ParserCreate()
 xl = xmlhandle()
 p.StartElementHandler = xl.se
 p.ExternalEntityRefHandler = xl.ex
 xl.parser = p
 p.ParseFile(file(fname))
 return

if __name__ == "__main__":
import sys
fromxml(sys.argv[1])

my document (in 2 parts):

[116] scylla(scylla)> more s3.xml


]>

&bookinfo;
technical description
 
 This chapter includes specification of the main simulation loop.
 



[118] scylla(scylla)> more bookinfo.xml

   BookTitle
   
 
 A
 B
 
   


The run produces:

[120] scylla(scylla)> python pbxml.py s3.xml
s 7 book {}
x bookinfo bookinfo.xml None
s 9 chapter {u'id': u'technicalDescription'}
s 9 title {}
s 10 para {}
Traceback (most recent call last):
   File "pbxml.py", line 25, in ?
 fromxml(sys.argv[1])
   File "pbxml.py", line 20, in fromxml
 p.ParseFile(file(fname))
TypeError: an integer is required

Anyone any idea where the error is produced?
Anyone any idea how to debug(? if it's really a bug or
missunderstanding of expate) this?

Hoping for an answer and wishing a happy day,
LOBI
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [ANN] Python courses this Fall

2007-08-23 Thread wesley chun
$1295/pp for the intro course and $495/ for the 1-day course (but $395
if you take the intro course too).

http://cyberwebconsulting.com (click "Python Training") for more details

-wesley


On 8/23/07, Jeff Pang <[EMAIL PROTECTED]> wrote:
> Sounds good.How about the costs for those lessons?thanks.
>
>> WEB:   http://cyberwebconsulting.com (click "Python Training")
>> See website for costs, venue info, and registration.  Discounts are
> available for multiple registrations as well as for teachers/students.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: simple spider in python

2007-08-23 Thread gmcalendar
Well, it turned out that google since Dec 2006 is not giving out SOAP
api keys anymore.
What a shame! any tip? ;-)

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


Re: simple spider in python

2007-08-23 Thread Cameron Laird
In article <[EMAIL PROTECTED]>,
 <[EMAIL PROTECTED]> wrote:
>thanks everybody, s kind. I'll take a look at booth.
>have a nice day/night (depending on your latitude!) ^_^
>
>ciao!
>

Somewhere in the middle between the two suggestions you've already
received is http://www.unixreview.com/documents/s=10133/ur0706e/ >.
-- 
http://mail.python.org/mailman/listinfo/python-list


comparing two lists

2007-08-23 Thread Ladislav Andel
Hi,
what would be the most efficient way to do following?

I have a list of dictionaries  taken from DB e.g.  
dblist = [{'id:1, 'host':'google.com','ip_address':'1.2.3.4'},
{'id:3, 'host':'yahoo.com','ip_address':'5.6.7.8'},
{'id:9, 'host':'msn.com','ip_address':'11.3.2.3'}]

and list of object instances in memory(it's just for example)
which are looping within itself and testing particular hosts

memlist = [,]
memlist[0].id  is 1 and  memlist[0].host is google.com etc.
memlist[1].id  is 9 and  memlist[1].host is msn.com etc.

Now I want to add a new instance to memlist since id=3(in dblist) is not 
in memlist.
How would you iterate through it and insert a new instance?

The result should be:
memlist = [,, ]
memlist[0].id  is 1 and  memlist[0].host is google.com etc.
memlist[1].id  is 3 and  memlist[1].host is yahoo.com etc.
memlist[2].id  is 9 and  memlist[2].host is msn.com etc.

Furthermore, I can have the opposite situation.
This time I need to remove from memlist a host which is not in dblist.
How would you do this?

The way how it works is that DBlist is loaded every 10 minutes and 
compares with memlist.
The memlist should be the same as dblist.

Could you help me, please?
I'm working on my version of this but somebody might be quicker than me.
In case I have it done I will post it.

Thanks,
Lada






There is



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


Re: optparse - required options

2007-08-23 Thread Omari Norman
On Mon, Aug 20, 2007 at 05:31:00PM -0400, Jay Loden wrote:
> Robert Dailey wrote:
> > Well, I don't know what is wrong with people then. I don't see how
> > required arguments are of bad design. Some command-line applications are
> > built around performing tasks based on information received. Compilers,
> > for example. A compiler can't do much of anything unless you give it at
> > the very least a filename. So, a --file command would most definitely be
> > one required argument. Anyway, I'm not trying to start a debate on this
> > issue. I have my own implementation for required arguments at the
> > moment, I am just a little bit surprised that this module doesn't make
> > it convenient. It would definitely help on code duplication.
> > 
> > Thanks for your response.
> 

> I tend to agree...while "required option" may be an oxymoron in
> English, I can think of quite a few scripts I've written myself (in
> various languages) that needed at least some kind of user input to
> operate. At least the documentation points to some examples for
> helpful hints, example code is a lot better than nothing ;)

The idea with optparse is not that programs should not require certain
information on the command line; rather, the idea is that this
information should be positional arguments, not 'options'.

That is, to use the compiler example:

compiler file

is preferred if a file argument is necessary.

compiler --file file

is not preferred.


-- 
Due to some violent content, viewer discretion is advised.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python submodules and name imports

2007-08-23 Thread Pádraig
On Aug 23, 2:58 pm, Frank Aune <[EMAIL PROTECTED]> wrote:
> Hi,
>
> First take a look at:
>
> http://www.network-theory.co.uk/docs/pytut/Packages.html
>
> as I will use this module file layout as an example.
>
> If I want to do the following:
>
> from Sound import Effects
> ...
> Effects.echo.echofilte(bla bla)
>
> What will Sound/Effects/__init__.py need to contain then? I tried to define
> the __all__ = ['echo','surround','reverse']  parameter in the init file, but
> this only seems to be effective for " .. import *" statements.
>
> Is the correct way of accomplishing this to explicitly import the submodules
> in sound/Effects/__init__.py? I'm looking for the "official" way of doing
> this.
>
> Thank you,
> Frank Aune

You can put 'import echo' into sound/Effects/__init__.py. This is a
widespread practice. You could also put 'from echo import *' into the
file, if you wanted to have a single namespace for all methods in
Effects.

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


Re: Socket recv(1) seems to block instead of returning end of file.

2007-08-23 Thread Dan Stromberg - Datallegro
On Thu, 23 Aug 2007 11:54:01 +0200, Hendrik van Rooyen wrote:

> 
> While doing a netstring implementation I noticed that if you
> build a record up using socket's recv(1), then when you close
> the remote end down, the recv(1) hangs, despite having a short
> time out of  0.1 set.
> 
> If however, you try to receive more than one char, (I tested with 3,
> did not try 2), then when you shut the remote end down you do not
> get a time out, but an empty string - the normal end of file, I suppose.
> 
> Has anybody else seen this behaviour?
> 
> The transmit side seems to give a broken pipe error, which is fine.
> 
> I am using stock standard SuSe 10, Python 2.4, out of the box.
> 
> - Hendrik

Are you using sock.settimeout()?

I've always done timed-out sockets in python using select; IINM, the
settimeout method is a new addition.

I agree with Grant though - posting a minimal snippet of code that
replicates the problem would help us help you.  In fact, it might help you
help yourself :)


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


Re: C# and Python

2007-08-23 Thread subeen
On Aug 21, 5:00 pm, Bikal KC <[EMAIL PROTECTED]> wrote:
> subeenwrote:
> > When the user clicks Quick Sort button, the quicksort.py will be
> > called and it will sort the numbers.
>
> One way to do this:
> In your C# app, have the mouse click event handler call python
> interpreter "/path/to/python /path/to/quicksort.py". Make quicksort.py
> write to a file the result. After the quicksort.py finishes, read the
> file from your normal C# app.
>
> Cheers.

Hi, what's the C# function to call python interpreter?

regards,
Subeen.

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


Re: comparing two lists

2007-08-23 Thread kyosohma
On Aug 23, 11:27 am, Ladislav Andel <[EMAIL PROTECTED]> wrote:
> Hi,
> what would be the most efficient way to do following?
>
> I have a list of dictionaries  taken from DB e.g.
> dblist = [{'id:1, 'host':'google.com','ip_address':'1.2.3.4'},
> {'id:3, 'host':'yahoo.com','ip_address':'5.6.7.8'},
> {'id:9, 'host':'msn.com','ip_address':'11.3.2.3'}]
>
> and list of object instances in memory(it's just for example)
> which are looping within itself and testing particular hosts
>
> memlist = [,]
> memlist[0].id  is 1 and  memlist[0].host is google.com etc.
> memlist[1].id  is 9 and  memlist[1].host is msn.com etc.
>
> Now I want to add a new instance to memlist since id=3(in dblist) is not
> in memlist.
> How would you iterate through it and insert a new instance?
>
> The result should be:
> memlist = [,, ]
> memlist[0].id  is 1 and  memlist[0].host is google.com etc.
> memlist[1].id  is 3 and  memlist[1].host is yahoo.com etc.
> memlist[2].id  is 9 and  memlist[2].host is msn.com etc.
>
> Furthermore, I can have the opposite situation.
> This time I need to remove from memlist a host which is not in dblist.
> How would you do this?
>
> The way how it works is that DBlist is loaded every 10 minutes and
> compares with memlist.
> The memlist should be the same as dblist.
>
> Could you help me, please?
> I'm working on my version of this but somebody might be quicker than me.
> In case I have it done I will post it.
>
> Thanks,
> Lada
>
> There is
>
> and wt

On lists that change in memory, I use the following looping structure:

for i in range(len(in_memory_list)-1,-1,-1)

This loops over the list backwards. I found this method here:
http://mail.python.org/pipermail/python-list/1999-September/012451.html

Hopefully this will fulfill your needs. I've used it to great effect!

Mike

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


Re: comparing two lists

2007-08-23 Thread Ladislav Andel
[EMAIL PROTECTED] wrote:
> On Aug 23, 11:27 am, Ladislav Andel <[EMAIL PROTECTED]> wrote:
>   
>> Hi,
>> what would be the most efficient way to do following?
>>
>> I have a list of dictionaries  taken from DB e.g.
>> dblist = [{'id:1, 'host':'google.com','ip_address':'1.2.3.4'},
>> {'id:3, 'host':'yahoo.com','ip_address':'5.6.7.8'},
>> {'id:9, 'host':'msn.com','ip_address':'11.3.2.3'}]
>>
>> and list of object instances in memory(it's just for example)
>> which are looping within itself and testing particular hosts
>>
>> memlist = [,]
>> memlist[0].id  is 1 and  memlist[0].host is google.com etc.
>> memlist[1].id  is 9 and  memlist[1].host is msn.com etc.
>>
>> Now I want to add a new instance to memlist since id=3(in dblist) is not
>> in memlist.
>> How would you iterate through it and insert a new instance?
>>
>> The result should be:
>> memlist = [,, ]
>> memlist[0].id  is 1 and  memlist[0].host is google.com etc.
>> memlist[1].id  is 3 and  memlist[1].host is yahoo.com etc.
>> memlist[2].id  is 9 and  memlist[2].host is msn.com etc.
>>
>> Furthermore, I can have the opposite situation.
>> This time I need to remove from memlist a host which is not in dblist.
>> How would you do this?
>>
>> The way how it works is that DBlist is loaded every 10 minutes and
>> compares with memlist.
>> The memlist should be the same as dblist.
>>
>> Could you help me, please?
>> I'm working on my version of this but somebody might be quicker than me.
>> In case I have it done I will post it.
>>
>> Thanks,
>> Lada
>>
>> There is
>>
>> and wt
>> 
>
> On lists that change in memory, I use the following looping structure:
>
> for i in range(len(in_memory_list)-1,-1,-1)
>
>   
well, actually I will need to iterate over 2 sequences which are not the 
same length
and synchronize it against the dblist i have.
But I will look at your post. Thanks a lot.

Lada
> This loops over the list backwards. I found this method here:
> http://mail.python.org/pipermail/python-list/1999-September/012451.html
>
> Hopefully this will fulfill your needs. I've used it to great effect!
>
> Mike
>
>   

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


My 'time' module is broken, unsure of cause

2007-08-23 Thread darren kirby
Hi all,

I have a strange error here and I am unsure how to further investigate it:

Python 2.4.4 (#1, Aug 23 2007, 10:51:29)
[GCC 4.1.2 (Gentoo 4.1.2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import time
40:42:0
>>> now = time.time()
Traceback (most recent call last):
  File "", line 1, in ?
AttributeError: 'module' object has no attribute 'time'

Notice the '40:42:0' that always gets output. I searched Gentoo's bugzilla but 
can not see anything relevant. I rebuilt python but the behavior recurs. I am 
unsure if the issue is with Python, Gentoo, or perhaps with the underlying 
lib (presumably glibc) that Python uses for the time module. This is working 
fine on another machine (also 2.4.4, GCC 3.4.6,  Gentoo Hardened).

Anyone seen this? Any hints for me to track this issue down? Any further 
information I could provide?

Thanks for consideration,
-d
-- 
darren kirby :: Part of the problem since 1976 :: http://badcomputer.org
"...the number of UNIX installations has grown to 10, with more expected..."
- Dennis Ritchie and Ken Thompson, June 1972
-- 
http://mail.python.org/mailman/listinfo/python-list


creating a tar file with python

2007-08-23 Thread Brian McCann
Hi,
 
I'm trying to create a tar file of the contents of the current directory
 
right now there is only one file "text.xml" in the current dir,  I'm using"." 
current dir as source
but that gives syntax error

any help would be greatly appreciated
--Brian
 
 
#!/usr/bin/python
import string
import os
import sys
import time
import errno
import shutil
import tarfile
 

tar = tarfile.open(.,"test.tar.gz", "w:gz)

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

Re: My 'time' module is broken, unsure of cause

2007-08-23 Thread Jean-Paul Calderone
On Thu, 23 Aug 2007 11:22:55 -0600, darren kirby <[EMAIL PROTECTED]> wrote:
>Hi all,
>
>I have a strange error here and I am unsure how to further investigate it:
>
>Python 2.4.4 (#1, Aug 23 2007, 10:51:29)
>[GCC 4.1.2 (Gentoo 4.1.2)] on linux2
>Type "help", "copyright", "credits" or "license" for more information.
 import time
>40:42:0
 now = time.time()
>Traceback (most recent call last):
>  File "", line 1, in ?
>AttributeError: 'module' object has no attribute 'time'
>
>Notice the '40:42:0' that always gets output. I searched Gentoo's bugzilla but
>can not see anything relevant. I rebuilt python but the behavior recurs. I am
>unsure if the issue is with Python, Gentoo, or perhaps with the underlying
>lib (presumably glibc) that Python uses for the time module. This is working
>fine on another machine (also 2.4.4, GCC 3.4.6,  Gentoo Hardened).

[EMAIL PROTECTED]:~$ echo "print '40:42:0'" > time.py
[EMAIL PROTECTED]:~$ python
Python 2.4.3 (#2, Oct  6 2006, 07:52:30)
[GCC 4.0.3 (Ubuntu 4.0.3-1ubuntu5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import time
40:42:0
>>> time.time()
Traceback (most recent call last):
  File "", line 1, in ?
AttributeError: 'module' object has no attribute 'time'
>>> print time.__file__
time.py
>>> ^D
[EMAIL PROTECTED]:~$ rm time.py
[EMAIL PROTECTED]:~$ rm time.pyc
[EMAIL PROTECTED]:~$ python
Python 2.4.3 (#2, Oct  6 2006, 07:52:30)
[GCC 4.0.3 (Ubuntu 4.0.3-1ubuntu5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import time
>>> time.time()
1187890226.9293921
>>> print time.__file__
/usr/lib/python2.4/lib-dynload/time.so
>>>

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


Re: My 'time' module is broken, unsure of cause

2007-08-23 Thread Will Maier
On Thu, Aug 23, 2007 at 11:22:55AM -0600, darren kirby wrote:
> Python 2.4.4 (#1, Aug 23 2007, 10:51:29)
> [GCC 4.1.2 (Gentoo 4.1.2)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import time
> 40:42:0
> >>> now = time.time()
> Traceback (most recent call last):
>   File "", line 1, in ?
> AttributeError: 'module' object has no attribute 'time'

Uh...that's obviously not right (as you noticed). You probably have
a different module that's shadowing the stdlib's time. To check:

Python 2.4.4 (#1, Jul 26 2007, 14:42:10)
[GCC 3.3.5 (propolice)] on openbsd4
Type "help", "copyright", "credits" or "license" for more information.
>>> import time
>>> print time.__file__
/usr/local/lib/python2.4/lib-dynload/time.so

-- 

[Will [EMAIL PROTECTED]|http://www.lfod.us/]
-- 
http://mail.python.org/mailman/listinfo/python-list


Co-developers wanted: document markup language

2007-08-23 Thread Torsten Bronger
Hallöchen!

Some LaTeX users in Aachen thought about a general-use markup
language this spring.  I wrote some code and a rough project
description, however, we could need some help.

If you are interested, visit the provisional project page at
http://latex-bronger.sourceforge.net/gummi/

Tschö,
Torsten.

Crosspost & Followup-To: comp.lang.python
-- 
Torsten Bronger, aquisgrana, europa vetus
  Jabber ID: [EMAIL PROTECTED]
  (See http://ime.webhop.org for ICQ, MSN, etc.)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: My 'time' module is broken, unsure of cause

2007-08-23 Thread darren kirby
quoth the   Calderone:

>
> [EMAIL PROTECTED]:~$ echo "print '40:42:0'" > time.py
> [EMAIL PROTECTED]:~$ python
> Python 2.4.3 (#2, Oct  6 2006, 07:52:30)
> [GCC 4.0.3 (Ubuntu 4.0.3-1ubuntu5)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>
> >>> import time
>
> 40:42:0
>
> >>> time.time()
>
> Traceback (most recent call last):
>   File "", line 1, in ?
> AttributeError: 'module' object has no attribute 'time'
>
> >>> print time.__file__
>
> time.py
>
> >>> ^D
>
> [EMAIL PROTECTED]:~$ rm time.py
> [EMAIL PROTECTED]:~$ rm time.pyc
> [EMAIL PROTECTED]:~$ python
> Python 2.4.3 (#2, Oct  6 2006, 07:52:30)
> [GCC 4.0.3 (Ubuntu 4.0.3-1ubuntu5)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>
> >>> import time
> >>> time.time()
>
> 1187890226.9293921
>
> >>> print time.__file__
>
> /usr/lib/python2.4/lib-dynload/time.so
>
>
> Jean-Paul

Ahh, so it was pebkac. Thanks Jean-Paul, I can be thick sometimes...

-d
-- 
darren kirby :: Part of the problem since 1976 :: http://badcomputer.org
"...the number of UNIX installations has grown to 10, with more expected..."
- Dennis Ritchie and Ken Thompson, June 1972
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: My 'time' module is broken, unsure of cause

2007-08-23 Thread Gary Herron
darren kirby wrote:
> Hi all,
>
> I have a strange error here and I am unsure how to further investigate it:
>
> Python 2.4.4 (#1, Aug 23 2007, 10:51:29)
> [GCC 4.1.2 (Gentoo 4.1.2)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>   
 import time
 
> 40:42:0
>   
 now = time.time()
 
> Traceback (most recent call last):
>   File "", line 1, in ?
> AttributeError: 'module' object has no attribute 'time'
>   
You probably has a file named time.py in your current directory, and it
is *that* file you are importing.
(Run Python with a "-v" option to see what file "import time" is
actually importing.)
> Notice the '40:42:0' that always gets output. I searched Gentoo's bugzilla 
> but 
> can not see anything relevant. I rebuilt python but the behavior recurs. I am 
> unsure if the issue is with Python, Gentoo, or perhaps with the underlying 
> lib (presumably glibc) that Python uses for the time module. This is working 
> fine on another machine (also 2.4.4, GCC 3.4.6,  Gentoo Hardened).
>
> Anyone seen this? Any hints for me to track this issue down? Any further 
> information I could provide?
>
> Thanks for consideration,
> -d
>   

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


Re: simple spider in python

2007-08-23 Thread samushack
> Somewhere in the middle between the two suggestions you've already
> received is http://www.unixreview.com/documents/s=10133/ur0706e/>.

I followed that link, and got an error page...

As to the Google API key issue, I was unaware of that. Very annoying
of them to stop that service. PyGoogle will basically be useless. The
next best thing might be getting an API key for the AJAX API, and
using a browser based implementation...


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


Re: Simple Python Spider

2007-08-23 Thread Thomas Wittek
luca bertini schrieb:
> 1) ask google a query

http://code.google.com/apis/
http://code.google.com/apis/ajaxsearch/
But you probably have to reverse engineer the JavaScript lib.

> 2) parse the data

http://blog.hill-street.net/?p=7

-- 
Thomas Wittek
Web: http://gedankenkonstrukt.de/
Jabber: [EMAIL PROTECTED]
GPG: 0xF534E231
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: comparing two lists

2007-08-23 Thread Erik Jones
On Aug 23, 2007, at 11:27 AM, Ladislav Andel wrote:

> Hi,
> what would be the most efficient way to do following?
>
> I have a list of dictionaries  taken from DB e.g.
> dblist = [{'id:1, 'host':'google.com','ip_address':'1.2.3.4'},
> {'id:3, 'host':'yahoo.com','ip_address':'5.6.7.8'},
> {'id:9, 'host':'msn.com','ip_address':'11.3.2.3'}]
>
> and list of object instances in memory(it's just for example)
> which are looping within itself and testing particular hosts
>
> memlist = [,]
> memlist[0].id  is 1 and  memlist[0].host is google.com etc.
> memlist[1].id  is 9 and  memlist[1].host is msn.com etc.
>
> Now I want to add a new instance to memlist since id=3(in dblist)  
> is not
> in memlist.
> How would you iterate through it and insert a new instance?
>
> The result should be:
> memlist = [,, ]
> memlist[0].id  is 1 and  memlist[0].host is google.com etc.
> memlist[1].id  is 3 and  memlist[1].host is yahoo.com etc.
> memlist[2].id  is 9 and  memlist[2].host is msn.com etc.

Well, if you add a constructor for object instances that can take  
those dictionaries you could do something like:

for row in dblist.iteritems():
obj = Obj(row)   # where Obj is your classname
if obj is not in memlist:
memlist.append(obj)
>
> Furthermore, I can have the opposite situation.
> This time I need to remove from memlist a host which is not in dblist.
> How would you do this?

Similarly, if you add an toHash() method to you object class you  
could do something like (using the reverse iteration solution  
mentioned in another reply):

for i in range(len(memlist) -1, -1, -1):
if memlist[[i].toHash() not in dblist:
del memlist[i]

Erik Jones

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

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


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


Re: comparing two lists

2007-08-23 Thread Peter Otten
Ladislav Andel wrote:

> what would be the most efficient way to do following?
> 
> I have a list of dictionaries  taken from DB e.g.
> dblist = [{'id:1, 'host':'google.com','ip_address':'1.2.3.4'},
> {'id:3, 'host':'yahoo.com','ip_address':'5.6.7.8'},
> {'id:9, 'host':'msn.com','ip_address':'11.3.2.3'}]
> 
> and list of object instances in memory(it's just for example)
> which are looping within itself and testing particular hosts
> 
> memlist = [,]
> memlist[0].id  is 1 and  memlist[0].host is google.com etc.
> memlist[1].id  is 9 and  memlist[1].host is msn.com etc.
> 
> Now I want to add a new instance to memlist since id=3(in dblist) is not
> in memlist.
> How would you iterate through it and insert a new instance?
> 
> The result should be:
> memlist = [,, ]
> memlist[0].id  is 1 and  memlist[0].host is google.com etc.
> memlist[1].id  is 3 and  memlist[1].host is yahoo.com etc.
> memlist[2].id  is 9 and  memlist[2].host is msn.com etc.

You should replace the memlist with a dictionary using (host, id) tuples as
the keys. Here's an example that uses a set but requires you to modify the
 class:

dblist = [{'id':1, 'host':'google.com','ip_address':'1.2.3.4'},
{'id':3, 'host':'yahoo.com','ip_address':'5.6.7.8'},
{'id':9, 'host':'msn.com','ip_address':'11.3.2.3'}]

class Item(object):
def __init__(self, id, host, **discarded):
self._tuple = (id, host)
def __hash__(self):
return hash(self._tuple)
def __eq__(self, other):
return self._tuple == other._tuple
def __repr__(self):
return "Item(id=%r, host=%r)" % self._tuple

items = set([Item(1, "google.com")])
for d in dblist:
item = Item(**d)
if item not in items:
print "adding", item
items.add(item)
else:
print item, "already there"

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


Question about embedding python in C++

2007-08-23 Thread TheShadow
When extending python in c/c++ after you register a module is there a
way in c/c++ to check if they were correctly registered?

Cause I'm having the problem where when I execute the the python
script it finds the module but none of the functions.

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


Re: Socket recv(1) seems to block instead of returning end of file.

2007-08-23 Thread Grant Edwards
On 2007-08-23, Dan Stromberg - Datallegro <[EMAIL PROTECTED]> wrote:

> Are you using sock.settimeout()?

Hey, somebody snuck timeouts into the socket module when I wasn't
looking...

> I agree with Grant though - posting a minimal snippet of code that
> replicates the problem would help us help you.  In fact, it might help you
> help yourself :)

Yup, in my experience attempting to produce a minimally failing
example will usually reveal what's wrong.

-- 
Grant Edwards   grante Yow! I have seen these EGG
  at   EXTENDERS in my Supermarket
   visi.com... I have read the
   INSTRUCTIONS ...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Socket recv(1) seems to block instead of returning end of file.

2007-08-23 Thread Grant Edwards
On 2007-08-23, Dan Stromberg - Datallegro <[EMAIL PROTECTED]> wrote:
> On Thu, 23 Aug 2007 11:54:01 +0200, Hendrik van Rooyen wrote:
>
>> 
>> While doing a netstring implementation I noticed that if you
>> build a record up using socket's recv(1), then when you close
>> the remote end down, the recv(1) hangs, despite having a short
>> time out of  0.1 set.
>> 
>> If however, you try to receive more than one char, (I tested with 3,
>> did not try 2), then when you shut the remote end down you do not
>> get a time out, but an empty string - the normal end of file, I suppose.
>> 
>> Has anybody else seen this behaviour?
>> 
>> The transmit side seems to give a broken pipe error, which is fine.
>> 
>> I am using stock standard SuSe 10, Python 2.4, out of the box.
>> 
>> - Hendrik
>
> Are you using sock.settimeout()?

FWIW, I added a call to sock.setttimeout(0.2) to my example's
receive code and added 0.1 delays in the transmit code, and it
still seems to work fine:

---8<-
#!/usr/bin/python

# writer
import socket,random,time

HOST = '' # Symbolic name meaning the local host
PORT = 8765   # Arbitrary non-privileged port
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))
print 'Connected to',((HOST,PORT))
total = 0
for i in range(10):
data = "abcdefghijklmnopqrstuvwxyz"[:random.randint(1,20)]
total += len(data)
s.send(data)
print "tx:",len(data)
time.sleep(0.1)
s.close()
print total
---8<-
#!/usr/bin/python

#reader
import socket

HOST = '' # Symbolic name meaning the local host
PORT = 8765   # Arbitrary non-privileged port
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((HOST, PORT))
s.listen(1)
conn, addr = s.accept()
print 'Connected by', addr
conn.settimeout(0.2)
total = 0
while 1:
data = conn.recv(1)
total += len(data)
print "rx:",len(data)
if not data: break
conn.close()
print total
---8<-

-- 
Grant Edwards   grante Yow! We have DIFFERENT
  at   amounts of HAIR --
   visi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Question about embedding python in C++

2007-08-23 Thread Farshid Lashkari
TheShadow wrote:
> When extending python in c/c++ after you register a module is there a
> way in c/c++ to check if they were correctly registered?
> 
> Cause I'm having the problem where when I execute the the python
> script it finds the module but none of the functions.
> 

Are you calling Py_InitModule(...) in your initmodule function? If so, 
Py_InitModule(...) returns a reference to the module object. You can use 
this object to double check that your function names exist in the 
modules dictionary. Most likely, there is an error in your code. If you 
post it, it would be easier to tell what the problem is.

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


Re: ctypes and unsigned char*

2007-08-23 Thread [EMAIL PROTECTED]
On 23 Aug., 05:46, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote:
> If the result can contain nul bytes, you have to specify its size
> explicitely (else it will be truncated at the first zero). Use the
> string_at utility function:
>
> result_str = string_at(result, length)
>
> (That should work fine, I presume...)

Thank a lot, that does exactly what I expected it to do.

Best regards,
Oliver

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


Re: comparing two lists

2007-08-23 Thread Ladislav Andel
Peter Otten wrote:
> Ladislav Andel wrote:
>
>   
>> what would be the most efficient way to do following?
>>
>> I have a list of dictionaries  taken from DB e.g.
>> dblist = [{'id:1, 'host':'google.com','ip_address':'1.2.3.4'},
>> {'id:3, 'host':'yahoo.com','ip_address':'5.6.7.8'},
>> {'id:9, 'host':'msn.com','ip_address':'11.3.2.3'}]
>>
>> and list of object instances in memory(it's just for example)
>> which are looping within itself and testing particular hosts
>>
>> memlist = [,]
>> memlist[0].id  is 1 and  memlist[0].host is google.com etc.
>> memlist[1].id  is 9 and  memlist[1].host is msn.com etc.
>>
>> Now I want to add a new instance to memlist since id=3(in dblist) is not
>> in memlist.
>> How would you iterate through it and insert a new instance?
>>
>> The result should be:
>> memlist = [,, ]
>> memlist[0].id  is 1 and  memlist[0].host is google.com etc.
>> memlist[1].id  is 3 and  memlist[1].host is yahoo.com etc.
>> memlist[2].id  is 9 and  memlist[2].host is msn.com etc.
>> 
>
> You should replace the memlist with a dictionary using (host, id) tuples as
> the keys. Here's an example that uses a set but requires you to modify the
>  class:
>
> dblist = [{'id':1, 'host':'google.com','ip_address':'1.2.3.4'},
> {'id':3, 'host':'yahoo.com','ip_address':'5.6.7.8'},
> {'id':9, 'host':'msn.com','ip_address':'11.3.2.3'}]
>
> class Item(object):
> def __init__(self, id, host, **discarded):
> self._tuple = (id, host)
> def __hash__(self):
> return hash(self._tuple)
> def __eq__(self, other):
> return self._tuple == other._tuple
> def __repr__(self):
> return "Item(id=%r, host=%r)" % self._tuple
>
> items = set([Item(1, "google.com")])
> for d in dblist:
> item = Item(**d)
> if item not in items:
> print "adding", item
> items.add(item)
> else:
> print item, "already there"
>
>   
Thank you for this nice solution. I wouldn't be able to write it this 
way at all
but what about removing from memlist if there is less items in dblist 
than in items (instances)?
I will have to iterate over items(instances) and remove that one which 
is not in dblist I guess.

Lada

> Peter
>   

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


Issue tracker migration is complete

2007-08-23 Thread Brett Cannon
Thanks to the work of Erik Forsberg and Martin von Löwis, Python's
issue tracker now lives at http://bugs.python.org .

Because this is a new tracker on a new system you cannot use your
SourceForge password on the new tracker.  But account names have been
migrated, so if you go to "Lost your login?" and follow the
instructions for SF accounts you can continue to use the same account
name on the new tracker (you can also change it once you get a new
password).

And if you come across any bugs in the tracker, please report them
using the "Report Tracker Problem" link.

There are a bunch of people to thank for making this all happen.
Beyond the huge thanks to Erik (http://efod.se/) and Martin, other
people heavily involved include Paul DuBois for coming forward as
another tracker admin, the guys at Upfront Systems
(http://www.upfrontsystems.co.za/) providing the hosting, Skip
Montanaro for working on an anti-spam system, Stefan Seefeld for
helping with the test tracker back when this whole process started,
the Python Software Foundation's Infrastructure committee for helping
choose a tracker, and all the people who participated on the
tracker-discuss mailing list.  And if I forgot someone, thanks to them
as well.  =)

-Brett Cannon
Chairman, PSF Infrastructure committee
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Question about embedding python in C++

2007-08-23 Thread TheShadow
On Aug 23, 11:57 am, Farshid Lashkari <[EMAIL PROTECTED]> wrote:
> TheShadow wrote:
> > When extending python in c/c++ after you register a module is there a
> > way in c/c++ to check if they were correctly registered?
>
> > Cause I'm having the problem where when I execute the the python
> > script it finds the module but none of the functions.
>
> Are you calling Py_InitModule(...) in your initmodule function? If so,
> Py_InitModule(...) returns a reference to the module object. You can use
> this object to double check that your function names exist in the
> modules dictionary. Most likely, there is an error in your code. If you
> post it, it would be easier to tell what the problem is.
>
> -Farshid

Hrmm I forgot about the module init function... I was just calling
Py_initModule()

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


how to select between two file libraries with same name?

2007-08-23 Thread Jose Borreguero
Imagine my file one.py contains the statement
import two
If there's a two.py in same directory as one.py, then this file will be
loaded. However, I want to load a different file named also two.py, say file
~username/mypythonlib/two.py
How can I select between the two two.py files ?

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

how to select between two file libraries with same name?

2007-08-23 Thread jmborr
Imagine my file one.py contains the statement
import two
If there's a two.py in same directory as one.py, then this file will
be loaded. However, I want to load a different file named also two.py,
say file ~username/mypythonlib/two.py
How can I select between the two two.py files ?
-jose

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


python setup.py: how to override a setup.cfg value ?

2007-08-23 Thread Chris Shenton
I'm building python-ldap and need to change values of library and
include paths that are in the setup.cfg file.  This is an automated
build (using "buildit") so I'd prefer not to have edit the .cfg by hand,
with sed, or even with buildit's Substitute().

I'd like to be able to do something like I'd do with "make", specify a
value on the command line like:

  make -Dprefix=/usr/local

or in this case

  python setup.py -Dlibs="ldap lber" build   [Does NOT work]

I cannot see how to do this from the --help or from googling.  
The closest I've gotten is to do:

  python setup.py setopt --command=_ldap --option=libs --set-value="ldap lber"

but that overwrites the python.cfg, a bit rude it seems to me. 

Am I missing something? is there a way to override a .cfg value on the
command line while running a setup.py command like "build" or "install"?

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


Re: Impersonate another user temporarily (Unix and Windows)

2007-08-23 Thread billiejoex
On 23 Ago, 13:13, "Chris Mellon" <[EMAIL PROTECTED]> wrote:
> On 8/23/07, billiejoex <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > On 23 Ago, 10:38, Tim Golden <[EMAIL PROTECTED]> wrote:
> > > billiejoex wrote:
> > > > Hi there. I'm writing a modification for a FTP server library I'm
> > > > maintaining.
> > > > Depending on the system I'd want to temporarily impersonate the logged
> > > > user to perform actions on filesystem.
> > > > Something like:
>
> > > > try:
> > > > change_user('user', 'password')
> > > > os.rmdir('dir')
> > > > except:
> > > > print "some error"
> > > > finally:
> > > > change_user('old_user', 'password')
>
> > > > On Unix I took at look at os.seteuid() and os.setegid() functions and
> > > > I noticed they could be useful for my purpose.
> > > > On Windows I have no idea about how could I emulate a similar
> > > > behaviour.
> > > > Could someone please point me in the right direction?
>
> > > (Warning: not tried, but at least gives you the things to Google for!)
>
> > > You need the win32security module from the pywin32 extensions. [1]
> > > In particular, you want to look at the LogonUser and
> > > ImpersonateLoggedOnUser functions.
>
> > > TJG
>
> > > [1]http://pywin32.sf.net-Nascondi testo tra virgolette -
>
> > > - Mostra testo tra virgolette -
>
> > Thanks for suggestion.
> > I made it.
>
> Note that running your process as a user with enough priviledges to
> impersonate another user pretty much eliminates all the benefits of
> running as a low-priviledged user in the first place. Consider
> re-thinking your application model and having an "ftp" user instead.- 
> Nascondi testo tra virgolette -
>
> - Mostra testo tra virgolette -

Could you be more precise?
Why it's not a good idea?
I was thinking of starting ftpd as limited user ('nobody'/'ftp' on
unix, 'Guest' on Windows), then temporary switching to another user
when I got to perform actions on file system.
Maybe you're saying that as limited user I can't do such switching?

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


Re: Question about embedding python in C++

2007-08-23 Thread TheShadow
On Aug 23, 11:57 am, Farshid Lashkari <[EMAIL PROTECTED]> wrote:
> TheShadow wrote:
> > When extending python in c/c++ after you register a module is there a
> > way in c/c++ to check if they were correctly registered?
>
> > Cause I'm having the problem where when I execute the the python
> > script it finds the module but none of the functions.
>
> Are you calling Py_InitModule(...) in your initmodule function? If so,
> Py_InitModule(...) returns a reference to the module object. You can use
> this object to double check that your function names exist in the
> modules dictionary. Most likely, there is an error in your code. If you
> post it, it would be easier to tell what the problem is.
>
> -Farshid

Alright that was a dead end. Here is the source code.

bool CPythonModule::Register()
{
bool bReturn = false;
unsigned int uiSize = static_cast(m_LPyMethodDefs.size());
if (m_LPyMethodDefs.size() > 0)
{
m_pEmbMethods = new PyMethodDef[m_LPyMethodDefs.size()+1];
unsigned int uiCounter = 0;

IterQPyMethodDefs iterMethods = m_LPyMethodDefs.begin();

while (m_LPyMethodDefs.end() != iterMethods)
{
m_pEmbMethods[uiCounter].ml_name =
m_LPyMethodDefs.front().sName.c_str();
m_pEmbMethods[uiCounter].ml_meth =
m_LPyMethodDefs.front().pFunction;
m_pEmbMethods[uiCounter].ml_flags = 
m_LPyMethodDefs.front().iFlags;
m_pEmbMethods[uiCounter].ml_doc =
m_LPyMethodDefs.front().sDoc.c_str();

++uiCounter;
++iterMethods;
}

PyMethodDef PyMethodNullDef = {NULL, NULL, 0, NULL};

m_pEmbMethods[uiSize] = PyMethodNullDef;

Py_InitModule(m_sModuleName.c_str(),m_pEmbMethods);

//PythonInterfaceInst->RegisterModule(this);

m_pInitFunc();

bReturn = true;
}
return bReturn;
}

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


Re: how to select between two file libraries with same name?

2007-08-23 Thread kyosohma
On Aug 23, 1:46 pm, jmborr <[EMAIL PROTECTED]> wrote:
> Imagine my file one.py contains the statement
> import two
> If there's a two.py in same directory as one.py, then this file will
> be loaded. However, I want to load a different file named also two.py,
> say file ~username/mypythonlib/two.py
> How can I select between the two two.py files ?
> -jose

This kind of thing has been discussed before. See below:

http://mail.python.org/pipermail/python-list/2002-October/167055.html

The basic idea is not to do this. Fix your code so that you never have
this problem through code refactoring.

Mike

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


Re: advice about `correct' use of decorator

2007-08-23 Thread Gerardo Herzig
BJörn Lindqvist wrote:

>On 8/22/07, Gabriel Genellina <[EMAIL PROTECTED]> wrote:
>  
>
>>On 22 ago, 10:00, "BJörn Lindqvist" <[EMAIL PROTECTED]> wrote:
>>
>>
>>>As I said, you can accomplish the exact same thing by calling a
>>>function from within the function that requires the user to be logged
>>>in.
>>>
>>>def change_pass():
>>>check_user_logged_in()
>>>... more stuff here...
>>>
>>>is less complex (and therefore preferable) than:
>>>
>>>@check_user_logged_in
>>>def change_pass():
>>>... more stuff here...
>>>
>>>An important principle in engineering is that you should always strive
>>>to make your design as simple as possible. If you have two equal
>>>designs, you should always choose the one that is simpler because
>>>simple things are easier to understand than complex things.
>>>  
>>>
>>I don't see the complexity in this case - both are a single line of
>>code. Any internal complexity is hidden by the language. In fact, I
>>
>>
>
>"Hiding" doesn't reduce complexity, quite the opposite.
>
>  
>
>>consider the decorated function simpler than the other: its body
>>represents exactly what the function does, without any distracting
>>precondition calls.
>>
>>
>
>Think about how the decorator is implemented. It is a high order
>function, taking a function and returning a new function. Something
>like this:
>
>def check_user_logged_in(func):
>def f(*args, **kwargs):
>if global_state.the_user.is_logged_in:
>return func(*args, **kwargs)
>return show_login_page()
>return f
>
>@check_user_logged_in
>def change_pass():
>... more stuff here...
>
>or:
>
>def check_user_logged_in():
>return global_state.the_user.is_logged_in
>
>def change_pass():
>if not check_user_logged_in():
>return show_login_page()
>... more stuff here ...
>
>or even:
>
>def change_pass():
>if not global_state.the_user.is_logged_in:
>return show_login_page()
>... more stuff here ...
>
>  
>
>>The decorator has some advantages: can have syntax support on your
>>editor, can perform some registering/logging, it's even easier to
>>quickly check visually if it's here.
>>
>>
>
>The decorator has just as many disadvantages. For example, what if you
>want to redirect back to the change_pass page once the user has
>pressed the Login button on the login_page? Or if you want to show
>different login pages depending on user properties? How much control
>flow do you really want to "hide" in your decorator?
>
>  
>
Thanks Björn. Maybe im blind here in my intent to use decorators 
somewhere, but even re-checking you samples (pretty much the kind of 
example i show to my boss), it looks nicer (to me) when using a 
decorator!! I guess im becoming a  `deco junky' :)

Later you expose some interesing points about that login page and 
redirecting stuff...well, im my case, the login page does depends on 
user properties, wich (at this point) are stored in a `session data 
variable' (actually a table row), so the login pages take care about 
user properties, not the decorator itself, but the other part of the page.

I guess decorators has is own public, well, im one of that public. Let 
my be with my deco-junk alone, you bastard :)

Thanks a lot for your opinnions, guys!
Gerardo
-- 
http://mail.python.org/mailman/listinfo/python-list


Using Regular Expresions to change .htm to .php in files

2007-08-23 Thread sebzzz
Hi,

I have a bunch of files that have changed from standard htm files to
php files but all the links inside the site are now broken because
they point to the .htm files while they are now .php files.

Does anyone have an idea about how to do a simple script that changes
each .htm in a given file to a .php

Thanks a lot in advance

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


Re: Question about embedding python in C++

2007-08-23 Thread TheShadow
On Aug 23, 1:17 pm, TheShadow <[EMAIL PROTECTED]> wrote:
> On Aug 23, 11:57 am, Farshid Lashkari <[EMAIL PROTECTED]> wrote:
>
> > TheShadow wrote:
> > > When extending python in c/c++ after you register a module is there a
> > > way in c/c++ to check if they were correctly registered?
>
> > > Cause I'm having the problem where when I execute the the python
> > > script it finds the module but none of the functions.
>
> > Are you calling Py_InitModule(...) in your initmodule function? If so,
> > Py_InitModule(...) returns a reference to the module object. You can use
> > this object to double check that your function names exist in the
> > modules dictionary. Most likely, there is an error in your code. If you
> > post it, it would be easier to tell what the problem is.
>
> > -Farshid
>
> Alright that was a dead end. Here is the source code.
>
> bool CPythonModule::Register()
> {
> bool bReturn = false;
> unsigned int uiSize = static_cast int>(m_LPyMethodDefs.size());
> if (m_LPyMethodDefs.size() > 0)
> {
> m_pEmbMethods = new PyMethodDef[m_LPyMethodDefs.size()+1];
> unsigned int uiCounter = 0;
>
> IterQPyMethodDefs iterMethods = m_LPyMethodDefs.begin();
>
> while (m_LPyMethodDefs.end() != iterMethods)
> {
> m_pEmbMethods[uiCounter].ml_name =
> m_LPyMethodDefs.front().sName.c_str();
> m_pEmbMethods[uiCounter].ml_meth =
> m_LPyMethodDefs.front().pFunction;
> m_pEmbMethods[uiCounter].ml_flags = 
> m_LPyMethodDefs.front().iFlags;
> m_pEmbMethods[uiCounter].ml_doc =
> m_LPyMethodDefs.front().sDoc.c_str();
>
> ++uiCounter;
> ++iterMethods;
> }
>
> PyMethodDef PyMethodNullDef = {NULL, NULL, 0, NULL};
>
> m_pEmbMethods[uiSize] = PyMethodNullDef;
>
> Py_InitModule(m_sModuleName.c_str(),m_pEmbMethods);
>
> //PythonInterfaceInst->RegisterModule(this);
>
> m_pInitFunc();
>
> bReturn = true;
> }
> return bReturn;
>
> }

Forget I said anything I found my bug... I was using m_LPyMethodDefs
instead of my iterator... hurray for writing code at 12am :P

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


Re: beginner, idiomatic python

2007-08-23 Thread Zentrader
Does page count change? i.e. is it necessary to retrieve it in every
loop or
tempList = ['1','2','3','4','5','6','7','8']
sampleList=[]
page_count = self.parent.GetPageCount()

 for i in range(page_count):

Also, once pagefound is set to True, all pages following will not be
appended to sampleList because it is not initialized to False under
the "for i in range(self.parent.GetPageCount())" loop.

Finally, if I understand the logic and question correctly, you want
something like
tempList = ['1','2','3','4','5','6','7','8']
sampleList=[]
page_count = self.parent.GetPageCount()
for port in tempList:
for i in range(page_count):
page=self.parent.GetPage(i)
if (hasattr(page, "port")) and (page.port != int(port)) :
sampleList.append(port)

or perhaps (I'm not sure)
tempList = [1, 2, 3, 4, 5, 6, 7, 8]
sampleList=[]
page_count = self.parent.GetPageCount()
for i in range(page_count):
page=self.parent.GetPage(i)
if (hasattr(page, "port")) and (page.port not in tempList) :
sampleList.append(port)
 HTH

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


Newbie: List file system roots

2007-08-23 Thread Einar W. Høst
Hi,

How would you list the file system roots in Python? That is, I'm looking
for a way to list all connected drives (C:, D: etc) on a Windows box, or
all /root, /tmp etc on a *nix box. In Java, there's a built-in API
function to do this, File.listRoots(), but I couldn't find any
equivalents in the Python libraries.

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


Re: libgmail failure

2007-08-23 Thread [EMAIL PROTECTED]
Thanks!  That worked brilliantly.

-James

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


Re: MsiLib

2007-08-23 Thread Martin v. Löwis
Charlie schrieb:
> Thank you everybody for your help. It finally runs without errors and I
> should be able to use this as I figure out more of it. I am curios if
> there is any idea as to when GetString will be implemented?

If I can find the time, it may be for Python 2.6. If not, Python 2.7,
3.1, or so. Faster if a patch is contributed.

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


Re: Using Regular Expresions to change .htm to .php in files

2007-08-23 Thread Tim Williams
On 23/08/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I have a bunch of files that have changed from standard htm files to
> php files but all the links inside the site are now broken because
> they point to the .htm files while they are now .php files.
>
> Does anyone have an idea about how to do a simple script that changes
> each .htm in a given file to a .php
>
> Thanks a lot in advance
>

Something like:

Infile = open(f_name,'r+')
Data =  Infile.read()
InFile.write(Data.replace('.htm','.php'))
Infile.close()

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


Putting #'s and variables together in 1 variable

2007-08-23 Thread Lamonte Harris
  File "Desktop\python\newsystem\init.py", line 51, in random_n
random_name = a+b+c+d+e+ 'temp.txt'
TypeError: unsupported operand type(s) for +: 'int' and 'str'

import random
def random_name():
a = random.randint(0,9)
b = random.randint(0,9)
c = random.randint(0,9)
d = random.randint(0,9)
e = random.randint(0,9)
random_name = a+b+c+d+e+ 'temp.txt'
return random_name
print random_name

How can i make it so that it adds the random numbers and the temp.txt to
random_name variable w/out causing any error?
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Newbie: List file system roots

2007-08-23 Thread kyosohma
On Aug 23, 2:48 pm, "Einar W. Høst" <[EMAIL PROTECTED]> wrote:
> Hi,
>
> How would you list the file system roots in Python? That is, I'm looking
> for a way to list all connected drives (C:, D: etc) on a Windows box, or
> all /root, /tmp etc on a *nix box. In Java, there's a built-in API
> function to do this, File.listRoots(), but I couldn't find any
> equivalents in the Python libraries.
>
> Kind regards,
> Einar

Looks like the win32 modules save the day again.

http://mail.python.org/pipermail/python-win32/2004-January/001562.html

from win32com.client import Dispatch
fso = Dispatch('scripting.filesystemobject')
for i in fso.Drives :
print i

# Mike

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

Re: Using Regular Expresions to change .htm to .php in files

2007-08-23 Thread Tim Williams
On 23/08/07, Tim Williams <[EMAIL PROTECTED]> wrote:
> On 23/08/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > I have a bunch of files that have changed from standard htm files to
> > php files but all the links inside the site are now broken because
> > they point to the .htm files while they are now .php files.
> >
> > Does anyone have an idea about how to do a simple script that changes
> > each .htm in a given file to a .php
> >
> > Thanks a lot in advance
> >
>
> Something like:
>
> Infile = open(f_name,'r+')
> Data =  Infile.read()
> InFile.write(Data.replace('.htm','.php'))
> Infile.close()
>

Actually,  scrub that, its been a long day!You either need a
Infile.seek(0)  in the above before the write() , or you can do.

Data = open(f_name).read()
outfile = open(f_name,'w')
outfile.write(Data.replace('.htm','.php'))
outfile.close()
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Putting #'s and variables together in 1 variable

2007-08-23 Thread Jay Loden
Lamonte Harris wrote:
>   File "Desktop\python\newsystem\init.py", line 51, in random_n
> random_name = a+b+c+d+e+ 'temp.txt'
> TypeError: unsupported operand type(s) for +: 'int' and 'str'
> 
> import random
> def random_name():
> a = random.randint(0,9)
> b = random.randint(0,9)
> c = random.randint(0,9)
> d = random.randint(0,9)
> e = random.randint(0,9)
> random_name = a+b+c+d+e+ 'temp.txt '
> return random_name
> print random_name
> 
> How can i make it so that it adds the random numbers and the temp.txt to
> random_name variable w/out causing any error?

1) If you're just trying to create temporary files, you would be much better 
   off using the tempfile module. It's more secure and saves you the hassle 
   of doing it yourself: http://docs.python.org/lib/module-tempfile.html 

2) Since all you're doing is adding a bunch of numeric values to each other
   to build the string, why wouldn't you just create a random number between
   0 -> 9 and use that?

3) If you really, really, really still want to do this, the best way I can 
   think of would be to use the string format operator: 

import random
def random_name():
a = random.randint(0,9)
b = random.randint(0,9)
c = random.randint(0,9)
d = random.randint(0,9)
e = random.randint(0,9)
random_name = '%s%s%s%s%stemp.txt' % (a,b,c,d,e)
return random_name

OR, using suggestion 2 above:

import random
def random_name():
num = random.randint(0,9)
random_name = '%stemp.txt' % (num)
return random_name


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


Re: Putting #'s and variables together in 1 variable

2007-08-23 Thread Grant Edwards
On 2007-08-23, Jay Loden <[EMAIL PROTECTED]> wrote:

> 2) Since all you're doing is adding a bunch of numeric values to each other
>to build the string, why wouldn't you just create a random number between
>0 -> 9 and use that?

Since the OP calls randint 5 times, his answer is 5 times more
random!

-- 
Grant Edwards   grante Yow! Everybody gets free
  at   BORSCHT!
   visi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Syslog

2007-08-23 Thread Michael Bentley

On Aug 20, 2007, at 4:56 PM, greg wrote:

> Hi All,
>
> Could anyone tell me how I could syslog to a specific log (e.g. /var/
> log/daemon.log, /var/log/syslog.log...)?
>

# something like this:

import logging
logging.basicConfig(level=logging.DEBUG,
 format='%(asctime)s %(levelname)-8s %(message)s',
 datefmt='%a, %d %b %Y %H:%M:%S',
 filename='/var/log/whatever.log',
 filemode='a')

logging.info('random message')

hth,
Michael
---
# Something just doesn't seem right in those
# "Every kiss begins with 'K'" commercials.

 >>> 'Every Kiss'.startswith('K')
False




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


Re: MsiLib

2007-08-23 Thread Charlie
Quoting "Martin v. Löwis" <[EMAIL PROTECTED]>:

> Charlie schrieb:
>> Thank you everybody for your help. It finally runs without errors and I
>> should be able to use this as I figure out more of it. I am curios if
>> there is any idea as to when GetString will be implemented?
>
> If I can find the time, it may be for Python 2.6. If not, Python 2.7,
> 3.1, or so. Faster if a patch is contributed.
>
> Regards,
> Martin
>

Thank you. I would be willing to help out, but as of now I have no  
idea how to get started on it. If you would be willing to provide some  
guidance, then I would be fine with giving it a shot if nothing more.  
My guess is that it would have to implement the MsiRecordGetString  
function so that it is accessible, but I don't know beyond that.

Charlie

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


  1   2   >