Re: New to python

2007-09-30 Thread James Matthews
Both are good however when looking for a book i would recommend core python
programming version 2! Enjoy OOP

On 30 Sep 2007 05:21:50 GMT, Stargaming <[EMAIL PROTECTED]> wrote:
>
> On Sat, 29 Sep 2007 21:20:10 -0700, Googy wrote:
>
> > I am new to python...
> >
> > The programming language i know well is C Can any one recommend me the
> > good ebook for beginners. I have loads of ebooks but i am not able to
> > decide which to start with which book. Also i am learning XML so later
> > on i can switch to books on Python and XML but initially which book to
> > read??
> >
> > Please help...
>
> Generically, `A byte of Python`_ and `Dive into Python`_ are pretty
> common. ABOP has a few comments for C programmers as well, AFAIK.
>
> If you already got a few (e)books, you should perhaps just look through
> all of them and then, sequentially, read them.
>
> .. _A byte of Python: http://www.byteofpython.info/download/
> .. _Dive into Python: http://www.diveintopython.org/
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
http://www.goldwatches.com/mens/cufflinks.html
http://www.jewelerslounge.com
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Optparse and help formatting?

2007-09-30 Thread Steven Bethard
Tim Chase wrote:
> I've been learning the ropes of the optparse module and have been
> having some trouble getting the help to format the way I want.
> 
> I want to specify parts of an option's help as multiline.
> However, the optparse formatter seems to eat newlines despite my
> inability to find anything in optparse.py that does something
> obvious like .replace("\n", " ") to eat the newlines I stick in
> the help.  It also seems to mung tabs.  An example from my code:
> 
> parser.add_option("-x", "--extended",
>   action="callback",
>   callback=callback_test,
>   type="string",  # required to get metavar to show in help
>   dest="test",
>   metavar="CONF",
>   help="a comma-separated list of options.\n"
> "s=[]MMDD,n=NAME,c=COLOR\n"
> "s,start=[]MMDD\n"
> "\tstart day of period (default, current day)\n"
>   ...
>   )
> 
> which would accept options that looked something like
> 
>   test.py -x s=20070401,n=XR71,c=black
> 
> (my callback_test breaks apart parser.rargs[0] to deal with the
> funky params).
> 
> However, when I display the help, its reformatting eats the
> newlines in my help-string and strangely looks like it converts
> my tabs to spaces.
> 
> Any hints on how to either work around the problem or fix it?

I guess this is just an optparse-y week on c.l.py. ;-)  Ben Finney 
pointed you in the right direction for optparse.

If you care to try out argparse (http://argparse.python-hosting.com/) 
which has a similar API, it has a builtin RawTextHelpFormatter formatter 
class::

 import argparse

 def my_type(string):
 # split string and turn it into appropriate object(s)
 return 'foo(%s)' % string

 parser = argparse.ArgumentParser(
 formatter_class=argparse.RawTextHelpFormatter
 )
 parser.add_argument(
 "-x", "--extended",
 type=my_type,  dest="test", metavar="CONF",
 help="a comma-separated list of options.\n"
  "s=[]MMDD,n=NAME,c=COLOR\n"
  "s,start=[]MMDD\n"
  "\tstart day of period (default, current day)\n"
 )

 args = parser.parse_args()
 print args.test

This program will produce output like::

 $ python script.py -x sdfsdfas
 foo(sdfsdfas)

 $ python script.py --help
 usage: script.py [-h] [-x CONF]

 optional arguments:
   -h, --helpshow this help message and exit
   -x CONF, --extended CONF
 a comma-separated list of options.
 s=[]MMDD,n=NAME,c=COLOR
 s,start=[]MMDD
 start day of period ...

HTH,

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


Re: How to display a videostream in the PyQt GUI by a efficient way

2007-09-30 Thread kivilaya
Hi, David, thank you for your help! ^__^

   I read the method in the given link and learn a lot from it. I'll
try to display the data inside a QWidget directly instead of the
current way. But I still have a question, is there any way to make the
displaying of RGB data in a QWidget more quickly.

   In fact, my work is to make a gui for displaying my
partners'experimental results to our teacher, the source video is no
need to be encoded to mpeg or h264 format, so I get the video from
camera in the raw format and display them without encodeing or
decoding process.

   As my partners will do some experiments on the raw data, maybe add
a mark to label some area in the current frame, or change some part of
it, I get every frame as a picture before they process the picture
data, and then display the picture after their process. But displaying
the pictures one by one in my current way is so slow, I'm afraid that
time spend on it is too long and the displaying of results will be
discontinuous. So I think maybe there is another way to show these
pictures.

   Look forward to more advices.^ ^

   Thanks!
Kivilaya

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


Re: Balloon Taskbar Popup for Windows XP

2007-09-30 Thread momobear
On Sep 29, 6:40 pm, makko <[EMAIL PROTECTED]> wrote:
> Greetings,
> I need to create a function that will produce a balloon popup in the
> taskbar when called. Whats the shortest and easiest way to do this?
> Thanks.
>
> regards,
> Makko

look at the website, maybe helpful to you.
http://xoomer.alice.it/infinity77/main/freeware.html

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


Can you please give me some advice?

2007-09-30 Thread Byung-Hee HWANG
Hi there,

What is different between Ruby and Python? I am wondering what language
is really mine for work. Somebody tell me Ruby is clean or Python is
really easy! Anyway I will really make decision today what I have to
study from now on. What I make the decision is more difficult than to
know why I have to learn English. Yeah I do not like to learn English
because it is just very painful..

Can you please give me some advice?  

Byung-Hee

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


Re: Can you please give me some advice?

2007-09-30 Thread morphine
Byung-Hee HWANG wrote:

> Hi there,
> 
> What is different between Ruby and Python? I am wondering what language
> is really mine for work. Somebody tell me Ruby is clean or Python is
> really easy! Anyway I will really make decision today what I have to
> study from now on. 

What kind of advice do you expect on a NG called comp.lang.PYTHON ?

> What I make the decision is more difficult than to 
> know why I have to learn English. Yeah I do not like to learn English
> because it is just very painful..

Then stop learning it ;)

ciao
-- 
morphine

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


Re: Can you please give me some advice?

2007-09-30 Thread Steven D'Aprano
On Sun, 30 Sep 2007 19:22:07 +0900, Byung-Hee HWANG wrote:

> Hi there,
> 
> What is different between Ruby and Python? I am wondering what language
> is really mine for work. Somebody tell me Ruby is clean or Python is
> really easy! Anyway I will really make decision today what I have to
> study from now on. What I make the decision is more difficult than to
> know why I have to learn English. Yeah I do not like to learn English
> because it is just very painful..
> 
> Can you please give me some advice?


Hello World in Ruby (and a few other languages):
http://www.oreillynet.com/ruby/blog/2005/12/hello_world.html

More here:
http://en.wikibooks.org/wiki/Programming:Ruby_Creating_Ruby_programs

Hello World in Python:
http://python.about.com/od/gettingstarted/ss/helloworld.htm

A Python tutorial:
http://docs.python.org/tut/


Sorry about the English.





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


which language allows you to change an argument's value?

2007-09-30 Thread Summercool

I wonder which language allows you to change an argument's value?
like:

foo(&a) {
  a = 3
}

n = 1
print n

foo(n) # passing in n, not &n
print n

and now n will be 3.  I think C++ and PHP can let you do that, using
their reference (alias) mechanism.  And C, Python, and Ruby probably
won't let you do that.  What about Java and Perl?

is there any way to prevent a function from changing the argument's
value?

isn't "what i pass in, the function can modify it" not a desireable
behavior if i am NOT passing in the address of my argument?  For one
thing, if we use a module, and call some functions in that module, and
the module's author made some changes to his code, then we have no way
of knowing what we pass in could get changed.  Of course, if it is in
Java, Python, and Ruby, and we pass in a reference to object (not C+
+'s meaning of alias reference), so the object can get changed, but
that can be expected, vs passing in n, when n = 1.  Even when it is
Ruby, when everything is an object, passing n in when n = 1 won't ever
make n become 3.  Is there a way to prevent it from happening in the
languages that allows it?

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


Re: which language allows you to change an argument's value?

2007-09-30 Thread rolkA
On 30 sep, 12:47, Summercool <[EMAIL PROTECTED]> wrote:
> I wonder which language allows you to change an argument's value?
> like:
>
> foo(&a) {
>   a = 3
>
> }
>
> ...
> is there any way to prevent a function from changing the argument's
> value?
> ...
> Is there a way to prevent it from happening in the
> languages that allows it?

Hi,
Of course in C++, functions that don't modify argument's value should
(i'd rather say MUST) wait for a CONST reference or a value :

// const ref
foo(const T& a) {
  a = 3; // error

}
// value
foo(T a) {
  a = 3; // ok, but modify only the formal parameter : the argument
(aka actual parameter) is not changed

}

Now if you want to prevent a function (from a library you are using)
to modify it... Erm well, you shouldn't : a good librairy will never
wait for a non-const argument if it doesn't need to be modified. So in
this case "Is there a way to prevent it from happening" is
unpertinent : you could copy the object, but if the purpose of the
fucntion was to modify it, it's pointless.

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


Re: which language allows you to change an argument's value?

2007-09-30 Thread Gabriel Genellina
En Sun, 30 Sep 2007 07:47:13 -0300, Summercool <[EMAIL PROTECTED]>  
escribi�:

> I wonder which language allows you to change an argument's value?
> like:
>
> foo(&a) {
>   a = 3
> }
>
> n = 1
> print n
>
> foo(n) # passing in n, not &n
> print n
>
> and now n will be 3.  I think C++ and PHP can let you do that, using
> their reference (alias) mechanism.  And C, Python, and Ruby probably
> won't let you do that.  What about Java and Perl?
>
> is there any way to prevent a function from changing the argument's
> value?
>
> isn't "what i pass in, the function can modify it" not a desireable
> behavior if i am NOT passing in the address of my argument?  For one

C++ lets you use const references - and any well written code should use  
const& whenever the argument is not to be modified. A function/method may  
have two overloaded versions, with and without the const modifier.
So, if the argument *is* to be modified, there is no point in avoiding it  
(unless the interfase is not well designed in the first place)

In Python, rebinding a name inside a function does not have any effects in  
the caller. That is,

def foo(a):
   a = 3

n = 1
foo(n)
print n

will still print 1, not 3.

-- 
Gabriel Genellina

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

Re: The Modernization of Emacs: terminology buffer and keybinding

2007-09-30 Thread Klaus Schilling
Ken Tilton <[EMAIL PROTECTED]> writes:
>
> Sure, but where does the infection thing come in? Suppose RMS
> publishes a new library call add-42, whose api is add-42, inputs n,
> outputs n+42, source left as an exercise, and Kenny decides he can use
> it, it is great. Now if Kenny uses it in his commercial software,

commercial software can be free as well, such as the GNU Ada compiler.

> add-42 does not somehow become less free to ride 'neath the starry
> skies above, don't fence me in. But RMS wants Kenny's hide. Nothing
> Kenny wrote derived from add-42, but RMS wants it all.

that's because it's immoral not to give it all


> Kenny happened
> to solve the traveling salesman problem and protein-folding and passed
> the fricking Turing test by using add-42 wherever he needed 42 added
> to a number, and  RMS wants credit and ownership and control of it
> all. He and his license  shall now dictate access and use of all that
> code. The handcuffs are on, and they are inscribed "free".

of course they are free
>
> No wonder the GPL has gone nowhere. Freely. RMS reasonably wanted that
> add-42 not get co-opted, but that in no way necessitated the land grab
> that is GPL. The GPL is a gratuitous reach only fancifully justified
> by wanting to ensure that open source remain open.

which is necessary in a moral culture.
Only an immoral culture may accept non-disclosure

> So this has nothing
> to do with freedom in /any/ sense of the word, it has to do with a
> political agenda opposed to the idea of private property.
>

private property is unethical

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


Re: which language allows you to change an argument's value?

2007-09-30 Thread Erik Wikström
On 2007-09-30 12:47, Summercool wrote:
> I wonder which language allows you to change an argument's value?
> like:
> 
> foo(&a) {
>   a = 3
> }
> 
> n = 1
> print n
> 
> foo(n) # passing in n, not &n
> print n
> 
> and now n will be 3.  I think C++ and PHP can let you do that, using

Since you know C++ can do it why do you include c.l.c++? Honestly cross-
posting to groups discussing so many different groups is seldom a good
idea since the languages differ too much for a useful discussion.

> their reference (alias) mechanism.  And C, Python, and Ruby probably
> won't let you do that.  What about Java and Perl?

C will let you do it with pointers (it is just a syntactical difference
from references in this case) and Java's references allows it. I do not
know about Ruby, Python and Perl, but (AFAIK) the all have OO support so
I would be surprised if they used purely value semantics.

> is there any way to prevent a function from changing the argument's
> value?

Some languages, like C++ have the ability to make an argument const.

> isn't "what i pass in, the function can modify it" not a desireable
> behavior if i am NOT passing in the address of my argument?  For one

Being able to pass the actual object instead of a copy is highly
desirable for two reasons. In most languages only one return value is
allowed for a function so the ability to change parameters allows you to
artificially return more without having to wrap them in constructs. The
second reason is that for large objects the performance hit of having to
create a copy each time you call a function can be forbidding.

> thing, if we use a module, and call some functions in that module, and
> the module's author made some changes to his code, then we have no way
> of knowing what we pass in could get changed.  Of course, if it is in

As for knowing when a library function modifies an argument or not, well
that is why we have documentation.

> Java, Python, and Ruby, and we pass in a reference to object (not C+
> +'s meaning of alias reference)

In what way does the C++ reference differ from those in Java, Python,
and Ruby in this situation?

-- 
Erik Wikström
-- 
http://mail.python.org/mailman/listinfo/python-list

OSDC 2007 earlybird registration now open!

2007-09-30 Thread Richard Jones
[and now with more information]

The Open Source Developers' Conference is designed by open source developers, 
for developers and business people. It covers numerous programming languages 
across a range of operating systems, and related topics such as business 
processes, licensing, and strategy. Talks vary from introductory pieces 
through to the deeply technical.

Registration for OSDC Australia 2007 (26th to 29th November in Brisbane, 
Queensland( is now open at http://osdc.com.au/registration/

The earlybird price is $275 (until October 14th), after that the full 
conference price is $325. All regular tickets include the conference dinner!

Peruse the overview of confirmed sessions at:

http://www.cgpublisher.com/conferences/107/web/session_descriptions.html


OSDC 2007 is proud and grateful to have a group of global as well as local 
companies sponsoring this year's event:

  Apress, CNET/BuilderAU, Common Ground, Freeway/Zac-Ware, Google,  
  Linux Magazine, Opengear, Open Query, Rea Group, Red Hat, Sun  
  Microsystems, Trolltech, Woodslane.

Sponsorship opportunities are still available - please contact OSDC through 
their website http://osdc.com.au/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Optparse and help formatting?

2007-09-30 Thread Tim Chase
>> I've been learning the ropes of the optparse module and have been
>> having some trouble getting the help to format the way I want.
> 
> A quick perusal of the 'optparse.py' code shows me this:
> 
> 
> [...]
> class OptionParser([...]):
> def __init__([...],
>  formatter=None,
>  [...]):
> [...]
> if formatter is None:
> formatter = IndentedHelpFormatter()
> [...]
> 
> 
> So, the OptionParser init method accepts the help formatter as the
> 'formatter' argument, defaulting to a new instance of
> IndentedHelpFormatter.
> 
> Presumably, it's a matter of subclassing 'optparse.HelpFormatter' and
> overriding the behaviour you want to change, then passing an instance
> of your new class as the 'formatter' argument to the 'OptionParser()'
> invocation.

Ben, thanks for pointing me in the right direction.  Digging in
this code, it looks like textwrap.[fill|wrap] method calls were
what was eating my NL and munging my tabs.

While not a terribly elegant solution, as there's no easy way to
intercept the two bits I want without copying and pasting a large
bit of the format_description and format_option methods just to
change the behavior of one call to textwrap.*, I did manage to
get it working as desired.

In the event that anybody else needs the solution I hacked
together, I've pasted it below which, as Ben suggests, can be
used with

  parser = OptionParser(...
formatter=IndentedHelpFormatterWithNL()
)

Hope this helps somebody else too.

-tim



class IndentedHelpFormatterWithNL(IndentedHelpFormatter):
  def format_description(self, description):
if not description: return ""
desc_width = self.width - self.current_indent
indent = " "*self.current_indent
# the above is still the same
bits = description.split('\n')
formatted_bits = [
  textwrap.fill(bit,
desc_width,
initial_indent=indent,
subsequent_indent=indent)
  for bit in bits]
result = "\n".join(formatted_bits) + "\n"
return result

  def format_option(self, option):
# The help for each option consists of two parts:
#   * the opt strings and metavars
#   eg. ("-x", or "-fFILENAME, --file=FILENAME")
#   * the user-supplied help string
#   eg. ("turn on expert mode", "read data from FILENAME")
#
# If possible, we write both of these on the same line:
#   -xturn on expert mode
#
# But if the opt string list is too long, we put the help
# string on a second line, indented to the same column it would
# start in if it fit on the first line.
#   -fFILENAME, --file=FILENAME
#   read data from FILENAME
result = []
opts = self.option_strings[option]
opt_width = self.help_position - self.current_indent - 2
if len(opts) > opt_width:
  opts = "%*s%s\n" % (self.current_indent, "", opts)
  indent_first = self.help_position
else: # start help on same line as opts
  opts = "%*s%-*s  " % (self.current_indent, "", opt_width, opts)
  indent_first = 0
result.append(opts)
if option.help:
  help_text = self.expand_default(option)
# Everything is the same up through here
  help_lines = []
  for para in help_text.split("\n"):
help_lines.extend(textwrap.wrap(para, self.help_width))
# Everything is the same after here
  result.append("%*s%s\n" % (
indent_first, "", help_lines[0]))
  result.extend(["%*s%s\n" % (self.help_position, "", line)
for line in help_lines[1:]])
elif opts[-1] != "\n":
  result.append("\n")
return "".join(result)



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


Re: Optparse and help formatting?

2007-09-30 Thread Steven D'Aprano
On Sun, 30 Sep 2007 07:37:10 -0500, Tim Chase wrote:

>   def format_option(self, option):
> # The help for each option consists of two parts: 
> #   * the opt strings and metavars
[snip]

Tim, I notice you're using lots of # lines as comments to describe the 
function. Perhaps you should consider using docstrings instead.

Pardon me if I'm telling you what you already know... 

A docstring is a string that immediately follows a class, function or 
method declaration, or at the beginning of a module:


def parrot():
"This is a doc string."
s = "this is not a docstring"


The advantage of docstrings is that unlike # comments, they aren't 
discarded at compile time, and can be accessed by the caller:

>>> parrot.__doc__
'This is a doc string'

This is especially useful in the interactive interpreter, where 
help(object) will grab the docstring and format it nicely on screen.



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


Re: Can you please give me some advice?

2007-09-30 Thread Byung-Hee HWANG
On Sun, 2007-09-30 at 12:33 +0200, morphine wrote:
> Byung-Hee HWANG wrote:
> 
> > Hi there,
> > 
> > What is different between Ruby and Python? I am wondering what language
> > is really mine for work. Somebody tell me Ruby is clean or Python is
> > really easy! Anyway I will really make decision today what I have to
> > study from now on. 
> 
> What kind of advice do you expect on a NG called comp.lang.PYTHON ?

Your advice is the best.. really it hit my head very strongly..

> 
> > What I make the decision is more difficult than to 
> > know why I have to learn English. Yeah I do not like to learn English
> > because it is just very painful..
> 
> Then stop learning it ;)
 ^^^
You are bad.. I'm really pain..

sorry for noise.. but I really wanted to say about the above matters.. 


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


Re: is it possible to use different font within one wxpython static text widget?

2007-09-30 Thread hyena
[EMAIL PROTECTED] :
> On Sep 12, 10:26 am, "hyena" <[EMAIL PROTECTED]> wrote:
>> problem is as title, bear me if this too silly or too naive.
>>
>> I use wx.statictext widget to show some information in GUI, there are some
>> numbers in the text to be emphasized in bigger other color. For example, in
>> sentence "the travel speed of this car is 40 km /hour", I would like "40" to
>> be bigger and in red color. I know I can use several statictext to get this
>> effect. But i am quite relucktant to do so since I am quite unfamiliar with
>> manageing the layout of widgets.
>>
>> Is there a convinient way to have this done? Thanks for any .input
> 
> 
> Without knowing what kind of interface you're making, I can only shoot
> in the dark. From your question, I would think that the FancyText
> widget would suffice. Other widgets that would be harder to use would
> be the StyledTextCtrl and the HtmlWindow (which I use for About
> dialogs).
> 
> Check out the wxPython Demo for sample code on each of these widgets
> and sizers. Also see the Wiki for tips and tricks on using Sizers.
> There's a new SizedControl that's supposed to simplify creating
> layouts, although I haven't used it. And there's also XRC too.
> 
> Mike
> 
Sorry did not check this group for a while. Thanks Mike for your input. 
I will go take a look at the fancytext widget.

Thanks again.

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

Re: Optparse and help formatting?

2007-09-30 Thread Tim Chase
>>   def format_option(self, option):
>> # The help for each option consists of two parts: 
>> #   * the opt strings and metavars
> [snip]
> 
> Tim, I notice you're using lots of # lines as comments to describe the 
> function. Perhaps you should consider using docstrings instead.
> 
> Pardon me if I'm telling you what you already know... 

Yes, I do know about and use docstrings, and no, no offense
taken.  You'll have to persuade the [Debian/Python] maintainer of
optparse.py from whom I pilfered the code.  :)

[EMAIL PROTECTED]:~$ sed -n '/def format_option(/{N;N;N;N;N;p}'
/usr/lib/python2.4/optparse.py

def format_option(self, option):
# The help for each option consists of two parts:
#   * the opt strings and metavars
# eg. ("-x", or "-fFILENAME, --file=FILENAME")
#   * the user-supplied help string
# eg. ("turn on expert mode", "read data from FILENAME")


-tim




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


Re: Can you please give me some advice?

2007-09-30 Thread Byung-Hee HWANG
On Sun, 2007-09-30 at 10:36 +, Steven D'Aprano wrote:
[...snip...]
> Sorry about the English.
That's alright. I am always struggling against English. It is not
strange now. Thank you for your kindness.

Byung-Hee

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


s.split() on multiple separators

2007-09-30 Thread mrkafk
Hello everyone,

OK, so I want to split a string c into words using several different
separators from a list (dels).

I can do this the following C-like way:

>>> c=' abcde abc cba fdsa bcd '.split()
>>> dels='ce '
>>> for j in dels:
cp=[]
for i in xrange(0,len(c)-1):
cp.extend(c[i].split(j))
c=cp


>>> c
['ab', 'd', '', 'ab', '', '']

But. Surely there is a more Pythonic way to do this?

I cannot do this:

>>> for i in dels:
c=[x.split(i) for x in c]

because x.split(i) is a list.

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


notify when process finishes (on unix)

2007-09-30 Thread bahoo
Hi,

I'd like to write a script that sends me an email when a unix (Linux)
process ends running (or CPU drops below some threshold).  Could
anyone point me to the relevant functions, or show me an example?

Thanks
bahoo

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


Re: Command-line does work when scheduled

2007-09-30 Thread Jim
On Sep 29, 8:45 pm, "Gabriel Genellina" <[EMAIL PROTECTED]>
wrote:
> En Sat, 29 Sep 2007 22:04:06 -0300, Jim <[EMAIL PROTECTED]> escribi?:
>
> >> If it works this way, maybe the .py file extension is not correctly
> >> registered.
>
> > Yes, it works this way.
> > How do I register the .py extension correctly?
>
>  From a command line, type:
> assoc .py
> You should get:
> .py=Python.File
> If you get an error, or another thing like py_auto_file:
> assoc .py=Python.File
>
> Then:
> ftype Python.File
> You should get:
> Python.File=c:\path\to\python.exe "%1" %*
> If you don't:
> ftype Python.File=c:\path\to\python.exe "%1" %*
>
> The %* at the end is important: if you created the association by using  
> "Open with...", or selecting Python from the list of installed programs,  
> very likely the command says only "%1" - that is, the script being open,  
> but without any additional arguments.
>
> Better if you have administrative rights to do this tasks.
>
> --
> Gabriel Genellina

I believe I get the correct results as follows:
==
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

J:\Jim Crerar\mypython\misc>assoc .py
.py=Python.File

J:\Jim Crerar\mypython\misc>ftype Python.File
Python.File="E:\Python25\python.exe" "%1" %*

J:\Jim Crerar\mypython\misc>
===
What else could be wrong?
Thanks,
Jim

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


Re: How to unload a module after I've imported it.

2007-09-30 Thread Fuzzyman
On Sep 29, 9:32 pm, marvinla <[EMAIL PROTECTED]> wrote:
> Have you tried a del?
>
> >> import socket
> >> dir()
>
> ['__builtins__', '__doc__', '__name__', 'socket']>> del socket
> >> dir()
>
> ['__builtins__', '__doc__', '__name__']
>
> See you!

>>> import socket
>>> import sys
>>> 'socket' in sys.modules
True
>>> del sys.modules['socket']
>>> 'socket' in sys.modules
False

Although as Gabriel says, this may not be the best approach for this
particular need.

A new import will do a full reload of the socket module.

Michael
http://www.manning.com/foord

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


Re: s.split() on multiple separators

2007-09-30 Thread Francesco Guerrieri
On 9/30/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Hello everyone,
>
> OK, so I want to split a string c into words using several different
> separators from a list (dels).

Have a look at this recipe:

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

which contains several ways to solve the problem. You could both
translate all your separators to a single one, and then split over it,
or (maybe the simpler solution) going for the list comprehension
solution.

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


Re: s.split() on multiple separators

2007-09-30 Thread Francesco Guerrieri
On 9/30/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Hello everyone,
>
> OK, so I want to split a string c into words using several different
> separators from a list (dels).

Have a look at this recipe:

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

which contains several ways to solve the problem. You could both
translate all your separators to a single one, and then split over it,
or (maybe the simpler solution) going for the list comprehension
solution.

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


Create a string array of all comments in a html file...

2007-09-30 Thread sophie_newbie
Hi, I'm wondering how i'd go about extracting a string array of all
comments in a HTML file, HTML comments obviously taking the format
"".

I'm fairly stumped on how to do this? Maybe using regular expressions?

Thanks.

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


Re: Create a string array of all comments in a html file...

2007-09-30 Thread Robin Becker
sophie_newbie wrote:
> Hi, I'm wondering how i'd go about extracting a string array of all
> comments in a HTML file, HTML comments obviously taking the format
> "".
> 
> I'm fairly stumped on how to do this? Maybe using regular expressions?
> 
> Thanks.
> 
You should probably eat beautiful soup at

http://www.crummy.com/software/BeautifulSoup/documentation.html

which helps with this sort of task.
-- 
Robin Becker
-- 
http://mail.python.org/mailman/listinfo/python-list


ANN: eric 4.0.2 released

2007-09-30 Thread Detlev Offenbach
Hi,

this is to inform you about the release of eric 4.0.2. This is mainly a
bugfix release.

As usual you may get it at
http://www.die-offenbachs.de/eric/index.html

ChangeLog
-
- compatibility fixes for Debian
- added '-z' to the installer to inhibit compilation of the python files
- changed code to not look for the Qt4 tools in a subdirectory of the Qt
  installation directory (it is now required, that the Qt bin directory 
  is in the PATH)
- changed code of Python debug client to better intercept output on
  non-win32 systems

What is eric?
-
eric is a Python and Ruby IDE with all batteries included. It is written
using PyQt4 and QScintilla2. For details see the a.m. web site.

Regards,
Detlev
-- 
Detlev Offenbach
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The Modernization of Emacs: terminology buffer and keybinding

2007-09-30 Thread Timofei Shatrov
On Sun, 30 Sep 2007 08:43:39 +0200, Klaus Schilling <[EMAIL PROTECTED]>
tried to confuse everyone with this message:

>
>that's because it's immoral not to give it all
>
>which is necessary in a moral culture.
>Only an immoral culture may accept non-disclosure
>
>private property is unethical
>

I see the light! You really won me over with your preaching.

-- 
|Don't believe this - you're not worthless  ,gr-.ru
|It's us against millions and we can't take them all... |  ue il   |
|But we can take them on!   | @ma  |
|   (A Wilhelm Scream - The Rip)|__|
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The Modernization of Emacs: terminology buffer and keybinding

2007-09-30 Thread Matthias Benkard
> So this has nothing to
> do with freedom in /any/ sense of the word, it has to do with a
> political agenda opposed to the idea of private property.

Freedom is inherently political, you know.  You're condemning the FSF
for being political, although the FSF's stated purpose is a political
one.  How does that make any sense?

~ Matthias

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


Re: Can you please give me some advice?

2007-09-30 Thread George Sakkis
On Sep 30, 6:22 am, Byung-Hee HWANG <[EMAIL PROTECTED]> wrote:
> Hi there,
>
> What is different between Ruby and Python? I am wondering what language
> is really mine for work. Somebody tell me Ruby is clean or Python is
> really easy! Anyway I will really make decision today what I have to
> study from now on. What I make the decision is more difficult than to
> know why I have to learn English. Yeah I do not like to learn English
> because it is just very painful..
>
> Can you please give me some advice?
>
> Byung-Hee


"Dive into Python" has been translated in Chinese:
http://www.woodpecker.org.cn/diveintopython/

Hope it helps,
George

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


Re: which language allows you to change an argument's value?

2007-09-30 Thread Summercool
On Sep 30, 4:18 am, 7stud -- <[EMAIL PROTECTED]> wrote:
> SpringFlowers AutumnMoon wrote:
> > we have no way
> > of knowing what we pass in could get changed.
>
> Sure you do.  You look at the function's signature.  In order to use
> someone else's library, you have to know the function's signature.  And
> the signature explicitly tells you whether the value you pass in could
> be changed.

do you mean in C++?  I tried to find signature in two C++ books and it
is not there.  Google has a few results but it looks something like
prototype.  Is signature the same as the function prototype in the .h
file?  If so, don't we usually just include <___.h> and forget about
the rest.  Documentation is fine although in some situation, the
descriptions is 2 lines, and notes and warnings are 4, 5 times that,
and the users' discussing it, holding different opinion is again 2, 3
times of that length.  I think in Pascal and C, we can never have an
argument modified unless we explicitly allow it, by passing in the
pointer (address) of the argument.

also i think for string, it is a bit different because by default,
string is a pointer to char or the address of the first char in C and C
++.  So it is like passing in the address already.  it is when the
argument n is something like 1 that makes me wonder.


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


Re: s.split() on multiple separators

2007-09-30 Thread Tim Chase
> OK, so I want to split a string c into words using several different
> separators from a list (dels).
> 
> I can do this the following C-like way:
> 
 c=' abcde abc cba fdsa bcd '.split()
 dels='ce '
 for j in dels:
>   cp=[]
>   for i in xrange(0,len(c)-1):
>   cp.extend(c[i].split(j))
>   c=cp
> 
> 
 c
> ['ab', 'd', '', 'ab', '', '']


Given your original string, I'm not sure how that would be the
expected result of "split c on the characters in dels".

While there's a certain faction of pythonistas that don't esteem
regular expressions (or at least find them overused/misused,
which I'd certainly agree to), they may be able to serve your
purposes well:

  >>> c=' abcde abc cba fdsa bcd '
  >>> import re
  >>> r = re.compile('[ce ]')
  >>> r.split(c)
  ['', 'ab', 'd', '', 'ab', '', '', 'ba', 'fdsa', 'b', 'd', '']

given that a regexp object has a split() method.

-tkc



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


Re: which language allows you to change an argument's value?

2007-09-30 Thread Daniel Pitts
On Sep 30, 3:47 am, Summercool <[EMAIL PROTECTED]> wrote:
> I wonder which language allows you to change an argument's value?
> like:
>
> foo(&a) {
>   a = 3
>
> }
>
> n = 1
> print n
>
> foo(n) # passing in n, not &n
> print n
>
> and now n will be 3.  I think C++ and PHP can let you do that, using
> their reference (alias) mechanism.  And C, Python, and Ruby probably
> won't let you do that.  What about Java and Perl?
>
> is there any way to prevent a function from changing the argument's
> value?
>
> isn't "what i pass in, the function can modify it" not a desireable
> behavior if i am NOT passing in the address of my argument?  For one
> thing, if we use a module, and call some functions in that module, and
> the module's author made some changes to his code, then we have no way
> of knowing what we pass in could get changed.  Of course, if it is in
> Java, Python, and Ruby, and we pass in a reference to object (not C+
> +'s meaning of alias reference), so the object can get changed, but
> that can be expected, vs passing in n, when n = 1.  Even when it is
> Ruby, when everything is an object, passing n in when n = 1 won't ever
> make n become 3.  Is there a way to prevent it from happening in the
> languages that allows it?

Some would say that in truely good OO design, the state should be
protected by the object (not the constness of the reference to the
object)

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


Re: Can you please give me some advice?

2007-09-30 Thread cmpython

> Hello World in Ruby (and a few other 
> languages):http://www.oreillynet.com/ruby/blog/2005/12/hello_world.html

> Hello World in 
> Python:http://python.about.com/od/gettingstarted/ss/helloworld.htm

I know nothing of Ruby, but just the fact that in Ruby the Hello World
program is

puts 'Hello, World!'

whereas the Python Hello World program is

print 'Hello, World!'

suggests to me that Python is more intuitive because the word "print"
has a meaning in English that makes sense given what you want to do,
but "puts" just doesn't.  And, as someone who has been learning Python
from almost no knowledge of programming, I've found it is not too bad
in trying to keep as reasonably close to a natural language like
English
as possible.

I also think the mandatory indenting of Python is helpful in forcing
new programmers to be neat and see code blocks quickly.  Plus I doubt
the Ruby community has such a large group of helpful people and
libraries
and such (but I could be wrong about that, just assuming it based on
the
fact that Python has been around longer).

On the other hand, perhaps because Ruby is newer it has been able to
freshly start with advantages learned from the difficulties of other
languages.  Byung-Hee Hwang ought to go the Ruby group and see what
they are saying.

As far as English goes, Byung-Hee, you have to admit English grammar
is easy (though spelling is not so easy).  That anyone can speak and
write Chinese is impressive to me, as the language looks completely
impossible!  Good luck!


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


Re: s.split() on multiple separators

2007-09-30 Thread Bryan Olson
[EMAIL PROTECTED] wrote:
> Hello everyone,
> 
> OK, so I want to split a string c into words using several different
> separators from a list (dels).
> 
> I can do this the following C-like way:
> 
>  c=' abcde abc cba fdsa bcd '.split()
>  dels='ce '
>  for j in dels:
>   cp=[]
>   for i in xrange(0,len(c)-1):

The "-1" looks like a bug; remember in Python 'stop' bounds
are exclusive. The indexes of c are simply xrange(len(c)).

Python 2.3 and up offers: for (i, word) in enumerate(c):

>   cp.extend(c[i].split(j))
>   c=cp
> 
> 
> c
> ['ab', 'd', '', 'ab', '', '']

The bug lost some words, such as 'fdsa'.


> But. Surely there is a more Pythonic way to do this?

When string.split() doesn't quite cut it, try re.split(), or
maybe re.findall(). Is one of these what you want?

 import re

 c = ' abcde abc cba fdsa bcd '

 print re.split('[ce ]', c)

 print re.split('[ce ]+', c)

 print re.findall('[^ce ]+', c)


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


Re: which language allows you to change an argument's value?

2007-09-30 Thread Erik Wikström
On 2007-09-30 18:49, Summercool wrote:
> On Sep 30, 4:18 am, 7stud -- <[EMAIL PROTECTED]> wrote:
>> SpringFlowers AutumnMoon wrote:
>> > we have no way
>> > of knowing what we pass in could get changed.
>>
>> Sure you do.  You look at the function's signature.  In order to use
>> someone else's library, you have to know the function's signature.  And
>> the signature explicitly tells you whether the value you pass in could
>> be changed.
> 
> do you mean in C++?  I tried to find signature in two C++ books and it
> is not there.  Google has a few results but it looks something like
> prototype.  Is signature the same as the function prototype in the .h
> file?

A signature is what is required to identify a function and includes
return type, name of function and the types of the parameters, while it
looks just like a prototype it is not. A prototype is something you
write to satisfy your compiler while a signature identifies a function.
Below are some examples of signatures, only the last can modify the
values of its parameter.

  void foo(int, float)
  std::string bar(const std::string&, int, int)
  void baz(std::string&)

> If so, don't we usually just include <___.h> and forget about
> the rest.  Documentation is fine although in some situation, the
> descriptions is 2 lines, and notes and warnings are 4, 5 times that,
> and the users' discussing it, holding different opinion is again 2, 3
> times of that length.

Unless you read the documentation how do you know which files to
include? And what documentation are you reading which does not clearly
specify the functionality of the functions described?

> I think in Pascal and C, we can never have an
> argument modified unless we explicitly allow it, by passing in the
> pointer (address) of the argument.

In C++ the arguments cannot be modified unless you either pass a pointer
to a non-const object or a non-const reference, so it is just as
explicit. (Notice that it is possible to cast the constness away, but
doing is extremely dangerous and should not be done.)

> also i think for string, it is a bit different because by default,
> string is a pointer to char or the address of the first char in C and C
> ++.  So it is like passing in the address already.

No. A string in C++ is a string, a char array or a pointer to a char is
something different.

> it is when the
> argument n is something like 1 that makes me wonder.


Get a good book on whatever language you are interested in (I do not
know which it is since you are all over the place) and read up on that
languages references, if you still do not understand after that ask your
questions in the group discussing that language.

-- 
Erik Wikström
-- 
http://mail.python.org/mailman/listinfo/python-list

code for number guessing by computer

2007-09-30 Thread [EMAIL PROTECTED]
hi, please help me,, a newbie...send me code for a programme
in which the computer tell u the number that u guessed

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


Re: which language allows you to change an argument's value?

2007-09-30 Thread Jerry Stuckle
Summercool wrote:
> On Sep 30, 4:18 am, 7stud -- <[EMAIL PROTECTED]> wrote:
>> SpringFlowers AutumnMoon wrote:
>>> we have no way
>>> of knowing what we pass in could get changed.
>> Sure you do.  You look at the function's signature.  In order to use
>> someone else's library, you have to know the function's signature.  And
>> the signature explicitly tells you whether the value you pass in could
>> be changed.
> 
> do you mean in C++?  I tried to find signature in two C++ books and it
> is not there.  Google has a few results but it looks something like
> prototype.  Is signature the same as the function prototype in the .h
> file?  If so, don't we usually just include <___.h> and forget about
> the rest.  Documentation is fine although in some situation, the
> descriptions is 2 lines, and notes and warnings are 4, 5 times that,
> and the users' discussing it, holding different opinion is again 2, 3
> times of that length.  I think in Pascal and C, we can never have an
> argument modified unless we explicitly allow it, by passing in the
> pointer (address) of the argument.
>

You need to get more C++ books :-).  You generally won't find them in 
basic books, but some of the more advanced ones talk about function 
signatures.

A C++ function's signature is dependent on the function name, number of 
parameters being passed, and the type of each parameter.  This is passed 
onto the linker.  In any C++ program, every function signature must be 
unique.

But in this case he's a little incorrect.  You *could* look at the 
function's signature, but it's much easier just to look at the 
function's declaration.

> also i think for string, it is a bit different because by default,
> string is a pointer to char or the address of the first char in C and C
> ++.  So it is like passing in the address already.  it is when the
> argument n is something like 1 that makes me wonder.
> 
> 


-- 
==
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
[EMAIL PROTECTED]
==
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Can you please give me some advice?

2007-09-30 Thread Bruno Desthuilliers
Byung-Hee HWANG a écrit :
> Hi there,
> 
> What is different between Ruby and Python? 

Not much - both are hi-level dynamic object oriented languages with some 
functional aspects - and quite a lot (their respective object models are 
totally different).

Also, Python, being somewhat older, has perhaps a better implementation, 
more 3rd part librairies, and a greater (in size) community - but it 
also suffers from cruft accumulated thru the years and a documentation 
that's getting a bit messy (not that it's badly documented, but some 
features are not necessarily covered in the official tutorial...)

> I am wondering what language
> is really mine for work.

The one that best fit your brain, I'd say - or the one that best fit 
your project.

> Anyway I will really make decision today what I have to
> study from now on. What I make the decision is more difficult than to
> know why I have to learn English. Yeah I do not like to learn English
> because it is just very painful..
> 
> Can you please give me some advice?  

Not wrt/ learning English !-)

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


Re: New to python

2007-09-30 Thread Bruno Desthuilliers
Googy a écrit :
> I am new to python...
> 
> The programming language i know well is C
> Can any one recommend me the good ebook for beginners. I have loads of
> ebooks but i am not able to decide which to start with which book.
> Also i am learning XML so later on i can switch to books on Python and
> XML but initially which book to read??

The canonical answer is:
- the official tutorial
- dive into python

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


Re: How to display a videostream in the PyQt GUI by a efficient way

2007-09-30 Thread David Boddie
On Sun Sep 30 09:10:40 CEST 2007, Kivilaya wrote:

>I read the method in the given link and learn a lot from it. I'll
> try to display the data inside a QWidget directly instead of the
> current way. But I still have a question, is there any way to make the
> displaying of RGB data in a QWidget more quickly.

You can set certain flags to ensure that the widget isn't being updated
or painted on too often. See the WA_OpaquePaintEvent and
WA_NoSystemBackground flags:

http://www.riverbankcomputing.com/Docs/PyQt4/html/qt.html#WidgetAttribute-enum

The problem may be related to the conversion process rather than the time
it takes to display the image. You mentioned that you were obtaining the
images as PIL Image objects, but these need to be converted to QImage or
QPixmap objects, so the raw data from the camera is being converted at
least twice before it reaches the screen!

>In fact, my work is to make a gui for displaying my
> partners'experimental results to our teacher, the source video is no
> need to be encoded to mpeg or h264 format, so I get the video from
> camera in the raw format and display them without encodeing or
> decoding process.

Which operating system is this on? (I'm guessing that it's Windows because
you mentioned the videocapture module.)

>As my partners will do some experiments on the raw data, maybe add
> a mark to label some area in the current frame, or change some part of
> it, I get every frame as a picture before they process the picture
> data, and then display the picture after their process.

So, do you intend to process the video and store it in a file, or do you
want to make these changes on a live video stream?

> But displaying the pictures one by one in my current way is so slow,
> I'm afraid that time spend on it is too long and the displaying of
> results will be discontinuous. So I think maybe there is another way
> to show these pictures.

Is there another way of getting the data from the camera? Perhaps the
author of videocapture has some ideas that can help you speed up the
conversion and rendering process. Maybe the Device.getBuffer() function
will provide data that can be passed directly to QPixmap.loadFromData().

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


Re: code for number guessing by computer

2007-09-30 Thread Tim Chase
> hi, please help me,, a newbie...send me code for a programme
> in which the computer tell u the number that u guessed

I can think of at least two versions of this:

>>> _ = raw_input("Think of an integer greater than 1 and less
than 3")
>>> print "Your number was 2!  This code is teh awesome!"

or, if you need to guess an arbitrary number greater than "N",
you can use this spiffy code:

>>> print "Think of an integer greater than zero and I will guess it"
>>> i = 1
>>> while raw_input("Was your number %i?" % i) <> "yes": i += 1
...

>>> print "I guessed your number correctly!"


Oh...unless this was a homework problem and you were looking for
a standard binary search of a problem-space, in which case,
mailing lists don't generally do your homework for you.
However, the first solution I provided is *far* better than a
boring old binary-search because it solves the problem in O(1)
rather than O(log N)  which any good math wonk will tell you is a
much more efficient algorithm!  :)

-tkc





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


Re: s.split() on multiple separators

2007-09-30 Thread William James
On Sep 30, 8:53 am, [EMAIL PROTECTED] wrote:
> Hello everyone,
>
> OK, so I want to split a string c into words using several different
> separators from a list (dels).
>
> I can do this the following C-like way:
>
> >>> c=' abcde abc cba fdsa bcd '.split()
> >>> dels='ce '
> >>> for j in dels:
>
> cp=[]
> for i in xrange(0,len(c)-1):
> cp.extend(c[i].split(j))
> c=cp
>
> >>> c
>
> ['ab', 'd', '', 'ab', '', '']
>
> But. Surely there is a more Pythonic way to do this?
>
> I cannot do this:
>
> >>> for i in dels:
>
> c=[x.split(i) for x in c]
>
> because x.split(i) is a list.

E:\Ruby>irb
irb(main):001:0> ' abcde abc cba fdsa bcd '.split(/[ce ]/)
=> ["", "ab", "d", "", "ab", "", "", "ba", "fdsa", "b", "d"]

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


Re: Python and SSL

2007-09-30 Thread Heikki Toivonen
John Nagle wrote:
> Any progress on getting M2Crypto 0.18 to build successfully
> on Fedora Core?

I have had no luck getting a Fedora Core environment running. Ubuntu is
my main OS, but I do have VMWare installed. I tried to install FC7 from
the live CD into VMWare, but the installer dies. I also tried to
download a ready-made FC8t1 VMWare appliance, but it fails to boot. So
currently I am dead in the water.

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


Re: Create a string array of all comments in a html file...

2007-09-30 Thread William James
On Sep 30, 10:39 am, sophie_newbie <[EMAIL PROTECTED]> wrote:
> Hi, I'm wondering how i'd go about extracting a string array of all
> comments in a HTML file, HTML comments obviously taking the format
> "".
>
> I'm fairly stumped on how to do this? Maybe using regular expressions?
>
> Thanks.

E:\Ruby>irb --prompt xmp
"And so funny!
It was a dark and stormy night.
".scan(//m)
==>["", ""]

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


Re: Can you please give me some advice?

2007-09-30 Thread Byung-Hee HWANG
On Sun, 2007-09-30 at 17:27 +, [EMAIL PROTECTED] wrote:
> I know nothing of Ruby, but just the fact that in Ruby the Hello World
> program is
> 
> puts 'Hello, World!'
> 
> whereas the Python Hello World program is
> 
> print 'Hello, World!'
> 
> suggests to me that Python is more intuitive because the word "print"
> has a meaning in English that makes sense given what you want to do,
> but "puts" just doesn't.  And, as someone who has been learning Python
> from almost no knowledge of programming, I've found it is not too bad
> in trying to keep as reasonably close to a natural language like
> English
> as possible.
> 
> I also think the mandatory indenting of Python is helpful in forcing
> new programmers to be neat and see code blocks quickly.  Plus I doubt
> the Ruby community has such a large group of helpful people and
> libraries
> and such (but I could be wrong about that, just assuming it based on
> the
> fact that Python has been around longer).
> 
> On the other hand, perhaps because Ruby is newer it has been able to
> freshly start with advantages learned from the difficulties of other
> languages.  Byung-Hee Hwang ought to go the Ruby group and see what
> they are saying.
> 
> As far as English goes, Byung-Hee, you have to admit English grammar
> is easy (though spelling is not so easy).  That anyone can speak and
> write Chinese is impressive to me, as the language looks completely
> impossible!  Good luck!
> 
I read above your comments all. It will be good reason for my decision
must be Python. Anyway, your guidance has been useful and is greatly
appreciated. Okay, I will study English very hardly, as well. Thanks,
again!

Byung-Hee
 

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


Re: Can you please give me some advice?

2007-09-30 Thread Ricardo Aráoz
[EMAIL PROTECTED] wrote:
>> Hello World in Ruby (and a few other 
>> languages):http://www.oreillynet.com/ruby/blog/2005/12/hello_world.html
> 
>> Hello World in 
>> Python:http://python.about.com/od/gettingstarted/ss/helloworld.htm
> 
> I know nothing of Ruby, but just the fact that in Ruby the Hello World
> program is
> 
> puts 'Hello, World!'
> 
> whereas the Python Hello World program is
> 
> print 'Hello, World!'
> 
> suggests to me that Python is more intuitive because the word "print"
> has a meaning in English that makes sense given what you want to do,
> but "puts" just doesn't.  And, as someone who has been learning Python
> from almost no knowledge of programming, I've found it is not too bad
> in trying to keep as reasonably close to a natural language like
> English
> as possible.
> 
> I also think the mandatory indenting of Python is helpful in forcing
> new programmers to be neat and see code blocks quickly.  Plus I doubt
> the Ruby community has such a large group of helpful people and
> libraries
> and such (but I could be wrong about that, just assuming it based on
> the
> fact that Python has been around longer).
> 
> On the other hand, perhaps because Ruby is newer it has been able to
> freshly start with advantages learned from the difficulties of other
> languages.  Byung-Hee Hwang ought to go the Ruby group and see what
> they are saying.
> 
> As far as English goes, Byung-Hee, you have to admit English grammar
> is easy (though spelling is not so easy).  That anyone can speak and
> write Chinese is impressive to me, as the language looks completely
> impossible!  Good luck!
> 
> 

Errhhh. guys.. I think .kr means Korea so he would speak
Korean, not Chinese


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


Re: notify when process finishes (on unix)

2007-09-30 Thread Michael Bentley

On Sep 30, 2007, at 7:11 AM, bahoo wrote:
> I'd like to write a script that sends me an email when a unix (Linux)
> process ends running (or CPU drops below some threshold).  Could
> anyone point me to the relevant functions, or show me an example?

man at.


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


Re: s.split() on multiple separators

2007-09-30 Thread mrkafk

> > ['ab', 'd', '', 'ab', '', '']
>
> Given your original string, I'm not sure how that would be the
> expected result of "split c on the characters in dels".

Oops, the inner loop should be:

for i in xrange(0,len(c)):

Now it works.


>   >>> c=' abcde abc cba fdsa bcd '
>   >>> import re
>   >>> r = re.compile('[ce ]')
>   >>> r.split(c)
>   ['', 'ab', 'd', '', 'ab', '', '', 'ba', 'fdsa', 'b', 'd', '']
>
> given that a regexp object has a split() method.

That's probably optimum solution. Thanks!

Regards,
Marcin

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


Re: s.split() on multiple separators

2007-09-30 Thread mrkafk
On 30 Wrz, 20:27, William James <[EMAIL PROTECTED]> wrote:
> On Sep 30, 8:53 am, [EMAIL PROTECTED] wrote:

> E:\Ruby>irb
> irb(main):001:0> ' abcde abc cba fdsa bcd '.split(/[ce ]/)
> => ["", "ab", "d", "", "ab", "", "", "ba", "fdsa", "b", "d"]

That's acceptable only if you write perfect ruby-to-python
translator. ;-P

Regards,
Marcin

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


[Python] Matrix convergence

2007-09-30 Thread Zhengzheng Pan
Hi all,

I'm trying to check whether a (stochastic/transition) matrix
converges, i.e. a function/method that will return True if the input
matrix sequence shows convergence and False otherwise. The background
is a Markov progress, so the special thing about the transition matrix
is the values of elements in each row add up to be 1. Fail to find any
relevant build-in methods in Python...

Currently the standard theorem on convergence in Markov chain
literature is involved with the properties of aperiodic and
connectivity, which I'm not able to implement with Python either...
Therefore I'm actually also looking for alternative conditions to
check for convergence, and am willing to sacrifice a little bit of
precision.

If you have any ideas/suggestions on how to examine the convergence of
a matrix in general or specifically about this kind of matrices, and
are willing to share, that'd be really great.

Thx!

Zz

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


Re: which language allows you to change an argument's value?

2007-09-30 Thread Michael Fesser
.oO(Summercool)

>I think in Pascal and C, we can never have an
>argument modified unless we explicitly allow it, by passing in the
>pointer (address) of the argument.

Pascal also allows passing by reference, which is done with the keyword
'var' when declaring the function parameters. Object Pascal also allows
const parameters.

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


Re: s.split() on multiple separators

2007-09-30 Thread mrkafk
> >  c=' abcde abc cba fdsa bcd '.split()
> >  dels='ce '
> >  for j in dels:
> >cp=[]
> >for i in xrange(0,len(c)-1):
>
> The "-1" looks like a bug; remember in Python 'stop' bounds
> are exclusive. The indexes of c are simply xrange(len(c)).

Yep. Just found it out, though this seems a bit counterintuitive to
me, even if it makes for more elegant code: I forgot about the high
stop bound.

>From my POV, if I want sequence from here to there, it should include
both here and there.

I do understand the consequences of making high bound exclusive, which
is more elegant code: xrange(len(c)). But it does seem a bit
illogical...

>  print re.split('[ce ]', c)

Yes, that does the job. Thanks.

Regards,
Marcin

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


Re: which language allows you to change an argument's value?

2007-09-30 Thread Bryan Olson
Summercool wrote:
> I wonder which language allows you to change an argument's value?
> like:
> 
> foo(&a) {
>   a = 3
> }
> 
> n = 1
> print n
> 
> foo(n) # passing in n, not &n
> print n
> 
> and now n will be 3.  I think C++ and PHP can let you do that, using
> their reference (alias) mechanism.  And C, Python, and Ruby probably
> won't let you do that.  What about Java and Perl?

I think you've missed how Python works, and probably others.
A Python function receives a reference to the argument, and
can modify the object if the object is mutable.

Nevertheless, assigning to the parameter's name will not
change the passed object. This function does nothing:

 def clear_list_wrong(lst):
 lst = []  # useless re-binding of local name

This version empties the passed list:

 def clear_list(lst):
 del lst[:]


> is there any way to prevent a function from changing the argument's
> value?

Sure. First choice: Don't change the value in the function.
Alternatives include making a copy to use as the argument.

> isn't "what i pass in, the function can modify it" not a desireable
> behavior if i am NOT passing in the address of my argument?  For one
> thing, if we use a module, and call some functions in that module, and
> the module's author made some changes to his code, then we have no way
> of knowing what we pass in could get changed.

Don't rely on undocumented behavior. Modules worth using are by
good programmers. Authors of library modules tend to be zealous
about not breaking client code.


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


Re: Can you please give me some advice?

2007-09-30 Thread George Sakkis
On Sep 30, 2:54 pm, Ricardo Aráoz <[EMAIL PROTECTED]> wrote:
>
> Errhhh. guys.. I think .kr means Korea so he would speak
> Korean, not Chinese

In this case, http://kr.diveintopython.org/html/index.htm might be
more useful ;-)

George

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

Re: Can you please give me some advice?

2007-09-30 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit :
(snip)
> I know nothing of Ruby, but just the fact that in Ruby the Hello World
> program is
> 
> puts 'Hello, World!'
> 
> whereas the Python Hello World program is
> 
> print 'Hello, World!'
> 
> suggests to me that Python is more intuitive because the word "print"
> has a meaning in English that makes sense given what you want to do,
> but "puts" just doesn't.

Hem Sorry, but it reminds me of the most clueless comments on Python 
I've seen on c.l.ruby. I really don't think Python is more or less 
"intuitive" than Ruby, and making a judgement on such a pointless detail 
is not even worth the bandswith IMHO. FWIW, 'puts' means 'put string' 
(implied : on stdout), which is certainly much more semantically correct 
than what 'print' implies. When stdout is redirected to a socket that 
send bytes to a client program - like, say, a browser -, you're 
certainly not "printing" anything.

Anyway, at this level, Python and Ruby are surprisingly close to each 
other.

>  And, as someone who has been learning Python
> from almost no knowledge of programming, I've found it is not too bad
> in trying to keep as reasonably close to a natural language like
> English
> as possible.

Here again, Ruby claims (or at least some rubyists do) that Ruby is as 
close as possible to "natural language". With examples like:

5.times do {
something
and_something_else
}

which is arguably more "intuitive" than:

for i in range(5):
   do_something()
   and_something_else()


> I also think the mandatory indenting of Python is helpful in forcing
> new programmers to be neat and see code blocks quickly.  Plus I doubt
> the Ruby community has such a large group of helpful people

While perhaps smaller, the Ruby community is (AFAICT) known for being 
very active and helpful.

> and
> libraries
> and such (but I could be wrong about that, just assuming it based on
> the
> fact that Python has been around longer).

On this last point at least, you're probably right !-)

> On the other hand, perhaps because Ruby is newer it has been able to
> freshly start with advantages learned from the difficulties of other
> languages.   Byung-Hee Hwang ought to go the Ruby group and see what
> they are saying.

Indeed. Or even better, try both languages and find out which one he 
likes best. Implementation and 3rd part libs set aside, I could not say 
one is better than the other, so it's mostly a matter of personal taste 
and affinities.

> As far as English goes, Byung-Hee, you have to admit English grammar
> is easy

Would you say French is easy ? Because as far as I'm concerned, I find 
it the easiest language ever. Could it be because I'm french ?-)

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


Re: which language allows you to change an argument's value?

2007-09-30 Thread Jerry Stuckle
Erik Wikström wrote:
> On 2007-09-30 18:49, Summercool wrote:
>> On Sep 30, 4:18 am, 7stud -- <[EMAIL PROTECTED]> wrote:
>>> SpringFlowers AutumnMoon wrote:
 we have no way
 of knowing what we pass in could get changed.
>>> Sure you do.  You look at the function's signature.  In order to use
>>> someone else's library, you have to know the function's signature.  And
>>> the signature explicitly tells you whether the value you pass in could
>>> be changed.
>> do you mean in C++?  I tried to find signature in two C++ books and it
>> is not there.  Google has a few results but it looks something like
>> prototype.  Is signature the same as the function prototype in the .h
>> file?
> 
> A signature is what is required to identify a function and includes
> return type, name of function and the types of the parameters, while it
> looks just like a prototype it is not. A prototype is something you
> write to satisfy your compiler while a signature identifies a function.
> Below are some examples of signatures, only the last can modify the
> values of its parameter.
>

No, the function's signature does not include the return type.

>   void foo(int, float)
>   std::string bar(const std::string&, int, int)
>   void baz(std::string&)
> 

Actually, these are prototypes.  The signature is what's passed onto the 
linker - perhaps something like "?foo@@[EMAIL PROTECTED]".  It's also generally 
compiler dependent for C++ mangled names.

Also, I should clarify - the C++ function signature includes parameter 
information.  The C function signature is only dependent on the function 
name and is almost always the name preceded by an underscore).

You can see the function signatures in a map file if you leave the names 
mangled.
.
>> If so, don't we usually just include <___.h> and forget about
>> the rest.  Documentation is fine although in some situation, the
>> descriptions is 2 lines, and notes and warnings are 4, 5 times that,
>> and the users' discussing it, holding different opinion is again 2, 3
>> times of that length.
> 
> Unless you read the documentation how do you know which files to
> include? And what documentation are you reading which does not clearly
> specify the functionality of the functions described?
>

Exactly.


-- 
==
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
[EMAIL PROTECTED]
==
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Delete spaces

2007-09-30 Thread William James

John Machin wrote:
> On Sep 29, 1:43 am, [EMAIL PROTECTED] wrote:
> > If I have a text file that is delimited by spaces, how do I import it
> > and get to comma delimited?  Here is a row of data from the text file:
> >
> > 1110:55:14  265   8.5
> > 1.4+1.1   2.5   Class-2   0
> >
> > I tried a few examples from the group and it didn't work, since the
> > file also has a header row and a row of seperators ( ---).  The
> > lengths of each row is something like 130, so there are extra spaces
> > after the last value as well.  I have tried joining and other things,
> > but I couldn't figure out how to get the values to come together.
> > Thanks.
> >
> > Kou
>
> It would help enormously if you could show us UNAMBIGUOUSLY what is in
> say the first 3 lines after the headings and separators -- do this:
>
> print repr(open("thefile", "rb").read()[:400])
>
> The other thing you need is to know enough about the file format to
> show us what is the CSV output that you require from the sample input
> -- we don't have crystal balls, and are likely to make half-donkeyed
> guesses, like these:
>
> If the spaces are really tabs, use line.split('\t')
>
> Otherwise: the file has fixed column widths, and any use of line.split
> will mangle it.
>
> The clumsy way to handle this is to count column positions, and write
> something ugly like:
> field1 = line[0:8]
> field2 = line[8:20]
> etc
>
> "a row of seperators ( ---)" sounds suspiciously like the "column
> aligned" format that can be produced by running a SQL query on a SQL
> Server database using MS's "Query Analyser". It looks like this:
>
> RecordType  ID1  ID2 Description
> ---  --- --
> 1   12345678 123456  Widget
> 4   87654321 654321  Gizmoid
> etc
>
> Does your file look something like that? If so, then all you have to
> do is leverage off the fact that the second line has one-space gaps
> between each bunch of dashes, and you can write a little module that
> will read any file like that, just as though it were a CSV file.

If the fields are separated by whitespace, this Awk program can
handle the situation:

awk 'BEGIN{OFS=","} {$1=$1} 1' oldfile >newfile

If the fields are fixed-width and the 2nd line is a guide to those
widths,
then this Ruby program should work (not optimized for speed):

lines = IO.readlines( 'data2' )
# Dump header.
lines.shift
# Save column guide.
guide = lines.shift.scan( /-+ */ )
for line in lines do
  puts guide.map{|s| line.slice!(0,s.size).strip}.join(",")
end

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


Re: GUI for viewing/editing python data structures?

2007-09-30 Thread timaranz
On Sep 27, 11:23 am, "Joshua J. Kugler" <[EMAIL PROTECTED]> wrote:
> A while back, I seem to remember coming across a small program that could
> view and edit python data structures via a nice expanding tree view.  I'm
> now in need of something like that (to verify data is imported correctly
> into a shelve file) and having a GUI would be much simpler than trying to
> wade through the output of str(d) or repr(d).
>
> I've tried googling with the obvious keywords (gui (view OR edit) python
> data structures) but t didn't get me anywhere.
>
> Pointers?
>
> j
>
> --
> Joshua Kugler
> Lead System Admin -- Senior Programmerhttp://www.eeinternet.com
> PGP Key:http://pgp.mit.edu/ ID 0xDB26D7CE

Try any of the good Python IDE's and use breakpoints and the watch
window. I like wing IDE from wingware.com - they have a free version
now.

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


Re: Create a string array of all comments in a html file...

2007-09-30 Thread Paul McGuire
On Sep 30, 10:39 am, sophie_newbie <[EMAIL PROTECTED]> wrote:
> Hi, I'm wondering how i'd go about extracting a string array of all
> comments in a HTML file, HTML comments obviously taking the format
> "".
>
> I'm fairly stumped on how to do this? Maybe using regular expressions?
>
> Thanks.

>>> from pyparsing import htmlComment
>>> htmlComment.searchString("""And so funny!
... """).asList()
[[''], ['']]

-- Paul



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


Re: which language allows you to change an argument's value?

2007-09-30 Thread Arne Vajhøj
Erik Wikström wrote:
>> their reference (alias) mechanism.  And C, Python, and Ruby probably
>> won't let you do that.  What about Java and Perl?
> 
> C will let you do it with pointers (it is just a syntactical difference
> from references in this case) and Java's references allows it.

Neither C or Java has call by reference.

C pointers and Java references may work similarly in most cases
but it is still call by value.

>I do not
> know about Ruby, Python and Perl, but (AFAIK) the all have OO support so
> I would be surprised if they used purely value semantics.

I can not see why OO should indicate anything about call by reference
support.

>> isn't "what i pass in, the function can modify it" not a desireable
>> behavior if i am NOT passing in the address of my argument?  For one
> 
> Being able to pass the actual object instead of a copy is highly
> desirable for two reasons. In most languages only one return value is
> allowed for a function so the ability to change parameters allows you to
> artificially return more without having to wrap them in constructs. The
> second reason is that for large objects the performance hit of having to
> create a copy each time you call a function can be forbidding.

Usually it is not a good thing, because it makes the code much
more difficult to read.

But sometimes it is handy.

I think C# got it right.

It allows it but require an explicit marking of it in both formal
argument list and actual argument list.

>> Java, Python, and Ruby, and we pass in a reference to object (not C+
>> +'s meaning of alias reference)
> 
> In what way does the C++ reference differ from those in Java, Python,
> and Ruby in this situation?

C++ and Java are very different in this aspect.

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

ANN: Generating svn:externals by inspecting a repository - z3c.repoexternals

2007-09-30 Thread Ross Patterson
z3c.repoexternals recursively retrieves subversion directory listings
from the url or path and matches directories against a previous set of
svn:externals if provided then against regular expressions and generates
qualifying svn:externals lines.  The defaults generate a set of
svn:externals for all the trunks in a repository and keeps them up to
date with the repository as new trunks are added when the previous
externals are provided thereafter.

http://cheeseshop.python.org/pypi/z3c.repoexternals

Ross

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


Re: notify when process finishes (on unix)

2007-09-30 Thread Dan Stromberg
On Sun, 30 Sep 2007 11:54:38 -0700, Michael Bentley wrote:

> On Sep 30, 2007, at 7:11 AM, bahoo wrote:
>> I'd like to write a script that sends me an email when a unix (Linux)
>> process ends running (or CPU drops below some threshold).  Could anyone
>> point me to the relevant functions, or show me an example?
> 
> man at.

http://stromberg.dnsalias.org/~strombrg/notify-when-up2.html

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


Re: Matrix convergence

2007-09-30 Thread Mark Dickinson
On Sep 30, 3:10 pm, Zhengzheng Pan <[EMAIL PROTECTED]> wrote:
> I'm trying to check whether a (stochastic/transition) matrix
> converges, i.e. a function/method that will return True if the input
> matrix sequence shows convergence and False otherwise. The background
> is a Markov progress, so the special thing about the transition matrix
> is the values of elements in each row add up to be 1. Fail to find any
> relevant build-in methods in Python...

I'm not sure exactly what you want here.  Do you have a single
transition matrix, or a `matrix sequence'?  Can I assume that you're
working with a time-homogeneous Markov chain with a finite state
space?  And that the function should take the transition matrix, and
should return True if and only if there's a unique limiting
distribution for the Markov process, independent of starting state?
Or have I misunderstood?

What's the typical number of states?  Thousands?  Millions?

Can you explain why you're unable to implement detection of
periodicity and connectivity (is this the same as irreducibility)?
Are there technical problems, or just conceptual problems?

Detecting irreducibility ought to be straightforward: form the
directed graph corresponding to the transition matrix (one vertex per
state, an edge from i to j iff the corresponding entry in the
transition matrix is nonzero) and apply Tarjan's algorithm (google
it!), which detects strongly connected components:  if there's a
single strongly connected component consisting of the entire graph
then the Markov process is irreducible.  Figuring out the period
shouldn't be too hard either---I have a feeling that it ought to be
possible to adapt Tarjan's algorithm to detect the period: label the
vertices of the graph by depth (Tarjan's algorithm is essentially a
depth-first traversal of the graph), and every time Tarjan's algorithm
detects a cycle, comparing depths will give you a multiple of the
period;  taking the gcd of all these multiples should give the period
itself.

An alternative, quick and dirty way (quick for the human, not the
computer!) would be just to compute some large power of the transition
matrix and eyeball it to see if all columns are identical.  If so, the
process converges.

> Thx!

Ur wlcm!

Mark

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


Re: s.split() on multiple separators

2007-09-30 Thread Paul Hankin
On Sep 30, 8:16 pm, [EMAIL PROTECTED] wrote:
> > >  c=' abcde abc cba fdsa bcd '.split()
> > >  dels='ce '
> > >  for j in dels:
> > >cp=[]
> > >for i in xrange(0,len(c)-1):
>
> > The "-1" looks like a bug; remember in Python 'stop' bounds
> > are exclusive. The indexes of c are simply xrange(len(c)).
>
> Yep. Just found it out, though this seems a bit counterintuitive to
> me, even if it makes for more elegant code: I forgot about the high
> stop bound.

You made a common mistake of using a loop index instead of iterating
directly.
Instead of:
  for i in xrange(len(c)):
 cp.extend(c[i].split(j))

Just write:
  for words in c:
 cp.extend(words.split(j))

Then you won't make a bounds mistake, and this snippet becomes a LOT
more readable.

(Of course, you're better using re.split instead here, but the
principle is good).

--
Paul Hankin

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


Re: Can you please give me some advice?

2007-09-30 Thread Bjoern Schliessmann
 [EMAIL PROTECTED] wrote:

> And, as someone who has been learning Python from almost no
> knowledge of programming, I've found it is not too bad in trying
> to keep as reasonably close to a natural language like English
> as possible.

Sure, your next project should be learning COBOL -- it must be
*very* intuitive. 

> On the other hand, perhaps because Ruby is newer it has been able
> to freshly start with advantages learned from the difficulties of
> other languages. 

What are those advantages in respect to Python?

Regards,


Björn

-- 
BOFH excuse #4:

static from nylon underwear

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


Re: [Python] Matrix convergence

2007-09-30 Thread Robert Israel
Zhengzheng Pan <[EMAIL PROTECTED]> writes:

> Hi all,
> 
> I'm trying to check whether a (stochastic/transition) matrix
> converges, i.e. a function/method that will return True if the input
> matrix sequence shows convergence and False otherwise. The background
> is a Markov progress, so the special thing about the transition matrix
> is the values of elements in each row add up to be 1. Fail to find any
> relevant build-in methods in Python...
> 
> Currently the standard theorem on convergence in Markov chain
> literature is involved with the properties of aperiodic and
> connectivity, which I'm not able to implement with Python either...
> Therefore I'm actually also looking for alternative conditions to
> check for convergence, and am willing to sacrifice a little bit of
> precision.
> 
> If you have any ideas/suggestions on how to examine the convergence of
> a matrix in general or specifically about this kind of matrices, and
> are willing to share, that'd be really great.
>

Do you mean you have an n x n stochastic matrix T and you're trying to find
out whether the sequence T^j converges? 

Let A = (I + T)^(n-1) and B = T^((n-1)^2+1).  Powers of matrices are easy
to compute using repeated squaring.

i and j are in the same class iff A_{ij} > 0 and A_{ji} > 0.  A class
containing state i is recurrent iff A_{ij} = 0 for all j not in the class.

A recurrent class containing state i is aperiodic iff 
B_{ij} > 0 for all j in the class.

T^j converges iff all recurrent classes are aperiodic.  Thus the test
can be written as follows:
For each i, either there is some j for which A_{ij} > 0 but A_{ji} = 0, 
or there is no j for which A_{ij} > 0 but B_{ij} = 0.
-- 
Robert Israel  [EMAIL PROTECTED]
Department of Mathematicshttp://www.math.ubc.ca/~israel 
University of British ColumbiaVancouver, BC, Canada
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: The Modernization of Emacs: terminology buffer and keybinding

2007-09-30 Thread Ken Tilton


Matthias Benkard wrote:
>>So this has nothing to
>>do with freedom in /any/ sense of the word, it has to do with a
>>political agenda opposed to the idea of private property.
> 
> 
> Freedom is inherently political, you know.  You're condemning the FSF
> for being political, although the FSF's stated purpose is a political
> one. 

Oh, I missed that. I just saw something about software should be shared 
and programmers should be content with an hourly wage, not sales.

kt

-- 
http://www.theoryyalgebra.com/

"We are what we pretend to be." -Kurt Vonnegut
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Command-line does work when scheduled

2007-09-30 Thread Jim
On Sep 30, 6:16 pm, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote:
> On Sun, 30 Sep 2007 07:42:56 -0700, Jim <[EMAIL PROTECTED]>
> declaimed the following in comp.lang.python:
>
> > What else could be wrong?
> > Thanks,
>
> Possibly those associations are only defined for your login account,
> and not active for the "account" that the task scheduler is running
> under?
> --
> WulfraedDennis Lee Bieber   KD6MOG
> [EMAIL PROTECTED] [EMAIL PROTECTED]
> HTTP://wlfraed.home.netcom.com/
> (Bestiaria Support Staff:   [EMAIL PROTECTED])
> HTTP://www.bestiaria.com/

As far as know, since I'm the major user of my PC it runs under my
account (computer administrator).   It even asked for the password for
my account when I added this scheduled task.
Any further ideas?
Thanks,
Jim

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


Re: Command-line does work when scheduled

2007-09-30 Thread Gabriel Genellina
En Sun, 30 Sep 2007 11:42:56 -0300, Jim <[EMAIL PROTECTED]> escribi�:

> On Sep 29, 8:45 pm, "Gabriel Genellina" <[EMAIL PROTECTED]>
> wrote:

>> The %* at the end is important: if you created the association by using
>> "Open with...", or selecting Python from the list of installed programs,
>> very likely the command says only "%1" - that is, the script being open,
>> but without any additional arguments.

> I believe I get the correct results as follows:
> ==
> Microsoft Windows XP [Version 5.1.2600]
> (C) Copyright 1985-2001 Microsoft Corp.
>
> J:\Jim Crerar\mypython\misc>assoc .py
> .py=Python.File
>
> J:\Jim Crerar\mypython\misc>ftype Python.File
> Python.File="E:\Python25\python.exe" "%1" %*
>
> J:\Jim Crerar\mypython\misc>
> ===
> What else could be wrong?

No more ideas... I think the scheduler just executes the command line, and  
if it works in a console, should work in the scheduler too... Unless you  
execute the job under another user, who has a different association for  
.py files, that's the only reason I can think of.

-- 
Gabriel Genellina

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

Re: Can you please give me some advice?

2007-09-30 Thread Alex Martelli
Byung-Hee HWANG <[EMAIL PROTECTED]> wrote:

> Hi there,
> 
> What is different between Ruby and Python?

Not all that much; Python is more mature, Ruby more fashionable.

 I am wondering what language
> is really mine for work. Somebody tell me Ruby is clean or Python is
> really easy! Anyway I will really make decision today what I have to
> study from now on. What I make the decision is more difficult than to
> know why I have to learn English. Yeah I do not like to learn English
> because it is just very painful..

www.python.or.kr/
http://wiki.python.org/moin/KoreanPythonBooks


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


ANN: PyPE 2.8.8

2007-09-30 Thread Josiah Carlson

=== What is PyPE? ===
PyPE (Python Programmers' Editor) was written in order to offer a
lightweight but powerful editor for those who think emacs is too much
and idle is too little. Syntax highlighting is included out of the box,
as is multiple open documents via tabs.

Beyond the basic functionality, PyPE offers an expandable source tree,
filesystem browser, draggable document list, todo list, filterable
function list, find and replace bars (no dialog to find or replace simple
strings), recordable and programmable macros, spell checker,
reconfigurable menu hotkeys, triggers, find in files, external process
shells, and much more.

=== More Information ===

If you would like more information about PyPE, including screenshots,
where to download the source or windows binaries, bug tracker, contact
information, or a somewhat complete listing of PyPE's features, visit
PyPE's home on the web:

http://pype.sf.net/index.shtml

If you have any questions about PyPE, please contact me, Josiah Carlson,
aka the author of PyPE, at jcarlson at uci.edu (remember to include
"PyPE" in the subject).


PyPE 2.8.7 includes the following changes and bugfixes since release
2.8.5:

# PyPE 2.8.8 -
(fixed) a bug related to realtime parsing of non-ascii Python source.


# PyPE 2.8.7 -
(fixed) some bugs related to the parsers module movement.
(fixed) ordering of user profile path discovery to not break when confronted
with insane 'HOME' environment variable on Windows (will use USERPROFILE or
HOMEDRIVE/HOMEPATH first).
(fixed) unrepr mechansim can now handle negative value storage for disabled
realtime options, etc.


# PyPE 2.8.6 -
(fixed) a bug with "Wrap Try/Except" as per emailed bug report from Ian York.
(added) ability to choose what port PyPE will listen on via --port= .
(fixed) workspaces in wxPython 2.8+, patch thanks to Craig Mahaney.
(added) explicit exclude dirs for find in files, patch thanks to Craig
Mahaney.
(added) paste and down mechanism to paste and move the cursor down, patch
thanks to Craig Mahaney.
(added) delete right mechanism to delete everything from the cursor to the end
of the line, patch thanks to Craig Mahaney.
(added) delete line mechanism to delete the current line, patch thanks to
Craig Mahaney.
(added) paste rectangle command for rectangular pasting, patch thanks to Craig
Mahaney.
(fixed) support for alternate background colors thanks to bug report from
Craig Mahaney.
(added) macro support to Craig Mahaney's added functionality.
(added) implementation for regular expression replacements, possibly to be
integrated as part of a 'replace in all open documents' in the future.
(added) automatic spellcheck for text and tex documents of up to 200,000 byes
in size.  Will only spellcheck if the user has enabled "check syntax" in the
"Realtime Options".
(fixed) issue when trying to save language settings when cursor position is
not to be saved.
(added) support for \chapter section delimiter in *tex files.
(fixed) issue that prevented the highest level source listing from being
sorted in the Name and Line sorted source trees.
(changed) rather than reading and executing a file for configuration loading,
we now use a variant of the 'unrepr()' mechanism with support for True/False.
(changed) find/replace bar now uses variant of 'unrepr()' rather than the
compiler module directly.
(changed) moved parsers.py to plugins and stopped using import * to get its
contents.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Command-line does work when scheduled

2007-09-30 Thread Jim
On Sep 30, 6:37 pm, "Gabriel Genellina" <[EMAIL PROTECTED]>
wrote:
> En Sun, 30 Sep 2007 11:42:56 -0300, Jim <[EMAIL PROTECTED]> escribi?:
>
>
>
>
>
> > On Sep 29, 8:45 pm, "Gabriel Genellina" <[EMAIL PROTECTED]>
> > wrote:
> >> The %* at the end is important: if you created the association by using
> >> "Open with...", or selecting Python from the list of installed programs,
> >> very likely the command says only "%1" - that is, the script being open,
> >> but without any additional arguments.
> > I believe I get the correct results as follows:
> > ==
> > Microsoft Windows XP [Version 5.1.2600]
> > (C) Copyright 1985-2001 Microsoft Corp.
>
> > J:\Jim Crerar\mypython\misc>assoc .py
> > .py=Python.File
>
> > J:\Jim Crerar\mypython\misc>ftype Python.File
> > Python.File="E:\Python25\python.exe" "%1" %*
>
> > J:\Jim Crerar\mypython\misc>
> > ===
> > What else could be wrong?
>
> No more ideas... I think the scheduler just executes the command line, and  
> if it works in a console, should work in the scheduler too... Unless you  
> execute the job under another user, who has a different association for  
> .py files, that's the only reason I can think of.
>
> --
> Gabriel Genellina- Hide quoted text -
>
> - Show quoted text -

Just logged into the only other account (my Wife's -- uses only for
hotmail access) and it will not run this scheduled Python program.
Thank you for your help.
Jim

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


Using fractions instead of floats

2007-09-30 Thread andresj
I was doing some programming in Python, and the idea came to my mind:
using fractions instead of floats when doing 2/5.

The problem arises when you try to represent some number, like 0.4 in
a float. It will tell you that it's equal to 0.40002.
"This is easy to fix", you may say. "You just use the decimal.Decimal
class!". Well, firsly, there would be an excess of typing I would need
to do to calculate 0.4+0.6:

from decimal import Decimal
print Decimal("0.4")+Decimal("0.6")

Secondly, what happens if I need to sum 1/3 and 0.4? I could use
Decimal to represent 0.4 precisely, but what about 1/3? Sure, I could
use _another_ class which works in a base (binary, decimal, octal,
hexadecimal) in which 1/3 can be represented exactly... Not to mention
the problem of operating with those two different classes...

So the solution I think is using a fraction type/class, similar to the
one found in Common Lisp. If you have used CLisp before, you only need
to type:
(+ 1/3 6/10)
to get the exact result. (Yes, I also hate the (operator arg1 arg2)
syntax, but it's just an example). I would like to have something
similar in Python, in which dividing two numbers gives you a fraction,
instead of an integer (python 2.x) or a float (decided for python
3.x).

an implementation could be like this:
class frac(object): # PS: This (object) thing will be removed in
python 3.0, right?
def __init__(self, numerator, denominator):
pass
def __add__(self, other):
pass
#...

(I have an implementation of the frac class done (this meaning, it
works for me), and although it's pretty dirty, I'd be happy to post it
here if you want it.)

My idea, in summary would be that this python shell session is true:
>>> 5/2
2 1/2
>>> f = 5/2
>>> f.__class__

>>> # or 
>>> (0.6).__class__ # Treat decimal literals as fractions, so that...

>>> 1/3+0.6
14/15
>>> # That was easy. ;)

I would like to get some feedback on this idea. Has this been posted
before? If so, was it rejected? and for what?
Also, I would like to know if you have improvements on the initial
design, and if it would be appropiate to send it as a PEP.

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


Re: Using fractions instead of floats

2007-09-30 Thread Ben Finney
andresj <[EMAIL PROTECTED]> writes:

> The problem arises when you try to represent some number, like 0.4 in
> a float.

Which is really a specific case of the general problem that, for any
given number base, some non-integer numbers cannot be exactly
represented as fractions.

> Secondly, what happens if I need to sum 1/3 and 0.4? I could use
> Decimal to represent 0.4 precisely, but what about 1/3?

What about the sum of π (pi) and √2 (sqrt(2))?

> So the solution I think is using a fraction type/class

As explained above, a fractional-number class only shifts the "exact
representation" problem, it doesn't solve it.

-- 
 \ "Facts do not cease to exist because they are ignored."  -- |
  `\ Aldous Huxley |
_o__)  |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: which language allows you to change an argument's value?

2007-09-30 Thread Roedy Green
On Sun, 30 Sep 2007 10:47:13 -, Summercool
<[EMAIL PROTECTED]> wrote, quoted or indirectly quoted someone
who said :

>and now n will be 3.  I think C++ and PHP can let you do that, using
>their reference (alias) mechanism.  And C, Python, and Ruby probably
>won't let you do that.  What about Java and Perl?

Seem to me you could in FORTRAN and Pascal, and maybe even Algol.  It
has been a while.

I have come to appreciate Java's strong isolation convention. It makes
it a lot easier to track down WHERE in the code a value could
potentially change and keeps those places to a minimum.

-- 
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Using fractions instead of floats

2007-09-30 Thread andresj
On Sep 30, 6:48 pm, Ben Finney <[EMAIL PROTECTED]>
wrote:
> andresj <[EMAIL PROTECTED]> writes:
> > The problem arises when you try to represent some number, like 0.4 in
> > a float.
>
> Which is really a specific case of the general problem that, for any
> given number base, some non-integer numbers cannot be exactly
> represented as fractions.

Yes. That's what I meant to say, by giving an example.

> > Secondly, what happens if I need to sum 1/3 and 0.4? I could use
> > Decimal to represent 0.4 precisely, but what about 1/3?
>
> What about the sum of   (pi) and  2 (sqrt(2))?

Mm... To be honest I hadn't thought of that in the moment I wrote the
last post...
But I think then, that I'll be more specific, so that my proposal only
deals with *rational numbers*, not irrationals.

>
> > So the solution I think is using a fraction type/class
>
> As explained above, a fractional-number class only shifts the "exact
> representation" problem, it doesn't solve it.

I don't understand completely what you said, but I think you are
saying that it doesn't solve the problem with irrational numbers.
Which is exactly what this proposal doesn't solve. (Mainly because I
do not know of any way of doing it in "normal" math).

(While I write this, my mind reminds me of operating with roots " 2
(sqrt(2))", which I think could be solved in another similar way,
although it has some more specific use cases... But in any case,
that's not in the scope of this proposal, as they are irrational
numbers.)



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


Re: Using fractions instead of floats

2007-09-30 Thread [EMAIL PROTECTED]
On Sep 30, 8:35?pm, andresj <[EMAIL PROTECTED]> wrote:
> I was doing some programming in Python, and the idea came to my mind:
> using fractions instead of floats when doing 2/5.
>
> The problem arises when you try to represent some number, like 0.4 in
> a float. It will tell you that it's equal to 0.40002.
> "This is easy to fix", you may say. "You just use the decimal.Decimal
> class!". Well, firsly, there would be an excess of typing I would need
> to do to calculate 0.4+0.6:
>
> from decimal import Decimal
> print Decimal("0.4")+Decimal("0.6")
>
> Secondly, what happens if I need to sum 1/3 and 0.4? I could use
> Decimal to represent 0.4 precisely, but what about 1/3? Sure, I could
> use _another_ class which works in a base (binary, decimal, octal,
> hexadecimal) in which 1/3 can be represented exactly... Not to mention
> the problem of operating with those two different classes...
>
> So the solution I think is using a fraction type/class, similar to the
> one found in Common Lisp. If you have used CLisp before, you only need
> to type:
> (+ 1/3 6/10)
> to get the exact result. (Yes, I also hate the (operator arg1 arg2)
> syntax, but it's just an example). I would like to have something
> similar in Python, in which dividing two numbers gives you a fraction,
> instead of an integer (python 2.x) or a float (decided for python
> 3.x).
>
> an implementation could be like this:
> class frac(object): # PS: This (object) thing will be removed in
> python 3.0, right?
> def __init__(self, numerator, denominator):
> pass
> def __add__(self, other):
> pass
> #...
>
> (I have an implementation of the frac class done (this meaning, it
> works for me), and although it's pretty dirty, I'd be happy to post it
> here if you want it.)
>
> My idea, in summary would be that this python shell session is true:
>
> >>> 5/2
> 2 1/2
> >>> f = 5/2
> >>> f.__class__
> 
> >>> # or 
> >>> (0.6).__class__ # Treat decimal literals as fractions, so that...
> 
> >>> 1/3+0.6
> 14/15
> >>> # That was easy. ;)
>
> I would like to get some feedback on this idea. Has this been posted
> before? If so, was it rejected? and for what?
> Also, I would like to know if you have improvements on the initial
> design, and if it would be appropiate to send it as a PEP.

The gmpy module has unlimited precision rationals.
Works pretty good, too.

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


Re: Using fractions instead of floats

2007-09-30 Thread George Sakkis
On Sep 30, 9:35 pm, andresj <[EMAIL PROTECTED]> wrote:
> I was doing some programming in Python, and the idea came to my mind: using 
> fractions instead of floats when doing 2/5.
> (...)
> I would like to get some feedback on this idea. Has this been posted
> before? If so, was it rejected? and for what?

Is internet down today ?

http://pypi.python.org/pypi/clnum/1.2
http://www.python.org/dev/peps/pep-0239/

George

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


call for collaboration (python / freesound)

2007-09-30 Thread patrick
hi,

i have an idea, who doesn't have?

the technologies required:
gtk+
glade
gobject
Queue
threading
gstreamer (GNonLin)
config

here's the result of my week-end trying to understand how it's working:
http://www.workinprogress.ca/pd/freesound.png

the idea is to make a bridge from python to freesound:
http://freesound.iua.upf.edu/

here's the class i used:
http://www.leonard-ritter.com/freesound_integration

there's some already solutions, but they are linked to an application:
http://www.jokosher.org/screenshots
http://trac.zeitherrschaft.org/aldrin/wiki/AldrinScreenshots

if anybody is interested into "working / helping" on this project, i 
would be very happy.

cheers guys,
pat


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


Fwd: Using fractions instead of floats

2007-09-30 Thread Andres Riofrio
PS: Sorry, George Sakkis, for the double emailing... I forgot to add
python-list in the To: field the first time. :)

Haha. Ok. Thank you for pointing me to those links :). I hadn't
thought of searching for the word 'rational' instead of 'decimal'...

>From what I've read, seems that the principal reason for rejecting the
PEP is that there was not much need (enthusiasm)... Well, then I have
a question: Is there a way to make 5/2 return something other than an
integer? I can do:
class int(int):
  def __add__(self, other):
pass
but that will only work if I do int(5)/int(2)...

(setting __builtin__.int=int doesn't work, either)

What I'd like is to be able to implement what I put in the proposal,
as I don't think it's a really big language change...

On 9/30/07, George Sakkis <[EMAIL PROTECTED]> wrote:
> On Sep 30, 9:35 pm, andresj <[EMAIL PROTECTED]> wrote:
> > I was doing some programming in Python, and the idea came to my mind: using 
> > fractions instead of floats when doing 2/5.
> > (...)
> > I would like to get some feedback on this idea. Has this been posted
> > before? If so, was it rejected? and for what?
>
> Is internet down today ?
>
> http://pypi.python.org/pypi/clnum/1.2
> http://www.python.org/dev/peps/pep-0239/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Using fractions instead of floats

2007-09-30 Thread Gabriel Genellina
En Sun, 30 Sep 2007 23:36:23 -0300, George Sakkis  
<[EMAIL PROTECTED]> escribi�:

> On Sep 30, 9:35 pm, andresj <[EMAIL PROTECTED]> wrote:
>> I was doing some programming in Python, and the idea came to my mind:  
>> using fractions instead of floats when doing 2/5.
>> (...)
>> I would like to get some feedback on this idea. Has this been posted
>> before? If so, was it rejected? and for what?
>
> Is internet down today ?
>
> http://pypi.python.org/pypi/clnum/1.2
> http://www.python.org/dev/peps/pep-0239/

And gmpy: http://www.aleax.it/gmpy.html

-- 
Gabriel Genellina

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

Creating a custom python python distribution

2007-09-30 Thread shailesh
Hi,
I wish to create a Python distribution includind Python and some other
libraries (Zope 3, PyWin32, numpy, lxml, etc.) which are required for
my applications. e.g. there are Enthough and ASPN distributions of
Python.

Unfortunately, I have not been able to find the right documentation
for this purpose.

Could some one give an overview of what needs to be done for this
purpose?

With regards,
 -Shailesh

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


Re: s.split() on multiple separators

2007-09-30 Thread Gabriel Genellina
En Sun, 30 Sep 2007 16:16:30 -0300, <[EMAIL PROTECTED]> escribi�:

>> From my POV, if I want sequence from here to there, it should include
> both here and there.
>
> I do understand the consequences of making high bound exclusive, which
> is more elegant code: xrange(len(c)). But it does seem a bit
> illogical...

See this note from E.W.Dijkstra in 1982 where he says that the Python  
convention is the best choice.
http://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html

-- 
Gabriel Genellina

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

Re: Command-line does work when scheduled

2007-09-30 Thread Jay Loden
I sometimes see issues like this at work because certain processes, including 
scheduled tasks if I remember right, can run as Local System user instead of as 
your user account. That tends to be a real pain for Python or Perl scripts 
because that means that they don't have the associations configured properly. 
You can play around a bit as Local System to find out, using an old trick: 

open a command prompt and type the following:

  at nn:nn /interactive cmd

where nn:nn is one minute from the current time (24 hour clock, so 11:30 pm 
would be 24:30). This will launch a cmd prompt on your desktop, but running as 
Local System instead of as yourself. From there you can see what your script 
does when you run it as the System user, and see what assoc .py says etc. 

If you still can't figure it out, the only other things I can think of would be 
to wrap it in a .bat file and try using that for your scheduled task, or using 
py2exe to compile your script to an exe which should eliminate the whole file 
association/PATH issue altogether ;)

Hope that helps,

-Jay

Gabriel Genellina wrote:
> No more ideas... I think the scheduler just executes the command line, and  
> if it works in a console, should work in the scheduler too... Unless you  
> execute the job under another user, who has a different association for  
> .py files, that's the only reason I can think of.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Using fractions instead of floats

2007-09-30 Thread Terry Reedy

"Andres Riofrio" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
| a question: Is there a way to make 5/2 return something other than an
| integer?

>>> from __future__ import division
>>> 1/2
0.5
>>> 5/2
2.5

tjr



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


Editor extensions to get a full IDE (was: An Editor that Skips to the End of a Def)

2007-09-30 Thread Ben Finney
Bruno Desthuilliers <[EMAIL PROTECTED]> writes:

> Ben Finney a écrit :
> > Both Emacs and Vim are highly customisable text editors. They are
> > configurable with complete programming languages specific to the
> > program, and both have a huge community of programmers writing
> > useful extensions.
> 
> FWIW, emacs has
> [...]
> - ECB (emacs-code-browser), that adds a file explorer and
> functions/classes inspector

Thank you very much for making me aware of this amazing tool. I've now
been using it for a couple of weeks, and not only does it work
smoothly with Python, it works smoothly with loads of other source
file formats, such as targets in a Makefile or changelog entries.

This is really important, because developing programs is much more
than just editing files in one language. A "python IDE" is all well
and good, but it's much better to have a solid generic text editor
that can be extended by the community.

When the editor supports hundreds of common (and less-common) file
syntaxes that are associated with programming, the job becomes that
much more streamlined. I had become accustomed to this with syntax
highlighting, but I'm very pleased to see that ECB has a similarly
broad support for organising and browsing the variety of file syntaxes
I'm likely to be editing when developing with Python.

It also goes without saying that it's great to have all this with
*optional* GUI support; it all works just the same when I'm connecting
to a text terminal remotely over a slow link.

Talk about "huge community of programmers writing useful
extensions". Wow.

What's the equivalent in the Vim world?

-- 
 \ "He who laughs last, thinks slowest."  -- Anonymous |
  `\   |
_o__)  |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list

boost.python error with DirectX

2007-09-30 Thread Ling
I am using boost.python to wrap C++ function which includes
directmusic libraries to simply play the midi, but lots of linkage
errors "error LNK2001: unresolved external symbol". I wonder if it is
possible to work with DirectX - directmusic libs.  Are there any ways
to wrap it?

*compilation errors *
 msvc.link.dll bin\msvc-7.1\debug\threading-multi\playmusic.pyd bin
\msvc-7.1\debu
g\threading-multi\playmusic.lib
   Creating library bin\msvc-7.1\debug\threading-multi\playmusic.lib
and object
bin\msvc-7.1\debug\threading-multi\playmusic.exp
playmusic.obj : error LNK2001: unresolved external symbol
_GUID_PerfMasterTempo
playmusic.obj : error LNK2019: unresolved external symbol
__imp__CoUninitialize@
0 referenced in function "void __cdecl `anonymous
namespace'::StartPlay(void)" (
[EMAIL PROTECTED]@@YAXXZ)
playmusic.obj : error LNK2001: unresolved external symbol
_CLSID_DirectMusicSegm
ent
playmusic.obj : error LNK2001: unresolved external symbol
_IID_IDirectMusicSegme
nt8
playmusic.obj : error LNK2001: unresolved external symbol
_GUID_DirectMusicAllTy
pes
playmusic.obj : error LNK2001: unresolved external symbol
_CLSID_DirectMusicPerf
ormance
playmusic.obj : error LNK2001: unresolved external symbol
_IID_IDirectMusicPerfo
rmance8
playmusic.obj : error LNK2019: unresolved external symbol
__imp__CoCreateInstanc
[EMAIL PROTECTED] referenced in function "void __cdecl `anonymous
namespace'::StartPlay(void)
" ([EMAIL PROTECTED]@@YAXXZ)
playmusic.obj : error LNK2001: unresolved external symbol
_CLSID_DirectMusicLoad
er
playmusic.obj : error LNK2001: unresolved external symbol
_IID_IDirectMusicLoade
r8
playmusic.obj : error LNK2019: unresolved external symbol
[EMAIL PROTECTED]
referenced in function "void __cdecl `anonymous
namespace'::StartPlay(void)" (?S
[EMAIL PROTECTED]@@YAXXZ)
bin\msvc-7.1\debug\threading-multi\playmusic.pyd : fatal error
LNK1120: 11 unres
olved externals

call "C:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\bin\vcvars3
2.bat"  >nul
link /NOLOGO /INCREMENTAL:NO /DLL /DEBUG /subsystem:console /out:"bin
\msvc-7.1\d
ebug\threading-multi\playmusic.pyd" /IMPLIB:"bin\msvc-7.1\debug
\threading-multi\
playmusic.lib" /LIBPATH:"C:\Panda3D-1.4.0\python\libs"   @"bin
\msvc-7.1\debug\th
reading-multi\playmusic.pyd.rsp"
if %ERRORLEVEL% NEQ 0 EXIT %ERRORLEVEL%
if exist "bin\msvc-7.1\debug\threading-multi
\playmusic.pyd.manifest" (
mt -nologo -manifest "bin\msvc-7.1\debug\threading-multi
\playmusic.p
yd.manifest" "-outputresource:bin\msvc-7.1\debug\threading-multi
\playmusic.pyd;2
"
)

...failed msvc.link.dll bin\msvc-7.1\debug\threading-multi
\playmusic.pyd bin\msv
c-7.1\debug\threading-multi\playmusic.lib...
...removing bin\msvc-7.1\debug\threading-multi\playmusic.lib
...failed updating 2 targets...

**compiliation
errors**

In C++, Inside "playmusic.cpp", it needs to include following
DirectMusic libs.  The link errors mainly related to directmusic
stuff.

#include 
#include 
#include 

* playmusic.cpp*

#include 
#include 
#include 
#include "boost/python/detail/wrap_python.hpp"

//using namespace std;
#include 
#include 
#include 
#include 

namespace {
//-
// Defines, constants, and global variables
//-
void StartPlay();

IDirectMusicLoader8*  g_pLoader = NULL;
IDirectMusicPerformance8* g_pPerformance= NULL;
IDirectMusicSegment8* g_pSegment= NULL;
FLOAT fTempo;

void StartPlay() {


// Initialize COM
CoInitialize(NULL);

// Create loader object
CoCreateInstance( CLSID_DirectMusicLoader, NULL, CLSCTX_INPROC,
  IID_IDirectMusicLoader8, (void**)&g_pLoader );

.
.
namespace python = boost::python;

BOOST_PYTHON_MODULE(playmusic)
{
python::def("StartPlay", StartPlay);
}

*** playmusic.cpp***

The code in void StartPlay() inside "playmusic.cpp" can be compiled
and executed successfully before in C++, so I extract that part.
Any ideas?  Thanks so much for your help

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


I earn $36800 a month with google adsense

2007-09-30 Thread panguohua
www.space666.com


a good website for making money with your blog.more information there

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


Re: Balloon Taskbar Popup for Windows XP

2007-09-30 Thread makko
Thanks all.

regards,
Makko


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


Re: Fwd: Using fractions instead of floats

2007-09-30 Thread Gabriel Genellina
En Mon, 01 Oct 2007 00:10:05 -0300, Andres Riofrio  
<[EMAIL PROTECTED]> escribi�:

> From what I've read, seems that the principal reason for rejecting the
> PEP is that there was not much need (enthusiasm)... Well, then I have
> a question: Is there a way to make 5/2 return something other than an
> integer? I can do:
> class int(int):
>   def __add__(self, other):
> pass
> but that will only work if I do int(5)/int(2)...

I'm afraid not. But if you are crazy enough you can preprocess your source  
using something similar to the tokenize example  


-- 
Gabriel Genellina

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

Re: Program inefficiency?

2007-09-30 Thread Dimiter "malkia" Stanev
Sorry for intruding here,

But one inefficiency of the Windows XP (not NTFS in general) is that 
NTFS must generate 8.3 names (for old-DOS/Win31/Win95/Win98/WinME 
compatibility).

Generating such a name could slow down the system, as the name must be 
unique, and finding such unique name would be slow.

Off course this should only affect the CREATION, not the SEARCH 
(although with 8.3 support enabled you might end up with x2 times more 
entries (if all your names are bigger than 8.3)).

Here's more:

http://www.windowsdevcenter.com/pub/a/windows/2005/02/08/NTFS_Hacks.html

Thanks,
Dimiter "malkia" Stanev.

[EMAIL PROTECTED] wrote:
>  
> 
>> -Original Message-
>> From: [EMAIL PROTECTED]
>> the program works great except for one thing. It's significantly
>> slower through the later files in the search then through the early
>> ones... Before anyone criticizes, I recognize that that middle section
>> could be simplified with a for loop... I just haven't cleaned it
>> up...
>>
>> The problem is that the first 300 files take about 10-15 seconds and
>> the last 300 take about 2 minutes... If we do more than about 1500
>> files in one run, it just hangs up and never finishes...
>>
>> Is there a solution here that I'm missing? What am I doing that is so
>> inefficient?
> 
> You did not mention the OS, but because you are using
> "pathname\editfile.txt", it sounds like you are using an MS OS.  From
> past experience with various MS OSes, I found that as the number of
> files in a directory increases the slower your process runs for each
> file.  You might try putting these files into multiple sub-directories.
> 
> 
> The information contained in this message and any attachment may be
> proprietary, confidential, and privileged or subject to the work
> product doctrine and thus protected from disclosure.  If the reader
> of this message is not the intended recipient, or an employee or
> agent responsible for delivering this message to the intended
> recipient, you are hereby notified that any dissemination,
> distribution or copying of this communication is strictly prohibited.
> If you have received this communication in error, please notify me
> immediately by replying to this message and deleting it and all
> copies and backups thereof.  Thank you.
> 
-- 
http://mail.python.org/mailman/listinfo/python-list