Re: variable hell

2005-08-25 Thread Adriaan Renting
Not in my Python.

>>> for count in range(0, 10):
... value = count
... exec("'a%s=%s' % (count, value)")
... 
>>> dir()
['__builtins__', '__doc__', '__name__', 'count', 'value']
>>> for count in range(0, 10):
... value = count
... exec(eval("'a%s=%s' % (count, value)"))
... 
>>> dir()
['__builtins__', '__doc__', '__name__', 'a0', 'a1', 'a2', 'a3', 'a4', 'a5', 
'a6', 'a7', 'a8', 'a9', 'count', 'value']
>>> 

I myself use code like this to load user defined classes.
exec(eval("'from %s import %s' % (script, script)"))
exec(eval("'self.user_class = %s()' % script"))
self.user_class.run()

But this can probably be done with the imp module too.
 
>>>rafi <[EMAIL PROTECTED]> 08/25/05 6:03 pm >>> 
Adriaan Renting wrote: 
>You might be able to do something along the lines of 
> 
>for count in range(0,maxcount): 
>  value = values[count] 
>  exec(eval("'a%s=%s' % (count, value)")) 
 
why using the eval? 
 
exec ('a%s=%s' % (count, value)) 
 
should be fine 
 
-- 
rafi 
 
"Imagination is more important than knowledge." 
   (Albert Einstein) 
-- 
http://mail.python.org/mailman/listinfo/python-list 

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


Re: Jargons of Info Tech industry

2005-08-25 Thread Gordon Burditt
>>> HTML is designed to degrade gracefully (never mind that most web
>>> authors and many browser developers don't seem to comprehend this),
>>> so you don't really need a "subset" html to get the safety features
>>> you want. All you need to do is disable the appropriate features in
>>> the HTML renderer in your news and mail readers. JavaScript, Java,
>>> and any form of object embedding. Oh yeah, and frames.
>> 
>> And links.  And cookies.  And any kind of external site or local
>> file access.  And browser history.
>
>What is the risk with browser history?

spyware and viruses (which can come from places other than email)
sending it somewhere.  Actually, there's not much point in keeping
a browser history if all it can contain is mail in YOUR mailbox
that may or may not have been already deleted.

Gordon L. Burditt
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Email client in Pyhton

2005-08-25 Thread Oren Tirosh
> IIRC, many of the mailbox modules (such as mailbox and
> mhlib) are read-only, but they should provide a good starting point.

The mailbox module has recently been upgraded for full read-write
access by a student participating in google's Summer of Code. It is
currently under review for inclusion in the standard library.

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


Re: loop in python

2005-08-25 Thread travlr
I gotta say that as number cruncher, iteration in python is my biggest
nightmare. I do what is possible with numpy, but element by element
processing is a hassle. My programming experience is still pretty fresh
at a year, so "exotics" as such are not in play yet. I also wish python
looping/iterative features could be improved as best possible (what
ever extent that may be). Generators are a friend, but not as
performance friendly as when I am able to do all the needed work in
numpy. I dunno I guess I got spoiled :)

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


Re: Jargons of Info Tech industry

2005-08-25 Thread Mike Schilling

"Denis Kasak" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Mike Schilling wrote:
>>
>> I see a difference between "X would be useful for A, B, and C" and "Y 
>> will always be the only proper way."
>>
>> Don't you?
>
> Y would not be useful because of the bandwidth it consumes, the malware it 
> would introduce, the additional time spent focusing on the format rather 
> than quality of the content and, frankly, because it's useless.

Threaded mail-readers too, screen-based editors , spell-checkers, all 
useless frills.


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


Re: Jargons of Info Tech industry

2005-08-25 Thread Chris Head
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

John Bokma wrote:
[snip]
>>usage consists of downloading your e-mail. When using a Webmail
>>service, your bandwidth usage consists of downloading the message,
>>PLUS the entire user interface.
> 
> 
> Not necessary when using (i)frames + cache

True. Perhaps Hotmail is not very well designed, but it doesn't use
frames. I'm not really familiar with other Webmail systems, but the one
provided by my ISP doesn't either.

> 
> 
>>Additionally, a user interface operating inside an HTML
>>renderer can NEVER be as fast as a native-code user interface with
>>only the e-mail message itself passed through the renderer.
> 
> 
> Nowadays, more then futile.

Sorry, I don't understand what you mean. Even on my 2.8GHz Pentium 4,
using Thunderbird to juggle messages is noticeably faster than wandering
around Hotmail. Complex HTML rendering still isn't absolutely
instantaneous. It's significantly more painful when I use my 433MHz
Celeron. It simply takes a long time to jump between message, inbox,
other message, inbox, other other message, inbox, etc.

> 
> 
>>I mean, the way
>>Webmail works, you're at the message list and click on a message to
>>view. This causes a whole new page, user-interface and all, to be
>>loaded. In comparison, that's like shutting down and re-opening your
>>e-mail program for every single message you want to view!
> 
> 
> This can be designed much better by using iframes, maybe even Ajax.

Agreed. Judicious use of frames (internal or otherwise) or
Javascript-based partial reloads could seriously improve the situation.
They might also provide an easier way for Webmail providers to implement
their pages in valid HTML: if you render the entire e-mail message alone
 in a frame, you don't have to start stripping out pieces of e-mail
because they already exist (html and body elements, for example)

> 
> 
>>Why can't we use the Web for what it was meant for: viewing hypertext
>>pages? Why must we turn it into a wrapper around every application
>>imaginable?
> 
> 
> Because it works?
> 

... and purpose-built client applications (e.g. Thunderbird) don't?
Maybe I'm old-fashioned but I still very much prefer thick clients. They
simply feel much more solid. Perhaps part of it is that thin clients
have to communicate with the server at least a little bit for just about
everything they do, while thick clients can do a lot of work without ANY
Internet round-trip delay at all. Hotmail has to talk to the server to
move a message from one mailbox to another. Thunderbird doesn't. Ergo,
Thunderbird is faster as soon as the Internet gets congested.

Chris
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.1 (MingW32)

iD8DBQFDDqXh6ZGQ8LKA8nwRAsVyAKCjwP9iyrPRBnMsI1pB+wqZdANE6ACfYeGx
w8SLwXln0VjpuwF+L7BDfKM=
=pZ/B
-END PGP SIGNATURE-
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Email client in Pyhton

2005-08-25 Thread knaren

> Start reading related RFCs like RFC2822, RFC2045/6/7, RFC2231, RFC821
> ... and then read Python documentation and you'll find that most of
> these RFC are supported/implemented by python modules like 
> 
> - email
> - smtlib
> - rfc822
> 
> As far I know the most complete mail client written in Python is Pyne,
> wich is a news/mail client written with PyGTK.
thank u, for suggestions. have started to read these RFCs

> I'm writing a newsreader (XPN), wich can send mail replies, maybe you
> can read its code.
i like have a look at this too... 

-- 
K Naren,MeTel Team.
http://www.midascomm.com/

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


Re: Jargons of Info Tech industry

2005-08-25 Thread John Bokma
Chris Head <[EMAIL PROTECTED]> wrote:

> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
> 
> [EMAIL PROTECTED] wrote:
> [snip]
>> ... and generally these "web based message boards" (i.e. forums I
>> assume you mean) have none of the useful tools that Usenet offers and
>> are much, much slower.
> [snip]
> 
> Arrgh, I *emphatically* *hate* Web-based-(almost anything). Why, oh
> WHY, would we subject ourselves to Web-based message boards and
> Webmail services? When using a proper e-mail client, your bandwidth
> usage consists of downloading your e-mail. When using a Webmail
> service, your bandwidth usage consists of downloading the message,
> PLUS the entire user interface.

Not necessary when using (i)frames + cache

> Additionally, a user interface operating inside an HTML
> renderer can NEVER be as fast as a native-code user interface with
> only the e-mail message itself passed through the renderer.

Nowadays, more then futile.

> I mean, the way
> Webmail works, you're at the message list and click on a message to
> view. This causes a whole new page, user-interface and all, to be
> loaded. In comparison, that's like shutting down and re-opening your
> e-mail program for every single message you want to view!

This can be designed much better by using iframes, maybe even Ajax.

> Why can't we use the Web for what it was meant for: viewing hypertext
> pages? Why must we turn it into a wrapper around every application
> imaginable?

Because it works?

-- 
John   Small Perl scripts: http://johnbokma.com/perl/
   Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html

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


Re: Newbie question: Sub-interpreters for CAD program

2005-08-25 Thread sonicSpammersGoToHellSmooth
Hi,

Actually I was thinking of doing the bulk of everything in Python, and
then embedding a Python interpreter into the CAD program.  Anything in
C++ would be to speed up critical things, like rules checking, etc.  I
have looked at python cad (found it a year or two ago) and am inspired
by it; I'm glad someone's done the legwork, although it's a long way
from anything EDA related (well, the 2d stuff could be used for
schematics).  I have also looked at gEDA and found it lacked the
"modern feel" I'm looking for.  It seems people are stuck on batch
processing of text descriptions, and NOT integrating completely the
front-to-back design process.  I'd like to write something that
(eventually) would actually have an install program and run like a
normal app, on Windoze or Linux.  Most of my experience with open
source software is that it's not user-oriented.  Finally, if I write
something that's cool, I may try to make money from it, which means I'm
not sure how much I'm going to want to release to the general public.
This means I can't use code from pythonCad, etc., if I want to keep it
propietary.  I could make it free for noncommercial use.  Anyway,
that's a long way off.  My original question was about how to run an
interpreter within the interpreter, and whether that's what needs to be
done to have some scripting capabilities which separated the user's
code from the main application.

Michael

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


Re: Jargons of Info Tech industry

2005-08-25 Thread Denis Kasak
Mike Schilling wrote:
> 
> I see a difference between "X would be useful for A, B, and C" and "Y will 
> always be the only proper way."
> 
> Don't you?

Y would not be useful because of the bandwidth it consumes, the malware 
it would introduce, the additional time spent focusing on the format 
rather than quality of the content and, frankly, because it's useless. 
As Rich already said, if one wants to look at neatly formatted content, 
one can always visit the web. Usenet is meant to be an 
information-sharing facility, and I cannot see *any* reason why it 
should be exposed to all the disadvantages stated in numerous places in 
thread to gain a pale "advantage" such as flashy content. We already 
have a World Wide Web, no need to make Usenet it's clone.

-- Denis

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


Static vs. dynamic checking for support of concurrent programming

2005-08-25 Thread Mike Meyer
The recent thread on threads caused me to reread the formal definition
of SCOOP, and I noticed something I hadn't really impressed me the
first time around: it's using staticly checkable rules to help ensure
correct behavior in a concurrent environment.

That's impressive. That's *really* impressive. I know of no other
language that does that - though they probably exist. I'd be
interested in references to them.

Normally, I think of static checking as something that's not critical,
as a good test suite will cause exceptions on the things that static
checking catches. But concurrency errors are a completely different
class of critter entirely, and generally result in really nasty
runtime errors.

Which leads to the question - what would it take to get Python to
throw exceptions in the cases where a compiler implementing SCOOP will
emit an error message? There's two reasons for looking into this. One,
wanting to continue to believe that static checking doesn't really buy
anything. Two, wanting Python to have more powerful and robust tools
for dealing with threads. If these can be made to work, then they're a
candidate for addition. If not, then we need to look elsewhere. I'm
not going to worry about how the semantics would be implemented at
this point - I'm more interested in whether the static rules can be
enforced in a dynamic environment.

First, the rules. These are greatly simplified and mangled to describe
a hypothetical Python-like language. If you want to see the formald
definitions yourself, you can find them at http://archive.eiffel.com/doc/manuals/technology/concurrency/CONCURRENCY.html
>.

The new feature: a variable can be marked as "separate". This means
the object it refers to is running on a different thread, and changes
the semantics of accessing it in various ways:

First, invoking a method and ignoring it's return value is run
asynchronously. Likewise, an assigment to an attribute is run
asynchronously. I'm going to call such actions a "command".  Commands
are queued by the object in question, and are guaranteed to run in the
order they appear in the code. The execution order of the commands
with respect to purely thread-local statements or commands on other
separate objects is not guaranteed.

Reading the value of an attribute is a synchronization point. All
commands on the object will be execute before you are allowed to read
the value of the attribute, and no following commands on the object
will execute before the value is read.

Note that this makes the Law of Demeter something your really want to
pay attention to. Doing "so.addChild(newChild)" runs asynchronously,
whereas doing "so.children.append(newChild)" causes a read of
so.children, which will synchronize the object, then an update of
children.

Now, the constraints:

1) Any object assigned to a separate variable must really be
   separate. This applies to all the ways you can do an assignment.

2) The invocation of a command on a separate objects is only legal if
   the separate object is a formal argument of the enclosing
   function/method.

The first one seems trivial, but avoids some nasty bugs. For instance,
if you have a list of separate objects and you want to divide a
workload up among them, you'd do something like:

def divide(self, work, workers):
for worker in workers:
self.startWork(worker, work.getNextChunk)

def startWork(self, separate worker, chunk):
worker.process(chunk)


Adding a deceleration seems to the the only way to handle this in
Python. It's basically an assertion isinstance(object,
Separate). startWork should throw an exception if it's called with an
object that isn't separate.

What happens if you call a routine with a separate object and the
routine doesn't expect one? That's almost certainly bad - most
functions expect all their statements to be executed in order. Does
solving this requrie a check on every argument passed to a function to
verify that it's not separate?

The second rule is how locking is handled. If you invoke a function
with one or more separate objects, the language processor waits until
it has the locks on all the separate objects before running the body
of the routine. This means that locking order when you need multiple
locks is determined by the language processor, not the programmer, so
you've eliminated locking order errors as a source of deadlocks.

If you don't declare separate objects, then this would seem to require
that every command be checked to see if it's on a separate object, and
if so throw an exception if the object isn't a formal argument to the
enclosing routine. If you have declarations and enforce them, you can
limit the checks to objects declared separate.

These solutions aren't very dynamic. Can anyone see how to do this
without having to declare separate variables as such?

Thanks,
  http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.

wanna stop by my homemade glory hole?

2005-08-25 Thread Lacy
my husband is installing an extra bathroom poolside.  there is a perfect size 
hole (unless you have a huge cock) to stick your dick through into the adjoing 
room.  come around the side of my house(perfect if you look like a repair man) 
enter into the unfisnished bathroom and I'll service you from the other side.  
you can leave when your done, no talking or small talk.  i want to do this 
before the hole gets patched up. its been a huge fantasy of mine ever since 
I've seen a glory hole online. you can email me for a time convienient for you. 
im home all-day most days so my schedule is open. do you prefer a certain color 
of lipstick? check out my pic and email here under kallegirl26 
www.no-strings-fun.net/kallegirl26 
ready and waiting, me ;o)


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


Re: Jargons of Info Tech industry

2005-08-25 Thread CBFalconer
Gordon Burditt wrote:
> 
>> HTML is designed to degrade gracefully (never mind that most web
>> authors and many browser developers don't seem to comprehend this),
>> so you don't really need a "subset" html to get the safety features
>> you want. All you need to do is disable the appropriate features in
>> the HTML renderer in your news and mail readers. JavaScript, Java,
>> and any form of object embedding. Oh yeah, and frames.
> 
> And links.  And cookies.  And any kind of external site or local
> file access.  And browser history.

What is the risk with browser history?

-- 
Chuck F ([EMAIL PROTECTED]) ([EMAIL PROTECTED])
   Available for consulting/temporary embedded and systems.
     USE worldnet address!

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


Re: Jargons of Info Tech industry

2005-08-25 Thread CBFalconer
Chris Head wrote:
> 
... snip ...
> 
> Why can't we use the Web for what it was meant for: viewing
> hypertext pages? Why must we turn it into a wrapper around every
> application imaginable?

Because the Lord High PoohBah (Bill) has so decreed.  He has
replaced General bullMoose.

-- 
Chuck F ([EMAIL PROTECTED]) ([EMAIL PROTECTED])
   Available for consulting/temporary embedded and systems.
     USE worldnet address!


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


Re: Jargons of Info Tech industry

2005-08-25 Thread BJ Swope
So says Chris from his webmail account...

On 8/25/05, Chris Head <[EMAIL PROTECTED]> wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
> 
> [EMAIL PROTECTED] wrote:
> [snip]
> > ... and generally these "web based message boards" (i.e. forums I
> > assume you mean) have none of the useful tools that Usenet offers and
> > are much, much slower.
> [snip]
> 
> Arrgh, I *emphatically* *hate* Web-based-(almost anything). Why, oh WHY,
> would we subject ourselves to Web-based message boards and Webmail
> services? When using a proper e-mail client, your bandwidth usage
> consists of downloading your e-mail. When using a Webmail service, your
> bandwidth usage consists of downloading the message, PLUS the entire
> user interface. Additionally, a user interface operating inside an HTML
> renderer can NEVER be as fast as a native-code user interface with only
> the e-mail message itself passed through the renderer. I mean, the way
> Webmail works, you're at the message list and click on a message to
> view. This causes a whole new page, user-interface and all, to be
> loaded. In comparison, that's like shutting down and re-opening your
> e-mail program for every single message you want to view!
> 
> Why can't we use the Web for what it was meant for: viewing hypertext
> pages? Why must we turn it into a wrapper around every application
> imaginable?
> 
> ...
> 
> 
> 
> Chris
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v1.2.1 (MingW32)
> 
> iD8DBQFDDoRR6ZGQ8LKA8nwRAvinAKCVi3Sfztpm3ILUk7TnunPJxBEVzwCguvAu
> ME8mWt2eVNpPUckJ3NT39KY=
> =TdTk
> -END PGP SIGNATURE-
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Jargons of Info Tech industry

2005-08-25 Thread Chris Head
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

[EMAIL PROTECTED] wrote:
[snip]
> ... and generally these "web based message boards" (i.e. forums I
> assume you mean) have none of the useful tools that Usenet offers and
> are much, much slower.
[snip]

Arrgh, I *emphatically* *hate* Web-based-(almost anything). Why, oh WHY,
would we subject ourselves to Web-based message boards and Webmail
services? When using a proper e-mail client, your bandwidth usage
consists of downloading your e-mail. When using a Webmail service, your
bandwidth usage consists of downloading the message, PLUS the entire
user interface. Additionally, a user interface operating inside an HTML
renderer can NEVER be as fast as a native-code user interface with only
the e-mail message itself passed through the renderer. I mean, the way
Webmail works, you're at the message list and click on a message to
view. This causes a whole new page, user-interface and all, to be
loaded. In comparison, that's like shutting down and re-opening your
e-mail program for every single message you want to view!

Why can't we use the Web for what it was meant for: viewing hypertext
pages? Why must we turn it into a wrapper around every application
imaginable?

...



Chris
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.1 (MingW32)

iD8DBQFDDoRR6ZGQ8LKA8nwRAvinAKCVi3Sfztpm3ILUk7TnunPJxBEVzwCguvAu
ME8mWt2eVNpPUckJ3NT39KY=
=TdTk
-END PGP SIGNATURE-
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Jargons of Info Tech industry

2005-08-25 Thread Gordon Burditt
>HTML is designed to degrade gracefully (never mind that most web
>authors and many browser developers don't seem to comprehend this), so
>you don't really need a "subset" html to get the safety features you
>want. All you need to do is disable the appropriate features in the
>HTML renderer in your news and mail readers. JavaScript, Java, and any
>form of object embedding. Oh yeah, and frames.

And links.  And cookies.  And any kind of external site or local
file access.  And browser history.  

Gordon L. Burditt
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Jargons of Info Tech industry

2005-08-25 Thread John Bokma
Paul Rubin  wrote:

> Mike Meyer <[EMAIL PROTECTED]> writes:
>> > Another advantage is that evewry internet-enabled computer today
>> > already comes with an HTML renderer (AKA browser)
>> 
>> No, they don't. Minimalist Unix distributions don't include a browser
>> by default. I know the BSD's don't, and suspect that gentoo Linux
>> doesn't. 
> 
> Lynx?

Emacs?

-- 
John   Small Perl scripts: http://johnbokma.com/perl/
   Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html

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


Re: Jargons of Info Tech industry

2005-08-25 Thread Paul Rubin
Mike Meyer <[EMAIL PROTECTED]> writes:
> > Another advantage is that evewry internet-enabled computer today already 
> > comes with an HTML renderer (AKA browser)
> 
> No, they don't. Minimalist Unix distributions don't include a browser
> by default. I know the BSD's don't, and suspect that gentoo Linux
> doesn't. 

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


Re: variable hell

2005-08-25 Thread Nx
Thanks for all the responses and animated discussion,
which is still the best way to learn something new.

Most of the time it is not that you want to do something
in a certain way , it rather is one cannot think of a
better , faster more efficient way .

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


Re: Jargons of Info Tech industry

2005-08-25 Thread Mike Meyer
"Mike Schilling" <[EMAIL PROTECTED]> writes:
> Another advantage is that evewry internet-enabled computer today already 
> comes with an HTML renderer (AKA browser)

No, they don't. Minimalist Unix distributions don't include a browser
by default. I know the BSD's don't, and suspect that gentoo Linux
doesn't. 

HTML is designed to degrade gracefully (never mind that most web
authors and many browser developers don't seem to comprehend this), so
you don't really need a "subset" html to get the safety features you
want. All you need to do is disable the appropriate features in the
HTML renderer in your news and mail readers. JavaScript, Java, and any
form of object embedding. Oh yeah, and frames.

No problem.

 http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: argument matching question

2005-08-25 Thread Learning Python
thanks, got it.
I want to test the **name option for argument matching.

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


Re: argument matching question

2005-08-25 Thread Leif K-Brooks
Learning Python wrote:
> A code like this:
> 
> def adder(**varargs):
>   sum=varargs[varargs.keys()[0]]
>   for next in varargs.keys()[1:]:
> sum=sum+varargs[next]
>   return sum
> 
> print adder( "first","second",'third')
> 
> How to pass arguments to a functions that use dictionary collection?

Like adder(foo="bar", bar="baz"), but I think you really want a function
like this:

def adder(*args):
sum = args[0]
for value in args[1:]:
sum += value
return sum
-- 
http://mail.python.org/mailman/listinfo/python-list


argument matching question

2005-08-25 Thread Learning Python
I know this is dummy, just never saw an example of this.


I want to use the special argument matching.

A code like this:

def adder(**varargs):
  sum=varargs[varargs.keys()[0]]
  for next in varargs.keys()[1:]:
sum=sum+varargs[next]
  return sum

print adder( "first","second",'third')



It pop up error like this:

Traceback (most recent call last):
  File "learn.py", line 7, in ?
print adder( "first","second",'third')
TypeError: adder() takes exactly 0 arguments (3 given)


How to pass arguments to a functions that use dictionary collection?


Thanks

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


wanna stop by my homemade glory hole?

2005-08-25 Thread Casee
my husband is installing an extra bathroom poolside.  there is a perfect size 
hole (unless you have a huge cock) to stick your dick through into the adjoing 
room.  come around the side of my house(perfect if you look like a repair man) 
enter into the unfisnished bathroom and I'll service you from the other side.  
you can leave when your done, no talking or small talk.  i want to do this 
before the hole gets patched up. its been a huge fantasy of mine ever since 
I've seen a glory hole online. you can email me for a time convienient for you. 
im home all-day most days so my schedule is open. do you prefer a certain color 
of lipstick? check out my pic and email here under kallegirl26 
www.no-strings-fun.net/kallegirl26 
ready and waiting, me ;o)


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


Re: variable hell

2005-08-25 Thread Ron Garret
In article <[EMAIL PROTECTED]>,
 Steve Holden <[EMAIL PROTECTED]> wrote:

> rafi wrote:
> > Reinhold Birkenfeld wrote:
> > 
> > 
>  exec(eval("'a%s=%s' % (count, value)"))
> >>>
> >>>why using the eval?
> >>>
> >>>exec ('a%s=%s' % (count, value))
> >>>
> >>>should be fine
> >>
> >>And this demonstrates why exec as a statement was a mistake ;)
> >>
> >>It actually is
> >>
> >>exec 'a%s=%s' % (count, value)
> > 
> > 
> > Noted.
> > 
> > In the meantime another question I cannot find an answer to: any idea 
> > why does eval() consider '=' as a syntax error?
> > 
> >  >>> eval ('a=1')
> > Traceback (most recent call last):
> >File "", line 1, in ?
> >File "", line 1
> >  a=1
> >   ^
> > SyntaxError: invalid syntax
> > 
> > Thanks
> > 
> Because eval() takes an expression as an argument, and assignment is a 
> statement.

And if you find this distinction annoying, try Lisp.

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


Re: Anyone recognize this numeric storage format - similar to "float", but not quite

2005-08-25 Thread geskerrett
I am not sure if you are still watching this thread, but I seem to have
a bit of a problem with the code sample you so graciously provided.
It seems to work in all instances, except the original example I
provided (namely, 1234567890). On my system, the number 1234567890,
gets converted to 1234567895.5.

I made a few changes to your original program, but it is largely the
same with different test samples samples.  Any thoughts ??

Sample Code Below --
# Conversion of Microsoft Binary Format numbers to Python Floats

import binascii as bn
import struct as st

data = [(1234567890,'00AF052C139F'),
(4069954144,'0060929672A0'),
(99.99, '703D0AD7FF237494'),
( 8.88, '400ad7a3709c2d91'),
( 2.22, '400ad7a3709c2d8f'),
( 3.33, 'b047e17a54350290'),
(  1500.34, '7814ae47e18a3b8b'),
( 42345.00, '00692590'),
]

def msd2float(bytes):
if sum(bytes) in [0,72,127]:   #take out values that don't make
sense possible the NaN and Infinity ??
return 0.0
b = bytes[:]
sign = bytes[-2]&0x80
b[-2] |= 0x80 #hidden most sig bit in place of sign
exp = bytes[-1] - 0x80 - 56  #exponent offset
acc = 0L
for i,byte in enumerate(b[:-1]):
acc |=(long(byte)<<(i*8))
return (float(acc)*2.0**exp)*((1.,-1.)[sign!=0])

for line in data:
val = line[0]
binval = bn.unhexlify(line[1])
le_bytes = list(st.unpack('',binval))
test = msd2float(le_bytes)
print " In:",val, "\nOut:",test,"\n"

Sample Output 
C:/Python24/pythonw.exe -u  "C:/pytest/dms/Test MBF.pyw"
 In: 1234567890
Out: 1234567895.5

 In: 4069954144
Out: 4069954144.0

 In: 99.99
Out: 99.99

 In: 8.88
Out: 8.88

 In: 2.22
Out: 2.22

 In: 3.33
Out: 3.33

 In: 1500.34 
Out: 1500.34 

 In: 42345.0 
Out: 42345.0

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


Re: pre-PEP: Object-oriented file module

2005-08-25 Thread Martin v. Löwis
Kenneth McDonald wrote:
> Why would any of the issues below be any more difficult than they are with
> the current file functions? I'm not proposing a C replacement for current
> functions, merely a Python module that wraps all of those functions (and
> adds some additional ones) in an appropriate class.

I'm not saying they are difficult. I want to know how your library deals
with them. There is a good chance that some of these questions remain
unanswered in the PEP, and I just want to indicate that I would be
unhappy if they are. Specifying this API is a huge task, much more so
than coming up with an implementation that does "something".

This is one of the reasons why nothing like this has made it to the
standard library: as a library module, it would have to face many
more scenarios that the authors of the module originally did not
consider. Therefore, the documentation must be complete and consistent,
and there should be an agreement as to what this library can do and
what it cannot do.

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


Re: pre-PEP: Object-oriented file module

2005-08-25 Thread Kenneth McDonald
Why would any of the issues below be any more difficult than they are withthe current file functions? I'm not proposing a C replacement for currentfunctions, merely a Python module that wraps all of those functions (andadds some additional ones) in an appropriate class.On Aug 25, 2005, at 5:28 PM, Martin v. Löwis wrote:I'd be personally curious as to how you would be dealing with Unicode file names. How to access file attributes is also an interesting question (e.g. how to find out whether it is a symlink, whether it is a hidden file, what the POSIX ACL is, and what the 8.3 short name is) -- 
http://mail.python.org/mailman/listinfo/python-list

Re: Bug in string.find; was: Re: Proposed PEP: New style indexing, was Re: Bug in slice type

2005-08-25 Thread Bryan Olson
Steve Holden asked:
 > Do you just go round looking for trouble?

In the course of programming, yes, absolutly.

 > As far as position reporting goes, it seems pretty clear that find()
 > will always report positive index values. In a five-character string
 > then -1 and 4 are effectively equivalent.
 >
 > What on earth makes you call this a bug?

What you just said, versus what the doc says.

 > And what are you proposing that
 > find() should return if the substring isn't found at all? please don't
 > suggest it should raise an exception, as index() exists to provide that
 > functionality.

There are a number of good options. A legal index is not one of
them.


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


Re: pre-PEP: Object-oriented file module

2005-08-25 Thread Martin v. Löwis
Kenneth McDonald wrote:
> I'd like to propose a new PEP [no, that isn't a redundant 'process'  in
> there :-)--pre-PEP is a different process than PEP], for a  standard
> library module that deals with files and file paths in an  object
> oriented manner. I believe this module should be included as  part of
> the standard Python distribution.

See the discussions at

http://python.org/sf/1226256
http://mail.python.org/pipermail/python-dev/2005-June/054439.html
http://mail.python.org/pipermail/python-dev/2005-July/054535.html

I'd be personally curious as to how you would be dealing with
Unicode file names. How to access file attributes is also
an interesting question (e.g. how to find out whether it is
a symlink, whether it is a hidden file, what the POSIX ACL
is, and what the 8.3 short name is)

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


Embedding Python in other programs

2005-08-25 Thread Thomas Bartkus
Name: lib64python2.4-devel
Summary: The libraries and header files needed for Python development

Description: The Python programming language's interpreter can be extended
with dynamically loaded extensions and can be embedded in other programs.
This package contains the header files and libraries needed to do these
types of tasks.
--


*** The Python programming language's interpreter ... can be embedded in
other programs. ***

That's very intriguing!
But I can't seem to locate much information about this.

Can anyone direct me to greater enlightenment?
Thomas Bartkus

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


Re: MacPython 2.2 on Mac OS X 10.3.8 - configurePython error

2005-08-25 Thread Robert Kern
Paul Miller wrote:
> I have a user who is is having trouble getting MacPython on his OS X 
> 10.3.8 system.
> 
> When he runs ConfigurePythonCarbon, he gets this error:
> 
> [terminated]
> 'import site' failed; use -v for traceback
> traceback )most recent call last):
> File "Moes:SWdev:Jack:Python2.2:Mac:script:configurePython.py", line 11 
> , in ?
> Import error: No module named os
> 
> 
> I have had no trouble on my system (same version).
> 
> What can cause this?

os.py got deleted from its home, probably. I doubt anyone is going to
help fix the problem though. MacPython 2.2 has been long abandoned. The
official OS X binary for Python 2.4.1 can be found here:

http://www.python.org/ftp/python/2.4.1/MacPython-OSX-2.4.1-1.dmg

-- 
Robert Kern
[EMAIL PROTECTED]

"In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die."
  -- Richard Harter

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


Re: a dummy python question

2005-08-25 Thread Learning Python
Thanks all for replying.
I finally know what's going on.

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


Re: pickle.load not working?

2005-08-25 Thread [EMAIL PROTECTED]
I get it, I missed the little parintheses or however you spell it. () .

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


Re: a dummy python question

2005-08-25 Thread Robert Kern
infidel wrote:
> Learning Python wrote:
> 
>>A example in learning Python by Mark Lutz and David Ascher
>>
>>about function scope
>>
>>example like this:
>>
>>
def outer(x):
>>
>> def inner(i):
>>print i,
>>if i: inner(i-1)
>> inner(x)
>>
outer(3)
>>
>>Here supposely, it should report error, because the function inner
>>cannot see itself since inner is only in local namespace of outer.
> 
> If that were so, Pythonistas could never write a recursive function!

No, presumably at the writing of the edition of _Learning Python_ that
he is reading, Python did not have nested scopes in the language, yet.
One could always write a recursive function provided it was at the
top-level of the module. One could not write a recursive function inside
another function because inside inner(), it could only access two
namespaces, the one local to inner() and the module's namespace, not the
namespace of outer() where inner() is defined.

For the original poster: Your book is old. You will want to catch up on
recent additions to the language by reading the "What's New in Python
2.x" portions of the documentation for each major revision. Specifically:

http://www.python.org/doc/2.2.3/whatsnew/node9.html

http://www.python.org/doc/2.2.3/whatsnew/whatsnew22.html
http://www.python.org/doc/2.3.5/whatsnew/whatsnew23.html
http://www.python.org/doc/2.4.1/whatsnew/whatsnew24.html

-- 
Robert Kern
[EMAIL PROTECTED]

"In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die."
  -- Richard Harter

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


Re: a dummy python question

2005-08-25 Thread rafi
Learning Python wrote:

>>>def outer(x):
> 
>  def inner(i):
> print i,
> if i: inner(i-1)
>  inner(x)
> 
>>>outer(3)
>  
> Here supposely, it should report error, because the function inner
> cannot see itself since inner is only in local namespace of outer.

There is no error. the function inner is defined recursively: It calls 
itself with a different value than the one it has been called with. When 
defining a recursive function, there are case when it calls itself and 
other when it does not (otherwise the recursion is infinite and the 
program crashes after all the memory is used). Here it does not call 
itself when the value given as parameter is 0 (the if fails).

one can always see itself (even at definition time)

> but I typed in this in python interface. It works!
> it print out:
> 3 2 1 0
> 
> If you turn this into a module file and run this
> it print out
> 3 2 1 0 none

I suppose you wrote this down (instead of cut and paste) as the none is 
not capitalized. There must be something else in your module that writes 
the none as your code presented above should really not "as is".

-- 
rafi

"Imagination is more important than knowledge."
(Albert Einstein)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: New Arrival to Python

2005-08-25 Thread [EMAIL PROTECTED]
1.  Whichever one works best for you, of course.  :)  There are lots of
editors and IDEs out there.  I find myself coming back to Emacs and
jEdit the most, but there are a sizable number of vi partisans
(benighted heathens tho they be) and an increasing number of Eclipse,
Wing and Komodo partisans.  Having tried all the free ones I could get
my mitts on... well, Emacs and jEdit serve my needs just fine.  Your
mileage may vary significantly.

2-5 are all either IDE opinion questions, which I'll duck, or specific
technologies I don't use, which I'll duck.  Resuming with 6...

_Core Python Programming_ is a reasonable read for a beginner.  I
prefer Mark Lutz's _Programming Python_ 2nd Ed, though.  _Learning
Python_ is also a good choice, but only for real beginners to
programming--if you already know a programming language, _Programming
Python_ is the better choice.

I use Beazley's _Python Essential Reference_ about once every couple of
days.  Surprisingly, I use it more than _Python in a Nutshell_, but
that may be due more to the fact _PER_ is usually within closer reach.
They're both good references, with _PiaN_ being more heavyweight with
better coverage.

The _Python Cookbook_ is a great way to expand your knowledge of Python
and discover the weird and cool stuff you can do with it.

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


MacPython 2.2 on Mac OS X 10.3.8 - configurePython error

2005-08-25 Thread Paul Miller
I have a user who is is having trouble getting MacPython on his OS X 
10.3.8 system.

When he runs ConfigurePythonCarbon, he gets this error:

[terminated]
'import site' failed; use -v for traceback
traceback )most recent call last):
File "Moes:SWdev:Jack:Python2.2:Mac:script:configurePython.py", line 11 
, in ?
Import error: No module named os


I have had no trouble on my system (same version).

What can cause this?

-Paul

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


Re: a dummy python question

2005-08-25 Thread [EMAIL PROTECTED]
This is not reproducible under either Python 2.3.4 (UNIX), Python 2.4.1
(UNIX) or Python 2.4.1 (Windows).  If you still need help, we need to
know precisely what you're doing.

= scope_test.py =
#!/usr/bin/env python
#
# (insert his code, verbatim...)
#
if __name__=='__main__':
outer(3)

= end scope_test.py =

[EMAIL PROTECTED] ~]$ ./scope_test.py
3 2 1 0

[EMAIL PROTECTED] ~]$ python
Python 2.3.4 (#1, Feb  2 2005, 11:44:13)
[GCC 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from scope_test import outer
>>> outer(3)
3 2 1 0

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


Re: a dummy python question

2005-08-25 Thread infidel

Learning Python wrote:
> A example in learning Python by Mark Lutz and David Ascher
>
> about function scope
>
> example like this:
>
> >>def outer(x):
>  def inner(i):
> print i,
> if i: inner(i-1)
>  inner(x)
> >>outer(3)
>
> Here supposely, it should report error, because the function inner
> cannot see itself since inner is only in local namespace of outer.

If that were so, Pythonistas could never write a recursive function!

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


Re: minimalist regular expression

2005-08-25 Thread John Bokma
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:

> Exists some tool, programs or some able to compute the minimal regular
> expression, namely ,taking a series of regular exoression, the minimal
> one that makes the same matching?
> thanx in advance

length? (define minimal) :-D.

-- 
John   Small Perl scripts: http://johnbokma.com/perl/
   Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html

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


Usenet, HTML (was Re: Jargons of Info Tech industry)

2005-08-25 Thread John Bokma
Ulrich Hobelmann <[EMAIL PROTECTED]> wrote:

> On the information side (in contrast to the discussion side) RSS is 
> replacing Usenet,

LOL, how? I can't post to RSS feeds. Or do you mean for lurkers?

> There is no real reason why NNTP couldn't be used like RSS (i.e.
> contain a small description and a web link as message text),

It has been used like that for ages (or as long as I can remember).

> or why a
> newsgroup shouldn't we written in HTML and contain a (default, or
> user-provided) CSS sheet.

It's called www. It's already here (or there)

> If things were that way, suddenly people
> *would* use Outlook and Thunderbird for news-reading,

But why do you want that? (Oh, and you can't read news with Outlook). Why 
do you want more people on Usenet? 

> while today
> everything is just Browser+HTTP.

And what's wrong with that?

-- 
John   Small Perl scripts: http://johnbokma.com/perl/
   Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html

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


Re: Jargons of Info Tech industry

2005-08-25 Thread John Bokma
[EMAIL PROTECTED] wrote:

> In comp.lang.perl.misc John Bokma <[EMAIL PROTECTED]> wrote:
>> 
>> > the argument that usenet should never change seems a little
>> > heavy-handed and anachronistic.
>> 
>> No, simple since there *are* alternatives: web based message boards.
>> Those alternatives *do* support HTML formatting (often the subset
>> mentioned 
> 
> ... and generally these "web based message boards" (i.e. forums I
> assume you mean) have none of the useful tools that Usenet offers and
> are much, much slower.

Yup, Slow because of all the HTML and avatars. And you suggest to introduce 
such a thing to Usenet?

And which useful tools do you require?

-- 
John   Small Perl scripts: http://johnbokma.com/perl/
   Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html

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


Re: Jargons of Info Tech industry

2005-08-25 Thread Rich Teer
On Thu, 25 Aug 2005, Ulrich Hobelmann wrote:

> CSS sheet.  If things were that way, suddenly people *would* use Outlook

No no no!  Let's keep those Outhouse lusers away from Usenet.  There's
tto much top posting as it is!

-- 
Rich Teer, SCNA, SCSA, OpenSolaris CAB member

President,
Rite Online Inc.

Voice: +1 (250) 979-1638
URL: http://www.rite-group.com/rich
-- 
http://mail.python.org/mailman/listinfo/python-list


a dummy python question

2005-08-25 Thread Learning Python
A example in learning Python by Mark Lutz and David Ascher

about function scope

example like this:

>>def outer(x):
 def inner(i):
print i,
if i: inner(i-1)
 inner(x)
>>outer(3)

Here supposely, it should report error, because the function inner
cannot see itself since inner is only in local namespace of outer.

but I typed in this in python interface. It works!
it print out:
3 2 1 0


If you turn this into a module file and run this
it print out
3 2 1 0 none

Can anyone explain to me what's going on?

Thanks

BTW: I am using Python 2.3

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


Re: minimalist regular expression

2005-08-25 Thread [EMAIL PROTECTED]
very nice

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


pre-PEP: Object-oriented file module

2005-08-25 Thread Kenneth McDonald
I'd like to propose a new PEP [no, that isn't a redundant 'process'  
in there :-)--pre-PEP is a different process than PEP], for a  
standard library module that deals with files and file paths in an  
object oriented manner. I believe this module should be included as  
part of the standard Python distribution.

Background
==
Some time ago, I wrote such a module for myself, and have found it  
extremely useful. Recently, I found a reference to a similar module,  
http://www.jorendorff.com/articles/python/path/ by Jeff Orendorff.  
There are of course differences--I think mine is more comprehensive  
but probably less stable--but the similarities in thought are  
striking. Both work by creating a class representing file paths, and  
then using that class to unify methods from shutil, os.path, and some  
builtin functions such as 'open' (and maybe some other stuff I can't  
remember).

I haven't looked at Jeff's code yet, but for my own, a major enabler  
of the enhanced functionality has been the inclusion of generators in  
Python. This allows, for example, a method which yields all of the  
lines in a file and automatically closes that file after. The  
availability of attributes also makes certain things cleaner than was  
the case in previous versions of python.

Fit With Python Philosophy
=
One of the strengths of Python is that it is a highly object-oriented  
language, but this is not true when it comes to handling files. As  
far as python is concerned a file path is just a string, and there  
are a bunch of things you can do with it, but they all have to be  
done with function calls (not methods) since there is no concept of a  
file path object. Even worse, these functions are spread out across  
various modules, and often have cryptic names that hardly make it  
obvious what they do.

Given that two different people concluded that such a module was  
desirable, and independently implemented modules that are actually  
very similar, I suspect there is an 'object-oriented mindset' to  
which this way of addressing files and file paths is natural. And  
that should be part of Python.

Pragmatic Justification
=
I've been using my module for about a year and a half now. The ease- 
of-use and uniformity make a huge (I'm tempted to say 'vast')  
difference in dealing with files. I believe other users would  
experience an increase in efficiency when dealing with files ranging  
from 'significant' to 'very large' (in precise technical terms :-) )   
Also, I think this type of API would be much easier for new users to  
learn and use.

Examples

A few examples are in order. Again, these are from my own library,  
since I'm not too familiar with Jeff's. Also, this is stuff I'm just  
typing in right now as an illustration--there may be syntactic  
errors. (However, all of this functionality is present.) And these by  
no means represent the full functionality that is already defined.

# define a new path object
mydir = filepath("#&*$directory")

# Note that special characters are automatically escaped
# by filepath, as necessary for the current OS. If a character
# is illegal in a file name no matter what (cannot be escaped),
# an exception will be raised.


# A file in that directory
f = mydir / "some.txt"

# Go through the lines in the file. When all lines are done,
# the file will be closed automatically. If the file does not
# actually exist, an appropriate exception will be raised.
for line in f.iterlines():
 ...do something...

#The directory containing f is, of course, 'mydir'
assert f.parent == mydir

#Another path
aPath = filepath()

#In my module (not in Jeff's), a file path is considered
# semantically as a sequence of directory names terminated
# by the name of a file or directory. This makes it easy to
# obtain the name of the file at the end of a path:
theFile = aPath[-1]

# or the directory leading to that file
parentDir = aPath[0:-1]

#of course, these two common indexes/slices are accessible through  
attributes
theFile = aPath.basename
parentDir = aPath.parent

# A more powerful 'walk'-type method is included. Below,
# the 'recursive' indicates that directories should be recursively
# walked, and the 'preorder' indicates that directories should
# be included in the iteration _before_ their contents are given.
# There is also a 'postorder' argument, and both may be used to
# yield directories both before and after their contents.
aPath.iterfiles(recursive=True, preorder=True)

# With the advent of the 'itertools' module in python, there is no
# need to provide an argument taking a function that is applied
# during the walk process, so in that sense, iterfiles is actually  
simpler than walk.

#...and more. All of the various file capabilities available in  
Python are provided
#  in a unified package in this module.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Speed quirk: redundant line gives six-fold speedup

2005-08-25 Thread Claudio Grondi
> I've learnt my lesson :)  Thank you for your help, and apologies
> for wasting other people's time with this as well as my own!

I've learnt my lesson reading through this thread, too.

I am glad to be given the chance of  wasting my time
with it and very happy and thankful, that you posted
your problem here before I have bumped into similar
one myself. I suppose, that there are many others
on this  newsgroup who appreciated your posting,
too.

Claudio


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


Re: Limited XML tidy

2005-08-25 Thread uche . ogbuji
> The problem is that when the sax handler raises an exception,
I can't see how to find out why. What I want to do is for
DodgyErrorHandler to do something different depending on
where we are in the course of parsing. Is there anyway
to get that information back from xml.sax (or indeed from
any other sax handler?)

You can get raw location information, yes.  See:

http://www.xml.com/pub/a/2004/11/24/py-xml.html

But I don't think this is enough for you.  You also need recovery,
which you're implementing in crude form.

I tend to agree with Magnus that using an SGML parser might be your
best bet.  You might even be able to turn that SGML into XML using a
tool such as James Clark's SX:

http://www.jclark.com/sp/sx.htm

-- 
Uche
http://copia.ogbuji.net

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


Re: minimalist regular expression

2005-08-25 Thread Trent Mick
[EMAIL PROTECTED] wrote]
> Exists some tool, programs or some able to compute the minimal regular
> expression, namely ,taking a series of regular exoression, the minimal
> one that makes the same matching?

def get_minimal_regex(*regexes):
return ".*"

:)  Or, slightly less smart-ass-y:

def get_not_really_minimal_regex(*regexes):
return "(" + "|".join(regexes) + ")"

Trent

-- 
Trent Mick
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Filetypes in email attachments.

2005-08-25 Thread Martin v. Löwis
[EMAIL PROTECTED] wrote:
> I would like to use the magic file to detect the filetype, if this is
> possible.  I have the attachement stored and (generally) decoded in a
> variable.

There is a Python binding to the libmagic library, see

http://mx.gw.com/pipermail/file/2003/55.html

Meanwhile, this binding is part of the standard file(1) distribution.

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


Re: New Arrival to Python

2005-08-25 Thread Luis M. Gonzalez
Windows Apps:
Since you said "professional looking" applications, I assume you mean
graphical interfaces (windows - GUI):
If so, I recomend PythonCard  ( http://pythoncard.sourceforge. net/ ).
It is very easy to use, very similar to Visual Basic or Delphi (drag
and drop widgets on a form...).

Web Development:
An excellent choice for simple (and complex, but easy) web development
in Python is Karrigell ( http://karrigell.sourceforge. net/ ). It is
not an IDE, but a web framework. The coding can de made with the
standard IDLE or simply notepad.

Books:
Learning Python 2nd Edition. Very good and complete introduction to
python.

Online resources:
A byte of Python (google this)
Dive into Python (for more experienced programmers)

Hope this helps...
Luis

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


Re: New Arrival to Python

2005-08-25 Thread Luis M. Gonzalez
Windows Apps:
Since you said "professional looking" applications, I assume you mean
graphical interfaces (windows - GUI):
If so, I recomend PythonCard  ( http://pythoncard.sourceforge.net/ ).
It is very easy to use, very similar to Visual Basic or Delphi (drag
and drop widgets on a form...).

Web Development:
An excellent choice for simple (and complex, but easy) web development
in Python is Karrigell ( http://pythoncard.sourceforge.net/ ). It is
not an IDE, but a web framework. The coding can de made with the
standard IDLE or simply notepad.

Books:
Learning Python 2nd Edition. Very good and complete introduction to
python.

Online resources:
A byte of Python (google this)
Dive into Python (for more experienced programmers)

Hope this helps...
Luis

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


Re: variable hell

2005-08-25 Thread rafi
Steve Holden wrote:

> Because eval() takes an expression as an argument, and assignment is a 
> statement.

I am definitely not a language lawyer... but I should a little bit more

thanks,

-- 
rafi

"Imagination is more important than knowledge."
(Albert Einstein)
-- 
http://mail.python.org/mailman/listinfo/python-list


Jargons of Info Tech industry

2005-08-25 Thread Alexander Zatvornitskiy
Привет Xah!

11 aug 2005 at 18:23, Xah Lee wrote:

 XL> Jargons of Info Tech industry
 XL> (A Love of Jargons)
 XL> Xah Lee, 2002 Feb
 XL> People in the computing field like to spur the use of spurious
...skipped...

Look at this site for some info: http://lleo.aha.ru/na/en


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

ANN: SPE 0.7.5.c: Improved documentation & bugfixes

2005-08-25 Thread SPE - Stani's Python Editor
With special thanks to Dimitri Pater to contribute his documenation
from http://www.serpia.com and Nir Aides for the documentation about
the debugger. Also thanks to all Mac donors who bring real Mac support
for SPE more and more close. For more info visit the homepage.

Stani

Spe is a free python IDE with auto indentation & completion, call tips,
syntax coloring & highlighting, UML diagrams, class explorer, source
index, auto todo list, sticky notes, pycrust shell, file browsers,
drag&drop, context help, Blender support, ... Spe ships with Python
debugger (remote & encrypted), wxGlade (gui designer), PyChecker
(source code doctor) and Kiki (regex console).

http://pythonide.stani.be
http://pythonide.stani.be/blog
http://pythonide.stani.be/screenshots

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


Re: Suppressing checking of modules with pychecker

2005-08-25 Thread MrJean1
FWIIW,

We use PyChecker all the time with Python files using importing wx plus
wx.grid or wx.stc, etc. and the run times vary between 5 and 15
seconds.

This is Python 2.4 with wxPython 2.4.2.4 and RedHat Fedora Core 2 Linux
running on a 1.2 GHz Pentium 4 M laptop.

/Jean Brouwers

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


Re: variable hell

2005-08-25 Thread Steve Holden
rafi wrote:
> Reinhold Birkenfeld wrote:
> 
> 
 exec(eval("'a%s=%s' % (count, value)"))
>>>
>>>why using the eval?
>>>
>>>exec ('a%s=%s' % (count, value))
>>>
>>>should be fine
>>
>>And this demonstrates why exec as a statement was a mistake ;)
>>
>>It actually is
>>
>>exec 'a%s=%s' % (count, value)
> 
> 
> Noted.
> 
> In the meantime another question I cannot find an answer to: any idea 
> why does eval() consider '=' as a syntax error?
> 
>  >>> eval ('a=1')
> Traceback (most recent call last):
>File "", line 1, in ?
>File "", line 1
>  a=1
>   ^
> SyntaxError: invalid syntax
> 
> Thanks
> 
Because eval() takes an expression as an argument, and assignment is a 
statement.

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/

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


minimalist regular expression

2005-08-25 Thread [EMAIL PROTECTED]
Exists some tool, programs or some able to compute the minimal regular
expression, namely ,taking a series of regular exoression, the minimal
one that makes the same matching?
thanx in advance

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


Re: variable hell

2005-08-25 Thread Robert Kern
rafi wrote:

> In the meantime another question I cannot find an answer to: any idea 
> why does eval() consider '=' as a syntax error?
> 
>  >>> eval ('a=1')
> Traceback (most recent call last):
>File "", line 1, in ?
>File "", line 1
>  a=1
>   ^
> SyntaxError: invalid syntax

eval *evaluates* an expression. "a=1" is a statement. It has no value.

-- 
Robert Kern
[EMAIL PROTECTED]

"In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die."
  -- Richard Harter

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


Re: variable hell

2005-08-25 Thread Robert Kern
Ron Garret wrote:
> In article <[EMAIL PROTECTED]>,
>  Robert Kern <[EMAIL PROTECTED]> wrote:
> 
>> In the
>>bowels of my modules, I may not know what the contents are at code-time,
> 
> Then how do you write your code?

With style.  ;-)

I use a Bunch where I might otherwise use a dictionary inside my modules
because it *is* a dictionary. Interactively, I'll usually use it as an
object with attributes. The keys are usually ideosyncratic, like station
codes for permanent GPS stations (e.g. "CAND", "USLO", "MNMC", "MIDA"),
rather than generic (e.g. "northing", "day").

So I might have a function that do some analysis on all of the GPS
stations within a Bunch. I don't know the names of the stations when I'm
writing the function, but I can iterate over the keys and values in the
Bunch.

  def subtract_reference(data, refstation):
"""Subtract the motion of the reference station from the remaining
timeseries.
"""
refdata = data[refstation]
for station in data:
  if station == refstation:
continue
  data[station].northing -= refdata.northing
  data[station].easting -= refdata.easting
  # ...

At the prompt, though, I may want to plot CAND's timeseries.

  In [10]: plot(data.CAND.t, data.CAND.northing)

Bunch allows me to use "data[station]" and "data.CAND" as the situation
demands rather than forcing me to use the clunkier "getattr(data,
station)" or "data['CAND']", respectively.

-- 
Robert Kern
[EMAIL PROTECTED]

"In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die."
  -- Richard Harter

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


Re: variable hell

2005-08-25 Thread rafi
Reinhold Birkenfeld wrote:

>>>  exec(eval("'a%s=%s' % (count, value)"))
>>
>>why using the eval?
>>
>>exec ('a%s=%s' % (count, value))
>>
>>should be fine
> 
> And this demonstrates why exec as a statement was a mistake ;)
> 
> It actually is
> 
> exec 'a%s=%s' % (count, value)

Noted.

In the meantime another question I cannot find an answer to: any idea 
why does eval() consider '=' as a syntax error?

 >>> eval ('a=1')
Traceback (most recent call last):
   File "", line 1, in ?
   File "", line 1
 a=1
  ^
SyntaxError: invalid syntax

Thanks

-- 
rafi

"Imagination is more important than knowledge."
(Albert Einstein)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Speed quirk: redundant line gives six-fold speedup

2005-08-25 Thread MrJean1
Two observations:

1 - The difference in run time with and without the dummy* globals is
due to a difference in the number of invokations of the search()
function: 1,140 resp. 27,530 in my environment.

To verify, just change the line

  def search():
  

to

  searches = 0
  def search():
  global searches
  searches += 1
  

and add at the very end

  print searches, "searches"


2 - The run times with and without the dummy* variables is equal(ly
slow) if the LLentry() class and min() function call are modified to be
independent of the object value.

Change line

  class LLentry: pass

to

  LLinst = 0
  class LLentry(object):
  def __init__(self):
  global LLinst
  LLinst += 1
  self.I = LLinst

and change line

mm = min((c.S, c) for c in rowitems(h))[1].D

to

mm = min((c.S, c.I, c) for c in rowitems(h))[2].D


/Jean Brouwers

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


Re: Speed quirk: redundant line gives six-fold speedup

2005-08-25 Thread rafi
Stelios Xanthakis wrote:
> Mark Dickinson wrote:
> 
>> I have a simple 192-line Python script that begins with the line:
>>
>> dummy0 = 47
>>
>> The script runs in less than 2.5 seconds.  The variable dummy0 is never
>> referenced again, directly or indirectly, by the rest of the script.
>>
>> Here's the surprise: if I remove or comment out this first line, the
>> script takes more than 15 seconds to run.  So it appears that adding a
>> redundant line produces a spectacular six-fold increase in speed!
>>
>> (Actually, I had to add 29 dummy lines at the beginning of the code to
>> get the speed increase; if any one of these lines is removed the
>> running time reverts to around 15 seconds again.)
>>
>> Questions:
>>
>> (1) Can anyone else reproduce this behaviour, or is it just some quirk
>> of my setup?
>> (2) Any possible explanations?  Is there some optimization that kicks
>> in at a certain number of lines, or at a certain length of
>> bytecode?
>> (3) If (2), is there some way to force the optimization, so that I can
>> get the speed increase without having to add the extra lines?
>>
> 
> Hi.
> 
> I haven't been able to reproduce this but I had a similar case
> before (a program that some times crashed and some times worked
> perfectly and the difference was whitespace in the comments!!!).
> 
> After lots of wondering and thinking that I must be dreaming
> (luckily I had pyvm which also crashed but for different amounts
> of whitespace), it was solved.  The explanation is this: hash
> and comparison of objects depends on the state of the memory
> allocator.  A sample case is this:
> 
> class A: pass
> dummy0=47  # comment this to get a different result for min
> a=A()
> b=A()
> print min (a, b)
> 
> the result of 'min' is not only non-deterministic but also depends
> on whether other things have been allocated before.  The same
> thing can happen for 'dictionary.keys()' if the keys are objects
> and 'iterate-over-set' when the set contains objects.

I do not get the point here: isn't min comparing the adress in memory as 
there is nothing else to compare?

[python 2.4.1 on ubuntu linux]

On 10 runs from within emacs I had about 50% for `a' and 50% for `b' 
returned by min (a,b). It was the same without the dummy0=47.

On 10 runs from the command line I had always `a' returned (with and 
without the dummy). The only difference was the address of b's object.
(For all the run of each case the two addresses were exactly the same)

For your first post:

On 10 tests run for each case (average time, but each time was never 
different one from the other more that .02s)

0.554 when the 28 dummies are in place
6.679 when commented out, removed or put in a single multiline string
2.576 when putting the 28 dummies in a list or a dict using a for loop
7.195 when creating the 28 dummies using an exec in a for loop

What about memory allocation that would be performed chunk by chunk by 
the interpreter? Then being at the end or at the beginning of a chunk 
may not be the same for processing? All the instructions of the program 
would then be in the cpu cache for example in the same block while in 
the other case theyr would be in two distinct block -> thus less caching 
for the cpu... [this particular problem arose when I was working several 
year ago on a persistent object manager for a distributed operating system]

-- 
rafi

"Imagination is more important than knowledge."
(Albert Einstein)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: variable hell

2005-08-25 Thread Reinhold Birkenfeld
rafi wrote:
> Adriaan Renting wrote:
>> You might be able to do something along the lines of
>> 
>> for count in range(0,maxcount):
>>   value = values[count]
>>   exec(eval("'a%s=%s' % (count, value)"))
> 
> why using the eval?
> 
> exec ('a%s=%s' % (count, value))
> 
> should be fine

And this demonstrates why exec as a statement was a mistake ;)

It actually is

exec 'a%s=%s' % (count, value)

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


Re: Speed quirk: redundant line gives six-fold speedup

2005-08-25 Thread Raymond Hettinger

Mark Dickinson wrote:
> I have a simple 192-line Python script that begins with the line:
>
> dummy0 = 47
>
> The script runs in less than 2.5 seconds.  The variable dummy0 is never
> referenced again, directly or indirectly, by the rest of the script.
>
> Here's the surprise: if I remove or comment out this first line, the
> script takes more than 15 seconds to run.  So it appears that adding a
> redundant line produces a spectacular six-fold increase in speed!

Thanks for your post.  It is cute, brilliant, and interesting.

I haven't had time to investigate but can point at the likely cause.
All of the global names are stored in a single hash table.  Search time
is dictated by two factors, the sparseness of the hash table and the
distribution of hash values.  With respect to sparseness, whenever that
table becomes 2/3 full, it grows by a factor of four and becomes only
1/6 full (leading to many fewer collisions).  With respect to
distribution, it should be noted that string hash values are decidely
non-random and your variable names likely congested consecutive spaces
in a nearly full table (resulting in seven times as many search probes
to find a global value).

When the extra value was added, it likely resized the table four-fold
and redistributed the hash values into fewer consecutive positions.


Raymond


P.S.  To analyze it further, start with something like this:

>>> len(set(hash('dummy%d' %i) & 31 for i in xrange(29)))
26
>>> len(set(hash('dummy%d' %i) & 127 for i in xrange(29)))
29

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


Re: Jargons of Info Tech industry

2005-08-25 Thread Ulrich Hobelmann
[EMAIL PROTECTED] wrote:
> In comp.lang.perl.misc John Bokma <[EMAIL PROTECTED]> wrote:
>>> the argument that usenet should never change seems a little
>>> heavy-handed and anachronistic.
>> No, simple since there *are* alternatives: web based message boards. Those 
>> alternatives *do* support HTML formatting (often the subset mentioned 
> 
> ... and generally these "web based message boards" (i.e. forums I
> assume you mean) have none of the useful tools that Usenet offers and
> are much, much slower.

That is because NNTP and its applications didn't evolve to feed the 
glitzy need lots of users have.

Sadly web forums (esp. the ugly, slw PHPBB, and the unspeakable 
Google groups) are increasingly replacing usenet, but there are 
exceptions (DragonflyBSD).

On the information side (in contrast to the discussion side) RSS is 
replacing Usenet, with some obvious disadvantages: go on vacation, 
return after a week, and -- yahoo! -- all your RSS feeds only turn of 
the, say, most recent 30 articles, while your newsgroups all show 
everything you missed.

There is no real reason why NNTP couldn't be used like RSS (i.e. contain 
a small description and a web link as message text), or why a newsgroup 
shouldn't we written in HTML and contain a (default, or user-provided) 
CSS sheet.  If things were that way, suddenly people *would* use Outlook 
and Thunderbird for news-reading, while today everything is just 
Browser+HTTP.

Oh, yes:

-- 
I believe in Karma.  That means I can do bad things to people
all day long and I assume they deserve it.
Dogbert
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: New Arrival to Python

2005-08-25 Thread calfdog
I have been using Eclispe IDE with the PyDev plugin for Python
Development.
it allow you to set up projects. you can use PyAnt to build them.
It works great for me. It's free an easy to use.
Eclipse is at http://www.eclipse.org


There is also Emacs with the python plugin



Rob M.
python project - http://pamie.sourceforge.net

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


Re: Jargons of Info Tech industry

2005-08-25 Thread usenet
In comp.lang.perl.misc John Bokma <[EMAIL PROTECTED]> wrote:
> 
> > the argument that usenet should never change seems a little
> > heavy-handed and anachronistic.
> 
> No, simple since there *are* alternatives: web based message boards. Those 
> alternatives *do* support HTML formatting (often the subset mentioned 

... and generally these "web based message boards" (i.e. forums I
assume you mean) have none of the useful tools that Usenet offers and
are much, much slower.

> earlier). However, Usenet is a stranger to most people on the Internet, 
> even with Usenet access, and hence, there is no real reason to see it 
> changed into something that is "available" for years and years to more 
> people: www.
> 
> -- 
> John   Small Perl scripts: http://johnbokma.com/perl/
>Perl programmer available: http://castleamber.com/
> Happy Customers: http://castleamber.com/testimonials.html
> 

-- 
Chris Green

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


Re: variable hell

2005-08-25 Thread Ron Garret
In article <[EMAIL PROTECTED]>,
 Robert Kern <[EMAIL PROTECTED]> wrote:

>  In the
> bowels of my modules, I may not know what the contents are at code-time,

Then how do you write your code?

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


Re: Speed quirk: redundant line gives six-fold speedup

2005-08-25 Thread Mark Dickinson
In article <[EMAIL PROTECTED]>, Bill 
Mill <[EMAIL PROTECTED]> wrote:
 
> I'm also pretty sure I've caught a bug in his code, though I'm not
> sure how it works exactly. I replaced the 'min' built-in with my own
> min, and he's going to get nondeterministic results from this line:
> 
>mm = min((c.S, c) for c in rowitems(h))[1].D
> 
> because 'c' is often the exact same object. A snippet from my
> debugging version of 'min', which prints out the tuple its handed:
> 
> (1, <  main  .LLentry object at 0x00969710>)
> (1, <  main  .LLentry object at 0x00969710>)
> (4, <  main  .LLentry object at 0x00969710>)
> 
> (4, <  main  .LLentry object at 0x00969710>)
> (3, <  main  .LLentry object at 0x00969710>)
> (3, <  main  .LLentry object at 0x00969710>)
> (3, <  main  .LLentry object at 0x00969710>)
> (2, <  main  .LLentry object at 0x00969710>)
> 

The c's returned by any one call to rowitems(h) should all be distinct. 
This seems to work in my code---I can't reproduce your results above, and
I don't *think* there's a bug there.

> Although they appear in order here, they don't always. Often, multiple
> objects have a value of 1, and he's going to get one of them at random
> as the 'min' object. I'm pretty sure.

I agree entirely---this is where my bug, and the source of 
all the confusion comes from.  I was briefly aware as I wrote this that the
result would be nondeterministic, but persuaded myself after two second's
thought that it didn't matter, then forgot all about it.

So mild changes in the rest of the program give rise to a different `random'
choice in the min, and choosing to eunumerate all 3 possibilities for position 
5,7
instead of the 3 possibilities for position 2, 1 (say) makes a huge diffference
to the running time.  I'm still surprised by the magnitude of the differences, 
though.

I've learnt my lesson :)  Thank you for your help, and apologies 
for wasting other people's time with this as well as my own!

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


Re: Unix diff command under Window.

2005-08-25 Thread Thomas Heller
Trent Mick <[EMAIL PROTECTED]> writes:

> [Neil Hodgson wrote]
>> Thomas Heller:
>> 
>> > Yes.  There's a script in your Python distribution:
>> > Tools/scripts/diff.py
>> > 
>> > See also the docs for the 'difflib' standard library module.
>> 
>> Is the opposite code, a Python equivalent to 'patch' available? I 
>> have endless trouble receiving patch files that assume one of Windows or 
>> Unix (in terms of path names and line end characters) which then fail to 
>> apply on the other platform. I would like to have a version I could hack on.
>
> So would I! I also have problems with the available patch.exe binaries
> hanging or crashing occassionally on Windows.

The only slightly related thing that I know of is the 'Perl Power Tools'
Unix reconstruction project.  Seems they have a 'patch' command
implemented in perl:

http://ppt.perl.org/commands/patch/

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


Re: Unix diff command under Window.

2005-08-25 Thread Max M
TonyHa wrote:
> Hello,
> 
> Does any one have using Python to write a Unix "diff" command for
> Window?


I generally just us the diff built into tortoiseSVN. That way it's only 
a rightclick away.


-- 

hilsen/regards Max M, Denmark

http://www.mxm.dk/
IT's Mad Science
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: loop in python

2005-08-25 Thread James
>> I don't want to offend you or anything, but doesn't the second sentence mean 
>> that someone DID do a speed comparison?

I did provide Language Shootout link in the next paragraph of the post
you referred to along with an obligatory caution about interpreting
benchmarks. The Language Shootout is a general enough benchmark to
cover all popular languages not just comparing between
Perl/Python/Ruby/Tcl (which I said was pointless). So the statements
are not in conflict.

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


Suppressing checking of modules with pychecker

2005-08-25 Thread Qopit
Does anyone know how to stop the command line pychecker from analyzing
particular modules?  It really gets slowed down on some big ones.

In particular having 'import wx' takes a long while (30 - 60s).  If you
try pycheck'ing the program below it takes a while and prints a zillion
warnings.

#---
import wx
print "Go make a sandwich while this finishes..."
#---

I tried the blacklisting -b option, but can't seem to get it to work
right.  Plus I think it just suppresses the warnings but does not stop
it from digging through the wx module.

Anyone using pychecker with wxPython apps know what to do?

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


Re: Speed quirk: redundant line gives six-fold speedup

2005-08-25 Thread Mark Dickinson
In article <[EMAIL PROTECTED]>, 
Stelios Xanthakis <[EMAIL PROTECTED]> wrote:
 
> In the sudoku solver, there is a min (number, object) which is
> probably what's affected by the extistance of the dummy variable.
> Now, in sudoku puzzles some times the algorithm has to suppose
> that in a box the right solution is one of the possible, try it
> and if it fails then try the other one.  I guess that the result
> of from the different 'min' leads the solver to first try the
> correct solution in the fast case and therefore need not attempt
> the wrong one.  Or at least this is what I think that happens.

Thank you!  That does indeed seem to be the explanation.  
The min() line looks for the shortest `constraint';  that is, the box 
with the fewest possible symbols, or the symbol with the smallest 
number of possible positions within a given row, column or block;  the
code below that line then tries all possibilities for this constraint.
The line should really be something like

  min(c for c in rowitems(h), key = lambda c: c.S)

but that isn't going to work until Python 2.5 comes out, and I was
too lazy to expand the whole thing properly instead of using the 
cheap trick I did.

Thanks again for clearing up this confusion.

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


Re: variable hell

2005-08-25 Thread bruno modulix
[EMAIL PROTECTED] wrote:
> Hey, if the man wants to write it that way, let the man write it that
> way. If it works for him, great... he's sure confused the heck out of
> all of us, and that translates into job security for him! As you can
> see, the name of the post is 'variable hell' and that is exactly what
> he is creating, so "Adriaan Renting", excellent response!
> 

http://mindprod.com/jgloss/unmain.html

-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in '[EMAIL PROTECTED]'.split('@')])"
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Superclass files and order - oh my!! Questioning the experts!!

2005-08-25 Thread rh0dium
Slight correction..

rh0dium wrote:
> Hi all,
>
> Still a newbie but making some headway.  So I have a file structure
> like this..
>
> top/
> --modules/
> metrics.py
> --metrix/
> uptime.py
>
> Now metrics.py is my superclass, and uptime.py inherits the superclass
> metrics.py.
>
> So for arguments sake
>
> metrics.py
> 
> class metrics():
>def __init__(self, foo=bar):
>   self.foo=foo
>def run():
>   pass
> 
>
>
> uptime.py
> 
> class metrics(metrics):
class uptime(metrics):
>def run():
>   print "hello"
>
> if __name__ == '__main__':
>
> if os.path.exists("../modules"):
> print "importing modules"
> sys.path.insert( 0, "../modules")
> import metrics
> else:
> print "Unable to bring in main metric instance - path not correct"
> sys.exit(1)
>
> 
>
> Now if simply try to run ./uptime.py it complains about not having the
> metrics module?  Huh but I brought it in?
>
> File "./uptime.py", line 19, in ?
> class uptime(metrics):
> NameError: name 'metrics' is not defined
>
> BUT...
>
> If I do this then it it imports..  ( NOTE the order is different.. )
>
> uptime.py
> 
> if os.path.exists("../modules"):
> print "importing modules"
> sys.path.insert( 0, "../modules")
> import metrics
> else:
> print "Unable to bring in main metric instance - path not correct"
> sys.exit(1)
>
> class metrics(metrics):
class uptime(metrics):
>def run():
>   print "hello"
>
> if __name__ == '__main__':
>pass
>
> 
>
> But I get the next erorr:
> Path exists
> importing modules
> Traceback (most recent call last):
>   File "./uptime.py", line 34, in ?
> class uptime(metrics):
> TypeError: Error when calling the metaclass bases
> module.__init__() takes at most 2 arguments (3 given)
>
> So the question is..
>
> Why is it not looking at the "if __name__ == '__main__':"  statement
> and starting there?  I thought it was supposed to do that?   Why can't
> I just put a class statement in a file and if you put nothing (like if
> __name__) the class is just "registered" so later if (like
> __main__) I use it then it's available.
>
> I want to not have to put that ugly code at the top but it seems as
> though that's the only way?  Someone must have figured this out and can
> you explain why it workst this way?
>
> I must be missing something cause that's how modules work.  How is this
> different than a module?

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


Re: Jargons of Info Tech industry

2005-08-25 Thread Rich Teer
On Thu, 25 Aug 2005, John Bokma wrote:

> Just have a look at some web based message boards, and you might see why it
> would be another disaster on Usenet. Moreoever, why keep people insisting
> on making Usenet "better"? If you want HTML and fancy mark up, start a
> message board. You probably can get even more people.

Right.  I avoid web based forums like the plague.  Why?  Because apart
from the (usually) very low SNR, for me interacting with a browser is
more effort than using my email/news client of 10+ years, pine.

I find that fact that something is technically possible (e.g., HTML
email and Usenet) is not necessarily a good argument for actully
DOING it.

-- 
Rich Teer, SCNA, SCSA, OpenSolaris CAB member

President,
Rite Online Inc.

Voice: +1 (250) 979-1638
URL: http://www.rite-group.com/rich
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Speed quirk: redundant line gives six-fold speedup

2005-08-25 Thread Bill Mill
On 8/25/05, Jack Diederich <[EMAIL PROTECTED]> wrote:
> On Thu, Aug 25, 2005 at 09:23:09PM +0300, Stelios Xanthakis wrote:
> > The explanation is this: hash
> > and comparison of objects depends on the state of the memory
> > allocator.  A sample case is this:
> >
> >   class A: pass
> >   dummy0=47  # comment this to get a different result for min
> >   a=A()
> >   b=A()
> >   print min (a, b)
> >
> > the result of 'min' is not only non-deterministic but also depends
> > on whether other things have been allocated before.  The same
> > thing can happen for 'dictionary.keys()' if the keys are objects
> > and 'iterate-over-set' when the set contains objects.
> >

I'm also pretty sure I've caught a bug in his code, though I'm not
sure how it works exactly. I replaced the 'min' built-in with my own
min, and he's going to get nondeterministic results from this line:

   mm = min((c.S, c) for c in rowitems(h))[1].D

because 'c' is often the exact same object. A snippet from my
debugging version of 'min', which prints out the tuple its handed:

(1, <__main__.LLentry object at 0x00969710>)
(1, <__main__.LLentry object at 0x00969710>)
(4, <__main__.LLentry object at 0x00969710>)

(4, <__main__.LLentry object at 0x00969710>)
(3, <__main__.LLentry object at 0x00969710>)
(3, <__main__.LLentry object at 0x00969710>)
(3, <__main__.LLentry object at 0x00969710>)
(2, <__main__.LLentry object at 0x00969710>)


Although they appear in order here, they don't always. Often, multiple
objects have a value of 1, and he's going to get one of them at random
as the 'min' object. I'm pretty sure.

Mark, can you confirm that this is/isn't a bug?

(btw, it still runs fast with and slow without the dummies with my
custom min() func)

Peace
Bill Mill
bill.mill at gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Command Line arguments

2005-08-25 Thread Trent Mick
[michael wrote]
> SOLVED! Thank you.
> 
> I wonder why this was needed for 2.4 and not 2.2? I don't think it was
> lingering things from old installs because it happened on a persons
> computer that had never had any python installed before 2.4.

It might be due to a bug in the Python 2.4 installer not setting the
proper file associations. What installer package did you use?

Trent

-- 
Trent Mick
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Unix diff command under Window.

2005-08-25 Thread Trent Mick
[Neil Hodgson wrote]
> Thomas Heller:
> 
> > Yes.  There's a script in your Python distribution:
> > Tools/scripts/diff.py
> > 
> > See also the docs for the 'difflib' standard library module.
> 
> Is the opposite code, a Python equivalent to 'patch' available? I 
> have endless trouble receiving patch files that assume one of Windows or 
> Unix (in terms of path names and line end characters) which then fail to 
> apply on the other platform. I would like to have a version I could hack on.

So would I! I also have problems with the available patch.exe binaries
hanging or crashing occassionally on Windows.

Trent

-- 
Trent Mick
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Jargons of Info Tech industry

2005-08-25 Thread Mike Schilling

<[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> "Mike Schilling" <[EMAIL PROTECTED]> writes:
>
>> "Rich Teer" <[EMAIL PROTECTED]> wrote in message
>> news:[EMAIL PROTECTED]
>> > On Thu, 25 Aug 2005, Mike Schilling wrote:
>> >
>> >> Another advantage is that evewry internet-enabled computer today
>> >> already comes with an HTML renderer (AKA browser), so that a
>> >> message saved to a file can be read very easily.
>> >
>> > I think you're missing the point: email and Usenet are,
>> > historically have been, and should always be, plain text mediums.
>>
>> Gosh, if you say they should be, there's no point trying to have an
>> intelligent discussion, is there?
>
> Errm, isn't that what you're doing as well then? Rich just gave an
> opinion, you've been giving an opinion. Rich's opinion happens to have
> a lot of history and good reasons behind it. I don't see why it should
> be viewed as some kind of discussion ending dogmatism.

I see a difference between "X would be useful for A, B, and C" and "Y will 
always be the only proper way."

Don't you?


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


Superclass files and order - oh my!! Questioning the experts!!

2005-08-25 Thread rh0dium
Hi all,

Still a newbie but making some headway.  So I have a file structure
like this..

top/
--modules/
metrics.py
--metrix/
uptime.py

Now metrics.py is my superclass, and uptime.py inherits the superclass
metrics.py.

So for arguments sake

metrics.py

class metrics():
   def __init__(self, foo=bar):
  self.foo=foo
   def run():
  pass



uptime.py

class metrics(metrics):
   def run():
  print "hello"

if __name__ == '__main__':

if os.path.exists("../modules"):
print "importing modules"
sys.path.insert( 0, "../modules")
import metrics
else:
print "Unable to bring in main metric instance - path not correct"
sys.exit(1)



Now if simply try to run ./uptime.py it complains about not having the
metrics module?  Huh but I brought it in?

File "./uptime.py", line 19, in ?
class uptime(metrics):
NameError: name 'metrics' is not defined

BUT...

If I do this then it it imports..  ( NOTE the order is different.. )

uptime.py

if os.path.exists("../modules"):
print "importing modules"
sys.path.insert( 0, "../modules")
import metrics
else:
print "Unable to bring in main metric instance - path not correct"
sys.exit(1)

class metrics(metrics):
   def run():
  print "hello"

if __name__ == '__main__':
   pass



But I get the next erorr:
Path exists
importing modules
Traceback (most recent call last):
  File "./uptime.py", line 34, in ?
class uptime(metrics):
TypeError: Error when calling the metaclass bases
module.__init__() takes at most 2 arguments (3 given)

So the question is..

Why is it not looking at the "if __name__ == '__main__':"  statement
and starting there?  I thought it was supposed to do that?   Why can't
I just put a class statement in a file and if you put nothing (like if
__name__) the class is just "registered" so later if (like
__main__) I use it then it's available.

I want to not have to put that ugly code at the top but it seems as
though that's the only way?  Someone must have figured this out and can
you explain why it workst this way?

I must be missing something cause that's how modules work.  How is this
different than a module?

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


Re: Speed quirk: redundant line gives six-fold speedup

2005-08-25 Thread Jack Diederich
On Thu, Aug 25, 2005 at 09:23:09PM +0300, Stelios Xanthakis wrote:
> The explanation is this: hash
> and comparison of objects depends on the state of the memory
> allocator.  A sample case is this:
> 
>   class A: pass
>   dummy0=47  # comment this to get a different result for min
>   a=A()
>   b=A()
>   print min (a, b)
> 
> the result of 'min' is not only non-deterministic but also depends
> on whether other things have been allocated before.  The same
> thing can happen for 'dictionary.keys()' if the keys are objects
> and 'iterate-over-set' when the set contains objects.
> 
> In the sudoku solver, there is a min (number, object) which is
> probably what's affected by the extistance of the dummy variable.
> Now, in sudoku puzzles some times the algorithm has to suppose

Doh, I feel silly.  Without an 'import random' in the program I
assumed it was deterministic.  I would have also expected the
comparison to be a TypeError, and it sometimes is.

>>> mynum = 7
>>> myob = object()
>>> cmp(mynum, myob)
-1
>>> mynum.__cmp__(myob)
Traceback (most recent call last):
  File "", line 1, in ?
TypeError: int.__cmp__(x,y) requires y to be a 'int', not a 'object'


Thanks for the explanation,
-jackdied
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Speed quirk: redundant line gives six-fold speedup

2005-08-25 Thread Bill Mill
On 8/25/05, Erik Max Francis <[EMAIL PROTECTED]> wrote:
> Bill Mill wrote:
> 
> > Unlikely; 2 people have confirmed these results already.
> >
> > I did find, though, that if I remove all print statements from the
> > program, the dummy and non-dummy variable versions take indentical
> > time. Can others reproduce this?
> 
> Yes, it's obviously a real effect given the other sightings.  I don't
> see any speed difference, myself (Pentium IV 3.0 GHz running Slackware
> Linux).
> 

Pentium M 1.8 GHz Windows 2k. Here's the top of the profile results
for fast and slow on my machine (these won't look decent except in a
fixed-width font):

Slow:

 6766494 function calls (6737594 primitive calls) in 45.740 CPU seconds

   Ordered by: internal time

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
  3322320   20.5390.000   31.1520.000 test.py:135(
)
27520   10.6410.000   41.7920.002 :0(min)
  3322320   10.6130.000   10.6130.000 test.py:81(rowitems)
 28100/203.6200.000   45.6332.282 test.py:130(search)
275450.1130.0000.1130.000 :0(append)
275200.0980.0000.0980.000 :0(pop)
10.0410.041   45.736   45.736 test.py:36(?)

Fast:

 540174 function calls (536514 primitive calls) in 3.506 CPU seconds

   Ordered by: internal time

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
   2596401.5160.0002.3030.000 test.py:135(
)
 22800.7910.0003.0940.001 :0(min)
   2596400.7880.0000.7880.000 test.py:81(rowitems)
  2860/200.2690.0003.3910.170 test.py:130(search)
10.0450.0453.4993.499 test.py:2(?)
 36450.0210.0000.0210.000 test.py:71(colinsert)
 32400.0190.0000.0190.000 test.py:62(rowinsert)
 23050.0100.0000.0100.000 :0(append)

Interestingly, the test.py:36 line, which takes 45 seconds (!!) in the
slow version, does not appear at all in the fast profile. I can't
figure out why - both printed out their data, so template must have
been called somewhere.

Peace
Bill Mill
bill.mill at gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bug in string.find; was: Re: Proposed PEP: New style indexing, was Re: Bug in slice type

2005-08-25 Thread Paul Rubin
Steve Holden <[EMAIL PROTECTED]> writes:
> As far as position reporting goes, it seems pretty clear that find()
> will always report positive index values. In a five-character string
> then -1 and 4 are effectively equivalent.
> 
> What on earth makes you call this a bug? And what are you proposing
> that find() should return if the substring isn't found at all? please
> don't suggest it should raise an exception, as index() exists to
> provide that functionality.

Bryan is making the case that Python's use of negative subscripts to
measure from the end of sequences is bogus, and that it should be done
some other way instead.  I've certainly had bugs in my own programs
related to that "feature".  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Jargons of Info Tech industry

2005-08-25 Thread Alan J. Flavell
On Thu, 25 Aug 2005, Mike Schilling wrote:

[Off Topic discussion of netiquette, seen on comp.lang.perl.misc:]

> Gosh, if you say they should be, there's no point trying to have an 
> intelligent discussion, is there?

Discussion about netiquette on any of these cross-posted groups cannot 
by definition be "intelligent": there are proper places to discuss the 
netiquette (they'd have "news" as their top hierarchy, not "comp"), 
and your posting was cross-posted to none of them.

[f'ups set]  [I have been trolled, mea culpa]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Speed quirk: redundant line gives six-fold speedup

2005-08-25 Thread Stelios Xanthakis
Mark Dickinson wrote:
> I have a simple 192-line Python script that begins with the line:
> 
> dummy0 = 47
> 
> The script runs in less than 2.5 seconds.  The variable dummy0 is never
> referenced again, directly or indirectly, by the rest of the script.
> 
> Here's the surprise: if I remove or comment out this first line, the
> script takes more than 15 seconds to run.  So it appears that adding a
> redundant line produces a spectacular six-fold increase in speed!
> 
> (Actually, I had to add 29 dummy lines at the beginning of the code to
> get the speed increase; if any one of these lines is removed the
> running time reverts to around 15 seconds again.)
> 
> Questions:
> 
> (1) Can anyone else reproduce this behaviour, or is it just some quirk
> of my setup?
> (2) Any possible explanations?  Is there some optimization that kicks
> in at a certain number of lines, or at a certain length of
> bytecode?
> (3) If (2), is there some way to force the optimization, so that I can
> get the speed increase without having to add the extra lines?
>

Hi.

I haven't been able to reproduce this but I had a similar case
before (a program that some times crashed and some times worked
perfectly and the difference was whitespace in the comments!!!).

After lots of wondering and thinking that I must be dreaming
(luckily I had pyvm which also crashed but for different amounts
of whitespace), it was solved.  The explanation is this: hash
and comparison of objects depends on the state of the memory
allocator.  A sample case is this:

class A: pass
dummy0=47  # comment this to get a different result for min
a=A()
b=A()
print min (a, b)

the result of 'min' is not only non-deterministic but also depends
on whether other things have been allocated before.  The same
thing can happen for 'dictionary.keys()' if the keys are objects
and 'iterate-over-set' when the set contains objects.

In the sudoku solver, there is a min (number, object) which is
probably what's affected by the extistance of the dummy variable.
Now, in sudoku puzzles some times the algorithm has to suppose
that in a box the right solution is one of the possible, try it
and if it fails then try the other one.  I guess that the result
of from the different 'min' leads the solver to first try the
correct solution in the fast case and therefore need not attempt
the wrong one.  Or at least this is what I think that happens.

By the way, since we started posting code, here is a more pythonic
sudoku solver.

#The 'man with scissors runs around shifting barrels algorithm'

from sys import argv
SEMANTIC = 1'SEM' in argv

class Impossible:
 pass

Patterns = []
for r in range (9):
 for c in range (9):
p = 27*(r/3) + 3*(c/3)
pl = set (range (9*r, 9*r+9) + range (c, 81, 9) + [p+x for x in 
(0,1,2,9,10,11,18,19,20)])
pl.remove (9*r+c)
Patterns.append (tuple (sorted (list (pl

def initboard ():
 x = range (1, 10)
 return [ x [:] for i in xrange (9*9) ]

def printboard (board):
 if not SEMANTIC:
 return
 print 30*'-'
 for i in range (9):
for j in board [9*i:9*(i+1)]:
if type (j) is list:
#print 'X',
print ''.join (map (str, j)),
else: print j,
print
 print 30*'-'

def dupboard (board):
 B = []
 for i in board:
if type (i) is list:
B.append (i [:])
else:
B.append (i)
 return B

def solve (board, coords):
 while coords:
p, v = coords.pop ()
board [p] = v
for i in Patterns [p]:
if type (board [i]) is list:
if v in board [i]:
board [i].remove (v)
if len (board [i]) == 1:
board [i] = board [i][0]
coords.append ((i, board [i]))
else:
if board [i] == v:
raise Impossible
 for p, i in enumerate (board):
if type (i) is list:
for j in i:
try:
return solve (dupboard (board), [(p, j)])
except Impossible:
pass
raise Impossible
 return board


PP = [
[
"7xx19",
"46x19",
"xxx6827x4",
"x9xx7",
"xxx3xx4x5",
"xx67x",
"xx1xx",
"2xxx74xxx",
"xxx2xx3xx",
]
]

def puz2coord (P):
 if len (P) != 9:
print "P must have 9 rows"
raise SystemExit
 coords = []
 for r, i in enumerate (P):
if len (i) != 9:
print "Row [%s] doesn't have 9 columns" %i
raise SystemExit
for c, j in enumerate (list (i)):
if j != 'x':
coords.append ((9*r + c, int (j)))
 return coords

try:
   if SEMANTIC:
for i in xrange (10):
 for P in PP:
 printboard (solve (initboard (), puz2coord (P)))
   else:
for i in xrange (TIMES):
 for P in PP:

Re: Speed quirk: redundant line gives six-fold speedup

2005-08-25 Thread Bill Mill
On 8/25/05, Jack Diederich <[EMAIL PROTECTED]> wrote:
> On Thu, Aug 25, 2005 at 01:35:04PM -0400, Bill Mill wrote:
> > On 8/25/05, Erik Max Francis <[EMAIL PROTECTED]> wrote:
> > > Mark Dickinson wrote:
> > >
> > > > Questions:
> > > >
> > > > (1) Can anyone else reproduce this behaviour, or is it just some quirk
> > > > of my setup?
> > > > (2) Any possible explanations?  Is there some optimization that kicks
> > > > in at a certain number of lines, or at a certain length of
> > > > bytecode?
> > > > (3) If (2), is there some way to force the optimization, so that I can
> > > > get the speed increase without having to add the extra lines?
> > >
> >
> > I did find, though, that if I remove all print statements from the
> > program, the dummy and non-dummy variable versions take indentical
> > time. Can others reproduce this?
> >
> > I'm Investigating further...
> 
> I'm getting similarly freakish results.  I tried a little ghetto debugging
> by putting a printf in dictobject.c's resize method and recompiling python.
> Sadly I can't get the problem to reproduce itself with the new binary
> (with or without the printf).  The Ubuntu default 2.4.1 is sometimes fast,
> my hand compiled one (./configure && make) is always slow.
> 
> There are some very arcane low level things going on here.
> 

agreed. Also, either I was temporarily insane, or the version with the
explicit template no longer runs faster for me, so I hope nobody
spends a lot of time on that.

Peace
Bill Mill
bill.mill at gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Speed quirk: redundant line gives six-fold speedup

2005-08-25 Thread Jack Diederich
On Thu, Aug 25, 2005 at 01:55:48PM -0400, Bill Mill wrote:
> Bill Mill wrote:
> > 
> > Pentium M 1.8 GHz Windows 2k. Here's the top of the profile results
> > for fast and slow on my machine (these won't look decent except in a
> > fixed-width font):
> > 
> 
> >
> > Interestingly, the test.py:36 line, which takes 45 seconds (!!) in the
> > slow version, does not appear at all in the fast profile. I can't
> > figure out why - both printed out their data, so template must have
> > been called somewhere.
> > 
> 
> OK, I'm getting somewhere now. When I replace:
> 
> template = ("  | %s %s %s | %s %s %s | %s %s %s |\n" * 3).join([" 
> +---+---+---+\n"] * 4)
> 
> wtih:
> 
> template = """   | %s %s %s | %s %s %s | %s %s %s |\n
>   | %s %s %s | %s %s %s | %s %s %s |\n
>   | %s %s %s | %s %s %s | %s %s %s |\n
>   +---+---+---+\n
>   | %s %s %s | %s %s %s | %s %s %s |\n
>   | %s %s %s | %s %s %s | %s %s %s |\n
>   | %s %s %s | %s %s %s | %s %s %s |\n
>   +---+---+---+\n
>   | %s %s %s | %s %s %s | %s %s %s |\n
>   | %s %s %s | %s %s %s | %s %s %s |\n
>   | %s %s %s | %s %s %s | %s %s %s |\n
>   +---+---+---+\n"""
> 
> Then the non-dummy version is faster than the dummy version (very
> slightly, presumably because it doesn't need to allocate 28 dummy
> variables).

I think this is just another tweaking that hits the magic spot (or
avoids the bad spot) in some lookup table somewhere.  Perhaps it
has to do with the number interned strings and some worst case
behavior? varnames are interened, so changing the number of globals
would change the number of interened strings as well.

-jackdied

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


Re: Speed quirk: redundant line gives six-fold speedup

2005-08-25 Thread jay graves
Mark Dickinson wrote:
> Questions:
> (1) Can anyone else reproduce this behaviour, or is it just some quirk
> of my setup?

yes.  I get 7 sec vs 1 sec on my laptop.

> (2) Any possible explanations?  Is there some optimization that kicks
> in at a certain number of lines, or at a certain length of
> bytecode?

I don't think there are any optimizations at play here.

> (3) If (2), is there some way to force the optimization, so that I can
> get the speed increase without having to add the extra lines?

When I start a python interpreter and import the module the speed
difference disappears and it actually gets about two times faster.
YMMV.

I don't have a solution but I admire the problem. [1]

...
jay

[1] Google tells me that this is probably attributable to Ashleigh
Brilliant.

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


Re: Jargons of Info Tech industry

2005-08-25 Thread John Bokma
Rich Teer <[EMAIL PROTECTED]> wrote:

> On Thu, 25 Aug 2005, Mike Schilling wrote:
> 
>> Another advantage is that evewry internet-enabled computer today
>> already comes with an HTML renderer (AKA browser), so that a message
>> saved to a file can be read very easily.
> 
> I think you're missing the point: email and Usenet are, historically
> have been, and should always be, plain text mediums.  If I wanted to
> look at prettily formatted HTML, I'd use a web browser to look at the
> web. 

Just have a look at some web based message boards, and you might see why it 
would be another disaster on Usenet. Moreoever, why keep people insisting 
on making Usenet "better"? If you want HTML and fancy mark up, start a 
message board. You probably can get even more people.

-- 
John   Small Perl scripts: http://johnbokma.com/perl/
   Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html

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


Re: Speed quirk: redundant line gives six-fold speedup

2005-08-25 Thread Mark Dickinson
In article <[EMAIL PROTECTED]>, Bill 
Mill <[EMAIL PROTECTED]> wrote:

> One of my own: what in the world made you think "maybe I'll add 29
> dummy global variables to speed things up?"

You mean this isn't a well-known optimization technique? :)

I was refactoring the code, and after making a particular function
redundant I noticed that removing the code for that function produced
the slow down described.  Then I naturally experimented to try to figure
out what I had to put back in to recover the original speed.

Not that I really care about the speed itself, but I'd dearly like to
understand what's at work here.

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


Re: Jargons of Info Tech industry

2005-08-25 Thread joe
"T Beck" <[EMAIL PROTECTED]> writes:

> Mike Schilling wrote:
> > "Rich Teer" <[EMAIL PROTECTED]> wrote in message
> > news:[EMAIL PROTECTED]
> > > On Thu, 25 Aug 2005, Mike Schilling wrote:
> > >
> > >> Another advantage is that evewry internet-enabled computer
> > >> today already comes with an HTML renderer (AKA browser), so
> > >> that a message saved to a file can be read very easily.
> > >
> > > I think you're missing the point: email and Usenet are,
> > > historically have been, and should always be, plain text
> > > mediums.
> >
> > Gosh, if you say they should be, there's no point trying to have an
> > intelligent discussion, is there?
> 
> Not to mention that e-mail is practically to the point where it is
> {not} a plain text medium.  I notice this especially in a corporate
> environment (where, at least where I work, I get at least 10 times the
> number of e-mails at work than I do on my private account) HTML e-mail
> is the de-facto standard.  I have a tendancy to send out plain text
> e-mail, and I'm practically the only one, as HTML formatting is the
> default for the mail client on every corporate machine at my job.

If you're using exchange for email servers it might be reformatting
mail sent as plain text anyway. Waste of bandwidth.

> But let's not forget that most people which send me e-mail personally
> also have HTML tags in e-mail...  So if e-mail {is} a plain text
> medium, somebody needs to tell the general public, because I think they
> must've missed a memo.
> 
> If we argue that people are evolving the way e-mail is handled, and
> adding entire new feature sets to something which has been around since
> the earliest days of the internet, then that's perfectly feasable.
> HTML itself has grown.  We've also added Javascript and Shockwave.  The
> websites of today don't even resemble the websites of 10 years ago,
> e-mail of today only remotely resembles the original, so the argument
> that usenet should never change seems a little heavy-handed and
> anachronistic.

That's a good point, but just because things are evolving doesn't mean
they're making more sense. Html does waste bandwidth, it does open up
avenues for malware that text mail doesn't, etc.

It seems to me that any intelligent person has to turn off so many
"features" in html mail clients that they lose many of what are seen
of as advantages.

I suspect I either missed some of this thread or I'm misunderstanding
some of it. If what the OP was trying to suggest was a more confined
form of html, say, something that doesn't allow links, I'd consider
that a good thing. I doubt anyone will use it though, I think MS wants
all the bells and whistles, and all the embracing and extending it can
do. If they don't support such an html subset for email I suspect it
won't go anywhere.

But why bother? An html subset that takes everything away but
formatting sounds pretty much like what I'm doing right now with
gnus. 

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


Re: Speed quirk: redundant line gives six-fold speedup

2005-08-25 Thread Jack Diederich
On Thu, Aug 25, 2005 at 01:35:04PM -0400, Bill Mill wrote:
> On 8/25/05, Erik Max Francis <[EMAIL PROTECTED]> wrote:
> > Mark Dickinson wrote:
> > 
> > > Questions:
> > >
> > > (1) Can anyone else reproduce this behaviour, or is it just some quirk
> > > of my setup?
> > > (2) Any possible explanations?  Is there some optimization that kicks
> > > in at a certain number of lines, or at a certain length of
> > > bytecode?
> > > (3) If (2), is there some way to force the optimization, so that I can
> > > get the speed increase without having to add the extra lines?
> > 
> 
> I did find, though, that if I remove all print statements from the
> program, the dummy and non-dummy variable versions take indentical
> time. Can others reproduce this?
> 
> I'm Investigating further...

I'm getting similarly freakish results.  I tried a little ghetto debugging
by putting a printf in dictobject.c's resize method and recompiling python.
Sadly I can't get the problem to reproduce itself with the new binary
(with or without the printf).  The Ubuntu default 2.4.1 is sometimes fast,
my hand compiled one (./configure && make) is always slow.

There are some very arcane low level things going on here.

sprat:~/src/Python-2.4.1# time ./python /tmp/odd.py > /dev/null
7.876u 0.008s 0:07.91 99.4% 0+0k 0+0io 0pf+0w
sprat:~/src/Python-2.4.1# time python /tmp/odd.py > /dev/null
1.813u 0.004s 0:01.77 102.2%0+0k 0+0io 0pf+0w

sprat:~/src/Python-2.4.1# ./python
Python 2.4.1 (#5, Aug 25 2005, 13:55:44) 
[GCC 3.3.5 (Debian 1:3.3.5-8ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 

sprat:~/src/Python-2.4.1# python
Python 2.4.1 (#2, Mar 30 2005, 21:51:10) 
[GCC 3.3.5 (Debian 1:3.3.5-8ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 

No-idea-ly,

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


Re: Speed quirk: redundant line gives six-fold speedup

2005-08-25 Thread Bill Mill
Bill Mill wrote:
> 
> Pentium M 1.8 GHz Windows 2k. Here's the top of the profile results
> for fast and slow on my machine (these won't look decent except in a
> fixed-width font):
> 

>
> Interestingly, the test.py:36 line, which takes 45 seconds (!!) in the
> slow version, does not appear at all in the fast profile. I can't
> figure out why - both printed out their data, so template must have
> been called somewhere.
> 

OK, I'm getting somewhere now. When I replace:

template = ("  | %s %s %s | %s %s %s | %s %s %s |\n" * 3).join([" 
+---+---+---+\n"] * 4)

wtih:

template = """   | %s %s %s | %s %s %s | %s %s %s |\n
  | %s %s %s | %s %s %s | %s %s %s |\n
  | %s %s %s | %s %s %s | %s %s %s |\n
  +---+---+---+\n
  | %s %s %s | %s %s %s | %s %s %s |\n
  | %s %s %s | %s %s %s | %s %s %s |\n
  | %s %s %s | %s %s %s | %s %s %s |\n
  +---+---+---+\n
  | %s %s %s | %s %s %s | %s %s %s |\n
  | %s %s %s | %s %s %s | %s %s %s |\n
  | %s %s %s | %s %s %s | %s %s %s |\n
  +---+---+---+\n"""

Then the non-dummy version is faster than the dummy version (very
slightly, presumably because it doesn't need to allocate 28 dummy
variables).

Peace
Bill Mill
bill.mill at gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Jargons of Info Tech industry

2005-08-25 Thread John Bokma
"T Beck" <[EMAIL PROTECTED]> wrote:

> If we argue that people are evolving the way e-mail is handled, and
> adding entire new feature sets to something which has been around
> since the earliest days of the internet, then that's perfectly
> feasable. HTML itself has grown.  We've also added Javascript and
> Shockwave.

They are not additions to HTML, like PNG is no addition to HTML, or wav, 
mp3, etc.

> The websites of today don't even resemble the websites of
> 10 years ago,

Depends a lot on what site you visit. You can make a website of 10 years 
ago look modern with roughly the same HTML of 10 years ago, and a style 
sheet. (E.g. visit: http://johnbokma.com/ and turn off the stylesheet. And 
there are way better examples)

> e-mail of today only remotely resembles the original, so

Because there is no real alternative to email? If there was, email would 
have died, at least for me, long ago.

> the argument that usenet should never change seems a little
> heavy-handed and anachronistic.

No, simple since there *are* alternatives: web based message boards. Those 
alternatives *do* support HTML formatting (often the subset mentioned 
earlier). However, Usenet is a stranger to most people on the Internet, 
even with Usenet access, and hence, there is no real reason to see it 
changed into something that is "available" for years and years to more 
people: www.

-- 
John   Small Perl scripts: http://johnbokma.com/perl/
   Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html

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


Re: Speed quirk: redundant line gives six-fold speedup

2005-08-25 Thread Erik Max Francis
Bill Mill wrote:

> Unlikely; 2 people have confirmed these results already.
> 
> I did find, though, that if I remove all print statements from the
> program, the dummy and non-dummy variable versions take indentical
> time. Can others reproduce this?

Yes, it's obviously a real effect given the other sightings.  I don't 
see any speed difference, myself (Pentium IV 3.0 GHz running Slackware 
Linux).

-- 
Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
   There never was a good war or a bad peace.
   -- Benjamin Franklin
-- 
http://mail.python.org/mailman/listinfo/python-list


  1   2   3   >