Python library for RTSP protocol

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

Can you please tell me if there is a Python library which can talk
RTSP/RTP protocol?
i.e. i would like to write a script in python to download a video via
a RTSP server?

Thank you.

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


Re: Understanding closures

2007-08-19 Thread James Stroud
Ramashish Baranwal wrote:
> Hi,
> 
> I want to use variables passed to a function in an inner defined
> function. Something like-
> 
> def fun1(method=None):
> def fun2():
> if not method: method = 'GET'
> print '%s: this is fun2' % method
> return
> fun2()
> 
> fun1()
> 
> However I get this error-
> UnboundLocalError: local variable 'method' referenced before
> assignment
> 
> This however works fine.
> 
> def fun1(method=None):
> if not method: method = 'GET'
> def fun2():
> print '%s: this is fun2' % method
> return
> fun2()
> 
> fun1()
> 
> Is there a simple way I can pass on the variables passed to the outer
> function to the inner one without having to use or refer them in the
> outer function?

Why do you have this latter requirement? Will /method/ change in the 
outer scope before it is called in the inner scope? E.g.:


def fun1(method=None):
 def fun2():
 if not method: method = 'GET'
 print '%s: this is fun2' % method
 return
 method = 'POST'
 # Now its going to be 'POST' in fun2
 fun2()


To avoid this problem, you want something like this:


def fun1(method=None):
 def fun2(method=method):
 if not method: method = 'GET'
 print '%s: this is fun2' % method
 return
 method = 'POST'
 # Now the preceding line has no effect on fun2
 fun2()
 # Now method is explicitly 'POST' in fun2
 fun2('POST')


But a deeper question is: Why do you need to define fun2 with fun1 to 
begin with?


def fun2(method=None):
   if not method: method = 'GET'
   print '%s: this is fun2' % method
   return

def fun1(method=None):
   method = 'POST'
   # will be 'GET'
   fun2()
   # will be 'POST'
   fun2(method)


Also, empty "return" statements are unnecessary if they are the last 
statement in a function.

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


imaplib & Received: header(s)???

2007-08-19 Thread Petri Savolainen
Hello,

Is there a way to get at the "Received" header(s) or is there something 
in imaplib or imap server implementations that hides these? If not, what 
IMAP FETCH command should be used? I've used for example 
"BODY[HEADER.FIELDS (RECEIVED)]" and it always returns empty ("\r\n"). 
Despite the Received - header existing, as demonstrated by taking a look 
at message sources via desktop email clients.

I need to get at the Received-for header to figure out at which address 
we received an email. We subscribe to a number of mailing lists using 
per-mailing-list addresses, and often, To: field contains something else 
than our address, thus the need for Received-for.

Any help would be much appreciated - this is baffling me and I've not 
found anything recent that would help.

Thanks,

  Petri

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


1)URL QueryString Parsing 2)Search Engine Spiders

2007-08-19 Thread mosscliffe
I am trying to create a back link, equivalent to the browser back
action and I can not use java script. The target user does not allow
java script.

I am using HTTP_REFERER.

I need to add the original Query String values.

Is there a way to get the QueryString element other than by using
cgi.FieldStorage, as I just want to return with the values that were
current in the calling page.

gv.orgQueryString = ""

gv.BackButton = 'BACK'


Am I right in thinking Search Engine Spiders will never see my script
pages as they exist only for the duration of the python script's
execution ?  And even then as they are   xxx.py, they would not be
seen.

Thanks

Richard

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


Development for dual core machine

2007-08-19 Thread Andy
Hi guys,

I'm sorry, I'm not sure this is the correct group to be asking this
kind of question...

I'm going to develop a software package that includes a web server
(and PHP code) , a database, and some Python code of course.  I am
being strongly suggested to make it to work on a dual- or multi-core
computer, but I'm confused on how to take advantage of the multiple
CPUs.

>From what I read, I think that simply by making the package run in
several separate processes (web server, database server, Python
interpreter, etc.), and/or using multiple threads (which I will
anyway) the package should be able to use multiple CPUs.

Is my understanding correct?  So actually, all I have to do is just
write my multi-threaded Python code as usual?  And how is it decided
which process and which threads go to CPU 1, CPU 2, etc.?  Perhaps the
BIOS?

Any advice greatly appreciated.
Andy

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


Re: Symbolic Link

2007-08-19 Thread Diez B. Roggisch
mosscliffe schrieb:
> On 18 Aug, 23:49, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:
>> mosscliffe schrieb:
>>
>>
>>
>>> I am trying to create a link to a file, which I can then use in an
>>> HTML page.
>>> The system is Linux on a hosted web service, running python 2.3.
>>> Other than that I have no knowledge of the system.
>>> The link is created OK, but when I try to use it as filename for the
>>> IMG TAG, it does not get displayed.  The page source of the created
>>> page is pointing to the link as temp/test1.jpg
>>> Any ideas ?
>>> srcFile = "temp/test2.jpg"
>>> linkFile = "temp/test1.jpg"
>>> if os.path.islink(linkFile):
>>> print "Link Exists", nl
>>> pass
>>> else:
>>> print "Making Link", nl
>>> os.symlink(srcFile, linkFile)
>>> print 'the image' % linkFile
>>> print 'the image' % srcFile
>> In what environment is that script running? If it's apache, it might be
>> that the apache settings disallow for following links.
>>
>> Diez
> 
> It is Apache.
> 
> Can I create some override in the current directory.  I am afraid my
> Apache skills are almost zero.

As are mine. At least from the top of my head. You better ask in a more 
apache-centric forum.

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


Re: clarification

2007-08-19 Thread samwyse
Alex Martelli wrote:

> Of course, hoisting the unbound method out of the loops can afford the
> usual small optimization.  But my point is that, in Python, these
> operations (like, say, the concatenation of a sequence of lists, etc)
> are best performed "in place" via loops calling mutator methods such as
> update and intersection_update (or a list's extend, etc), rather than
> "functionally" (building and tossing away many intermediate results).
> E.g., consider:
> 
> brain:~ alex$ python -mtimeit -s'sos=[set(range(x,x+4)) for x in
> range(0, 100, 3)]' 'r=set()' 'for x in sos: r.update(x)'
> 10 loops, best of 3: 18.8 usec per loop
> 
> brain:~ alex$ python -mtimeit -s'sos=[set(range(x,x+4)) for x in
> range(0, 100, 3)]' 'r=reduce(set.union, sos, set())'
> 1 loops, best of 3: 87.2 usec per loop
> 
> Even in a case as tiny as this one, "reduce" is taking over 4 times
> longer than the loop with the in-place mutator -- and it only gets
> worse, as we're talking about O(N squared) vs O(N) performance!  Indeed,
> this is part of what makes reduce an "attractive nuisance"...;-).  [[And
> so is sum, if used OTHERWISE than for the documented purpose, computing
> "the sum of a sequence of numbers": a loop with r.extend is similarly
> faster, to concatenate a sequence of lists, when compared to sum(sol,
> [])...!!!]]

Curiously, when I attempt the actual problem at hand (set intersection) 
rather than something altogether different (set union) on my Dell laptop 
running Win2K Pro, I get the following results:

stmt = 'r=reduce(set.intersection, los)'
best of 3: 21.9 usec per loop
stmt = 'r=intersect_all(los)'
best of 3: 29.3 usec per loop

So, the "nuisance" is more attractive than you thought.  Apparently, one 
can't really depend on "in place" mutator methods being more efficient 
that using functional techniques.  BTW, the above figures reflect 10,000 
iterations; using larger counts makes the difference even larger.  I 
suspect that this is because the Python interpreter has fewer chances to 
be interrupted by external processes when it's using 'reduce'.  This in 
turn indicates that both implementations actually work about same and 
your "O(n squared)" argument is irrelevant.

P.S. Here's the source I used for the timings:

from timeit import Timer

setup = """
def intersect_all(los):
 it = iter(los)
 result = set(it.next())
 for s in it: result.intersection_update(s)
 return result

not7=range(2,11)
not7.remove(7)
los=[set(range(0,360,step)) for step in not7]
"""

number = 1
repeat = 3
precision = 3

for stmt in 'r=reduce(set.intersection, los)', 'r=intersect_all(los)':
 t = Timer(stmt, setup)
 r = t.repeat(repeat, number)
 best = min(r)
 usec = best * 1e6 / number
 print "stmt =", repr(stmt)
 print "best of %d: %.*g usec per loop" % (repeat, precision, usec)
-- 
http://mail.python.org/mailman/listinfo/python-list


Hot subject: a good python editor and/or IDE?

2007-08-19 Thread Sébastien
Hi folks,

I am currently using Eclipse+PyDev when developping Python projects but 
I lack a fast, simple editor for tiny bit of scripts. So here is my 
question: what is, for you, the current best ( but still kind of light! 
) Python editor/IDE ? A tiny precision, I am on Ubuntu so I am looking 
for a linux compatible editor.

Cheers,

Sébastien
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Symbolic Link

2007-08-19 Thread samwyse
mosscliffe wrote:
> I am trying to create a link to a file, which I can then use in an
> HTML page.
> 
> The system is Linux on a hosted web service, running python 2.3.
> Other than that I have no knowledge of the system.
> 
> The link is created OK, but when I try to use it as filename for the
> IMG TAG, it does not get displayed.  The page source of the created
> page is pointing to the link as temp/test1.jpg

What are you trying to do that you can't use the original file instead 
of creating a link?  There might be a way to side-step the entire problem.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Parser Generator?

2007-08-19 Thread samwyse
Jack wrote:
> Thanks for all the replies!
> 
> SPARK looks promising. Its doc doesn't say if it handles unicode
> (CJK in particular) encoding though.
> 
> Yapps also looks powerful: http://theory.stanford.edu/~amitp/yapps/
> 
> There's also PyGgy http://lava.net/~newsham/pyggy/
> 
> I may also give Antlr a try.
> 
> If anyone has experiences using any of the parser generators with CJK
> languages, I'd be very interested in hearing that.

I'm going to echo Tommy's reply.  If you want to parse natural language, 
conventional parsers are going to be worse than useless (because you'll 
keep thinking, "Just one more tweak and this time it'll work for 
sure!").  Instead, go look at what the interactive fiction community 
uses.  They analyse the statement in multiple passes, first picking out 
the verbs, then the noun phrases.  Some of their parsers can do 
on-the-fly domain-specific spelling correction, etc, and all of them can 
ask the user for clarification.  (I'm currently cobbling together 
something similar for pre-teen users.)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Hot subject: a good python editor and/or IDE?

2007-08-19 Thread Bjoern Schliessmann
Sébastien wrote:
> I am currently using Eclipse+PyDev when developping Python
> projects but I lack a fast, simple editor for tiny bit of scripts.
> So here is my question: what is, for you, the current best ( but
> still kind of light! ) Python editor/IDE ?

vim

BTW, this is an FAQ. Please look through the archives for many
threads with many, many IDEs.

Regards,


Björn

-- 
BOFH excuse #140:

LBNC (luser brain not connected)

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


Re: Development for dual core machine

2007-08-19 Thread Bjoern Schliessmann
Andy wrote:

> I'm going to develop a software package that includes a web server
> (and PHP code) , a database, and some Python code of course.  I am
> being strongly suggested to make it to work on a dual- or
> multi-core computer, 

No problem. CPython will work on any dual core CPU.

> but I'm confused on how to take advantage of the multiple CPUs.

First: Use a web server that can make use of multiple cores.

Second: Use a data base that can make use of multiple cores.

Third, for using multiple cores from CPython: this is an FAQ, please
look at the mailing list archives. Whether you should optimize your
python application to use all cores strongly depends on what your
Python application actually does.
 
> From what I read, I think that simply by making the package run in
> several separate processes (web server, database server, Python
> interpreter, etc.), and/or using multiple threads (which I will
> anyway) the package should be able to use multiple CPUs.

CPython has the GIL (global interpreter lock). Please search for it
in the archives, it's been discussed exhaustingly.
 
> And how is it decided which process and which threads go to CPU 1,
> CPU 2, etc.? Perhaps the BIOS?

No, the kernel (i. e., Linux). The BIOS is completely out of this.

Regards,


Björn

-- 
BOFH excuse #388:

Bad user karma.

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


Re: Searching for pixel color

2007-08-19 Thread samwyse
michael maver wrote:
> Hello, I was just wondering if anyone knew of a way to search the screen 
> for a certain color in Python.

I know of lots of ways to do this...

> I know it is possible to do this in other languages, but I'm not sure 
> how I'd go about doing this in Python. Just to let you know, I'm running 
> windows XP and I don't really need it to be a cross platform solution, 
> but if it was that'd be an extra bonus.

... but they are all platform dependent; not just Windows vs Unix, but 
PIL vs wxWin vs whatever.

def search_screen(desired_color):
   root = my_gui.root_window()
   width, height = root.get_size()
   for x in xrange(0, width):
 for y in xrange(0, height):
   if root.get_pixel(x,y) == desired_color:
 return x,y
   return -1, -1

Modify the above using the appropriate values for 'my_gui' and its 
methods, 'root_window', 'get_size' and 'get_pixel'.

 > Thanks very much for taking the time to read this and, hopefully, 
respond!

You're welcome.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to make a module function visible only inside the module?

2007-08-19 Thread Bjoern Schliessmann
beginner wrote:

> Thanks a lot. I was using two underscores, __module_method() as my
> static method convention, and then I had some problems calling
> them from inside class methods.

*Please* do yourself and other people that sometime may have to read
your code a favor and write code at least loosely oriented to 
PEP 8.

BTW, Python has no "static methods" at module level. And I suppose
what you call "class methods" actually aren't.

Regards,


Björn

-- 
BOFH excuse #183:

filesystem not big enough for Jumbo Kernel Patch

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


Re: Hot subject: a good python editor and/or IDE?

2007-08-19 Thread Kevin Walzer
Sébastien wrote:
> Hi folks,
> 
> I am currently using Eclipse+PyDev when developping Python projects but 
> I lack a fast, simple editor for tiny bit of scripts. So here is my 
> question: what is, for you, the current best ( but still kind of light! 
> ) Python editor/IDE ? A tiny precision, I am on Ubuntu so I am looking 
> for a linux compatible editor.
> 
> Cheers,
> 
> Sébastien

IDLE

-- 
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 1)URL QueryString Parsing 2)Search Engine Spiders

2007-08-19 Thread samwyse
mosscliffe wrote:
> I am trying to create a back link, equivalent to the browser back
> action and I can not use java script. The target user does not allow
> java script.
> 
> I am using HTTP_REFERER.
> 
> I need to add the original Query String values.
> 
> Is there a way to get the QueryString element other than by using
> cgi.FieldStorage, as I just want to return with the values that were
> current in the calling page.
> 
> gv.orgQueryString = ""
> 
> gv.BackButton = ' gv.orgQueryString + '">BACK'

I'm not sure I understand your problem.  Does the above code not work?

> Am I right in thinking Search Engine Spiders will never see my script
> pages as they exist only for the duration of the python script's
> execution ?  And even then as they are   xxx.py, they would not be
> seen.

Anyone who accesses your web server will see the pages that you serve. 
If you serve the xxx.py files, then they can be seen and indexed, 
otherwise they are invisible.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Development for dual core machine

2007-08-19 Thread samwyse
Andy wrote:
> Hi guys,
> 
> I'm sorry, I'm not sure this is the correct group to be asking this
> kind of question...
> 
> I'm going to develop a software package that includes a web server
> (and PHP code) , a database, and some Python code of course.  I am
> being strongly suggested to make it to work on a dual- or multi-core
> computer, but I'm confused on how to take advantage of the multiple
> CPUs.
> 
>>From what I read, I think that simply by making the package run in
> several separate processes (web server, database server, Python
> interpreter, etc.), and/or using multiple threads (which I will
> anyway) the package should be able to use multiple CPUs.
> 
> Is my understanding correct?  So actually, all I have to do is just
> write my multi-threaded Python code as usual?  And how is it decided
> which process and which threads go to CPU 1, CPU 2, etc.?  Perhaps the
> BIOS?
> 
> Any advice greatly appreciated.
> Andy
> 

The Python interpreter is not multi-cpu aware, so using Python threads 
won't work on multiple CPUs.  If your tasks are CPU-bound, then fork 
multiple processes.  Most web servers (Apache) can handle this 
automatically for you.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Development for dual core machine

2007-08-19 Thread Bryan Olson
Andy wrote:
> I'm going to develop a software package that includes a web server
> (and PHP code) , a database, and some Python code of course.  I am
> being strongly suggested to make it to work on a dual- or multi-core
> computer, but I'm confused on how to take advantage of the multiple
> CPUs.
> 
> From what I read, I think that simply by making the package run in
> several separate processes (web server, database server, Python
> interpreter, etc.), and/or using multiple threads (which I will
> anyway) the package should be able to use multiple CPUs.

Right. There is a theoretical possibility that Python's GIL
could limit thread parallelism, but in this kind of application
it should not matter in the least. Either you're I/O bound, or
there are plenty of tasks the operating system could schedule.

If you have the option to run the Python interpreter within a
web-server process, that's usually a performance winner.

> Is my understanding correct?  So actually, all I have to do is just
> write my multi-threaded Python code as usual?  And how is it decided
> which process and which threads go to CPU 1, CPU 2, etc.?  Perhaps the
> BIOS?

The O.S. actually. A lot of really smart people have put a whole
lot of work into making the O.S. do that well.

If you usually write your Python apps multi-threaded, as I do,
that's fine. Multi-core efficiency has only a little to do with
it. Web service are, for the most part, intrinsically
parallelizable: run multiple web servers, and multiple Python
interpreters serving multiple connections.

The only hard part is shared data. Scalability is all about
the database.


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


How to find script's directory

2007-08-19 Thread Papalagi Pakeha
Hi,

I have a project (a django project actually) that has a structure
something like:
/path/prj/settings.py
/path/prj/scripts/blah.py
/path/prj/...

In order to run blah.py I need to set $PYTHONPATH to /path/prj because
it does "import settings". That's all good. I would however like to
autodetect the path in blah.py somehow and not need to set PYTHONPATH
prior to execution.

Whether it's called as /path/prj/scripts/blah.py or ./blah.py or
../../prj/scripts/blah.py or even plain blah.py should the whole path
to it be in $PATH I'd like it to detect it's location in the
filesystem and append its parent dir to sys.path

I guess I could do it with a little help of os.path.realpath() for all
those cases where absolute or relative path was used. But how should I
approach it when it's invoked as plain 'blah.py' because its directory
name is in $PATH?

TIA!

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


Re: Hot subject: a good python editor and/or IDE?

2007-08-19 Thread Samuel
On Sun, 19 Aug 2007 11:47:03 +0200, Sébastien wrote:

> Hi folks,
> 
> I am currently using Eclipse+PyDev when developping Python projects but
> I lack a fast, simple editor for tiny bit of scripts. So here is my
> question: what is, for you, the current best ( but still kind of light!
> ) Python editor/IDE ? A tiny precision, I am on Ubuntu so I am looking
> for a linux compatible editor.

Vim with SnippetsEMU works great with Python. I made a demo of this in
action here:

http://debain.org/?p=198

Installation/configuration example on Ubuntu:

---
$ sudo apt-get install vim

$ mkdir -p $HOME/.vim/ftplugin/

$ mkdir -p $HOME/.vim/after/ftplugin/

$ wget http://www.vim.org/scripts/download_script.php?src_id=6951 -O se.vba

$ vim se.vba
:so %
:wq

$ echo "setlocal sw=4
setlocal ts=4
noremap  py o/**/
" >> ~/.vim/ftplugin/python.vim

$ wget 
http://code.google.com/p/snippetsemu/issues/attachment?aid=-6063627743376712928&name=python_snippets.vim

$ cp python_snippets.vim $HOME/.vim/after/ftplugin/

$ echo "syntax on 
set sw=2
set ts=2
set nu 
set nuw=3
set autoindent
set expandtab" >> $HOME/.vimrc
---

(not tested, but it should work)

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

Re: Hot subject: a good python editor and/or IDE?

2007-08-19 Thread Samuel
On Sun, 19 Aug 2007 13:08:35 +, Samuel wrote:

> $ sudo apt-get install vim

I just realized, this should be

$ sudo apt-get install vim-python

or

$ sudo apt-get install vim-full

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


Re: best GUI library for vector drawing program

2007-08-19 Thread sturlamolden
On Aug 17, 3:27 pm, chewie54 <[EMAIL PROTECTED]> wrote:

> What would be the best cross-platform GUI library to use for a vector
> based CAD program

I suggest you use different toolkits for windowing (GUI widgets) and
drawing the vector graphics.

It does not really matter which toolkit you use for windowing.
wxPython looks good on many platforms and are free. So it PyGTK.

For vector graphics part I suggest PyCairo, AggDraw or OpenGL,
depending on your need.

PIL and NumPy are also essential if you will be working with images

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


Re: Hot subject: a good python editor and/or IDE?

2007-08-19 Thread Buchoux Sébastien
Bjoern Schliessmann wrote:
> Sébastien wrote:
>   
>> I am currently using Eclipse+PyDev when developping Python
>> projects but I lack a fast, simple editor for tiny bit of scripts.
>> So here is my question: what is, for you, the current best ( but
>> still kind of light! ) Python editor/IDE ?
>> 
>
> vim
>
> BTW, this is an FAQ. Please look through the archives for many
> threads with many, many IDEs.
>
> Regards,
>
>
> Björn
>
>   
Yeah, I know this is a FAQ, but, as you mention, there is a whole bunch 
of editors, every one of them being updated constantly (+ the new ones 
getting out). So I am quite sure that looking through the archives is 
THE solution since it will only reflect what people thought when 
question was asked. Just type "best Python editor" on Google and you 
will see that almost all hits are completely out of date.
Fair enough though! ;)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Hot subject: a good python editor and/or IDE?

2007-08-19 Thread azrael
Try the WingIDE
Great Code Completition, Source Assistant, Debugger, PythonShell,
projects, The codeCompletition is really great.
Give it a try



On Aug 19, 3:37 pm, Buchoux Sébastien <[EMAIL PROTECTED]> wrote:
> Bjoern Schliessmann wrote:
> > Sébastien wrote:
>
> >> I am currently using Eclipse+PyDev when developping Python
> >> projects but I lack a fast, simple editor for tiny bit of scripts.
> >> So here is my question: what is, for you, the current best ( but
> >> still kind of light! ) Python editor/IDE ?
>
> > vim
>
> > BTW, this is an FAQ. Please look through the archives for many
> > threads with many, many IDEs.
>
> > Regards,
>
> > Björn
>
> Yeah, I know this is a FAQ, but, as you mention, there is a whole bunch
> of editors, every one of them being updated constantly (+ the new ones
> getting out). So I am quite sure that looking through the archives is
> THE solution since it will only reflect what people thought when
> question was asked. Just type "best Python editor" on Google and you
> will see that almost all hits are completely out of date.
> Fair enough though! ;)


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


Newbie question

2007-08-19 Thread Anonymous
I have exp with C/C++ (and a few other langs). I want to use Python to 
start doing the ff:

1). Data Munging (text processing)
2). Automating my build process
3). (Possibly) some web data retrieval jobs

Can anyone point me to resurces/possibly scripts that can get me up to 
speed (to do these 3 things) ASAP, without having to learn the basics of 
programming?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie question

2007-08-19 Thread Michael Tobis
http://diveintopython.org/

mt

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


Python syntax r prefix to a string

2007-08-19 Thread goldtech
Does anyone know this syntax and could link me to an explanation?

Something like:

Workspace = r'C:\foobar\mystuff\xyz'

What's that "r" doing? Sometimes I see a "u" too.

Explanation appreciated.

Thanks,
Lee G.

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


yet another indentation proposal

2007-08-19 Thread Aaron
Hello all.

I realize that proposals dealing with alternatives to indentation  have been 
brought up (and shot down) before, but I would like to take another stab at 
it, because it is rather important to me.

I am totally blind, and somewhat new to Python.  I put off learning Python 
for a long time, simply because of the indentation issue.  There is no easy 
way for a screenreader user, such as my self, to figure out how much a 
particular line of code is indented.  A sited person simply looks down the 
column to make sure that everything lines up.  I, on the other hand, 
generally find my self counting a lot of spaces.

Naturally, there are many other special circumstances in which depending on 
whitespace is impractical, but they have already been mentioned in previous 
threads on the topic, so I won't bother rehashing them.

Borrowing from another proposal, I would submit that the opening block and 
closing block markers could be _{ and }_ respectively.  If it seems that 
there is even a modicum of support, I'll write up a more complete proposal. 
But in short, an _{ will signify to the interpreter that one level of 
indentation is to be added to the current level, that all the statements 
that follow (until the closing _}) are to be understood to be at that level, 
and that all whitespace at the beginning of lines, or lack there of, is to 
be ignored.

I realize that this would result in some esthetically ugly code, and so 
naturally a simple tool to convert this type of block indication back to 
"normal indented format" should also be developed.

Any thoughts or suggestions?

I sincerely hope that this proposal can be given some serious consideration, 
and not simply dismissed as sacrilege.  There are many blind programmers, 
and I would hate to see them opt to learn other languages simply because of 
this one issue.

Thanks.

Aaron


-- 
To reply directly, remove j's from email address. 



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


Re: Python and Tkinter Programming--Expensive!

2007-08-19 Thread Kevin Walzer
Nick Craig-Wood wrote:
> W. Watson <[EMAIL PROTECTED]> wrote:
>>  Why is the book in Subject (author is Grayson) so expensive? $100 on Amazon 
>>  and $195 on ABE. Aren't there alternatives?
> 
> There is an excellent section (266 pages) on TKinter in "Programming
> Python" by Mark Lutz. I've got the 2nd edition.
> 
> Lutz concentrates on TK programming using classes, making re-usable
> components which I found really helpful compared to the ad-hoc way I'd
> seen TK presented previously.
> 
+1 on Lutz. It's very current, and has helped me learn Tkinter 
programming (and I already have a background with Tk via Tcl).

-- 
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: yet another indentation proposal

2007-08-19 Thread Paddy
On Aug 18, 7:22 pm, "Aaron" <[EMAIL PROTECTED]>
wrote:
> Hello all.
>
> I realize that proposals dealing with alternatives to indentation  have been
> brought up (and shot down) before, but I would like to take another stab at
> it, because it is rather important to me.
>
> I am totally blind, and somewhat new to Python.  I put off learning Python
> for a long time, simply because of the indentation issue.  There is no easy
> way for a screenreader user, such as my self, to figure out how much a
> particular line of code is indented.  A sited person simply looks down the
> column to make sure that everything lines up.  I, on the other hand,
> generally find my self counting a lot of spaces.
>
> Naturally, there are many other special circumstances in which depending on
> whitespace is impractical, but they have already been mentioned in previous
> threads on the topic, so I won't bother rehashing them.
>
> Borrowing from another proposal, I would submit that the opening block and
> closing block markers could be _{ and }_ respectively.  If it seems that
> there is even a modicum of support, I'll write up a more complete proposal.
> But in short, an _{ will signify to the interpreter that one level of
> indentation is to be added to the current level, that all the statements
> that follow (until the closing _}) are to be understood to be at that level,
> and that all whitespace at the beginning of lines, or lack there of, is to
> be ignored.
>
> I realize that this would result in some esthetically ugly code, and so
> naturally a simple tool to convert this type of block indication back to
> "normal indented format" should also be developed.
>
> Any thoughts or suggestions?
>
> I sincerely hope that this proposal can be given some serious consideration,
> and not simply dismissed as sacrilege.  There are many blind programmers,
> and I would hate to see them opt to learn other languages simply because of
> this one issue.
>
> Thanks.
>
> Aaron
>
> --
> To reply directly, remove j's from email address.

Oh wow. it never crossed my mind...

Can screen reaaderss be customized?
Maybe their is a way to get the screen reader to say indent and dedent
at thee appropriate places?
Or maybe a filter to put those wordds into the source?

- Paddy.

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


Re: Python syntax r prefix to a string

2007-08-19 Thread Paddy
On Aug 19, 4:43 pm, goldtech <[EMAIL PROTECTED]> wrote:
> Does anyone know this syntax and could link me to an explanation?
>
> Something like:
>
> Workspace = r'C:\foobar\mystuff\xyz'
>
> What's that "r" doing? Sometimes I see a "u" too.
>
> Explanation appreciated.
>
> Thanks,
> Lee G.

Search for raw strings and unicode stringss...

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


Re: Hot subject: a good python editor and/or IDE?

2007-08-19 Thread Paddy
On Aug 19, 10:47 am, Sébastien <[EMAIL PROTECTED]> wrote:
> Hi folks,
>
> I am currently using Eclipse+PyDev when developping Python projects but
> I lack a fast, simple editor for tiny bit of scripts. So here is my
> question: what is, for you, the current best ( but still kind of light!
> ) Python editor/IDE ? A tiny precision, I am on Ubuntu so I am looking
> for a linux compatible editor.
>
> Cheers,
>
> Sébastien

A hard question to answer. Why not just use the default gnome or kde
editors?

I've invested time in learning vim which has paid off handsomely for
me.

- Paddy.

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


Re: clarification

2007-08-19 Thread Alex Martelli
samwyse <[EMAIL PROTECTED]> wrote:
   ...
> > brain:~ alex$ python -mtimeit -s'sos=[set(range(x,x+4)) for x in
> > range(0, 100, 3)]' 'r=set()' 'for x in sos: r.update(x)'
> > 10 loops, best of 3: 18.8 usec per loop
> > 
> > brain:~ alex$ python -mtimeit -s'sos=[set(range(x,x+4)) for x in
> > range(0, 100, 3)]' 'r=reduce(set.union, sos, set())'
> > 1 loops, best of 3: 87.2 usec per loop
> > 
> > Even in a case as tiny as this one, "reduce" is taking over 4 times
> > longer than the loop with the in-place mutator -- and it only gets
> > worse, as we're talking about O(N squared) vs O(N) performance!  Indeed,
> > this is part of what makes reduce an "attractive nuisance"...;-).  [[And

The set-union case, just like the list-catenation case, is O(N squared)
(when approached in a functional way) because the intermediate result
often _grows_ [whenever a new set or list operand adds items], and thus
a new temporary value must be allocated, and the K results-so-far
"copied over" (as part of constructing the new temp value) from the
previous temporary value; and sum(range(N)) grows quadratically in N.
The in-place approach avoids that fate by a strategy of proportional
over-allocation (used by both set and lists) that makes in-place
operations such as .update(X) and .extend(X) amortized O(K) where K is
len(X).

In the set-intersection case, the intermediate result _shrinks_ rather
than growing, so the amount of data "copied over" is a diminishing
quantity at each step, and so the analysis showing quadratic behavior
for the functional approach does not hold; behavior may be roughly
linear, influenced in minor ways by accidental regularities in the sets'
structure and order (especially likely for short sequences of small
sets, as in your case).  Using a slightly longer sequence of slightly
larger sets, with little structure to each, e.g.:

random.seed(12345)  # set seed to ensure total repeatability
los=[set(random.sample(range(1000), 990)) for x in range(200)]

at the end of the setup (the intersection of these 200 sets happens to
contain 132 items), I measure (as usual on my 18-months-old Macbook Pro
laptop):

stmt = 'reduce(set.intersection,los)'
best of 3: 1.66e+04 usec per loop
stmt = 'intersect_all(los)'
best of 3: 1.66e+04 usec per loop

and occasionally 1.65 or 1.67 instead of 1.66 for either or both,
whether with 10,000 or 100,000 loops.  (Not sure whether your
observations about the reduce-based approach becoming faster with more
loops may be due to anomalies in Windows' scheduler, or the accidental
regularities mentioned above; my timings are probably more regular since
I have two cores, one of which probably ends up dedicated to whatever
task I'm benchmarking while the other one runs all "background" stuff).

> turn indicates that both implementations actually work about same and
> your "O(n squared)" argument is irrelevant.

It's indeed irrelevant when the behavior _isn't_ quadratic (as in the
case of intersections) -- but unfortunately it _is_ needlessly quadratic
in most interesting cases involving containers (catenation of sequences,
union of sets, merging of dictionaries, merging of priority-queues,
...), because in those cases the intermediate temporary values tend to
grow, as I tried to explain in more detail above.


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


Re: yet another indentation proposal

2007-08-19 Thread Alex Martelli
Paddy <[EMAIL PROTECTED]> wrote:
   ...
> Can screen reaaderss be customized?

Open-source ones surely can (e.g., NVDA is an open-source reader for
Windows written in Python,  -- alas, if
you search for NVDA Google appears to be totally convinced you mean
NVidia instead, making searches pretty useless, sigh).

> Maybe their is a way to get the screen reader to say indent and dedent
> at thee appropriate places?

There definitely should be.

> Or maybe a filter to put those wordds into the source?

.../Tools/scripts/pindent.py (comes with the Python source distribution,
and I hope that, like the whole Tools directory, it would also come with
any sensible packaged Python distribution) should already be sufficient
for this particular task.  The "indent" always happens (in correct
Python sources) on the next line after one ending with a colon;
pindent.py can add or remove "block-closing comments" at each dedent
(e.g., "# end for" if the dedent is terminating a for-statement), and
can adjust the indentation to make it correct if given a Python source
with such block-closing comments but messed-up indentation.


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


Re: yet another indentation proposal

2007-08-19 Thread Aaron
"Paddy" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
>
> Oh wow. it never crossed my mind...
>
> Can screen reaaderss be customized?
> Maybe their is a way to get the screen reader to say indent and dedent
> at thee appropriate places?
> Or maybe a filter to put those wordds into the source?
>
> - Paddy.
>


Interestingly enough, there is a feature in my screenreader that purports to 
do just that, but it has proven unreliable at best.  I think a filter to 
insert an indent indicator at the beginning of each line would not be too 
practical, as it would make copy and paste operations from one indentation 
level to another rather tedious (you'd have to add or remove one or more 
indicators from each line of code).

Finally, just to be clear, I do not want to change the way 99.9% of Python 
code is written.  I feel that the indentation model is a good one for 99.9% 
of users.  What I do want to do is simply give the Python interpreter a tiny 
bit more flexibility to handle code from users or environments where 
indentation is not possible or practical.

Aaron


-- 
To reply directly, remove j's from email address. 



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


Re: Hot subject: a good python editor and/or IDE?

2007-08-19 Thread Wildemar Wildenburger
Buchoux Sébastien wrote:
> Yeah, I know this is a FAQ, but, as you mention, there is a whole bunch 
> of editors, every one of them being updated constantly (+ the new ones 
> getting out). So I am quite sure that looking through the archives is 
> THE solution since it will only reflect what people thought when 
> question was asked. Just type "best Python editor" on Google and you 
> will see that almost all hits are completely out of date.
> Fair enough though! ;)
>   
Well, since this question pops up about once a *week* on this list, 
chances are the most recent replies are not outdated. Just search this 
group instead of the whole web.

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


Re: How to make a module function visible only inside the module?

2007-08-19 Thread beginner
On Aug 19, 7:45 am, Bjoern Schliessmann  wrote:
> beginner wrote:
> > Thanks a lot. I was using two underscores, __module_method() as my
> > static method convention, and then I had some problems calling
> > them from inside class methods.
>
> *Please* do yourself and other people that sometime may have to read
> your code a favor and write code at least loosely oriented to
> PEP 8.
>
> BTW, Python has no "static methods" at module level. And I suppose
> what you call "class methods" actually aren't.
>
> Regards,
>
> Björn
>
> --
> BOFH excuse #183:
>
> filesystem not big enough for Jumbo Kernel Patch

I just started learning the language. I wasn't aware of the PEP.

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

Re: "Variable variable name" or "variable lvalue"

2007-08-19 Thread inmmike
On Aug 15, 1:42 pm, mfglinux <[EMAIL PROTECTED]> wrote:
> Hello to everybody
>
> I would like to know how to declare in python a "variable name" that
> it is in turn a variable
> In bash shell I would wrote sthg like:
>
> for x in `seq 1 3`
> do
>   M$i=Material(x)  #Material is a python class
> done
>
> Why I need this? Cause I have a python module that obliges me to build
> a variable called Period, which should have a variable name of
> summands (depends on the value of x)
>
> #Let's say x=3, then Period definition is
> Period=Slab(Material1(12.5)+Material2(25)+Material3(12.5)) #Slab is a
> python class
>
> I dont know how to automatize last piece of code for any x
>
> thank you
>
> Marcos

Regardless of whether or not this is a "best practice" sometimes it is
necessary. For example, I am looping through a dictionary to set some
class properties. Anyway, here is what I finally came up with:

exec "self.%s = '%s'" % (item, plist[item])

A more simple example for setting a variable outside of a class...

exec '%s = '%s'" % ('variableName', 'variable value')

Cheers!
Mike

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


Re: How to setup pyOpenGL3.0.a6 for window xp?

2007-08-19 Thread Jason
On Aug 17, 6:42 pm, Carl Banks <[EMAIL PROTECTED]> wrote:
> Windows comes with OpenGL libraries.  However, before you can use
> OpenGL you'll need a package that can provide an OpenGL context, which
> PyOpenGL doesn't do (easily).
>
> PyGame is the typical choice for most uses.  If all you need is a
> simple window to draw on, this is the package you want.
>
> However, it doesn't (easily) work with common GUIs like GTK and Wx.
> If you want to use use OpenGL in a GUI app, then you'll want to find
> an "OpenGL canvas widget" for that GUI.
>
> Carl Banks

Sorry Carl, but I'm a bit confused with your third paragraph.  Do you
mean that PyGame doesn't work easily with Wx/GTK, or that OpenGL
doesn't work easily with Wx/GTK?

If it's the second, then I must disagree.  wxPython comes with an
OpenGL widget in the "wx.glcanvas" module.  The widget only requires
PyOpenGL.  The wxPython Demo shows how to set up and program the
widget quite easily.  Another example is at: "http://
aspn.activestate.com/ASPN/Cookbook/Python/Recipe/325392".

Unfortunately, I don't have much experience with PyGTK.  Their FAQ
does indicate that you need an extension to add OpenGL support.

  --Jason

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


Re: How to find script's directory

2007-08-19 Thread Jeffrey Froman
Papalagi Pakeha wrote:

> I guess I could do it with a little help of os.path.realpath() for all
> those cases where absolute or relative path was used. But how should I
> approach it when it's invoked as plain 'blah.py' because its directory
> name is in $PATH?


Use the value of __file__ rather than sys.argv[0] -- it contains the
directory information. You may still need to normalize the value using
various os.path functions.


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


Sorting a list of Unicode strings?

2007-08-19 Thread [EMAIL PROTECTED]
Hey Guys,

Maybe I'm missing something fundamental here, but if I have a list of
Unicode strings, and I want to sort these alphabetically, then it
places those that begin with unicode characters at the bottom. Is
there a way to avoid this, and make it sort them properly?

I'm sure that this is the "proper way" programatically with character
entities etc. - but when I have a list of countries, and I have Åland
Islands right at the bottom, it just doesn't look right.

Any help would be really appreciated.

Thanks,
Oliver

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


Re: Sorting a list of Unicode strings?

2007-08-19 Thread Stefan Behnel
[EMAIL PROTECTED] wrote:
> Hey Guys,

... and girls - maybe ...


> Maybe I'm missing something fundamental here, but if I have a list of
> Unicode strings, and I want to sort these alphabetically, then it
> places those that begin with unicode characters at the bottom.

That's because "Unicode" is more than one alphabet. unicode objects compare
based on the Unicode character value, so sort() does alike.

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


Re: Sorting a list of Unicode strings?

2007-08-19 Thread [EMAIL PROTECTED]
On Aug 19, 6:01 pm, Stefan Behnel <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > Hey Guys,
>
> ... and girls - maybe ...
>
> > Maybe I'm missing something fundamental here, but if I have a list of
> > Unicode strings, and I want to sort these alphabetically, then it
> > places those that begin with unicode characters at the bottom.
>
> That's because "Unicode" is more than one alphabet. unicode objects compare
> based on the Unicode character value, so sort() does alike.
>
> Stefan

Thanks for putting me right -- gals indeed!

Anyway, I know _why_ it does this, but I really do need it to sort
them correctly based on how humans would look at it.

Any ideas?

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


Re: "Variable variable name" or "variable lvalue"

2007-08-19 Thread Gary Herron
[EMAIL PROTECTED] wrote:
> On Aug 15, 1:42 pm, mfglinux <[EMAIL PROTECTED]> wrote:
>   
>> Hello to everybody
>>
>> I would like to know how to declare in python a "variable name" that
>> it is in turn a variable
>> In bash shell I would wrote sthg like:
>>
>> for x in `seq 1 3`
>> do
>>   M$i=Material(x)  #Material is a python class
>> done
>>
>> Why I need this? Cause I have a python module that obliges me to build
>> a variable called Period, which should have a variable name of
>> summands (depends on the value of x)
>>
>> #Let's say x=3, then Period definition is
>> Period=Slab(Material1(12.5)+Material2(25)+Material3(12.5)) #Slab is a
>> python class
>>
>> I dont know how to automatize last piece of code for any x
>>
>> thank you
>>
>> Marcos
>> 
>
> Regardless of whether or not this is a "best practice" sometimes it is
> necessary. For example, I am looping through a dictionary to set some
> class properties. Anyway, here is what I finally came up with:
>
> exec "self.%s = '%s'" % (item, plist[item])
>   
Yuck!  Not at all necessary.  Use setattr instead:

   setattr(self, item, plist[item])

That's much cleaner then an exec or eval.  You may also find getattr and
hasattr useful.

Gary Herron



> A more simple example for setting a variable outside of a class...
>
> exec '%s = '%s'" % ('variableName', 'variable value')
>
> Cheers!
> Mike
>
>   

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


Re: Hot subject: a good python editor and/or IDE?

2007-08-19 Thread Diez B. Roggisch
Buchoux Sébastien schrieb:
> Bjoern Schliessmann wrote:
>> Sébastien wrote:
>>  
>>> I am currently using Eclipse+PyDev when developping Python
>>> projects but I lack a fast, simple editor for tiny bit of scripts.
>>> So here is my question: what is, for you, the current best ( but
>>> still kind of light! ) Python editor/IDE ?
>>> 
>>
>> vim
>>
>> BTW, this is an FAQ. Please look through the archives for many
>> threads with many, many IDEs.
>>
>> Regards,
>>
>>
>> Björn
>>
>>   
> Yeah, I know this is a FAQ, but, as you mention, there is a whole bunch 
> of editors, every one of them being updated constantly (+ the new ones 
> getting out). So I am quite sure that looking through the archives is 
> THE solution since it will only reflect what people thought when 
> question was asked. Just type "best Python editor" on Google and you 
> will see that almost all hits are completely out of date.
> Fair enough though! ;)

http://groups.google.de/group/comp.lang.python/browse_thread/thread/77285bd20fafbf2b/75bf35b712b1432b?lnk=st&q=python+editor+comp.lang.python&rnum=1#75bf35b712b1432b

Six weeks don't strike me as "completely out of date".

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


Re: imaplib & Received: header(s)???

2007-08-19 Thread Donn Cave
Quoth Petri Savolainen <[EMAIL PROTECTED]>:

| Is there a way to get at the "Received" header(s) or is there something 
| in imaplib or imap server implementations that hides these? If not, what 
| IMAP FETCH command should be used? I've used for example 
| "BODY[HEADER.FIELDS (RECEIVED)]" and it always returns empty ("\r\n"). 
| Despite the Received - header existing, as demonstrated by taking a look 
| at message sources via desktop email clients.
|
| I need to get at the Received-for header to figure out at which address 
| we received an email. We subscribe to a number of mailing lists using 
| per-mailing-list addresses, and often, To: field contains something else 
| than our address, thus the need for Received-for.
|
| Any help would be much appreciated - this is baffling me and I've not 
| found anything recent that would help.

"Anything recent"?  If you're getting IMAP advice from comp.lang.python,
I think it's fair to say you will need to be more resourceful.  The
RFC for IMAP4rev1 should be helpful.  I don't know the IMAP to get a
single header field, but my guess is that your error is there.  Can you
retrieve other fields that way?  Does the one you're looking for appear
in the data if you get the whole header, for example with 'RFC822.HEADER'?
It certainly does in my Python IMAP client, and this would have at least
helped you refine your question.

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


Re: Development for dual core machine

2007-08-19 Thread Paul Rubin
Andy <[EMAIL PROTECTED]> writes:
> >From what I read, I think that simply by making the package run in
> several separate processes (web server, database server, Python
> interpreter, etc.), and/or using multiple threads (which I will
> anyway) the package should be able to use multiple CPUs.

Python threading doesn't support multiple CPU's because of the GIL.

One approach to using your multiple cores is to embed a Python
interpreter into a web server that runs in multiple processes,
e.g. mod_python under Apache.

Another is write your application as a separate process (e.g.  as an
FastCGI), then run multiple instances of it, connected to a concurrent
web server.  For what I'm currently doing, we're using lighthttpd as
the http server and flup to connect to a set of Python FCGI's.

For that matter, if your machine is just dual core, maybe it's ok to
just run a single Python process, figuring that will run on one core
and your database/httpd will run on the other one.  However, you
should figure the dual core situation won't last.  Dual socket
motherboards are fairly cheap these days, so we have a number of
4-core machines (two AMD dual core cpu's); Intel is already shipping
quad core cpu's, so that puts 8 cores in a dual socket board (you can
already buy Macintoshes configured that way).  Higher end server
motherboards have 4 sockets, so you have to expect that 16-core
servers will be common pretty soon.

So if you're working on a cpu-intensive application it's worth your
while figuring out how to parallelize it.

Note that the most careful concurrency stuff probably is in the
database.  Serious ones already know how to use multiple CPU's.
-- 
http://mail.python.org/mailman/listinfo/python-list


Latest models of Gibson guitars

2007-08-19 Thread mobilendd
Reviews of latest models of best guitars, fender, gibson, yamaha, and
many more, with pictures and prices.

http://pro-guitars.blogspot.com/


And if you want to win a free guitar go here

http://freeguitars.blogspot.com/

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


Re: How to find script's directory

2007-08-19 Thread Tuomas
#!/usr/bin/python
# module show_my_path
# ...
import os
print 'os.path.abspath(__file__):', os.path.abspath(__file__)
# ...
# end of module

[EMAIL PROTECTED] class]$ python
 >>> import show_my_path
os.path.abspath(__file__): /misc/proc/py/test/class/show_my_path.py
 >>>
[EMAIL PROTECTED] class]$ python show_my_path.py
os.path.abspath(__file__): /misc/proc/py/test/class/show_my_path.py
-- 
http://mail.python.org/mailman/listinfo/python-list


A/C Systems!

2007-08-19 Thread Cartuners
Everything you need to know about car air conditioners...

http://car-air-conditioning.blogspot.com/

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


Re: A/C Systems!

2007-08-19 Thread carairconditionersmail
On Aug 19, 7:39 pm, [EMAIL PROTECTED] wrote:
> Everything you need to know about car air conditioners...
>
> http://car-air-conditioning.blogspot.com/

Great website man, I found everything I need

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


ctypes and unsigned char*

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

can anybody with ctypes experience tell me, how to handle a C function
that returns an unsigned char*? Obviously it is not a restype of
c_char_p.

Best regards,
Oliver

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


Re: yet another indentation proposal

2007-08-19 Thread O.R.Senthil Kumaran
Hi Aaron,

> Finally, just to be clear, I do not want to change the way 99.9% of Python 
> code is written.  I feel that the indentation model is a good one for 99.9% 
> of users.  What I do want to do is simply give the Python interpreter a tiny 
> bit more flexibility to handle code from users or environments where 
> indentation is not possible or practical.

It never crossed my mind about the problem you have mentioned.
The indentation proposal that you have put forth is infact a beaten up one, and 
I think, python gurus did not subscribe to it. Your requirement, in fact 
requests to look at it from a new perspective. 
We got to figure out what the different ways in which this issue can be 
handled.a) Screen Reader Clients. Can Screen Reader have a plugin, that will 
overlay a brackets to the indented code. ?
b) How does software like voicecode handle the scenario?
c) Have you spoken to other python programmers like you? I can remember 'Peter 
Lundblad' who works on 'svn' and I kind of feel that he must have worked on 
Python as well. They will be your best guide, IMHO.

>From a normal user perspective, I can feel that addition of _{ and _} to the 
>language proper is not going to be acceptable by many users/programmers.


-- 
O.R.Senthil Kumaran
http://uthcode.sarovar.org
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A/C Systems!

2007-08-19 Thread Torrey Hills
On Aug 19, 10:42 am, [EMAIL PROTECTED] wrote:
> On Aug 19, 7:39 pm, [EMAIL PROTECTED] wrote:
>
> > Everything you need to know about car air conditioners...
>
> >http://car-air-conditioning.blogspot.com/
>
> Great website man, I found everything I need

A lot of wonderful tips. Thanks.

Ken


Opportunities are never lost. The other fellow takes those you miss.


| Torrey Hills Technologies, LLC|
| www.threerollmill.com|
| www.torreyhillstech.com |



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


Re: How to setup pyOpenGL3.0.a6 for window xp?

2007-08-19 Thread Gary Herron
Jason wrote:
> On Aug 17, 6:42 pm, Carl Banks <[EMAIL PROTECTED]> wrote:
>   
>> Windows comes with OpenGL libraries.  However, before you can use
>> OpenGL you'll need a package that can provide an OpenGL context, which
>> PyOpenGL doesn't do (easily).
>>
>> PyGame is the typical choice for most uses.  If all you need is a
>> simple window to draw on, this is the package you want.
>> 
If you want an *easy* way to create an OpenGL window and context, you
could try FLTK, and it's Python wrapper PyFLTK.  It's a simple (nice,
very small, well featured and consistent) widget toolkit with OpenGL
support.  Once the window is open, PyOpenGL (versions 2xx or 3xx) work
perfectly on the window.

See http://www.fltk.org/

Gary Herron



>> However, it doesn't (easily) work with common GUIs like GTK and Wx.
>> If you want to use use OpenGL in a GUI app, then you'll want to find
>> an "OpenGL canvas widget" for that GUI.
>>
>> Carl Banks
>> 
>
> Sorry Carl, but I'm a bit confused with your third paragraph.  Do you
> mean that PyGame doesn't work easily with Wx/GTK, or that OpenGL
> doesn't work easily with Wx/GTK?
>
> If it's the second, then I must disagree.  wxPython comes with an
> OpenGL widget in the "wx.glcanvas" module.  The widget only requires
> PyOpenGL.  The wxPython Demo shows how to set up and program the
> widget quite easily.  Another example is at: "http://
> aspn.activestate.com/ASPN/Cookbook/Python/Recipe/325392".
>
> Unfortunately, I don't have much experience with PyGTK.  Their FAQ
> does indicate that you need an extension to add OpenGL support.
>
>   --Jason
>
>   

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


Re: Sorting a list of Unicode strings?

2007-08-19 Thread Alex Martelli
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
   ...
> > > Maybe I'm missing something fundamental here, but if I have a list of
> > > Unicode strings, and I want to sort these alphabetically, then it
> > > places those that begin with unicode characters at the bottom.
   ...
> Anyway, I know _why_ it does this, but I really do need it to sort
> them correctly based on how humans would look at it.

Depending on the nationality of those humans, you may need very
different sorting criteria; indeed, in some countries, different sorting
criteria apply to different use cases (such as sorting surnames versus
sorting book titles, etc; sorry, I don't recall specific examples, but
if you delve on sites about i18n issues you'll find some).

In both Swedish and Danish, I believe, A-with-ring sorts AFTER the
letter Z in the alphabet; so, having Åaland (where I'm using Aa for
A-with-ring, since this newsreader has some problem in letting me enter
non-ascii characters;-) sort "right at the bottom", while it "doesn't
look right" to YOU (maybe an English-speaker?) may look right to the
inhabitants of that locality (be they Danes or Swedes -- but I believe
Norwegian may also work similarly in terms of sorting).

The Unicode consortium does define a standard collation algorithm (UCA)
and table (DUCET) to use when you need a locale-independent ordering; at

you'll be able to obtain James Tauber's Python implementation of UCA, to
work with the DUCET found at
.

I suspect you won't like the collation order you obtain this way, but
you might start from there, subsetting and tweaking the DUCET into an
OUCET (Oliver Unicode Collation Element Table;-) that suits you better.

A simpler, rougher approach, if you think the "right" collation is
obtained by ignoring accents, diacritics, etc (even though the speakers
of many languages that include diacritics, &c, disagree;-) is to use the
key=coll argument in your sorting call, passing a function coll that
maps any Unicode string to what you _think_ it should be like for
sorting purposes.  The .translate method of Unicode string objects may
help there: it takes a dict mapping Unicode ordinals to ordinals or
string (or None for characters you want to delete as part of the
translation).

For example, suppose that what we want is the following somewhat silly
collation: we only care about ISO-8859-1 characters, and want to ignore
for sorting purposes any accent (be it grave, acute or circumflex),
umlauts, slashes through letters, tildes, cedillas.  htmlentitydefs has
a useful dict called codepoint2name that helps us identify those "weirdy
decorated foreign characters".

def make_transdict():
import htmlentitydefs
cp2n = htmlentitydefs.codepoint2name
suffixes = 'acute crave circ uml slash tilde cedil'.split()
td = {}
for x in range(128, 256):
if x not in cp2n: continue
n = cp2n[x]
for s in suffixes:
if n.endswith(s):
td[x] = unicode(n[-len(s)])
break
return td

def coll(us, td=make_transdict()):
return us.translate(td)

listofus.sort(key=coll)


I haven't tested this code, but it should be reasonably easy to fix any
problems it might have, as well as making make_transdict "richer" to
meet your goals.  Just be aware that the resulting collation (e.g.,
sorting a-ring just as if it was a plain a) will be ABSOLUTELY WEIRD to
anybody who knows something about Scandinavian languages...!!!-)


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


Re: Parser Generator?

2007-08-19 Thread Jack
Thanks for the suggestion. I understand that more work is needed for natural 
language
understanding. What I want to do is actually very simple - I pre-screen the 
user
typed text. If it's a simple syntax my code understands, like, Weather in 
London, I'll
redirect it to a weather site. Or, if it's "What is ... " I'll probably 
redirect it to wikipedia.
Otherwise, I'll throw it to a search engine. So, extremelyl simple stuff ...

"samwyse" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Jack wrote:
>> Thanks for all the replies!
>>
>> SPARK looks promising. Its doc doesn't say if it handles unicode
>> (CJK in particular) encoding though.
>>
>> Yapps also looks powerful: http://theory.stanford.edu/~amitp/yapps/
>>
>> There's also PyGgy http://lava.net/~newsham/pyggy/
>>
>> I may also give Antlr a try.
>>
>> If anyone has experiences using any of the parser generators with CJK
>> languages, I'd be very interested in hearing that.
>
> I'm going to echo Tommy's reply.  If you want to parse natural language, 
> conventional parsers are going to be worse than useless (because you'll 
> keep thinking, "Just one more tweak and this time it'll work for sure!"). 
> Instead, go look at what the interactive fiction community uses.  They 
> analyse the statement in multiple passes, first picking out the verbs, 
> then the noun phrases.  Some of their parsers can do on-the-fly 
> domain-specific spelling correction, etc, and all of them can ask the user 
> for clarification.  (I'm currently cobbling together something similar for 
> pre-teen users.) 


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


Python on Computation, Math and Statistics

2007-08-19 Thread W. Watson
I would hope Python is doing a lot of standard computations beyond 
arithmetic. Trig functions and more. Comments?
-- 
  Wayne Watson (Nevada City, CA)

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


Re: Hot subject: a good python editor and/or IDE?

2007-08-19 Thread math2life
On Aug 19, 2:47 am, Sébastien <[EMAIL PROTECTED]> wrote:
> Hi folks,
>
> I am currently using Eclipse+PyDev when developping Python projects but
> I lack a fast, simple editor for tiny bit of scripts. So here is my
> question: what is, for you, the current best ( but still kind of light!
> ) Python editor/IDE ? A tiny precision, I am on Ubuntu so I am looking
> for a linux compatible editor.
>
> Cheers,
>
> Sébastien

I use SPE which is simple.

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


Re: ctypes and unsigned char*

2007-08-19 Thread Diez B. Roggisch
[EMAIL PROTECTED] schrieb:
> Hi,
> 
> can anybody with ctypes experience tell me, how to handle a C function
> that returns an unsigned char*? Obviously it is not a restype of
> c_char_p.

 From the docs:

c_ubyte

 Represents the C unsigned char datatype, it interprets the value as 
small integer. The constructor accepts an optional integer initializer; 
no overflow checking is done.



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


Re: Python on Computation, Math and Statistics

2007-08-19 Thread Diez B. Roggisch
W. Watson schrieb:
> I would hope Python is doing a lot of standard computations beyond 
> arithmetic. Trig functions and more. Comments?

Bad google day?

http://docs.python.org/lib/numeric.html

Additionally, there are several scientific extensions, like SciPy, 
Numeric/Numpy and so forth.


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


Re: ctypes and unsigned char*

2007-08-19 Thread Gabriel Genellina
On 19 ago, 14:44, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> Hi,
>
> can anybody with ctypes experience tell me, how to handle a C function
> that returns an unsigned char*? Obviously it is not a restype of
> c_char_p.

Being signed or unsigned is not important here. But you have to
disambiguate "returns an unsigned char*"
- the function returns a string of bytes (unsigned char), null-
terminated.
- the function returns a pointer to a single byte.

In the first case, use a plain c_char_p - the individual "chars" are
already unsigned in Python (that is, ord(xxx[i]) is always positive)
In the second case, first define the pointer type:

c_ubyte_p = POINTER(c_ubyte)
your_function.restype = c_ubyte_p

--
Gabriel Genellina

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


Re: Latest models of Gibson guitars

2007-08-19 Thread vedrandekovic
On 19 kol, 19:34, [EMAIL PROTECTED] wrote:
> Reviews of latest models of best guitars, fender, gibson, yamaha, and
> many more, with pictures and prices.
>
> http://pro-guitars.blogspot.com/
>
> And if you want to win a free guitar go here
>
> http://freeguitars.blogspot.com/

Hello,

This is  a newsgroup of programming language Python, stop with this!

Regards,
Vedran

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


Re: Latest models of Gibson guitars

2007-08-19 Thread Diez B. Roggisch
> Hello,
> 
> This is  a newsgroup of programming language Python, stop with this!


And by fully citing the message including the links, you increase the 
visibility of the spammers site. Don't do that.


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


Re: How to make a module function visible only inside the module?

2007-08-19 Thread Gabriel Genellina
On 18 ago, 22:46, beginner <[EMAIL PROTECTED]> wrote:
> On Aug 18, 8:27 pm, [EMAIL PROTECTED] (Lawrence Oluyede) wrote:
> > beginner <[EMAIL PROTECTED]> wrote:

> > > Is there any equivalent version of C's static function in Python. I
> > > know I can make a class function private by starting a function name
> > > with two underscores, but it does not work with module functions.
> > > For exmaple, __func1 is still visible outside the module.
>
> > Yes, and _f() will also be. There's no such thing as enforcing
> > encapsulation in Python, even the "__method()" trick can be easily
> > bypassed if you have to.
>
> Thanks a lot. I was using two underscores, __module_method() as my
> static method convention, and then I had some problems calling them
> from inside class methods.- Ocultar texto de la cita -

The convention is to use a single leading underscore _f to indicate
private things.
When you see something like:

from some_module import _function

you know you are messing with internal stuff.

There is another form of import:

from some_module import *

that will import all public names defined in some_module, into the
current namespace. By default, the public names are all names not
beginning with "_" - but you can customize it defining __all__ which
must be the list of public names. (Note that this form of import is
strongly discouraged).
For more info, see the Reference Manual: 

--
Gabriel Genellina

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


Re: Python on Computation, Math and Statistics

2007-08-19 Thread W. Watson
Google? What's that? Thanks. I like to get a insider's view when I know 
experts are out there. So now I ask a deeper question. Are there matrix 
computation libraries or even statistical (regression, factor analysis) 
libraries?

Diez B. Roggisch wrote:
> W. Watson schrieb:
>> I would hope Python is doing a lot of standard computations beyond 
>> arithmetic. Trig functions and more. Comments?
> 
> Bad google day?
> 
> http://docs.python.org/lib/numeric.html
> 
> Additionally, there are several scientific extensions, like SciPy, 
> Numeric/Numpy and so forth.
> 
> 
> Diez

-- 
  Wayne Watson (Nevada City, CA)

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


Re: Overriding Thread.join in derived class.

2007-08-19 Thread Gabriel Genellina
On 18 ago, 04:31, Graham Dumpleton <[EMAIL PROTECTED]> wrote:

> If one creates a thread using threading.Thread and makes it a daemon
> by calling setDaemon(), then when Python is exiting it will not
> attempt to call join() on that thread and wait for it to complete
> first. [...]
> End result is that it could result in a Python exception at some
> point, evidenced by messages starting with:
> Exception in thread Thread-1 (most likely raised during interpreter
> shutdown) [...]
>
> In order to avoid this, do people think that as an alternative to
> creating daemonised thread that it would be reasonable to create a
> derived Thread class for the particular task which overrides
> Thread.join() method to set some flag or otherwise take some action
> that the thread would notice to tell it to stop, and then call base
> class Thread.join().
>
> This way you can flag the thread to shutdown automatically when Python
> is going around calling join() on non daemonised threads.
>
> Or am I missing the obvious as far as ways of flagging threads to tell
> them to stop?
>
> Note that this is where Python is being used embedded in a C program.
> There is no Python main function where code can be put to signal
> threads to otherwise stop.

This last statement is important. You need "some" way to tell the
threads to stop working. Usually the thread's run() method is a big
loop; you need to tell it somehow to exit the loop. By example, if you
are using a Queue, put a sentinel object in it; or use an Event
object; or at least a global variable.
Overriding thread.join() as you suggest above may be a good place to
do that, if you don't have another chance.

--
Gabriel Genellina

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


Re: Python on Computation, Math and Statistics

2007-08-19 Thread Diez B. Roggisch
W. Watson schrieb:
> Google? What's that? Thanks. I like to get a insider's view when I know 
> experts are out there. So now I ask a deeper question. Are there matrix 
> computation libraries or even statistical (regression, factor analysis) 
> libraries?

That's your idea of an "in depth question"?

Did you even consider googling the projects I told you about? Reading up 
on them just the tiniest?

http://www.scipy.org/

"""
SciPy (pronounced "Sigh Pie") is open-source software for mathematics, 
science, and engineering. It is also the name of a very popular 
conference on scientific programming with Python. The SciPy library 
depends on NumPy, which provides convenient and fast N-dimensional array 
manipulation. The SciPy library is built to work with NumPy arrays, and 
provides many user-friendly and efficient numerical routines such as 
routines for numerical integration and optimization. Together, they run 
on all popular operating systems, are quick to install, and are free of 
charge. NumPy and SciPy are easy to use, but powerful enough to be 
depended upon by some of the world's leading scientists and engineers. 
If you need to manipulate numbers on a computer and display or publish 
the results, give SciPy a try!
"""

Or do you wish a comprehensive overview as Powerpoint presentation in 
your favorite colors?



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


Re: Latest models of Gibson guitars

2007-08-19 Thread Arne Vajhøj
[EMAIL PROTECTED] wrote:

[some spam deleted]

> This is  a newsgroup of programming language Python, stop with this!

Actually this was posted to a bunch of newsgroups of which one is
about python.

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


Re: Parser Generator?

2007-08-19 Thread Alex Martelli
Jack <[EMAIL PROTECTED]> wrote:

> Thanks for the suggestion. I understand that more work is needed for natural
> language
> understanding. What I want to do is actually very simple - I pre-screen the
> user
> typed text. If it's a simple syntax my code understands, like, Weather in
> London, I'll
> redirect it to a weather site. Or, if it's "What is ... " I'll probably
> redirect it to wikipedia.
> Otherwise, I'll throw it to a search engine. So, extremelyl simple stuff ...



"""
NLTK — the Natural Language Toolkit — is a suite of open source Python
modules, data sets and tutorials supporting research and development in
natural language processing.
"""


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

Re: Latest models of Gibson guitars

2007-08-19 Thread George
[EMAIL PROTECTED] wrote:
> On 19 kol, 19:34, [EMAIL PROTECTED] wrote:
>> Reviews of latest models of best guitars, fender, gibson, yamaha, and
>> many more, with pictures and prices.
>>
>> http://spam-guitars.blogspot.com/
>>
>> And if you want to win a free guitar go here
>>
>> http://spamguitars.blogspot.com/
> 
> Hello,
> 
> This is  a newsgroup of programming language Python, stop with this!
> 
> Regards,
> Vedran
> 

Thank Google for it. They own blogspot and officially encourage their 
users to look for click revenue. Then the users spam newsgroups using 
Google, the spammers friend.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A/C Systems!

2007-08-19 Thread Daniel Pitts
On Aug 19, 10:42 am, [EMAIL PROTECTED] wrote:
> On Aug 19, 7:39 pm, [EMAIL PROTECTED] wrote:
>
> > Everything you need to know about car air conditioners...
>
> >http://car-air-conditioning.spamspot.spam/
>
> Great website man, I found everything I need

Perhaps you did, after all, you advertise it all over. However, I fail
to see the relevance to a Java newsgroup.  Don't you know that
targeted advertising has far better return?

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


Re: Symbolic Link

2007-08-19 Thread mosscliffe
On 19 Aug, 13:16, samwyse <[EMAIL PROTECTED]> wrote:
> mosscliffewrote:
> > I am trying to create a link to a file, which I can then use in an
> > HTML page.
>
> > The system is Linux on a hosted web service, running python 2.3.
> > Other than that I have no knowledge of the system.
>
> > The link is created OK, but when I try to use it as filename for the
> > IMG TAG, it does not get displayed.  The page source of the created
> > page is pointing to the link as temp/test1.jpg
>
> What are you trying to do that you can't use the original file instead
> of creating a link?  There might be a way to side-step the entire problem.

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.

Thanks

Richard

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


Re: Latest models of Gibson guitars

2007-08-19 Thread Hermit

<[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Reviews of latest models of best guitars, fender, gibson, yamaha, and
> many more, with pictures and prices.
>
> http://pro-guitars.blogspot.com/
>
>
> And if you want to win a free guitar go here
>
> http://freeguitars.blogspot.com/
>

How does the image quality compare with a DSLR?



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


Re: 1)URL QueryString Parsing 2)Search Engine Spiders

2007-08-19 Thread mosscliffe
On 19 Aug, 13:54, samwyse <[EMAIL PROTECTED]> wrote:
> mosscliffewrote:
> > I am trying to create a back link, equivalent to the browser back
> > action and I can not use java script. The target user does not allow
> > java script.
>
> > I am using HTTP_REFERER.
>
> > I need to add the original Query String values.
>
> > Is there a way to get the QueryString element other than by using
> > cgi.FieldStorage, as I just want to return with the values that were
> > current in the calling page.
>
> > gv.orgQueryString = ""
>
> > gv.BackButton = ' > gv.orgQueryString + '">BACK'
>
> I'm not sure I understand your problem.  Does the above code not work?
>
> > Am I right in thinking Search Engine Spiders will never see my script
> > pages as they exist only for the duration of the python script's
> > execution ?  And even then as they are   xxx.py, they would not be
> > seen.
>
> Anyone who accesses your web server will see the pages that you serve.
> If you serve the xxx.py files, then they can be seen and indexed,
> otherwise they are invisible.

I currently have to build the query string from each field passed.  I
was hoping I could somehow just
split the query string. something like

TheQueryStribgBit = FullURL.split("&")

but I can't find a reference to FullURL with os.environ's

I apologise for my lack of clarity - the grey matter is getting a bit
long in the tooth.

Richard

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


Re: Python on Computation, Math and Statistics

2007-08-19 Thread Sebastian Bassi
On 8/19/07, W. Watson <[EMAIL PROTECTED]> wrote:
> Google? What's that? Thanks. I like to get a insider's view when I know
> experts are out there. So now I ask a deeper question. Are there matrix
> computation libraries or even statistical (regression, factor analysis)
> libraries?

If you are so inclined you can use R functions from Python (look for R
and Python in your favorite search engine).

-- 
Sebastián Bassi (セバスティアン)
Diplomado en Ciencia y Tecnología.
GPG Fingerprint: 9470 0980 620D ABFC BE63 A4A4 A3DE C97D 8422 D43D
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Hot subject: a good python editor and/or IDE?

2007-08-19 Thread Dick Moores
At 02:47 AM 8/19/2007, Sébastien wrote:
>Hi folks,
>
>I am currently using Eclipse+PyDev when developping Python projects but
>I lack a fast, simple editor for tiny bit of scripts. So here is my
>question: what is, for you, the current best ( but still kind of light!
>) Python editor/IDE ? A tiny precision, I am on Ubuntu so I am looking
>for a linux compatible editor.

I thought Ulipad WAS linux-compatible. Isn't it?

Dick Moores
XP, Python 2.5, editor is Ulipad



==
   Bagdad Weather
  

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


Re: Hot subject: a good python editor and/or IDE?

2007-08-19 Thread Bjoern Schliessmann
Buchoux Sébastien wrote:
> Yeah, I know this is a FAQ, but, as you mention, there is a whole
> bunch of editors, every one of them being updated constantly (+
> the new ones getting out). 

Are you really sure that you know the meaning of the
word "frequently"?

> So I am quite sure that looking through the archives is THE
> solution since it will only reflect what people thought when
> question was asked. Just type "best Python editor" on Google and
> you will see that almost all hits are completely out of date. Fair
> enough though! ;) 

I spoke of this MAILING LIST'S ARCHIVES, not of some web forum
you'll get with google.


Björn

-- 
BOFH excuse #119:

evil hackers from Serbia.

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


Re: Development for dual core machine

2007-08-19 Thread Bjoern Schliessmann
samwyse wrote:
> The Python interpreter is not multi-cpu aware, so using Python
> threads won't work on multiple CPUs.

Are you sure about this?

Regards,


Björn

-- 
BOFH excuse #12:

dry joints on cable plug

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


Re: Development for dual core machine

2007-08-19 Thread Bjoern Schliessmann
Paul Rubin wrote:

> Python threading doesn't support multiple CPU's because of the
> GIL.

:s/support/take full advantage of/

Regards,


Björn

-- 
BOFH excuse #46:

waste water tank overflowed onto computer

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


Re: Python on Computation, Math and Statistics

2007-08-19 Thread Paul McGuire
On Aug 19, 2:32 pm, "W. Watson" <[EMAIL PROTECTED]> wrote:
> Google? What's that? Thanks. I like to get a insider's view when I know
> experts are out there.

FYI the "insiders" and "experts" out there appreciate knowing that you
did a little work on your own before just posting questions. "I like
to get a insider's view when I know experts are out there" translates
to "My time is more valuable than other peoples', so I'll just ask
them to answer my questions instead of doing 5 minutes of digging for
myself."

Comments?  Here's mine: go away and come back after you've done some
homework.

-- Paul

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


Re: How to make a module function visible only inside the module?

2007-08-19 Thread Bjoern Schliessmann
beginner wrote:

> I just started learning the language. I wasn't aware of the PEP.

Mh, two postings before Lawrence already mentioned it.

I suggest looking through the BeginnersGuide.

http://wiki.python.org/moin/BeginnersGuide

Regards,


Björn

-- 
BOFH excuse #203:

Write-only-memory subsystem too slow for this machine. Contact your
local dealer.

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


Syntax Question - list multiplication

2007-08-19 Thread Pablo Torres
Hi guys!

I am working on Conway's Game of Life right now and I've run into a
little problem.
I represent dead cells with 0s and live ones with 1s. Check this out:

>>> grid = [[0] * 3] * 3
>>> grid
[[0, 0, 0], [0, 0, 0], [0, 0, 0]]
>>> grid[0][0] = 1
[[1, 0, 0], [1, 0, 0], [1, 0, 0]]

Now, that's not what I want. I just want the first element of the
first sublist to be a 1, not the first of every one. Here's what I
tried and didn't work:

0.  grid = [[0] * 3][:] * 3then the same grid[0][0] = 1 statement
1.  grid = [[0][:] * 3] * 3followed by the same assignment
2.  (grid[0])[0] = 1with the original initialization of the grid

So, that means that it isn't a problem with two different variables
refering to the same list (0. and 1. prove that). What I don't
understand is why 2. doesn't work either. I'm baby-feeding my
instructions to Python and the mistake is still there. Any ideas?

Hope you can help. Thanks in advance,

Pablo

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


Re: Syntax Question - list multiplication

2007-08-19 Thread MC
Classic

-- 
@-salutations

Michel Claveau


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


desperately in need of a tool

2007-08-19 Thread yagyala
Hi.

I recently started working for a company that has just implemented its
first set of software standards. So far, so good. Here's the problem:
one of those standards is that the comments for each routine must
indicate every other routine that it calls. As I try to keep my
routines small, and factor out methods alot, this can lead to an
enormous ammount of extra typing. I really, really, really don't want
to do this by hand. Does anyone know of a tool that could do this for
me, or at least a tool that can tell what other routines a given
routine calls that I could program against? (Preferably something that
works under pydev, but I'm not going to be choosy.)

I'm sure some will wonder about the reasoning of this standard. The
company primarily has experience writing scientific alogorythms which
can get rather long. It makes a bit more sense to document all
routines called for a very long routine, but for short routines that
primarily call other routines, as most mine do, well

Thanks.

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


Re: A problem with Time

2007-08-19 Thread Dick Moores
At 08:30 AM 8/16/2007, special_dragonfly wrote:
>Hello,
>
>I need to return the date yesterday in the form DDMM. I looked through
>the modules: time, datetime and calendar but can't find anything that leaps
>out at me.
>
>The problem I'm having is that although I can use time.localtime and get a
>tuple of the year, month, day and so forth, I don't believe I can just minus
>1 from the day, because I don't think it's cyclic, also, I can't see the
>date being linked in with the month.
>
>So is there any way of getting yesterdays date?

The question has already been well-answered, but since I've found 
using the datetime module to be tough going, I was wondering if 
either of these would be easier to understand and use:
1. 
I see that mxDateTime comes with a 55-page manual as a PDF.

2. 

Dick Moores




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


Re: How to setup pyOpenGL3.0.a6 for window xp?

2007-08-19 Thread Richard Jones
Gary Herron wrote:
> Jason wrote:
>> On Aug 17, 6:42 pm, Carl Banks <[EMAIL PROTECTED]> wrote:
>>   
>>> Windows comes with OpenGL libraries.  However, before you can use
>>> OpenGL you'll need a package that can provide an OpenGL context, which
>>> PyOpenGL doesn't do (easily).
>>>
>>> PyGame is the typical choice for most uses.  If all you need is a
>>> simple window to draw on, this is the package you want.
>>> 
> If you want an *easy* way to create an OpenGL window and context, you
> could try FLTK, and it's Python wrapper PyFLTK.

The simplest method by far uses pyglet from http://www.pyglet.org/

from pyglet import window
w = window.Window(200, 200)
while not w.has_exit:
w.dispatch_events()
... do OpenGL stuff

pyglet has no compilation and no dependencies and works on Linux, OS X and
Windows. You can use PyOpenGL with it just fine, or use its own gl layer
(which is intentionally less pythonic)


 Richard

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


Re: Python on Computation, Math and Statistics

2007-08-19 Thread Jaap Spies
W. Watson wrote:
> I would hope Python is doing a lot of standard computations beyond 
> arithmetic. Trig functions and more. Comments?

Try SAGE: http://www.sagemath.org/

Jaap


Permanents are here forever.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Syntax Question - list multiplication

2007-08-19 Thread Thomas Jollans
On Sunday 19 August 2007, Pablo Torres wrote:
> Hi guys!
>
> I am working on Conway's Game of Life right now and I've run into a
> little problem.
>
> I represent dead cells with 0s and live ones with 1s. Check this out:
>   >>> grid = [[0] * 3] * 3
>   >>> grid
>
>   [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
>
>   >>> grid[0][0] = 1
>
>   [[1, 0, 0], [1, 0, 0], [1, 0, 0]]
>
> Now, that's not what I want. I just want the first element of the
> first sublist to be a 1, not the first of every one. Here's what I
> tried and didn't work:
>
> 0.  grid = [[0] * 3][:] * 3then the same grid[0][0] = 1 statement
> 1.  grid = [[0][:] * 3] * 3followed by the same assignment
> 2.  (grid[0])[0] = 1with the original initialization of the grid
>
> So, that means that it isn't a problem with two different variables
> refering to the same list (0. and 1. prove that). What I don't
> understand is why 2. doesn't work either. I'm baby-feeding my
> instructions to Python and the mistake is still there. Any ideas?


If you want three copies of the list, you need to copy it thrice (well, twice)

Thus:

>>> row = [0] * 3
>>> grid = []
>>> for n in xrange(3): grid.append(row[:])
...
>>> grid
[[0, 0, 0], [0, 0, 0], [0, 0, 0]]
>>> grid[0][0] =1
>>> grid
[[1, 0, 0], [0, 0, 0], [0, 0, 0]]
>>>


-- 
  Regards,   Thomas Jollans
GPG key: 0xF421434B may be found on various keyservers, eg pgp.mit.edu
Hacker key :
v4sw6+8Yhw4/5ln3pr5Ock2ma2u7Lw2Nl7Di2e2t3/4TMb6HOPTen5/6g5OPa1XsMr9p-7/-6


signature.asc
Description: This is a digitally signed message part.
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Syntax Question - list multiplication

2007-08-19 Thread Roel Schroeven
Pablo Torres schreef:
> Hi guys!
> 
> I am working on Conway's Game of Life right now and I've run into a
> little problem.
> I represent dead cells with 0s and live ones with 1s. Check this out:
> 
>   >>> grid = [[0] * 3] * 3
>   >>> grid
>   [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
>   >>> grid[0][0] = 1
>   [[1, 0, 0], [1, 0, 0], [1, 0, 0]]
> 
> Now, that's not what I want. I just want the first element of the
> first sublist to be a 1, not the first of every one. Here's what I
> tried and didn't work:
> 
> 0.  grid = [[0] * 3][:] * 3then the same grid[0][0] = 1 statement
> 1.  grid = [[0][:] * 3] * 3followed by the same assignment
> 2.  (grid[0])[0] = 1with the original initialization of the grid
> 
> So, that means that it isn't a problem with two different variables
> refering to the same list (0. and 1. prove that). What I don't
> understand is why 2. doesn't work either. I'm baby-feeding my
> instructions to Python and the mistake is still there. Any ideas?
> 
> Hope you can help. Thanks in advance,

The multiplication operator doesn't make new copies; all elements 
reference the same object, as you can see with id():

 >>> lst = [0] * 3
 >>> lst
[0, 0, 0]
 >>> id(lst[0]), id(lst[1]), id(lst[2])
(9788716, 9788716, 9788716)

As a consequence, if you modify one element, you change them all (since 
it's all the same object). Solution: make sure to create independent lists.

 >>> grid = [[0] * 3 for i in range(3)]
 >>> grid
[[0, 0, 0], [0, 0, 0], [0, 0, 0]]
 >>> grid[0][0] = 1

-- 
If I have been able to see further, it was only because I stood
on the shoulders of giants.  -- Isaac Newton

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


Re: Python on Computation, Math and Statistics

2007-08-19 Thread W. Watson
Thanks. I appreciate the info.

Diez B. Roggisch wrote:
> W. Watson schrieb:
>> Google? What's that? Thanks. I like to get a insider's view when I 
>> know experts are out there. So now I ask a deeper question. Are there 
>> matrix computation libraries or even statistical (regression, factor 
>> analysis) libraries?
> 
> That's your idea of an "in depth question"?
> 
> Did you even consider googling the projects I told you about? Reading up 
> on them just the tiniest?
> 
> http://www.scipy.org/
> 
> """
> SciPy (pronounced "Sigh Pie") is open-source software for mathematics, 
> science, and engineering. It is also the name of a very popular 
> conference on scientific programming with Python. The SciPy library 
> depends on NumPy, which provides convenient and fast N-dimensional array 
> manipulation. The SciPy library is built to work with NumPy arrays, and 
> provides many user-friendly and efficient numerical routines such as 
> routines for numerical integration and optimization. Together, they run 
> on all popular operating systems, are quick to install, and are free of 
> charge. NumPy and SciPy are easy to use, but powerful enough to be 
> depended upon by some of the world's leading scientists and engineers. 
> If you need to manipulate numbers on a computer and display or publish 
> the results, give SciPy a try!
> """
> 
> Or do you wish a comprehensive overview as Powerpoint presentation in 
> your favorite colors?
> 
> 
> 
> Diez

-- 
  Wayne Watson (Nevada City, CA)

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


Re: Python on Computation, Math and Statistics

2007-08-19 Thread W. Watson
Thanks.

Paul McGuire wrote:
> On Aug 19, 2:32 pm, "W. Watson" <[EMAIL PROTECTED]> wrote:
>> Google? What's that? Thanks. I like to get a insider's view when I know
>> experts are out there.
> 
> FYI the "insiders" and "experts" out there appreciate knowing that you
> did a little work on your own before just posting questions. "I like
> to get a insider's view when I know experts are out there" translates
> to "My time is more valuable than other peoples', so I'll just ask
> them to answer my questions instead of doing 5 minutes of digging for
> myself."
> 
> Comments?  Here's mine: go away and come back after you've done some
> homework.
> 
> -- Paul
> 

-- 
  Wayne Watson (Nevada City, CA)

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


Re: Python on Computation, Math and Statistics

2007-08-19 Thread W. Watson
Thanks. That looks interesting.

Jaap Spies wrote:
> W. Watson wrote:
>> I would hope Python is doing a lot of standard computations beyond 
>> arithmetic. Trig functions and more. Comments?
> 
> Try SAGE: http://www.sagemath.org/
> 
> Jaap
> 
> 
> Permanents are here forever.

-- 
  Wayne Watson (Nevada City, CA)

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


Re: Latest models of Gibson guitars

2007-08-19 Thread thebjorn
On Aug 19, 8:41 pm, [EMAIL PROTECTED] wrote:
> On 19 kol, 19:34, [EMAIL PROTECTED] wrote:
>
[spam]
>
> Hello,
>
> This is  a newsgroup of programming language Python, stop with this!
>
> Regards,
> Vedran

As someone else pointed out, this is more widely disseminated than
just c.l.py. If you feel the need to do something about the post, and
you're using Google groups, there's a "More options" link in the top
right corner of every post where you can report it as spam. That might
be marginally more effective than trying to chastise a spammer for
being off-topic (it's what they do) -- at least it won't degrade the
signal/noise ratio further.

-- bjorn

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


Re: desperately in need of a tool

2007-08-19 Thread Chris Mellon
On 8/19/07, yagyala <[EMAIL PROTECTED]> wrote:
> Hi.
>
> I recently started working for a company that has just implemented its
> first set of software standards. So far, so good. Here's the problem:
> one of those standards is that the comments for each routine must
> indicate every other routine that it calls. As I try to keep my
> routines small, and factor out methods alot, this can lead to an
> enormous ammount of extra typing. I really, really, really don't want
> to do this by hand. Does anyone know of a tool that could do this for
> me, or at least a tool that can tell what other routines a given
> routine calls that I could program against? (Preferably something that
> works under pydev, but I'm not going to be choosy.)
>
> I'm sure some will wonder about the reasoning of this standard. The
> company primarily has experience writing scientific alogorythms which
> can get rather long. It makes a bit more sense to document all
> routines called for a very long routine, but for short routines that
> primarily call other routines, as most mine do, well
>
> Thanks.
>

To the extent that it's useful to do this at all in Python (dynamic
method invocation is impossible determine, and polymorphic method
invocations you can't pinpoint), pycallgraph
(http://pycallgraph.slowchop.com/) can do this.

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


Can I add methods to built in types with classes?

2007-08-19 Thread CC
Hi:

I've gotten through most of the "9. Classes" section of the tutorial.  I 
can deal with the syntax.  I understand the gist of what it does enough 
that I can play with it.  But am still a long way from seeing how I can 
use this OOP stuff.

But I have one idea.  Not that the functional approach isn't workable, 
but I have a situation where I need to test if all the characters in a 
string are in the set of hexadecimal digits.

So I wrote:
--
from string import hexdigits

def ishex(word):
 for d in word:
 if d not in hexdigits: return(False)
 else return(True)
--

Then I can do this to check if a string is safe to pass to the int() 
function without raising an exception:

if ishex(string):
 value = int(string, 16)

But can I create a class which inherits the attributes of the string 
class, then add a method to it called ishex()?  Then I can do:

if string.ishex():
 value = int(string, 16)

The thing is, it doesn't appear that I can get my hands on the base 
class definition/name for the string type to be able to do:

---
class EnhancedString(BaseStringType):
 def ishex(self):
 for d in word:
 if d not in hexdigits: return(False)
 else return(True)
---

Thanks.



-- 
_
Christopher R. Carlen
[EMAIL PROTECTED]
SuSE 9.1 Linux 2.6.5
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Can I add methods to built in types with classes?

2007-08-19 Thread Scott David Daniels
CC wrote:
> ... But am still a long way from seeing how I can use this OOP stuff.
> ... I wrote:
> from string import hexdigits
> def ishex(word):
> for d in word:
> if d not in hexdigits: return(False)
> else return(True)
> Then I can do this to check if a string is safe to pass to the int() 
> function without raising an exception:
> if ishex(string):
> value = int(string, 16)

The Pythonic way to do this is simply:
   try:
   value = int(string, 16)
   except ValueError:
   

> ... Can I create a class which inherits the attributes of the string 
> class, then add a method to it called ishex()? ...
 > The thing is, it doesn't appear that I can get my hands on the base
 > class definition/name for the string type to be able to 

  class MyStr(str):
  def ishex(self):
  try:
  value = int(self, 16)
  except ValueError:
  return False
  return True
# in fact, you could even say
#class MyStr(type('123')): ...

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


Re: Syntax Question - list multiplication

2007-08-19 Thread Pablo Torres
Thanks everyone. Now I see why every row in my grid were actually the
same object.

Pablo

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


Re: Syntax Question - list multiplication

2007-08-19 Thread Duncan Smith
Roel Schroeven wrote:
> Pablo Torres schreef:
> 
>> Hi guys!
>>
>> I am working on Conway's Game of Life right now and I've run into a
>> little problem.
>> I represent dead cells with 0s and live ones with 1s. Check this out:
>>
>> >>> grid = [[0] * 3] * 3
>> >>> grid
>> [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
>> >>> grid[0][0] = 1
>> [[1, 0, 0], [1, 0, 0], [1, 0, 0]]
>>
>> Now, that's not what I want. I just want the first element of the
>> first sublist to be a 1, not the first of every one. Here's what I
>> tried and didn't work:
>>
>> 0.  grid = [[0] * 3][:] * 3then the same grid[0][0] = 1 statement
>> 1.  grid = [[0][:] * 3] * 3followed by the same assignment
>> 2.  (grid[0])[0] = 1with the original initialization of the grid
>>
>> So, that means that it isn't a problem with two different variables
>> refering to the same list (0. and 1. prove that). What I don't
>> understand is why 2. doesn't work either. I'm baby-feeding my
>> instructions to Python and the mistake is still there. Any ideas?
>>
>> Hope you can help. Thanks in advance,
> 
> 
> The multiplication operator doesn't make new copies; all elements
> reference the same object, as you can see with id():
> 
 lst = [0] * 3
 lst
> [0, 0, 0]
 id(lst[0]), id(lst[1]), id(lst[2])
> (9788716, 9788716, 9788716)
> 

I think you probably meant something like,

>>> lst = [[0] * 3] * 3
>>> lst
[[0, 0, 0], [0, 0, 0], [0, 0, 0]]
>>> id(lst[0]), id(lst[1]), id(lst[2])
(15937704, 15937704, 15937704)
>>>

i.e. a list of mutable types where the difference between multiple
objects and multiple references to the same object will be apparent.
With small integers you're likely to find you have multiple references
to the same integer objects however the list is constructed.

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


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

2007-08-19 Thread Xah Lee
Dear computing comrades,

Today, i'd like to show you a piece of literature written by a eminent
mathematician Edsger W Dijkstra.

Here's 2 interesting quote from his letter:

“The prevaling attitude was reflected in the creation of two literary
figures — admittedly of rather poor literature, but nevertheless of
great paralyzing power —, viz. “the average programmer” and “the
casual user”. Up to these days, academic research in programming
methodology has been supposed to respect the severe intellectual
limitations of these fictitious morons: consequently any proposal that
required any further education of the programming person was out.”

“... On the other hand we should be glad that the gospel of design by
derivation rather by trial and error is still preached.”

I happened to read it today. And, i think in your busy schedule of
checking out slashdot and blogging and driveling with your excitement
and concerns about current fashions and trends with your fellow peers
and factions; It is good once in a while to read something
unfashionable and not for-dummies.

This letter of EWD is about 16 pages.

Is somewhat a quaint rant. The first half i find interesting but
without much sympathy, perhaps because the author is mostly talking
about the situation in the mid 1990s, of which, i'm unfamiliar and too
early a period to touch me personally. But the latter part of the
letter, i find much empathy and concurrence. In particular, his
remarks related to the formal methods.

(for you math illiterates out there: the “formal” here does not mean
the opposite of “informal”, as in “formal dress” vs “informal dress”.
Rather, “formal” here means “mathematical reasoning by symbol
manipulation; the ‘FORM’ in math FORMulas”. (for you mathematicians
out there: the root of the word “formal” as in “formal dress” and
“formalism”, actually are the same. They both refers to “form” as in a
empty shell, appearance.)) (So, when you “dress up formally” to attend
your friend's wedding or death ceremony, it literally means you are
putting on a appearance.)

Now, without further ado, the article is at:

“Under the spell of Leibniz's dream” (2000) By Edsger W Dijkstra
http://www.cs.utexas.edu/~EWD/ewd12xx/EWD1298.PDF

  Xah
  [EMAIL PROTECTED]
∑ http://xahlee.org/

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

  1   2   >