Developement Question?

2010-04-01 Thread Wayne
My town office uses Microsoft operating system. They have a proprietary
accounting system that uses excel for their accounting reports.
I would like to read these report and reproduce the report so that
the report can be seen on the web. I was thinking about using xlrd and
xlwt along with some sort of software for building the web pages. I
use linux only and do not use Microsoft.
Q. Does python have to be installed on there computer to run the script?

Q. Am I approaching this the wrong way? If so, what would be a better
approach?


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


Re: object.enable() anti-pattern

2013-05-09 Thread Wayne Werner



On Wed, 8 May 2013, Steven D'Aprano wrote:


I'm looking for some help in finding a term, it's not Python-specific but
does apply to some Python code.

This is an anti-pattern to avoid. The idea is that creating a resource
ought to be the same as "turning it on", or enabling it, or similar. For
example, we don't do this in Python:


I'm not entirely sure what the name of it is, but the basic concept is 
that you should never partially create, or create a class that can be in 
an unstable state. Which isn't to say you should prevent invalid input, 
only that with every valid input or single operation (including 
construction) your class should be valid.



Ah, that's it - the problem is that it introduces /Temporal Coupling/ to 
one's code: http://blog.ploeh.dk/2011/05/24/DesignSmellTemporalCoupling/


You don't ever want a class that has functions that need to be called in a 
certain order to *not* crash. That's fine if you have to call them in a 
certain sequence in order to get the correct data - that's what 
programming is all about, after all. But if you provide me a class with a 
constructor you better make sure that when I do this:


thing = YourSuperAwesomeClass()
thing.do_stuff()

that I don't get some horrid stack trace ending with

InvalidStateError: initialize() needs to be called before do_stuff()

Or something worse.


HTH,
Wayne

p.s. I'm interested in reading whatever is evenually written on the topic
--
http://mail.python.org/mailman/listinfo/python-list


Re: object.enable() anti-pattern

2013-05-12 Thread Wayne Werner

On Fri, 10 May 2013, Robert Kern wrote:


On 2013-05-10 12:00, Steven D'Aprano wrote:


But either way, that's fine. You've found an object where it does make
sense to have an explicit "make it go" method: first one entity has
permission to construct the object, but not to open the underlying file.
Another entity has permission to open the underlying file, but not to
create the object. I have no idea whether this is a reasonable security
design or not, it actually sounds a bit rubbish to me but what do I know?
So let's treat it as a reasonable design.

As I've said, repeatedly, that's not what I'm talking about.

When you DON'T have useful things that can be done with the object before
calling "enable", then it is an anti-pattern to require a separate call
to "enable" method, and the enable functionality should be moved into the
object constructor. If you DO have useful things that can be done, like
pass the object to another entity, for security, then that's a whole
'nuther story.


I'd be curious to see in-the-wild instances of the anti-pattern that you are 
talking about, then. I think everyone agrees that entirely unmotivated 
"enable" methods should be avoided, but I have my doubts that they come up 
very often. Do programmers have a natural tendency to make an extra, 
completely unnecessary method? I would think that they have a natural 
tendency to the opposite.


In my experience, everyone has a reason in mind when they follow a 
pattern/anti-pattern. It is pretty rare that someone just does some specific, 
nameable thing for no reason at all. There is no need to call out an 
anti-pattern for which no one has a reason to do it. But there is a continuum 
of reasons. Some reasons are better than others. Some reasons only apply in a 
small set of circumstances but seem like they would apply more generally, at 
least to novice programmers. Programmers can be wrong about what they think 
the (anti-)pattern actually achieves. The whole point of naming an 
anti-pattern is to discuss those reasons, show where they are misapplied, 
where YAGNI, why novices overuse it, other patterns that should be used 
instead, and also the circumstances where it is actually a good pattern 
instead.


I'll share the anti-pattern that I've seen many times (not actually in 
Python)


class CoolPresenter:
def __init__(self):
self.view = None
self.some_property = None
self.other_property = None

def initialize(self):
self.view.disable()
data = self.load_data()
self.view.data = data
self.view.enable()


def reload(self):
if self.view is None:
raise NotInitializedError("Error: Please setup class")
self.view.disable()
data = self.load_data()
self.view.data = data
self.view.enable()



Then you would see code like this:

presenter = CoolPresenter()
presenter.view = CoolView()

This is just plain silly for a few reasons:

- It's ambiguous. I don't know what's required for the CoolPresenter
  to function properly.

- The temporal coupling mentioned earlier. I can create an instance of
  a class and then call a function (say `reload`) and then boom! My
  program crashes. There is *no possible* use case of this class where
  you can use it without a view.


The motivation behind this anti-pattern that I've seen is the desire to 
not have a constructor that "does too much". So you end out with an empty 
constructor and temporal coupling, and a terrible API that doesn't clearly 
explain the requirements of the class. Your class constructor should 
*require* everything that is necessary to have a stable state when the 
class is created (i.e. you should be able to properly call any function, 
set any property without an exception happening)


Why? Less bugs, easier to comprehend, change/update your code. Easier to 
use the class.


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


Re: object.enable() anti-pattern

2013-05-12 Thread Wayne Werner

On Fri, 10 May 2013, Gregory Ewing wrote:


Wayne Werner wrote:
You don't ever want a class that has functions that need to be called in a 
certain order to *not* crash.


That seems like an overly broad statement. What
do you think the following should do?

  f = open("myfile.dat")
  f.close()
  data = f.read()


To clarify - you don't want a class that has functions that need to be 
called in a certain order with *valid input* in order to not crash.


Exactly what does happen - a ValueError is raised because you're(*) 
passing self into the file.read() function, and that input is invalid 
input - specifically:


ValueError: I/O operation on closed file

*where you actually means python, because when you call 
`your_instance.method()`, it works effectively like a call to 
`YourClass.method(your_instance)`


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


Re: object.enable() anti-pattern

2013-05-13 Thread Wayne Werner

On Mon, 13 May 2013, Greg Ewing wrote:


Wayne Werner wrote:

On Fri, 10 May 2013, Gregory Ewing wrote:


  f = open("myfile.dat")
  f.close()
  data = f.read()


To clarify - you don't want a class that has functions that need to be 
called in a certain order with *valid input* in order to not crash.


Exactly what does happen - a ValueError is raised because you're(*) passing 
self into the file.read() function, and that input is invalid


The same argument can be applied to:

  foo = Foo()
  foo.do_something()
  foo.enable() # should have done this first

You're passing an invalid input to Foo.do_something,
namely a Foo that hasn't been enabled yet.


That is the crux of the argument - as designer of the class *you* need to 
ensure that when your constructor is done, your class is in a stable 
state. And that every other state transition (with valid input) results in 
your class then being in a stable state.



If anything, the stronger argument is that `file.close()` is not a well 
designed function because it leaves your object in an unstable state.


Which I would be inclined to agree with, but I couldn't give you the 
answer for what makes it better. Because the answer is the best one you 
can get in computer science: It depends.



The reason that it depends, is because it depends on what you want to do. 
Do you want a program that seems purely functional? Do you want a program 
that's easy to maintain? Do you want a program that more accurately models 
the "real world"?


Personally, I think the file object API in Python is about as good as it 
can get - but that's because it's working with "physical" things (i.e. 
files - bits on a platter, or flash/SSD drive...) which necessarily have a 
temporal nature. And it's much less badness to blow up on a call to `read` 
than it is to remove the `read` function and die with a NameError when the 
underlying file is in a closed state.



At least in my opinion ;)
-W
--
http://mail.python.org/mailman/listinfo/python-list


Re: Determine actually given command line arguments

2013-05-15 Thread Wayne Werner

On Wed, 15 May 2013, Henry Leyh wrote:
Yes, I was trying that and it sort of works with strings if I use something 
sufficiently improbable like "__UNSELECTED__" as default.  But it gets 
difficult with boolean or even number arguments where you just may not have 
valid "improbable" defaults.  You could now say, so what, it's the default 
anyway.  But in my program I would like to distinguish between given and not 
given arguments rather than between default and non-default.


Have you looked into docopt? It's pretty awesome, and might really help in 
this case.


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


Re: FACTS: WHY THE PYTHON LANGUAGE FAILS.

2013-06-28 Thread Wayne Werner

On Fri, 28 Jun 2013, 8 Dihedral wrote:


KIND OF BORING TO SHOW HOW THE LISP PROGRAMMING
WAS ASSIMULATED BY THE PYTHON COMMUNITY.

OF COURSE PYTHON IS A GOOD LANGUAGE FOR DEVELOPING
ARTIFICIAL INTELEGENT ROBOT PROGRAMS NOT SO BRAIN DAMAGES,
OR SO SLAVERY AS C/C++ OR ASEMBLY PARTS.


Best. Post. EVER.

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


Re: FACTS: WHY THE PYTHON LANGUAGE FAILS.

2013-06-28 Thread Wayne Werner

On Fri, 28 Jun 2013, Joel Goldstick wrote:





On Fri, Jun 28, 2013 at 2:52 PM, Wayne Werner  wrote:
  On Fri, 28 Jun 2013, 8 Dihedral wrote:

KIND OF BORING TO SHOW HOW THE LISP PROGRAMMING
WAS ASSIMULATED BY THE PYTHON COMMUNITY.

OF COURSE PYTHON IS A GOOD LANGUAGE FOR DEVELOPING
ARTIFICIAL INTELEGENT ROBOT PROGRAMS NOT SO BRAIN DAMAGES,
OR SO SLAVERY AS C/C++ OR ASEMBLY PARTS.


Best. Post. EVER.


In the 'general' category? or  by a 'bot'?


I think generally - because Dihedral is a bot. I don't think it would be 
nearly as awesome if it were a person.


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


Re: DOS or not? [was Re: How to tell Script to use pythonw.exe ?]

2013-07-04 Thread Wayne Werner

On Wed, 3 Jul 2013, Dennis Lee Bieber wrote:


Consider that the Powershell default is to /prevent/ execution of
script files unless some security settings have been changed; even local
script files need to be "signed" to be executed.


Protip: No they don't - wrap it in a cmd/bat file and have it launch 
powershell[1]:


powershell -ExecutionPolicy Bypass -File ...


\o/

Microsoft "security" at it again! (reminds me a bit of just pushing 
"Cancel" to log into windows 98, I think it was)


-W

[1]: http://stackoverflow.com/q/728143/344286
--
http://mail.python.org/mailman/listinfo/python-list


Re: Default scope of variables

2013-07-04 Thread Wayne Werner

On Thu, 4 Jul 2013, Steven D'Aprano wrote:


[1] Based on empirical evidence that Python supports names with length at
least up to one million characters long, and assuming that each character
can be an ASCII letter, digit or underscore.



The specification *does* state unlimited length:

http://docs.python.org/release/2.5.2/ref/identifiers.html

Though practicality beats purity.

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


Re: Default scope of variables

2013-07-07 Thread Wayne Werner

On Fri, 5 Jul 2013, Chris Angelico wrote:


Oh. Uhm... ahh... it would have helped to mention that it also has a
commit() method! But yes, that's correct; if the object expires (this
is C++, so it's guaranteed to call the destructor at that close brace
- none of the Python vagueness about when __del__ is called) without
commit() being called, then the transaction will be rolled back.


If one wants to duplicate this kind of behavior in Python, that's what 
context managers are for combined with a `with` block, which does 
guarantee that the __exit__ method will be called - in this case it could 
be something as simple as:


from contextlib import contextmanager

@contextmanager
def new_transaction(conn):
tran = conn.begin_transaction()
yield tran
if not tran.committed:
tran.rollback()



Which you would then use like:


conn = create_conn()
with new_transaction(conn) as tran:
 rows_affected = do_query_stuff(tran)
 if rows_affected == 42:
  tran.commit()



And then you get the desired constructor/destructor behavior of having 
guaranteed that code will be executed at the start and at the end. You can 
wrap things in try/catch for some error handling, or write your own 
context manager class.


HTH,
Wayne
--
http://mail.python.org/mailman/listinfo/python-list


Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-07-12 Thread Wayne Werner

On Thu, 4 Jul 2013, Νίκος Γκρ33κ wrote:


Στις 4/7/2013 6:10 μμ, ο/η MRAB έγραψε:

What do you mean "I don't know how to catch the exception with
OSError"? You've tried "except socket.gaierror" and "except
socket.herror", well just write "except OSError" instead!



try:
host = socket.gethostbyaddr( os.environ['REMOTE_ADDR'] )[0]
except OSError:
host = "UnResolved"

produces also an internal server error.

Are you sure is just except OSError ?



Have you ensured that 'REMOTE_ADDR' is actually a key in os.environ? I 
highly recommend using the logging module to help diagnose what the actual 
exception is.


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


UTF-EBCDIC encoding?

2013-07-12 Thread Wayne Werner

Is anyone aware of a UTF-EBCDIC[1] decoder?

While Python does have a few EBCDIC dialects in the codecs, it does not 
have the (relatively new?) UTF-EBCDIC one.


Additionally, if anyone is aware of a Python tool that can unpack a 
mainframe PDS file, that would also be worthwhile.



Thanks,
Wayne

[1]: https://en.wikipedia.org/wiki/UTF-EBCDIC
--
http://mail.python.org/mailman/listinfo/python-list


Re: GeoIP2 for retrieving city and region ?

2013-07-13 Thread Wayne Werner

On Sat, 13 Jul 2013, Νικόλας wrote:
But it works for me, How can it be impossible and worked for me at the 
same time?


2 + 2 = 4
2 + 6 = 8???

Why can't I make 2 and 6 equal 4? It worked for 2, so I know it's not
impossible! I don't care what everyone says, I was able to make one case work
so obviously I juat need to figure out how to make it work!


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


Re: Ideal way to separate GUI and logic?

2013-07-13 Thread Wayne Werner

On Sat, 13 Jul 2013, fronag...@gmail.com wrote:


Well, I'm a newcome to Python, but I'm developing a program with a GUI in 
tkinter, and I'm wondering what is the best, 'most pythonic' way of doing this?

I could, obviously, write a monolithic block of code.

 True, you could, but don't do that.

 You should investigate strategies like model view presenter, and test or
 behavior driven development.


 My recommendation echos the other advice you've been given. Basically you
 think of your application in terms of two problems or domains. One is the what
 that you want no do. What information do you need?

 The other problem is how do you get that information from the user and retun
 to them information than they need?

 Regardless of which side you have driving, UI or Presenter, having a design
 such as this allows for much cleaner code.

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


Re: GeoIP2 for retrieving city and region ?

2013-07-15 Thread Wayne Werner

On Sat, 13 Jul 2013, Νικόλας wrote:


But then how do you explain the fact that
http://www.maxmind.com/en/geoip_demo
pinpointed Thessaloníki and not Athens and for 2 friends of mine that 
use the same ISP as me but live in different cities also accurately 
identified their locations too?


If you bothered doing something as simple as read the Wikipedia article on
Geolocation, you could answer this question yourself: Evidently you, and your 
friends have things like cookies, or some other helps that identify your

location, which is why your addresses are close.

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


Re: Dihedral

2013-07-15 Thread Wayne Werner

On Mon, 15 Jul 2013, Devyn Collier Johnson wrote:



On 07/15/2013 08:36 AM, Steven D'Aprano wrote:

On Mon, 15 Jul 2013 06:06:06 -0400, Devyn Collier Johnson wrote:


On 07/14/2013 02:17 PM, 8 Dihedral wrote:

[...]

Do we want volunteers to speed up
search operations in the string module in Python?

It would be nice if someone could speed it up.

Devyn,

8 Dihedral is our resident bot, not a human being. Nobody knows who
controls it, and why they are running it, but we are pretty certain that
it is a bot responding mechanically to keywords in people's posts.

It's a very clever bot, but still a bot. About one post in four is
meaningless jargon, the other three are relevant enough to fool people
into thinking that maybe it is a human being. It had me fooled for a long
time.



Wow! Our mailing list has a pet bot. I bet other mailing lists are so jealous 
of us. Who ever created Dihedral is a genius!


Artificial Intelligence developers put chatbots on mailing lists so that the 
program can learn. I use Python3 to program AI applications. If you see my 
Launchpad account, you will see my two AI projects - Neobot and Novabot. 
(https://launchpad.net/neobot Neo and Nova are still unstable) AI developers 
let their bots loose on the Internet to learn from people. Dihedral is 
learning from us. Dihedral only responses when it feels it has sufficient 
knowledge on the topic. Chatbots want to appear human. That is their goal. We 
should feel honored that Dihedral's botmaster feels that this mailinglist 
would benefit the development of Dihedral's knowledge.


Are *you* a bot? ~_^

That post felt surprisingly like Dihedral...

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


Re: UTF-EBCDIC encoding?

2013-07-15 Thread Wayne Werner

On Mon, 15 Jul 2013, Kev Dwyer wrote:


Joel Goldstick wrote:


On Fri, Jul 12, 2013 at 3:12 PM, Skip Montanaro  wrote:


I can't help you.  I'm astonished.  Trying to imagine the work

environment

where this technology would be necessary


http://www.iseriespython.com/app/ispMain.py/Start?job=Home

Skip


I remember the AS400 series.. although I never worked with one.  What kind
of business still use that stuff? Is it for large corporation accounting,
MIS stuff?




Some banks still run legacy systems on AS/400s, and I've seen them used for
airline booking systems and retail POS.


Sadly there are many larger corporations that have oodles of legacy code 
on the Mainframe. We run z/OS and IBM DB2 here. In my off time I fiddle 
around with Python in an attempt to make life more enjoyable - and one of 
these forays has led me to attempt to unpack some packed data. Which is 
also an interesting (if not terribly useful) project.


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


Re: Newbie: Python 3 and web applications?

2013-07-30 Thread Wayne Werner

On Fri, 26 Jul 2013, Rui Maciel wrote:


I'm currently learning Python, and I've been focusing on Python3.  To try to
kill two birds with one stone, I would also like to learn the basics of
writing small web applications.

These web applications don't need to do much more than provide an interface
to a small database, and they may not even be required to be accessible
outside of a LAN.

Does anyone have any tips on what's the best way to start off this
adventure?


Take a look at the Python3 branch of Flask: 
https://github.com/mitsuhiko/flask.git


And the werkzeug webserver:
https://github.com/mitsuhiko/werkzeug.git


If you download these you can install them with:


python setup.py install


(werkzeug first, then flask)


Here's the most basic webserver you can create that way:


from flask import Flask

app = Flask(__name__)

@app.route("/")
def main():
return "Hello, Web!"

if __name__ == "__main__":
app.run()



And yet flask is highly extensible with a lot of plugins.


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


Re: Algorithms using Python?

2012-09-26 Thread Wayne Werner

On Fri, 21 Sep 2012, Dennis Lee Bieber wrote:


On Fri, 21 Sep 2012 14:26:04 +0530, Mayuresh Kathe 
declaimed the following in gmane.comp.python.general:


Is there a good book on foundational as well as advanced algorithms
using Python?


Depends on what you mean by "foundational"...

Since Python has dynamic lists and dictionaries, I suspect you won't
find any textbook focusing on linked-list or hashed lookup algorithms
using Python.

You can probably implement them, but they're not going to be very
efficient. (And never "remove" an element from the linked-list
implementation because Python would shift all the other elements, hence
your "links" become invalid).


It's quite inefficient, but it would be fairly trivial to create a LL 
implementation like this:


class Link:
def __init__(self):
self.next = None
self.value = None

class LinkedList:
def __init__(self):
self.head = None

def add(self, value):
node = Link()
node.value = value
self.append(node)

def append(self, node):
# Write some code

It's fairly easy to use reference types as one would use pointers in 
.


But it might actually require understanding pointers and such in the first 
place...


I'm not really aware of any algorithm that's impossible/harder to 
implement in Python - Python just makes most things a lot easier so you 
never have to deal with the lower level algorithms. Which makes *me* happy 
:)


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


Re: One of my joomla webpages has been hacked. Please help.

2012-09-26 Thread Wayne Werner

On Sat, 22 Sep 2012, Νίκος Γκρεεκ wrote:


Okey i'll ask this to the officila joomla forum, one last thing though.

Is there a way to somehow embed(or utilize) python code, for example my python 
counter code script you have seen last week inside my Joomla/WordPress cms 
sites?

For example:

http://superhost.gr/ is my main website utilizing python counter script.

http://superhost.gr/html/?show=log is my own way(i prefer it over awstats - 
don't ask why) for viewing my visitors.

in my other sites which are CMS sites, like

http://varsa.gr
and
http://thessalonik.wordpress.com/

is there a possible way to embed(if thats the term) my python counter script 
there too?

so i can keep track of visitors info for each page i have there?


Sure, but why create a counter (ugh) when you can use something like 
Google Analytics for free and get much more interesting and useful 
metrics?


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


Re: One of my joomla webpages has been hacked. Please help.

2012-09-26 Thread Wayne Werner

On Sun, 23 Sep 2012, Dwight Hutto wrote:


We're the borg.


Oh, so you *are* a robot. That does explain your posts ;)


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


Re: Who's laughing at my responses, and who's not?

2012-09-26 Thread Wayne Werner

On Tue, 25 Sep 2012, Dwight Hutto wrote:


It sounds pretentious, but over the past several days, I've been
slammed on every post almost. All because of an argument over me not
posting a little context in a conversation, that seemed short and
chatty.


Your being slammed has nothing to do with your lack of context, and 
everything to do with the fact that the way you responded to it was 
through ad hominem attacks, and the fact that most of your responses read 
like a transcript from kids I remember in junior high.


It's annoying to most people - the same way pretentious teenage nitwits 
annoy most people who are interested in talking about Python code, and not 
who did what to who.


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


Re: Article on the future of Python

2012-09-27 Thread Wayne Werner

On 9/27/2012 9:05 PM, Jason Friedman wrote:

Fair enough, but it's the M in the LAMP stack I object to. I'd much
rather have P.

+1



I know this isn't the list for database discussions, but I've never gotten a 
decent answer. I don't know much about either, so I'm kind of curious why 
postgresql over mysql?


I'll try not to get too OT... I had previously just used MySQL (and 
SQLite), but have been reaading some PostGres stuff lately. I took a look 
around and basically... you and I won't know or notice a difference 
probably ever. There's all sorts of crazy tweaks you can get for 
reliability, speed, and backups depending on what you use. So the only 
advice I can give on that is just learn to use both.


And even better yet, just use SQLAlchemy if you're ever touching a 
database from Python because it handles all the mucky SQL for you - you 
just define the ORM. (Hey look! A Python module!)


My $0.02
-Wayne
--
http://mail.python.org/mailman/listinfo/python-list


Re: print or write on a text file ?

2012-09-28 Thread Wayne Werner

On Fri, 28 Sep 2012, Franck Ditter wrote:


Hi !
Here is Python 3.3
Is it better in any way to use print(x,x,x,file='out')
or out.write(x) ? Any reason to prefer any of them ?
There should be a printlines, like readlines ?
Thanks,


The print function automatically appends newlines to the end of what it 
prints.


So if you had

text = 'Hello!'

and you did:

print(text, file=outfile)

then outfile would contain 'Hello!\n'

In contrast, outfile.write(text) would only write 'Hello!'. No newline.

There are lots of other handy things you can do with the print function:

values = [1,2,3,4]
print(*values, sep='\n', file=outfile)

I'll leave it to you to experiment.
HTH,
Wayne
--
http://mail.python.org/mailman/listinfo/python-list


Posix call (execve) breaks mercurial?

2012-10-11 Thread Wayne Werner

So... this is certainly the deepest I've got to dig into any source code.

I'm experimenting with Review Board for code reviews, and trying to get it 
set up/working here at work. When using post-review, however, I started 
getting issues with untrusted users - even though they were set to trusted 
in my ~/.hgrc and things worked fine otherwise.


So here's where things got weird. I could call 
`subprocess.check_output(['hg', 'root'])`, and things worked just fine. 
But when I added the env parameter, I got the untrusted issues. So if I 
did:


import os, subprocess

# Works just fine
subprocess.check_output(['hg', 'root'])

# Gives untrusted issues
subprocess.check_output(['hg', 'root'], env=os.environ)


Long story short, I dug around the source code and ended up at the POSIX 
execve function. I've been reading the manpages, but nothing seems to pop 
out at me as "hey, this should/shouldn't work!".


Does anyone know what's going on here, or where I should go for more help?

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


Re: Posix call (execve) breaks mercurial?

2012-10-11 Thread Wayne Werner

On Thu, 11 Oct 2012, Wayne Werner wrote:

So here's where things got weird. I could call 
`subprocess.check_output(['hg', 'root'])`, and things worked just fine. But 
when I added the env parameter, I got the untrusted issues. So if I did:


import os, subprocess

# Works just fine
subprocess.check_output(['hg', 'root'])

# Gives untrusted issues
subprocess.check_output(['hg', 'root'], env=os.environ)


So... curiouser and curiouser - it looks like it's not *actually* execve's 
fault after all. I just compiled the code from the man page, tweaked it to 
run 'hg root', and passed it a new environment. No problems. Well, then I 
manually called the posix one from Python and thing worked fine. *Then* I 
actually tried the above code, and *it* worked fine.


However I *still* get problems with the post-review code. So it looks like 
when I get back to work on Monday I'll be looking to see  what the 
difference in environment is there.


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


Re: Why Doesn't This MySQL Statement Execute?

2012-12-18 Thread Wayne Werner

On Tue, 18 Dec 2012, Tom Borkin wrote:


Hi;
I have this test code:
 
    if i_id == "1186":
  sql = 'insert into interactions values(Null, %s, "Call Back", "%s")' % 
(i_id, date_plus_2)
  cursor.execute(sql)
  db.commit()
  print sql
It prints the sql statement, but it doesn't execute. If I copy and paste the 
sql into the mysql command line it does execute without warnings or errors. 
What gives?


Does date_plus_2 contain

 "Robert"); DROP TABLE interactions; --

By any chance?
-W-- 
http://mail.python.org/mailman/listinfo/python-list


Re: context aware execution

2012-12-19 Thread Wayne Werner

On Thu, 20 Dec 2012, Chris Angelico wrote:


On Thu, Dec 20, 2012 at 2:57 AM, Bart Thate  wrote:

I want in a function or method determine the context of my caller and adapt
the functionality accordingly.


First off, please don't! Your code will be *extremely* confusing.

Usually, the best way to adapt to your caller's environment is to be
passed a parameter that specifies the change.


Or assume that the caller is smart enough to determine which one of the 
functions to call, and provide them, with good names.


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


Re: New to python, do I need an IDE or is vim still good enough?

2013-01-02 Thread Wayne Werner

On Wed, 2 Jan 2013, Michael Torrie wrote:

On 01/01/2013 11:43 AM, Mitya Sirenef wrote:

Therefore, deleting 3 WORDs is 3daW (mnemonic: del a WORD 3 times).


Interesting.  I typically use just d3w.  3daW seems to delete 3 lines
for me, the same result as d3.  Another favorite command is d or
c followed by a number and then the right arrow key, for manipulating
letters instead of words.


Right arrow and not l? Surely you jest! ;)



In any case, I can be way more productive with just a few commands
(maybe 3 or 4 commands or concepts) in Vim than in almost any GUI
editor.  In my experience, Vim users almost always find this to be true
for them as well.  Vim really hits the sweet spot for productivity and
usability.  The only thing about Vim that I find clunky is how code
folding macros work, and also code completion hacks (which I have never
needed anyway).


Yep. That's how I feel. I had used ViEmu in Visual Studio for coding in .NET at
work - but I found that the buffers & macros were more powerful. So now I do
most of my programming in Vim, and only head to VS if I need autocomplete or
some of it's auto-generation tools.

(I'm even writing this email in Vim as my external editor from alpine ;)
-W
--
http://mail.python.org/mailman/listinfo/python-list


Re: New to python, do I need an IDE or is vim still good enough?

2013-01-02 Thread Wayne Werner

On Tue, 1 Jan 2013, Mitya Sirenef wrote:


On 01/01/2013 02:02 PM, Roy Smith wrote:
That's true with Vim, as well, especially when I'm making a custom
mapping and I can NEVER remember what some combination does, even though
if I actually needed to use it, it pops right out, so to find out, I
have to try it and then I say, "of course, dammit, I use this command 50
times every single day!"; so it's a curious case of one-directional
memory.


I've found writing macros helps me a lot in this regard. I do qaq"aP
fairly frequently.

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


Re: New to python, do I need an IDE or is vim still good enough?

2013-01-02 Thread Wayne Werner

On Tue, 1 Jan 2013, Ramchandra Apte wrote:


On Friday, 28 December 2012 01:31:16 UTC+5:30, mogul  wrote:

'Aloha!



I'm new to python, got 10-20 years perl and C experience, all gained on unix 
alike machines hacking happily in vi, and later on in vim.



Now it's python, and currently mainly on my kubuntu desktop.



Do I really need a real IDE, as the windows guys around me say I do, or will 
vim, git, make and other standalone tools make it the next 20 years too for me?



Oh, by the way, after 7 days I'm completely in love with this python thing. I 
should have made the switch much earlier!



/mogul %-)


I use Eclipse only because it has PEP 8 and Pylint integration.
Ezio Melotti, core Python developer, said in personal chat, that he uses Kate.
IDEs aren't that useful when coding in Python.


I concur. I think it's because with a language that has 43(?) keywords and 
I believe it's 12 different statement types, you can easily fit it all in 
your head. What you can't fit in your head is found in the docstrings of 
whatever you're using.


Give me an interactive interpreter, vim, and a web browser, and I'm more 
than fine.


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


Re: New to python, do I need an IDE or is vim still good enough?

2013-01-06 Thread Wayne Werner

On Fri, 4 Jan 2013, Roy Smith wrote:


In article ,
Cameron Simpson  wrote:


On 01/04/13 01:34, Anssi Saari wrote:
| Just curious since I read the same thing in a programming book recently
| (21st century C). So what's the greatness that terminal multiplexors
| offer over tabbed terminals? Especially for software development?


There's no doubt that you need access to multiple terminal sessions.
Whether you achieve that with multiple terminal windows on your desktop,
multiple desktops, tabbed terminals, or something like screen is
entirely personal preference.


+1

I use a tiling WM (awesomewm), but I still find that tmux has its place. 
Usually I'll have a terminal per box that I'm working on, and a tmux 
session within that.


This allows me to detach and reattach from any system I'm on. In addition, 
if I lose my connection, I don't have to figure out which processes I had 
in bg. There's also the neat ability (at least with tmux - I haven't used 
screen for a while now) to work across sessions - so I might have a 
personal session (with things like alpine and irssi), a dev session (with 
Vim, a python prompt, and a shell) - and I can either keep them separate 
if I need to focus, or join the windows if I need some help.


One thing that I've noticed that tmux does poorly is handle the mouse for 
selecting. And as I haven't yet written or found a cross-platform/machine 
clipboard manager, using the tmux copy or xclip doesn't really help that 
much :P


I'd say the main benefit (aside from tiling) is the attach/detach. Unless 
your machine powers off or you kill tmux/screen, your sessions will stay 
around.


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


Re: The best, friendly and easy use Python Editor.

2013-01-31 Thread Wayne Werner

On Thu, 24 Jan 2013, Tim Chase wrote:


On 01/24/13 13:34, Leonard, Arah wrote:

All true (especially the holy wars bit!). OP didn't (as far as
I can see) even say which OS he is using. Anyway, my suggestion
is generally that people use the editor with which they are
already comfortable.


Sound advice.  [snip] Whatever works is what works. It's just a
text file after all.


So even "ed" or "edlin" or even "cat" would do ;-)
?
-tkc
?
wq


ed *is* the standard editor.

Also, I see what you did there ;)

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


Re: newbie question

2011-04-01 Thread Wayne Brehaut
On Fri, 1 Apr 2011 21:52:24 +0200, Karl
<8213543ggxnvjx...@kabelmail.de> wrote:

>Hello,
>
>one beginner question:
>
>aList = [0, 1, 2, 3, 4]
>bList = [2*i for i in aList]
>sum = 0
>for j in bList:
>   sum = sum + bList[j]
>print j
>
>0
>2
>4
>IndexError: 'list index out of range'
>Why is j in the second run 2 and not 1 in the for-loop?? I think j is a 
>control variable with 0, 1, 2, 3, ...

No--to see what 'j' is, comment out your "sum = sum + bList[j]"
statement and run again.

The name 'j' refers in order to the 0th, 1st, etc., value in bList,
and it's therefore just 'j' (i.e., the value that j now refers to) you
want to add to the sum.

To get "the usual" (in many oter PLs) indexing instead you would use:

for j in range(len(bList)):
sum = sum + bList[j]

And if you again comment out the "sum =..." and add:

print j, bList[j]

you'll see the difference.

wwwayne

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


Re: Bloody rubbish

2021-05-06 Thread Wayne Lodahl
On 5/6/21 6:11 AM, Mr Flibble wrote:
> Python is slow and significant whitespace is patently absurd.
> 
> Bloody rubbish, it's all bloody rubbish.
> 
> Message ends.
> 
> /Flibble
> 
Machine language is so much simpler, and you can code with just a hexpad.
-- 
https://mail.python.org/mailman/listinfo/python-list


What is "self"?

2005-09-22 Thread Wayne Sutton
OK, I'm a newbie...
I'm trying to learn Python & have had fun with it so far.  But I'm having 
trouble following the many code examples with the object "self."  Can 
someone explain this usage in plain english?

Thanks,
Wayne 


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


Re: Deep vs. shallow copy?

2014-03-12 Thread Wayne Brehaut
On 12 Mar 2014 15:29:59 GMT, Alex van der Spek 
wrote:

>On Wed, 12 Mar 2014 10:00:09 -0500, Zachary Ware wrote:
>
>> On Wed, Mar 12, 2014 at 9:25 AM, Alex van der Spek 
>> wrote:

=== 8< ===

>Having been taught programming in Algol60 Python still defeats me at times!
>Particularly since Algol60 wasn't very long lived and what came
>thereafter (FORTRAN) much worse.

Actually, Algol 60 lived on (and lives on, though not so much used now
outside of Scandinavia) in an improved and OOP-extended form in Simula
67 (now just Simula). Most implementations excpt that for DEC-System10
were, however, overpriced and poorly marketed, so we had to wait for
C++ (improved and OOP-extended C) for OOP to catch on.

=== 8< ===
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PEP8 79 char max

2013-08-03 Thread Wayne Werner

On Wed, 31 Jul 2013, Joshua Landau wrote:


To explain, I tend to take the "HTML" form of alignment by wrapping:

open stuff stuff stuff close

to

open
    stuff
    stuff
    stuff
close


Depending on how much 'stuff' I have, I, for one, prefer a third:

open stuff
 stuff
 stuff
close


Which then makes it 1) fairly easy to read, 2) fairly easy to extend.

Of course it could just be that I'm used to that style - our brains are 
wired weird.



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


Re: Simple Python script as SMTP server for outgoing e-mails?

2013-08-03 Thread Wayne Werner

On Thu, 1 Aug 2013, Gilles wrote:


On Wed, 24 Jul 2013 10:38:52 -0400, Kevin Walzer 
wrote:

Thanks. hMailServer was one of the apps I checked, and I was just
making sure there weren't something simpler, considering my needs,
ideally something like Mongoose MTA.


Have you checked Kenneth Rietz's inbox.py[1]? It's fairly simple to 
use/extend and might fit your modest needs.



-W

[1]:https://crate.io/packages/inbox/


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


Re: Does Python 'enable' poke and hope programming?

2013-08-03 Thread Wayne Werner

On Thu, 1 Aug 2013, CM wrote:


(My subject line is meant to be tongue and cheek inflammatory)

I've been thinking about why programming for me often feels like ice skating uphill.  I 
think part of the problem, maybe the biggest part, is what now strikes me as a Very Bad 
Habit, which is "poke and hope" (trial and error) programming (of several names 
this page provided, I kind of like that one):

http://en.wikipedia.org/wiki/Programming_by_permutation

It seems that if I can make a change to the code and then immediately test it by running 
the Python interpreter and finding out, in a few seconds, if it worked, I am going to be 
*much* more likely to use this trial-and-error approach than if I had to use a compiled 
language, since compiling takes so long.  E.g. "Oh, that doesn't work?  Maybe if I 
add this...no.  OK, what about if I increment that?  No...OK, wait, maybe this...AH!  
That worked."  (obviously it is not quite that uninformed all the time).

Instead, with a compiled language, because of the pain of having to wait for 
the newest version to compile, one would be encouraged to get the mechanism of 
how something works *clear* and robustly represented in one's mind (or on scrap 
paper/notes document) prior to testing through compiling and running.

Basically this amounts to:  with an interpreted language (so of course this is 
not really just about Python--I just think in terms of Python), it's easier to 
be mentally lazy.  But, ironically, being lazy winds up creating *way* more 
work ultimately, since one winds up programming in this terribly inefficient 
way, and progress proceeds at an, at times, evolutionary (slow!) pace.

And of course I am not really blaming it on Python or any interpreted language; 
I am blaming it fully on my own lame habits and attitude.

I'm sick of this in my own work, and want to avoid this trap as much as I can 
from now on.

Thoughts?



I see that many others have had thoughts already - but rather than take the
time to read their responses and either find out that they said the same thing
(oops, sorry!) or become influenced by their arguments, I feel like I should
respond to this with a clean slate.


I don't think that Python enables the "poke and hope" style programming (I like
the name!) any more than a compiled language does - if you're doing it right.

Example: My brother had a kid in his C++ class that would go about randomly
flipping >, <, <=, >= signs until he got the behavior that he wanted. There was
no mental effort of thinking about the problem or applying the scientific
method - i.e. form a hypothesis, test the hypothesis, check results. My
experience is that people who go throughout their programming careers without
this attitude will do it whether it requires several seconds (or minutes) of
compile time or not. Whether or not it's a conscious choice I don't know - at
least in your case you seem to desire to make a conscious choice in the
direction of "wait a minute, this is a stupid way to program".

Though "poke and hope" is headed in the right direction, I think it's a bit
naive and misses the very essential nature of the better (best?) method -
formulation of a /real/ hypothesis. For instance "I think my program will work"
is a hypothesis of exactly the same quality of, "When I turn on my water
faucet, it will rain." Of course the smaller the application, the more valid
the original hypothesis. For instance, the "poke and hope" programmer might
write this program:

 x = 3
 if x > 3:
 print "x is less than 3"
 else:
 print "x is greater than 3"

And then of course make the weak hypothesis "if I change my > to < then maybe
my program will work" - or "if I change my x to 5 then maybe my program will
work".


The problem is that these are really just random guesses - flips of the coin
that eventually might produce a correct result - but only because of the
monkeys[1].

What you really want is to actually understand cause and effect at a more
fundamental level (in programming) than what you may currently enjoy. And this
is in fact something that, while makes it easier for the "poke and hope", also
provides a much more enjoyable laboratory experience for the initiated. And
when you combine that with the REPL (interactive interpreter) you get an
embarassingly powerful laboratory in which to experiment to your heart's
delight.

For instance, say you want to really understand the previous example. You could
do something like so:

>>> x = 3
>>> x > 3
False
>>> x < 3
False
>>> x >= 3
True
>>> x <= 3
True
>>> x == 3
True


And *this* type of "poke and hope" *is* actually valuable. This is where
understanding is formed, and high-quality developers are forged. At your
fingertips you begin to see "A hah! so *that's what this does!" You are free to
explore and play and understand the rules of the system. And you can build on
the previous experiments:


>>> if x > 3:
...  print("

Re: Logging help

2013-08-03 Thread Wayne Werner

On Thu, 1 Aug 2013, Joseph L. Casale wrote:


I have a couple handlers applied to a logger for a file and console destination.
Default levels have been set for each, INFO+ to console and anything to file.

How does one prevent logging.exception from going to a specific handler when
it falls within the desired levels?



There is probably a better way, I'm not too familiar with the more 
advanced logging, but off the top of my head I'd suggest subclassing the 
Handler classes that you're interested in and overriding the Handle method 
(I think - you can check the source to be sure) and if the type of message 
is exception then just skip handling it.


Alternatively, you could simply create a different logger, e.g.

exc_logger = logging.getLogger('mything.exceptions')


And use that to log exceptions.

Oh hai - as I was reading the documentation, look what I found:

http://docs.python.org/2/library/logging.html#filter

Methinks that should do exactly what you want.

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


Re: Python performance

2013-08-03 Thread Wayne Werner

On Fri, 2 Aug 2013, Schneider wrote:


Hi list,

I have to write a small SMTP-Relay script (+ some statistic infos) and 
I'm wondering, if this
can be done in python (in terms of performance, of course not in terms 
of possibility ;) ).


It has to handle around 2000 mails per hour for at least 8hours a day 
(which does not mean, that it is allowed not to respond the rest of 

the day.


Can this be done? or should I better use some other programming language?
My second choice would be erlang.


Check out Kenneth Rietz's inbox.py[1]

"It's quite quick. One instance should handle over one thousand emails per 
second."


So it should be able to handle your hour's load in oh, say 2 seconds? ;)

HTH,
W

[1]: https://crate.io/packages/inbox/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Moving to Python for web

2013-09-05 Thread Wayne Werner


On Thu, 29 Aug 2013, Andreas Ecaz wrote:


I've decided to go with Flask! It's now running on UWSGI with NGINX. Hopefully 
I can get some stuff done :)


@Chris “Kwpolska” Warrick

I just don't like the big frameworks, for me there is too much magic going on.


I'm a huge fan of Flask - I also find that when you start to learn more 
and more about Flask you can see how Django would be super useful, if you 
need all the bells and whistles.


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


Re: print function and unwanted trailing space

2013-09-11 Thread Wayne Werner

On Sat, 31 Aug 2013, candide wrote:

# -
for i in range(5):
   print(i, end=' ')   # <- The last ' ' is unwanted
print()
# -


Then why not define end='' instead?

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


Re: Language design

2013-09-11 Thread Wayne Werner

On Tue, 10 Sep 2013, Ben Finney wrote:

 The sooner we replace the erroneous
 “text is ASCII” in the common wisdom with “text is Unicode”, the
 better.


I'd actually argue that it's better to replace the common wisdom with 
"text is binary data, and we should normally look at that text through 
Unicode eyes". A little less catchy, but more accurate ;)


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


Re: better and user friendly IDE recommended?

2013-09-12 Thread Wayne Werner

On Thu, 12 Sep 2013, Ben Finney wrote:

Better to learn these once, in a single powerful tool that can be
maintained independent of any one vendor for as long as its community is
interested.


And if you're a developer, even a community of one is enough ;)

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


Re: JUST GOT HACKED

2013-10-04 Thread Wayne Werner
On Tuesday, October 1, 2013 5:06:38 PM UTC-5, Ben Finney wrote:
> This is an unmoderated forum, so we have occasional spates of persistent
> 
> nuisances, and those who respond with the maturity level and impulse
> 
> control of an average six-year-old.

Hey! That's so degrading! I don't know many six-year-olds (and certainly not 
mine, but maybe they're just not average) who would continue to respond in the 
same fashion that the OP of *this* thread did!

;-)
-W
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: JUST GOT HACKED

2013-10-04 Thread Wayne Werner
On Wednesday, October 2, 2013 5:43:32 AM UTC-5, Ferrous Cranus wrote:
>  
> I only re-ask the same thing if:
> 
> 
> 1. Di not understood what was provided or proposed to me as being a solution
> 
> 2. Still feel that that the solution provided to me doesn't meet my 
> needs and should have been re-written in a different way. Nevertheless 
> we are all improving, especially the newbies, by seeing alternative way, 
> best methods and wise practices of writing code for the specific problem 
> and pick the one that does the job best.
> 

If you feel that the provided solution doesn't meet your needs then the *most 
likely* answer is that you have asked the wrong question. Rather than, say, 
posting a new thread (unless your new question is clearly different and mostly 
unrelated), the appropriate course of action is to say something like,

"Hey, apparently I'm asking the wrong question, because all these answers are 
about frobnosticating, but I really wanted to foo the baz."

If you don't acknowledge that you goofed up, you come across as arrogant or 
ignorant (or both).

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


Re: Writting Dialog to enter preset items from a combo list

2015-06-12 Thread Wayne Norman
ok I have wxFormBuilder as well and so could use some help with working on my 
project I would explain exactally what I am doing to and one who wishes to aid 
me with this.

for now I will has it has to do with a minecraft mod if you would like to known 
more I will put more here
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Extracting and summing student scores from a JSON file using Python 2.7.10

2015-11-09 Thread wayne . wickson
On Monday, 9 November 2015 22:27:40 UTC-5, Denis McMahon  wrote:
> On Mon, 09 Nov 2015 15:52:45 -0800, Bernie Lazlo wrote:
> 
> > This should be a simple problem but I have wasted hours on it. Any help
> > would be appreciated. [I have taken my code back to almost the very
> > beginning.]
> > 
> > The student scores need to be summed.
> > 
> > import json import urllib url =
> > "http://www.wickson.net/geography_assignment.json";
> > response = urllib.urlopen(url)
> > data = json.loads(response.read())
> > lst1 = list(data.items())
> > print lst1
> 
> I find that pprint.pprint is useful for looking at data structures.
> 
> Having looked at the data, and then using appropriate substitutions for 
>  and  in the following:
> 
> sumscore = 0
> students = 0
> 
> for dic in :
> sumscore = sumscore + dic[]
> students += 1
> 
> print 'Sum of', students, 'scores is', sumscore
> print 'Average of', students, 'scores is', sumscore / students
> 
> It was trivial to generate:
> 
> Sum of 50 scores is 3028
> Average of 50 scores is 60
> 
> -- 
> Denis McMahon
=
Thanks for the reply, Denis. I hope this comes as easily to me some day. :-)

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


Re: Jinja2 installation help

2013-02-08 Thread Wayne Werner

On Fri, 8 Feb 2013, Robert Iulian wrote:


Hello,

I recently started learning Python. Just finished learning the basis of it, and 
now I think I'm ready to start working on a simple website but I am having some 
difficulties installing Jinja2.
Can anyone post a dummy guide on how to install it, and what to do step by step?
I am using the lastest Python version 3.3 .


Do you have easy_install or pip installed? If you do,

$ pip install jinja2

And that's it!


HTH,
Wayne
--
http://mail.python.org/mailman/listinfo/python-list


Re: "monty" < "python"

2013-03-21 Thread Wayne Werner

On Thu, 21 Mar 2013, Roy Smith wrote:


In article ,
Terry Reedy  wrote:


On 3/20/2013 10:03 AM, franzferdinand wrote:

Ok, thanks everybody!


Threads are like the Sorcerer's Apprentice. You can start 'em, but you
cannot stop 'em ;-)


Of course you can stop threads.  Just call _exit().  No more threads!


Thank you for making me laugh this morning - I found that extremely 
amusing.


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


Re: Problems with sockets and threads

2013-04-11 Thread Wayne Werner

On Thu, 11 Apr 2013, Dexter Deejay wrote:


When i try to run this code and to connect to server (server is written in java 
that part of code is ok) everything stalls. Thread that i created here occupies 
processor all the time and GUI freezes. It's supposed to be waiting for message 
from server. (asynchronous one) Is there something that i did wrong here, or is 
there better way to do this?


from tkinter import *
from threading import *


Everything I've read or used suggests to me that threading+tkinter is a 
dangerous combination.


Mainly because tkinter already has an event loop, so when you start mixing 
threads things tend to go sideways.


Instead what you'll want to do is put processing in the .after or 
.after_idle callbacks - just make sure that whatever is doing is quick (or 
can do a portion of the activity quickly).


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


Re: Problems with sockets and threads

2013-04-11 Thread Wayne Werner

On Thu, 11 Apr 2013, Dexter Deejay wrote:


Yeah, that seems to be problem. Waiting for message is in theory infinite. But 
why doesn't this separate thread leave processor while it is sleeping?


As far as I've been able to tell? Magic ;)

But I haven't really dug into it. If you're really doing some waiting 
stuff you might want to look into some other type of message passing 
mechanism, e.g. launch a subprocess to do ths listening and then writing 
to a file and checking that from within Tkinter. I expect there are other 
possibilities that more advanced people may be able to recommend and are 
probably better. But that seems like it would work.


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


Re: dynamic forms generation

2013-04-18 Thread Wayne Werner

On Tue, 16 Apr 2013, andrea crotti wrote:


This is not really scalable, and we want to make the whole thing more
generic.

So ideally there could be a DSL (YAML or something else) that we could
define to then generate the forms, but the problem is that I'm quite
sure that this DSL would soon become too complex and inadeguate, so I'm
not sure if it's worth since noone should write forms by hands anyway.

Between the things that we should be able to do there are:
- dependent fields
- validation (both server and client side, better if client-side
  auto-generated)
- following DRY as much as possible

Any suggestions of possible designs or things I can look at?


I would highly recommend a look at Flask, and Flask-WTF in particular. 
It's fairly easy to write forms, and with only a bit of setup you can end 
out with some fairly generic systems.


I don't think that by default it does any client-side validation 
generation, but as the HTML for the forms are completely generated, 
extending the form and adding validation logic to the output wouldn't be 
too difficult.


Example:

# form.py

from flask.ext.wtf import Form, TextField, Required

class MyBasicForm(Form):
some_text = TextField("Put some text here:", validators=[Required()])


# View/HTML

{% extends 'base.html' %}
{{ form.some_text.label() }}{{ form.some_text(size=40) }}


# Server code

@app.route("/basic_form", methods=['GET', 'POST'])
def basic():
form = MyBasicForm()
if form.validate_on_submit():
do_the_needful(form.some_text.data)
return redirect(url_for('main'))

return render_template('basic_form.html', form=form)



Obviously a really basic example. Check out Flask here:
http://flask.pocoo.org/

And Flask WTF here:
http://pythonhosted.org/Flask-WTF/


HTH,
Wayne-- 
http://mail.python.org/mailman/listinfo/python-list


Re: anyone know pandas ? Don't understand error: NotImplementedError...

2013-04-18 Thread Wayne Werner

On Wed, 17 Apr 2013, someone wrote:

 File "/usr/lib/pymodules/python2.7/pandas/tseries/offsets.py", line 214, in 
rule_code

   raise NotImplementedError
NotImplementedError


Can anyone tell why this error appears and how to fix it?


I don't know anything about pandas, but my recommendation?

  $ vim /usr/lib/pymodules/python2.7/pandas/tseries/offsets.py

(or nano or emacs - whatever editor you're comfortable with).

Go to line 214, and take a look-see at what you find. My guess is it will 
be something like:


def rule_code():
raise NotImplementedError()



Which is terribly unhelpful.

HTH,
Wayne
--
http://mail.python.org/mailman/listinfo/python-list


Re: Encoding NaN in JSON

2013-04-18 Thread Wayne Werner

On Wed, 17 Apr 2013, Miki Tebeka wrote:


I'm trying to find a way to have json emit float('NaN') as 'N/A'.

No.  There is no way to represent NaN in JSON.  It's simply not part of the
specification.

I know that. I'm trying to emit the *string* 'N/A' for every NaN.


Why not use `null` instead? It seems to be semantically more similar...

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


Re: Encoding NaN in JSON

2013-04-22 Thread Wayne Werner

On Sat, 20 Apr 2013, Chris “Kwpolska” Warrick wrote:


On Fri, Apr 19, 2013 at 9:42 PM, Grant Edwards  wrote:

The OP asked for a string, and I thought you were proposing the string
'null'.  If one is to use a string, then 'NaN' makes the most sense,
since it can be converted back into a floating point NaN object.

I infer that you were proposing a JSON null value and not the string
'null'?


Not me, Wayne Werner proposed to use the JSON null value.  I parsed
the backticks (`) used by him as a way to delimit it from text and not
as a string.


That was, in fact, my intention. Though it seems to me that you'll have to 
suffer between some sort of ambiguity - in Chrome, at least, 
`Number(null)` evaluates to `0` instead of NaN. But `Number('Whatever')` 
evaluates to NaN. However, a JSON parser obviously wouldn't be able to 
make the semantic distinction, so I think you'll be left with whichever 
API makes the most sense to you:


NaN maps to null

   or

NaN maps to "NaN" (or any other string, really)


Obviously you're not limited to these particular choices, but they're 
probably the easiest to implement and communicate.


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


Re: Python work in UK

2006-11-24 Thread Steven Wayne
On Thu, 23 Nov 2006 19:28:26 +, Will McGugan
<[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'd love to work in Python, for the sake of my blood pressure, but there 
> doesnt seem to be that many jobs that look for Python as the main skill. 
> I use Python at work from time to time, and occasionaly get to spend 
> several days on a Python project but the majority of the time I use C++. 
> How can I make that leap to working with Python? There doesn't seem to 
> be many UK positions on the jobs section of Python.org or the usual jobs 
> sites. Any recommended jobs sites or tips? (I have googled)
>
> In the off chance that a potential empolyer is reading this, I'm looking 
> for something in web development, applications, graphics or other 
> interesting field. Here is a copy of my CV.
>
> http://www.willmcgugan.com/cvwillmcgugan.pdf
>
> Regards,
>
> Will McGugan

www.riverhall.co.uk are looking.

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


Re: 2**2**2**2**2 wrong? Bug?

2007-07-13 Thread Wayne Brehaut
On Mon, 09 Jul 2007 23:51:25 -0700, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:

>On Jul 9, 11:42?pm, Paul McGuire <[EMAIL PROTECTED]> wrote:
>> On Jul 9, 11:21 pm, "Jim Langston" <[EMAIL PROTECTED]> wrote:> In Python 2.5 
>> on intel, the statement
>> > 2**2**2**2**2
>> > evaluates to>>> 2**2**2**2**2
>>
>> > 200352993040684646497907235156025575044782547556975141926501697371089405955
>> >   63114
>> > 530895061308809333481010382343429072631818229493821188126688695063647615470
>> >   29165
>> > 041871916351587966347219442930927982084309104855990570159318959639524863372
>> >   36720
>>
>> 
>>
>> Exponentiation is right associative, so this is the same as:
>>
>> 2**(2**(2**(2**2)))
>> 2**2**2**4
>> 2**2**16
>> 2**65536
>>
>> 2=10**0.3010, so 2**65536 is approx 10**19726
>>
>> There are 19730 digits in your answer,
>
 import gmpy
 n = 2**2**2**2**2
 gmpy.numdigits(n)
>19729
>
>Did you count the 'L'?

numdigits(n)?

What?  'L' is a digit in Python?  I'm going back to Fortran!

wwwayne

>>so this seems to be at least in
>> the ball park.
>>
>> -- Paul
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Understanding python functions - Instant Python tutorial

2007-07-13 Thread Wayne Brehaut
On Fri, 13 Jul 2007 18:49:06 +0200, Wildemar Wildenburger
<[EMAIL PROTECTED]> wrote:

>Wildemar Wildenburger wrote:
>> x = [1, 2, 3]
>> y = [1, 2, 3]
>> id(x), id(y)
>> x == y
>> x is y
>>   
>Ooops!
>
>Make that:
>
>x = [1, 2, 3]
>y = [1, 2, 3]
>id(x); id(y)
>x == y
>x is y
>
>(had to be a semicolon there)

Not "had to be" since a discerning reader will note that the two
values in the list:

>>> id(x), id(y)
(19105872, 19091664)

are different, and can guess that id() means "address of".  But "nicer
to be" perhaps since it makes it even more clea rto discerning
readers, and more likely clear to others.  ;-)

>>> id(x); id(y)
19105872
19091664

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


Re: 2**2**2**2**2 wrong? Bug?

2007-07-13 Thread Wayne Brehaut
On Wed, 11 Jul 2007 21:37:00 -0400, "Terry Reedy" <[EMAIL PROTECTED]>
wrote:

>
>"Evan Klitzke" <[EMAIL PROTECTED]> wrote in message 
>news:[EMAIL PROTECTED]
>| On 7/11/07, Gabriel Genellina <[EMAIL PROTECTED]> wrote:
>| > Just for curiosity: This helps to find the answer to the problem "Which 
>is
>| > the largest number that can be written with only 3 digits?"
>| > Some people stop at 999, others try 99**9 and 9**99, and the winner is
>| > 9**9**9, or:
>| >
>| > |   9
>| > |  9
>| > | 9
>| >
>| > Sorry, couldn't resist.
>|
>| But you can append ! (i.e. factorial) indefinitely without adding any
>| digits to make the number arbitrarily large ;-)
>
>But as Gabriel showed, 9**9**9 in standard math pen-and-paper or 
>chalk-and-blackboard notation, not the squished computer linear imitation 
>thereof, uses three nines and nothing else ;-)

Since no base was specified:

   (hex) F**F**F > (dec) 9**9**9

and we could use BASE-64 numbers (immediately coming to mind if we
ever drove a CDC CYBER machine), where:

   (base-64) del**del**del >  (hex) F**F**F > (dec) 9**9**9

Then someone who had read the Busy Beaver reference would introduce
base-BB2, or (where we assume the digits base-BB2 are 0, 1, ...,
BB2(???)):

   BB2(1) ** BB2(1) ** BB2(1)

and so on, ad infinitum--as the bard said
(http://www-groups.dcs.st-and.ac.uk/~history/Quotations/De_Morgan.html):

Great fleas have little fleas upon their backs to bite 'em,
And little fleas have lesser fleas, and so ad infinitum.
And the great fleas themselves, in turn, have greater fleas to go on;
While these again have greater still, and greater still, and so on.

wwwayne
===
"Come along son, and put your whip away.  That horse is dead!"
  --- Wise Old Man

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


Re: 2**2**2**2**2 wrong? Bug?

2007-07-13 Thread Wayne Brehaut
On Fri, 13 Jul 2007 11:30:16 -0700, Paul McGuire <[EMAIL PROTECTED]>
wrote:

>On Jul 13, 1:20 pm, Wayne Brehaut <[EMAIL PROTECTED]> wrote:
>> On Mon, 09 Jul 2007 23:51:25 -0700, "[EMAIL PROTECTED]"
>>
>>
>>
>>
>>
>> <[EMAIL PROTECTED]> wrote:
>> >On Jul 9, 11:42?pm, Paul McGuire <[EMAIL PROTECTED]> wrote:
>> >> On Jul 9, 11:21 pm, "Jim Langston" <[EMAIL PROTECTED]> wrote:> In Python 
>> >> 2.5 on intel, the statement
>> >> > 2**2**2**2**2
>> >> > evaluates to>>> 2**2**2**2**2
>>
>> >> > 200352993040684646497907235156025575044782547556975141926501697371089405955
>> >> >   63114
>> >> > 530895061308809333481010382343429072631818229493821188126688695063647615470
>> >> >   29165
>> >> > 041871916351587966347219442930927982084309104855990570159318959639524863372
>> >> >   36720
>>
>> >> 
>>
>> >> Exponentiation is right associative, so this is the same as:
>>
>> >> 2**(2**(2**(2**2)))
>> >> 2**2**2**4
>> >> 2**2**16
>> >> 2**65536
>>
>> >> 2=10**0.3010, so 2**65536 is approx 10**19726
>>
>> >> There are 19730 digits in your answer,
>>
>> >>>> import gmpy
>> >>>> n = 2**2**2**2**2
>> >>>> gmpy.numdigits(n)
>> >19729
>>
>> >Did you count the 'L'?
>>
>> numdigits(n)?
>>
>> What?  'L' is a digit in Python?  I'm going back to Fortran!
>>
>> wwwayne
>>
>>
>>
>> >>so this seems to be at least in
>> >> the ball park.
>>
>> >> -- Paul- Hide quoted text -
>>
>> - Show quoted text -- Hide quoted text -
>>
>> - Show quoted text -
>
>'L' counts for 50, but only when you use Roman font.

WTL?!  Not Times  New Roman I hope?

Now I'll have to extend my remarks below to include:

L**L**L
D**D**D
M**M**M
etc. (since I don't recall what comes next)

though these (L, D, M, ...)  would seem to be numbers rather than
digits: the Romans used a base-1 system [for purposes of this
argument, at least] so  I is the only Roman digit* and the others are
just shorthand for:

   I = 1
   V = I
   X = I*10
   L = I*50
   D = I*500
   M = I*1000
   etc.

---
For those who don't know which Roman digit I represents:

   |
_\|/__

wwwayne

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


Re: Can a low-level programmer learn OOP?

2007-07-13 Thread Wayne Brehaut
On Sat, 14 Jul 2007 06:01:56 +0200, Bruno Desthuilliers
<[EMAIL PROTECTED]> wrote:

>Chris Carlen a écrit :
>> Hi:
>> 
>>  From what I've read of OOP, I don't get it.  I have also found some 
>> articles profoundly critical of OOP.  I tend to relate to these articles.
>> 

=== 8< ===

>> 
>> Hence, being a hardware designer rather than a computer scientist, I am 
>> conditioned to think like a machine.  I think this is the main reason 
>> why OOP has always repelled me.
>
>OTOH, OO is about machines - at least as conceveid by Alan Key, who 
>invented the term and most of the concept. According to him, each object 
>is a (simulation of) a small machine.

Oh you young'uns, not versed in The Ancient Lore, but filled with
self-serving propaganda from Xerox PARC, Alan Kay, and Smalltalk
adherents everywhere!

As a few more enlightened have noted in more than one thread here, the
Mother of All OOP was Simula (then known as SIMULA 67).  All Alan Kay
did was define "OOPL", but then didn't notice (apparently--though this
may have been a "convenient oversight") that Simula satisfied all the
criteria so was actually the first OOPL--and at least 10 years earlier
than Smalltalk! 

So Kay actually invented NONE of the concepts that make a PL an OOPL.
He only stated the concepts concisely and named the result OOP, and
invented yet another implementation of the concepts-- based on a
LISP-like functional syntax instead of an Algol-60  procedural syntax,
and using message-passing for communication amongst objects (and
assumed a GUI-based IDE) (and introduced some new terminology,
especially use of the term "method" to distinguish class and instance
procedures and functions, which Simula hadn't done) . 

As Randy Gest notes on http://www.smalltalk.org/alankay.html, "The
major ideas in Smalltalk are generally credited to Alan Kay with many
roots in Simula, LISP and SketchPad."  Too many seem to assume that
some of these other "features" of Smalltalk are part of the definition
of an OOP, and so are misled into believing the claim that it was the
first OOPL. Or they claim that certain deficiencies in Simula's object
model--as compared to Smalltalk's--somehow disqualifies it as a "true
OOPL", even though it satisfies all the criteria as stated by Kay in
his definition. See http://en.wikipedia.org/wiki/Simula and related
pages, and "The History of Programming Languages I (HOPL I)",  for
more details.

Under a claim of Academic Impunity (or was that "Immunity"), here's
another historical tid-bit.  In a previous empolyment we once had a
faculty applicant from CalTech who knew we were using Simula as our
introductory and core language in our CS program, so he visited Xerox
PARC before coming for his inteview.  His estimate of Alan Kay and
Smalltalk at that time (early 80s) was that "They wanted to implement
Simula but didn't understand it--so they invented Smalltalk and now
don't understand _it_!"

wwwayne

=== 8< ===
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A Python newbie ask a simple question

2007-07-13 Thread Wayne Brehaut
On Fri, 13 Jul 2007 14:51:52 -0400, "Jeff McNeil" <[EMAIL PROTECTED]>
wrote:

>The raw_input built-in returns a string.  The '[0]' subscript returns
>the first character in the user supplied response as strings support
>indexing.
>
>[GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin
>Type "help", "copyright", "credits" or "license" for more information.
 mystr = "asdf"
 mystr[0]
>'a'

>
 raw_input("Another one, please: ")[0]
>Another one, please: ASDF
>'A'

>
>-Jeff

And, as I'm sure Jeff intended to add, you should always try to answer
such questions for yourself by just trying a few examples.  An
advantage of Python is that it's very quick and easy to test one idea
at a time without having to create a complete program skeleton before
getting started as you would have to in some other languages (such as
Java).

It also wouldn't hurt to start with one of the many introductory
tutorials, some referenced in similar threads above in this group
under topics like:

Off Topic: What is the good book to learn Python ?
Want to learn Python
Start

to see what others recommend you start with.  Or just take a common
suggestion and go to:

http://www.python.org/doc/

and check out some of the beginners' resources listed and linked to
there, such as the "offical" tutorial:

http://docs.python.org/tut/tut.html

or the widely used wiki site:

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

or the list of Introductory Books:

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

It may be that none of these answer the specific question you have,
but if you start with some of these you'll possibly get a more
efficient and enjoyable start than trying to find details of one
particular example--and you'll then also have a number of resources at
hand with which to try to find your own answers.  

In case you still have questions, you can always ask in this friendly
group; though perhaps more appropriate for "getting started" questions
might be the Python Tutorial list at:

http://mail.python.org/mailman/listinfo/tutor

I use ActivePython a lot, (from ActiveState at
http://aspn.activestate.com/ASPN/Python/Downloads/), and use Help,
Python Manuals, Python Documentation instead of having to store, open,
and maintain the most commonly used dfocumentation separately.  Note
that the Tutorial is listed here, so it's conveniently located and
easy to copy code and paste into the interactive window to test! Or
you can use the usual Help Index facility to find the description of
"raw_input":

===
raw_input( [prompt]) 

If the prompt argument is present, it is written to standard output
without a trailing newline. The function then reads a line from input,
converts it to a string (stripping a trailing newline), and returns
that. When EOF is read, EOFError is raised. Example: 
===

Knowing this, and having checked out some of the tutorials so you know
that [0] is the first element of any "indexable object" (sequence); or
using the Help Index again with "sequence" (since you will probably
have noted from your tutorial exercises  that strings are one type of
sequence) you find that one of the operations on strings is:

s[i] i'th item of s, origin 0 

so the answer to your question:

What does the statement "choice = raw_input(prompt)[0]" mean?

is now obvious.  And the more tutorials you work through, and the more
examples you try, the more such statements will be "obvious" or easy
to figure out!

Happy pythoning!

wwwayne

>On 7/13/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>> what does the statement "choice = raw_input(prompt)[0]" mean? I don't
>> know why there is a '[0]' in the statement.
>>
>> Thank you very much
>>
>> --
>> http://mail.python.org/mailman/listinfo/python-list
>>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Understanding python functions - Instant Python tutorial

2007-07-13 Thread Wayne Brehaut
On Sat, 14 Jul 2007 03:18:43 +0200, Wildemar Wildenburger
<[EMAIL PROTECTED]> wrote:

>Wayne Brehaut wrote:
>>> (had to be a semicolon there)
>>> 
>>
>> Not "had to be" since a discerning reader will note that the two
>> values in the list:
>>
>>  >>> id(x), id(y)
>>  (19105872, 19091664)
>
>Wll, as long as we are nitpicking: That's a tuple, not a list.

Yeah, just wanted to see if you'd catch it!

w

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


Re: Can a low-level programmer learn OOP?

2007-07-14 Thread Wayne Brehaut
On Fri, 13 Jul 2007 20:37:04 -0400, Steve Holden <[EMAIL PROTECTED]>
wrote:

>Aahz wrote:
>> In article <[EMAIL PROTECTED]>,
>> Chris Carlen  <[EMAIL PROTECTED]> wrote:
>>>From what I've read of OOP, I don't get it.  
>> 
>> For that matter, even using OOP a bit with C++ and Perl, I didn't get it
>> until I learned Python.
>> 
>>> The problem for me is that I've programmed extensively in C and .asm on 
>>> PC DOS way back in 1988.  
>> 
>> Newbie.  ;-)
>> 
>> (I started with BASIC in 1976.)
>> 
>Newbie ;-)
>
>(I started with Algol 60 in 1967).

Newbie ;-)

(I started with Royal McBee LGP 30 machine language (hex input) in
1958, and their ACT IV assembler later! Then FORTRAN IV in 1965. By
1967 I too was using (Burroughs) Algol-60, and 10 years later upgraded
to (DEC-10) Simula-67.)

Going---going---

>>> Form 2:  Use Python and PySerial and TkInter or wxWidgets.
>>>
>>> Pro:  Cross-platform goal will likely be achieved fully.  Have a 
>>> programmer nearby with extensive experience who can help.
>>> Con:  Must learn new language and library.  Must possibly learn a 
>>> completely new way of thinking (OOP) not just a new language syntax. 
>>> This might be difficult.
>> 
>> My experience is that learning GUI programming is difficult.  Moreover,
>> GUI programming in C involves a lot of boilerplate that can be automated
>> more easily with Python.  So I think this will be a better solution.
>> 
>I used to write in C for the SunView platform (back in the days when the 
>GUI was integrated into the kernel as the only way to get acceptable 
>speed on the display). From what I remember, "Hello World" took about 40 
>lines.
>
>The immense (relatively speaking: this was 1985) size of the libraries 
>required was one of the primary justifications for implementing shared 
>libraries.
>
>> Note very very carefully that Python does not require an OOP style of
>> programming, but it will almost certainly be the case that you just
>> naturally start using OOP techniques as you learn Python.
>
>That's very true. I still use a lot of (perhaps too much) procedural 
>coding, but driving the object-oriented libraries is a great way for a 
>noob to get started in OOP.
>
>regards
>  Steve
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Can a low-level programmer learn OOP?

2007-07-14 Thread Wayne Brehaut
On Sat, 14 Jul 2007 19:18:05 +0530, "Rustom Mody"
<[EMAIL PROTECTED]> wrote:

>On 7/14/07, Alex Martelli <[EMAIL PROTECTED]> wrote:
>>
>> OOP can be abused (particularly with deep or intricate inheritance
>> structures).  But the base concept is simple and clear: you can bundle
>> state and behavior into a stateful "black box" (of which you may make as
>> many instances, with independent state but equal behavior, as you need).
>>
>
>Many years ago (86??) Wegner wrote a paper in OOPSLA called Dimensions
>of Object Orientation in which he called the 'base concept' of 'bundle
>of state and behavior' as 'object based' programming and
>'object-oriented' as object-based + inheritance.

Not quite--according to him:

object-based + classes => class-based
class-based + class inheritance => object-oriented

I.e., "object-oriented = objects + classes + inheritance".

This was not the, by then, standard definition: to be OO would require
all four of:

1.  modularity (class-based? object-based?)
2.  inheritance (sub-classing)
3.  encapsulation (information hiding)
4.  polymorphism ((sub-) class-specific response to a message, or
processing of a method)

Unfortunately, most of the "definitions" (usually just hand-waving,
loosey-goosey descriptions) found on the web include none--or only one
or two--of these fundamental requirements by name, and are so loose
that almost any proramming paradigm or style would be OO.

>What Alex is saying is (in effect) that object-based is simple and
>clear (and useful) whereas the object-orientation is subject to abuse.

But OO is also simple and clear (if clearly defined and explained and
illustrated and implemented), and ANY programming style is subject to
abuse. During the hey-day of Pascal as an introductory programming
language (as often misused as more than that) I found many  often
spent much of their time defining the data types their program would
use.

>This anyway is my experience: C++ programmers are distinctly poorer
>programmers than C programmers -- for some strange reason closeness to
>the machine has a salutary effect whereas the encouragment of
>uselessly over-engineered programs makes worse programmers.

But this is a tautology: "over-engineered" programs are, by definition
or terminology,  not a good thing--independent of what PL or style
they're finally implemented in (assuming that by "engineering" you
mean "design" or similar).  Many of my Pascal students over-engineered
their solutions to simple problems too?

>GUI is one of those cases wherein inheritance actually helps people
>produce better code but this is something of an exception.

This seems to imply that the list of applications you have in mind or
have worked on includes fewer domains that might profit from full OO
instead of just OB. My guess is that there are many application
domains in which analysts and programmers often think in an "OO way",
but implement  in just an OB way because of the PL they or their
employer requires or prefers: in some--perhaps many--of these cases
they have to do "manually" what OO would have automated.  

There is a problem, though, of (especially university and college)
education and training in OOP  "talking about" how glorious OO is, and
requiring students to use OO techniques whether they're most
appropriate or not (the "classes early" pedagogical mindset).  And
this problem is compounded by teaching introductory programming using
a language like Java that requires one to use an OO style for even
trivial programs. And by using one of the many very similar
introductory texbooks that talk a lot about OO before actually getting
started on programming, so students don't realize how trivial a
program is required to solve a trivial problem, and hence  look for
complexity everywhere--whether it exists or not--and spend a lot of
time supposedly reducing the complexity of an already simple problem
and its method of solution.

But as I noted above, a similar problem occurred with the crop of
students who first learned Pascal: they often spent much of their time
defining the data types their program would use, just as OO
(especially "classes early")  graduates tend to waste time
"over-subclassing" and developing libraries of little-used classes.

The answer is always balance, and having an extensive enough toolkit
that one is not forced or encouraged to apply a programming model that
isn't appropriate and doesn't help in any way (including
maintainability).  And starting with a language that doesn't brainwash
one into believing that the style it enforces or implies is always the
best--and texbooks that teach proper choice of programming style
instead of rigid adherence to one.

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


Re: Can a low-level programmer learn OOP?

2007-07-14 Thread Wayne Brehaut
On Sat, 14 Jul 2007 11:49:48 -0600, darren kirby
<[EMAIL PROTECTED]> wrote:

>quoth the Wayne Brehaut:
>
>> (I started with Royal McBee LGP 30 machine language (hex input) in
>> 1958, and their ACT IV assembler later! Then FORTRAN IV in 1965. By
>> 1967 I too was using (Burroughs) Algol-60, and 10 years later upgraded
>> to (DEC-10) Simula-67.)
>>
>> Going---going---
>
>Mel? Is that you?
>
>http://www.pbm.com/~lindahl/mel.html
>

Ha-ha!  Thanks for that!

Although I'm not Mel, the first program I saw running on the LGP-30
was his Blackjack program! In 1958 I took a Numerical Methods course
at the University of Saskatchewan, and we got to program Newton's
forward difference method for the LGP-30.  Our "computer centre tour"
was to the attic of the Physics building, where their LGP-30 was
networked to a similar one at the Univeristy of Toronto (the first
educational computer network in Canada!), and the operator played a
few hands of Blackjack with the operator there to illustrate how
useful computers could be.

A few years later, as a telecommunications officer in the RCAF, I
helped design (but never got to teach :-( ) a course in LGP-30
architecture and  programming using both ML and ACT IV AL, complete
with paper tape input and Charactron Tube
(http://en.wikipedia.org/wiki/Charactron)  output--handy, since this
display was also used in the SAGE system.

We weren't encouraged to use card games as examples, so used
navigational and tracking problems involving fairly simple
trigonometry.

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


Re: Can a low-level programmer learn OOP?

2007-07-15 Thread Wayne Brehaut
On Sun, 15 Jul 2007 07:47:20 -, [EMAIL PROTECTED] wrote:

>On Jul 13, 3:20 pm, Wayne Brehaut <[EMAIL PROTECTED]> wrote:
>> On Sat, 14 Jul 2007 06:01:56 +0200, Bruno Desthuilliers
>>
>> <[EMAIL PROTECTED]> wrote:
>> >Chris Carlen a écrit :
>> >> Hi:
>>
>> >>  From what I've read of OOP, I don't get it.  I have also found some
>> >> articles profoundly critical of OOP.  I tend to relate to these articles.
>>
>> === 8< ===

=== 8< ===

>> Under a claim of Academic Impunity (or was that "Immunity"), here's
>> another historical tid-bit.  In a previous empolyment we once had a
>> faculty applicant from CalTech who knew we were using Simula as our
>> introductory and core language in our CS program, so he visited Xerox
>> PARC before coming for his inteview.  His estimate ofAlan Kayand
>> Smalltalk at that time (early 80s) was that "They wanted to implement
>> Simula but didn't understand it--so they invented Smalltalk and now
>> don't understand _it_!"
>>
>> wwwayne
>>
>> === 8< ===
>
>A couple of notes on this post.
>
>Alan Kay has always publicly credited Simula as the direct inspiration
>for Smalltalk, and if you know the man and his work, this implication
>of taking credit for the first OOP language is not true, it is a
>credit assigned to him by others, and one which he usually rights when
>confronted with it.

I know this, and was perhaps a little too flippant in my all-inclusive
statement "self-serving propaganda from Xerox PARC,Alan Kay, and
Smalltalk adherents everywhere!", for which I apologize. But it was
made with humorous intent, as I had hoped the opening "Oh you
young'uns, not versed in The Ancient Lore, but filled with
self-serving propaganda..." would imply.

A more accurate and unhumorous statement of my opinion is that it is
Smalltalk adherents who know virtually nothing of the history of
OOP--and even some who do--who  did and still do make such claims,
both personally and in the published literature of OOP. 

And my statement about a prospective faculty member's opinion was just
that: a historical anecdote, and the expression of an early 80s
opinion by a professional CS professor and researcher in formal
semantics  (which may have been part of his distrust of the Smalltalk
team's "understanding" of Smalltalk) .  The opinion he expressed was
his and not my own, and  I was just recording (what I thought might
be) an amusing anecdote in a context in which I thought it
appropriate: discussion of what OOP is, and after Bruno made the
claim: "OO is about machines - at least as conceveid by Alan Key, who
invented the term and most of the concept."   I don't think my
recording it here should be construed as my opinion of either
Smalltalk or its creators (at that time or now). 

As often happens in many arenas, the creator of an idea can lose
control to the flock, and many publications can get accepted if
referrees themselves don't know the facts or take care to check them
before recommending publication--which probably explains why so many
publications (especially in conference proceedings) on OOP  in the 80s
and 90s completely omitted any mention of Simula: so much so that I
once intended writing a paper on "Ignorance of Simula Considered
Harmful." 

On the other hand, anytyhing you may have inferred about my distaste
for those who doesn't bother to learn anything of the history of a
subject, then make  false or misleading claims, and don't bother to
correct themselves when questioned, is true. 

>You may be confused with the fact that "object oriented
>programming"was a term which I believe was first used by Alan and his
>group at PARC, so perhaps the coining of the term is what is being
>referenced by others.

No, I have been at more than one CS (or related area) conference where
a Smalltalk aficionado has stated unequivocally that Kay invented OOP
and that Smalltalk was the first OOPL. The last I recall for sure was
WebNet 2000, where a (quite young) presenter on Squeak made that
statement, and was not at all certain what Simula was when I asked
whether it might actually have been the first more  than 10 years
before Smalltalk 80.   So his claim, and that of many others,
explicitly or implicitly, is that not only the term, but most (or all)
of the concept, and (often) the first implementation of OOP was by Kay
and his Xerox PARC team in Smalltalk 80.

>Perhaps I'm mistaken, but the tone of your post conveys an animosity
>that did not exist between the original Smalltalk and Simula
>inventors; Nygard and Kay were good friends, and admired each others'
>work very much.

Yes, you are very much mistaken (as I note above), and appear not to
have understood the intended humorous  tone of my posting.  

wwwayne

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


Re: 2**2**2**2**2 wrong? Bug?

2007-07-15 Thread Wayne Brehaut
On Fri, 13 Jul 2007 14:27:13 -0700, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:

>On Jul 13, 1:20 pm, Wayne Brehaut <[EMAIL PROTECTED]> wrote:
>> On Mon, 09 Jul 2007 23:51:25 -0700, "[EMAIL PROTECTED]"
>>
>>
>>
>>
>>
>> <[EMAIL PROTECTED]> wrote:
>> >On Jul 9, 11:42?pm, Paul McGuire <[EMAIL PROTECTED]> wrote:
>> >> On Jul 9, 11:21 pm, "Jim Langston" <[EMAIL PROTECTED]> wrote:> In Python 
>> >> 2.5 on intel, the statement
>> >> > 2**2**2**2**2
>> >> > evaluates to>>> 2**2**2**2**2

=== 8< ===

>> >Did you count the 'L'?
>>
>> numdigits(n)?

=== 8< ===

>> What?  'L' is a digit in Python?  
>
>No, but it's a character. Don't you know the difference
>between str() and repr()?

Don't you know the difference between humorous (even if slightly silly
at times) banter and serious discussion? Did you bother to read the
context before responding? Do you know what you're attributing to
whom, and whether they're actually the ones who said it--and, if so,
do you understand what they meant by it?

=== 8< ===

>> I'm going back to Fortran!
>
>Sounds like you never left.

Now that's a low blow--but I'll consider the source and overlook it.

w

>>
>> wwwayne
>>
>> >>so this seems to be at least in
>> >> the ball park.
>>
>> >> -- Paul
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 2**2**2**2**2 wrong? Bug?

2007-07-15 Thread Wayne Brehaut
On Fri, 13 Jul 2007 14:32:03 -0700, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:

>On Jul 13, 2:52 pm, Wayne Brehaut <[EMAIL PROTECTED]> wrote:
>> On Fri, 13 Jul 2007 11:30:16 -0700, Paul McGuire <[EMAIL PROTECTED]>
>> wrote:
>>
>>
>>
>>
>>
>> >On Jul 13, 1:20 pm, Wayne Brehaut <[EMAIL PROTECTED]> wrote:
>> >> On Mon, 09 Jul 2007 23:51:25 -0700, "[EMAIL PROTECTED]"
>>
>> >> <[EMAIL PROTECTED]> wrote:
>> >> >On Jul 9, 11:42?pm, Paul McGuire <[EMAIL PROTECTED]> wrote:
>> >> >> On Jul 9, 11:21 pm, "Jim Langston" <[EMAIL PROTECTED]> wrote:> In 
>> >> >> Python 2.5 on intel, the statement
>> >> >> > 2**2**2**2**2
>> >> >> > evaluates to>>> 2**2**2**2**2

=== 8< ===

>> >> >Did you count the 'L'?
>>
>> >> numdigits(n)?
>>
>> >> What?  'L' is a digit in Python?  I'm going back to Fortran!
>>
>> >> wwwayne

=== 8< ===

>> >'L' counts for 50, but only when you use Roman font.
>>
>> WTL?!  Not Times  New Roman I hope?
>>
>> Now I'll have to extend my remarks below to include:
>>
>> L**L**L
>> D**D**D
>> M**M**M
>> etc. (since I don't recall what comes next)
>>
>> though these (L, D, M, ...)  would seem to be numbers rather than
>> digits: the Romans used a base-1 system
>
>No, "base" refers to a Positional Number system for which
>radix 1 is undefined.
>
>You can call Roman Numerals a Tally System of Radix 1.

I can call it what I want--within reason--so long as those I'm mainly
addressing understand what I mean and the context in which I'm saying
it.  As I note in my other response to your response below, my remark
was intended to be humorous, and everyone else who responded took it
that way.

There's no need to get all formal in such a context, and there's no
harm in defining a  tally system to be 1-based or to be a base-1
system. If I had intended this to be a formal discussion instead of
just having a little fun (and sorry for doing that) I would have
instead said: "Define a base-1 number system as...".

Since you clearly don;t want to accept my terminology and assume
there's just one right one, please see
http://www.psinvention.com/zoetic/basenumb.htm for an independent
opinion of the reasonableness of using this term: "Base Valued Numbers

Any use of numbers implies the use of a base value for the numbers.
The simplest base value to use in a numbering scheme is '1'."

Because we're most familiar with the use of the term "base" in the
context of positional notation in no way implies that's the only
possible context in which it can be used--or has been used--with
perfectly clear meaning.  So the Roman system was based on the number
1 and was, therefore, 1-based or base-1.

Even in the context of positional systems it's perfectly clear what a
base-1 system would be and the fact that it's generally excluded isn;t
because it's not cleaar what it weould be, but only that most assume
it isn't of any uise, so exclude it.  As we all know:

1^0 = 1
1^1 = 1
1^n = 1 for any positive natural number
 [and negative natural numbers don't exist, but extension to negative
integers is left as an exercise for the reader]

In the base 1 positional number system, what is the value of:

1
11
111
1...1 (with n 1s)?

And would the value be any different if I wrote them:

  1
11
  111
1...1 (with n 1s)?

In pictures:

Pos?   ?
Value  1  
Digit1  

Pos?   ?  ? 
Value  1  1
Digit1  1

Pos?   ?  ?   ?
Value  1  1  1
Digit1  1  1

Pos?   ?  ...   ?
Value  1  ...  1 (n positions)
Digit1  ...  1 (n 1s)

>Tally sytems ARE defined for radix 1, but operate
>completely different from positional systems.

Clearly, the algorithm to find the value of a base-1 number  is to
multiply the value of each position (1) by the digit in that position
(1) and add the results--just as you would do for any other positional
system. 

One common assumption for excluding base-1 is that this can't be a
proper positional number system because there's no zero digit, so how
can we represent the 0 value of a position? The obvious answer is that
there is no way of knowing what power of 1 each position represents
anyway, since the value of each and every  position is 1, so we just
leave out positions whose value is zero; equivalently, we just admit
that the base-1 tally system is equivalent to the base-1 positional
system so far as counting is concerned, since we don't count things
that aren't there.

I claim 

Re: 2**2**2**2**2 wrong? Bug?

2007-07-15 Thread Wayne Brehaut
On Sun, 15 Jul 2007 17:37:13 -0400, Steve Holden <[EMAIL PROTECTED]>
wrote:

>Wayne Brehaut wrote:
>> On Fri, 13 Jul 2007 14:32:03 -0700, "[EMAIL PROTECTED]"
>[...]
>> But I digress (but only because provoked!)...
>> 
>>>> [for purposes of this argument, at least]
>> 
>> This statement is the informal equivalent to  saying  "Define a base-1
>> number system as...", as I noted above. If you'd noted this, and
>> understood it, or were willing to accept it whether or not you
>> understood it, you'd have saved us both some bother--but me more than
>> you I guess, so maybe you were just trolling?
>> 
>wwway to beat a response to a pulp. Sometimes it's easier and better for 
>your blood pressure just to let someone else have the last word, however 
>ill-informed or hostile.

Best answer: Not hit Reply or Send. [Too late!]

Short answer: Yes, I agree--and thank you for this sage advice!

My answer: Guilty with an explanation.  I tend to use a "stream of
consciousness approach" when I have time, so my responses tend to grow
until I run out of time or energy, or I'm called to dinner  (so  not
without bounds). 

Also, I tend to follow the general Evolutionarily Stable Strategy
generally called "Retaliator".  In the simple game of Hawk vs. Dove a
Hawk always attacks and defends to the death, whereas a Dove always
runs. A mixed strategy would be to sometimes attack-and-defend and
sometimes run, and a special case is to always run except when you're
attacked--then defend to the death; i.e., behave like a Dove to a Dove
and like a Hawk to a Hawk. 

In Game Theory, if not in practice, Retaliator is dominant over both
pure Hawk and pure Dove, partly because some who present like Hawks
are actually Bullies--who behave like Hawks until an opponent defends,
then behave  like Doves.

Of course this  should be a cooperative group to help one another
learn more about Python and solve problems--perhaps with an occasional
sidebar of humour for relaxation-- rather than attacking and
defending; but when someone attacks my attempt at humour,  or makes a
demonstrably incorrect statement attacking  my peaceable,
well-reasoned one, I get really POd and my Hawk-like tendencies
emerge.  

And my blood pressure is fine, though I am monitoring it...  Moreover,
I find it's sometimes  harder on my blood pressure to lie awake at
night thinking of all the things I would  have liked  to say and
didn't.

But thank you for this sage advice!

w



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


Re: Can a low-level programmer learn OOP?

2007-07-16 Thread Wayne Brehaut
On Mon, 16 Jul 2007 10:10:05 +0200, Bruno Desthuilliers
<[EMAIL PROTECTED]> wrote:

>Wayne Brehaut a écrit :
>(snip)
> > after Bruno made the
>> claim: "OO is about machines - at least as conceveid by Alan Key, who
>> invented the term and most of the concept."
>
>Please reread more carefully the above. I do give credit to Smalltalk's 
>author for the *term* "OOP", and *most* (not *all*) of the concepts (I 
>strongly disagree with your opinion that message-passing is not a core 
>concept of OO).

One problem is that it's often not clear what lists of properties are
his definition of OOP vs. what are the intended properties of
Smalltalk--his intended impelmentation of OOP. Many of the lists begin
with the basic requirements that "everything is an object" and
"objects communicate by message passing", but the most common
"generally agreed upon" definition abstracts just four requirements
from these (changing)  lists--attempting to  separate implementation
details from what is essential to the underlying framework. As I note
below, these were:

1.  modularity (class-based? object-based?)
2.  inheritance (sub-classing)
3.  encapsulation (information hiding)
4.  polymorphism ((sub-) class-specific response to a message, or
processing of a method)

Other details in Kay's lists are considered  implementation details,
and important advances or alternatives to pevious methods, but not
required for a language to _be_ OO. It is reputed, though, that in
2003 Kay said
(http://c2.com/cgi/wiki?AlanKaysDefinitionOfObjectOriented)  "OOP to
me means only messaging, local retention and protection and hiding of
state-process, and extreme LateBinding of all things."

So I understand your accepting one of Kay's lists as being a
definition of OOP instead of "just" a description of Smalltalk, or of
accepting this fairly recent "definition" as being the true one (as
opposed to the previous lists of usually 6 properties). "It's hard to
hit a moving target!"

>FWIW, I first mentionned Simula too (about the state-machine and 
>simulation aspect), then sniped this mention because I thought it was 
>getting a bit too much OT - we're not on comp.object here.

Understood--sort of--but there is sufficient accurate information
about Simula available on the web now that it's no longer necessary to
use quotes from Kay about OOP and Smalltalk just  because they're more
accessible, as used to be the case. What would be so OT about
referring to Simulain one sentence instead of or in addition to
Smalltalk?

But I digress--my only real objection to your post was your opinion
and claim that Kay "invented the term and most of the concept": I've
never seen anyone claim that anyone else invented the term, but for
the claim that he invented "most of the concept" we need only refer to
Nygaard's claim in "How Object-Oriented Programming Started" at
http://heim.ifi.uio.no/~kristen/FORSKNINGSDOK_MAPPE/F_OO_start.html
that "Simula 67 introduced most of the key concepts of object-oriented
programming: both objects and classes, subclasses (usually referred to
as inheritance) and virtual procedures, combined with safe referencing
and mechanisms for bringing into a program collections of program
structures described under a common class heading (prefixed blocks)."

Combine this with the fact--as stated above by Bonnie MacBird (Alan
Kay's significant other)--that "Alan Kay has always publicly credited
Simula as the direct inspiration for Smalltalk, and... this
implication of taking credit for the first OOP language is not true,
it is a credit assigned to him by others, and one which he usually
rights when confronted with it." If he acknowledges this perhaps
others should too?

As has been noted before, it's often the fact that a cause becomes a
religion: true believers tend to take it over from the originator, and
this religiosity tends to blind them from the facts. Opinions and
rumours become facts, stories are invented, definitions are changed or
twisted, and another religion is born! Even those who don't belong to
the religion cpme to believe the oft-repreated stories, and then help
spread and perpetuate them. (Continuing in my original humorous vein I
was tempted to use terms like "religious zealots", "false gospel",
"propaganda",  etc., but thought better of it in case I was again
misunderstood.)

Again, I disagree only with this one claim. You make significant
contributions to the group and to ellucidating Python and OOP to the
great unwashed: in contrast, all I've done so far is complain about
those who don't accept the correct (i.e., my) definition or use of
terms.

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


Re: Can a low-level programmer learn OOP?

2007-07-16 Thread Wayne Brehaut
On Mon, 16 Jul 2007 09:55:35 +0200, Bruno Desthuilliers
<[EMAIL PROTECTED]> wrote:

>Wayne Brehaut a écrit :
>> On Sat, 14 Jul 2007 06:01:56 +0200, Bruno Desthuilliers
>> <[EMAIL PROTECTED]> wrote:
>> 
>>> Chris Carlen a écrit :
>>>> Hi:
>>>>
>>>>  From what I've read of OOP, I don't get it.  I have also found some 
>>>> articles profoundly critical of OOP.  I tend to relate to these articles.
>>>>
>> 
>> === 8< ===
>> 
>>>> Hence, being a hardware designer rather than a computer scientist, I am 
>>>> conditioned to think like a machine.  I think this is the main reason 
>>>> why OOP has always repelled me.
>>> OTOH, OO is about machines - at least as conceveid by Alan Key, who 
>>> invented the term and most of the concept. According to him, each object 
>>> is a (simulation of) a small machine.
>> 
>> Oh you young'uns, not versed in The Ancient Lore, but filled with
>> self-serving propaganda from Xerox PARC, Alan Kay, and Smalltalk
>> adherents everywhere!
>
>Not feeling concerned.
>
>(snip pro-simula/anti-Xerox propaganda).

Or, more accurately, pro:

1. Nygaard & Dahl as the inventors of most of the concept of OOP
2. Simula as the first OOP
3. Kay as the originator of the term OOP
4. Kay, Xerox PARC, and Smalltalk as making significant useful
advances in implementation of OOP and "popularizing" it 

and anti:

1. attributing credit for any accomplishment to someone who doesn't
himself claim it and even denies it

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


Re: 2**2**2**2**2 wrong? Bug?

2007-07-16 Thread Wayne Brehaut
On Mon, 16 Jul 2007 08:51:31 +0200, "Hendrik van Rooyen"
<[EMAIL PROTECTED]> wrote:

> "Wayne Brehaut" <[EMAIL PROTECTED]> wrote:
>
>> On Sun, 15 Jul 2007 17:37:13 -0400, Steve Holden <[EMAIL PROTECTED]>
>> wrote:
>> 
>> >Wayne Brehaut wrote:
>> >> On Fri, 13 Jul 2007 14:32:03 -0700, "[EMAIL PROTECTED]"
>
>8< -
>
>> Also, I tend to follow the general Evolutionarily Stable Strategy
>> generally called "Retaliator".  In the simple game of Hawk vs. Dove a
>> Hawk always attacks and defends to the death, whereas a Dove always
>> runs. A mixed strategy would be to sometimes attack-and-defend and
>> sometimes run, and a special case is to always run except when you're
>> attacked--then defend to the death; i.e., behave like a Dove to a Dove
>> and like a Hawk to a Hawk. 
>> 
>> In Game Theory, if not in practice, Retaliator is dominant over both
>> pure Hawk and pure Dove, partly because some who present like Hawks
>> are actually Bullies--who behave like Hawks until an opponent defends,
>> then behave  like Doves.
>
>*grin* - you realise of course, that this stated strategy leaves you wide
>open to trolls of the "Lets see what we can provoke him into responding"
>kind - from people whose sense of humour is either subtle, or evil...
>
>- Hendrik

Subtle is good  and generally easy enough to spot ("Never kid a
kidder!").  As for evil, no problem--I'm also a bit of an Equivocator
(perhaps even  Prevaricator), and probably won't bother to respond to
anyone who seems to be a waste of time or is beyond redemption.

I seldom use a kill filter though since I'm too curious about what
they're going to say next, but can just read and suffer silently when
I choose to!

And thanks for the sage advice!

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


Re: How to optimise this code?

2007-08-21 Thread Wayne Brehaut
On Tue, 21 Aug 2007 21:56:18 +0200, Hrvoje Niksic <[EMAIL PROTECTED]>
wrote:

>Christof Winter <[EMAIL PROTECTED]> writes:
>
>> To get rid of the if statements, replace __init__ function with:
>>
>>  def __init__(self, tc):
>>  functionToCall = eval("self.testCase%s" % tc)
>
>Or functionToCall = getattr(self, "testCase" + tc)
>
>eval can introduce unwanted side effects.

Hence the slogan "Do No Eval!"

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


RE: Python 2.1 and Daylight saving time

2007-03-07 Thread Hammett, Wayne
Thanks for the quick reply.

Help me OB1,

I mainly needed to know if I could avert Daylight Saving Time issues by
upgrading to Python 2.5.

It appears that Python gets it UTC settings from a table in the C
library. Does this still hold true for Python 2.5. It looks that it will
fail to recognize the new DST 2007 changes.


Thanks again,

Wayne Hammett - MCSE
Snr. Network Engineer
1214 Church Street
Nashville,  TN  37246
(615) 747-3092
[EMAIL PROTECTED]
 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, March 07, 2007 1:41 PM
To: Hammett, Wayne
Cc: [EMAIL PROTECTED]
Subject: Re: Python 2.1 and Daylight saving time


Wayne> It appears that Python 2.1 is affected by the DST 2007 issue.
I
    Wayne> cannot really tell.

    Wayne> Can you point me to support documentation?

Wayne,

Python 2.1 is quite old and no longer supported.  The last 2.1 release
(2.1.3) was April 8, 2002.  The current release is Python 2.5.  That
said,
can you describe your problem clearly?  Do you have a simple script that
demonstrates the problem?  If so, it's possible that you can get some
help
from the folks on the python-list@python.org mailing list.  At the very
least people should be able to tell you if the problem you see exists in
later versions or if there's a bug in your script you can fix to avoid
the
problem.

-- 
Skip Montanaro - [EMAIL PROTECTED] - http://www.webfast.com/~skip/
"The hippies and the hipsters did some great stuff in the sixties,
but the geeks pulled their weight too." -- Billy Bragg


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


Re: readline() - problem

2007-10-02 Thread Wayne Brehaut
On Tue, 02 Oct 2007 12:13:21 -, [EMAIL PROTECTED] wrote:

>On 2 Pa , 13:39, Ben Finney <[EMAIL PROTECTED]>
>wrote:
>> [EMAIL PROTECTED] writes:
>> > import string
>>
>> Why import 'string' if you're not using it?
>>
>> > f=open('/test/test.asc','r')
>> > o=open('/test/out.asc','w')
>> > for line in f:
>> > s= f.readline()
>>
>> Your line object is already bound to the 'line' name in each
>> iteration. You need to use that, not attempt to read yet another line
>> each time.
>>
>
>Of course, it helped. Many thanks for all.

But be sure you note Wesley's point in teh following post:

If you want the 15th character your subscript must be 14, since
there's a 0th element?

wwwayne

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


Re: Python Magazine: Issue 1 Free!

2007-10-05 Thread Wayne Brehaut
On Thu, 04 Oct 2007 04:12:04 +0200, Bruno Desthuilliers
<[EMAIL PROTECTED]> wrote:

>J. Clifford Dyer a écrit :
>> On Fri, Oct 05, 2007 at 04:11:07PM -, Grant Edwards wrote
>> regarding Re: Python Magazine: Issue 1 Free!:
>> 
>>> On 2007-10-05, Steve Holden <[EMAIL PROTECTED]> wrote:
>>> 
>> I've just been told by the editors at Python Magazine that
>> the first issue is out.
> 
> The first issue is issue number 10?
> 
> That's a bit silly.
 
 It's the October edition. They obviously decided to make sure the
 month numbering was consistent across the volumes.
>>> 
>>> I presumed that was the reasoning. It just seems counter-intuitive
>>> (and sort of un-Pythonic) to start numbering a sequence of objects
>>> at 10. ;)
>>> 
>> 
>> 
>> Well, it's also unpythonic to start numbering a sequence at 1, but
>> it's clearly the right thing to do in this case.
>
>As far as I'm concerned, if I had to number a magazine about 
>programming, I'd obviously start with 0.

And since the "first" issue is free that would be best here too.

>Then it would be n°1, n°10, 
>n°11, n°100 etc !-)

But probably with enough leading zeros to last the expected lifetime
(8 bits should about do it?)  so they'd sort properly:

 
 0001
etc.

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


Re: Python Magazine: Issue 1 Free!

2007-10-05 Thread Wayne Brehaut
On Thu, 04 Oct 2007 04:52:13 +0200, Bruno Desthuilliers
<[EMAIL PROTECTED]> wrote:

>Wayne Brehaut a écrit :
>> On Thu, 04 Oct 2007 04:12:04 +0200, Bruno Desthuilliers
>> <[EMAIL PROTECTED]> wrote:
>> 
>> 
>>>J. Clifford Dyer a écrit :
>(snip)
>>>>Well, it's also unpythonic to start numbering a sequence at 1, but
>>>>it's clearly the right thing to do in this case.
>>>
>>>As far as I'm concerned, if I had to number a magazine about 
>>>programming, I'd obviously start with 0.
>> 
>> And since the "first" issue is free that would be best here too.
>> 
>>>Then it would be n°1, n°10, 
>>>n°11, n°100 etc !-)
>> 
>> But probably with enough leading zeros to last the expected lifetime
>> (8 bits should about do it?)  so they'd sort properly:
>> 
>>  
>>  0001
>> etc.
>
>Mmm... sort of reminds me of y2k.

Funny, I was thinking IPv4.

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


Is this a bug of the lambda function

2007-10-11 Thread Zhu Wayne
Hi,
I have a short code which gives me strange results, the code is as follows:

f = [lambda x: None]*5
for j in range(0, 5):
 f[j] = lambda x: float(j)*x
print "print f[k](1.),"
for k in range(5):
 print f[k](1.),
print "expect 0. 1. 2. 3. 4."
print
print "print f[j](1.),"
for j in range(5):
 print f[j](1.),
print "expect 0. 1. 2. 3. 4."
print
print "print f[0](1.), f[1](1.), ..."
print f[0](1.), f[1](1.), f[2](1.), f[3](1.), f[4](1.)
print "expect 0. 1. 2. 3. 4."

*
The result is very strange:

print f[k](1.),
4.0 4.0 4.0 4.0 4.0 expect 0. 1. 2. 3. 4.

print f[j](1.),
0.0 1.0 2.0 3.0 4.0 expect 0. 1. 2. 3. 4.

print f[0](1.), f[1](1.), ...
4.0 4.0 4.0 4.0 4.0
expect 0. 1. 2. 3. 4.


It seems only when I use the index j (which is declear with the lambda
function), I can get expected answer, otherwise the result is not
unexpected.

Could anybody give me a possible explanation to this? Does python use kind
of pre-complie techinque to treat the lambda function? (like the macro in C
or inline function in C++)

Thanks in advance

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

Re: linear programming in Python

2007-10-17 Thread Wayne Brehaut
Hi Jorge,

On Wed, 17 Oct 2007 08:44:28 -0700, [EMAIL PROTECTED] wrote:

>Hi all,
>
>I'm new to this group so I don't know if this question has been posted
>before, but does anyone knows about linear/integer programming
>routines in Python that are available on the web, more specifically of
>the branch and bound method.

Try using your favourite search engine with a search string like
"linear programming Python branch bound".  Using Alta Vista
(http://www.altavista.com/web/adv) I got:

AltaVista found 16,500 results  

and Google gave:

Results 1 - 10 of about 7,990 

Some on the first page of each look like good possibilities, and I'm
sure there are others in the group that have first-hand experience and
can offer comparisons and advice. You might also try searching the
archives of this group--I searched just what my server has still
available and got no hits on "linear programming", but didn't try just
"LP" or similar.

Good luck!
Wayne

>Thanks,
>
>Jorge Velasquez
>PhD Student, Department of Ecology and Evolution at Stony Brook

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


Re: Learning Python book, new edition?

2007-01-12 Thread Steven Wayne
On Thu, 11 Jan 2007 16:42:34 -0600, Demel, Jeff
<[EMAIL PROTECTED]> wrote:
> John wrote:
>>So what happens with google bots etc... Information provided 
>>in the email could be helpful to others that are NOT the original 
>> recipient.  And what happens to the archive stuff?
>
> I will forward your response to our crack legal department.  Perhaps
> they can help you with your very astute questions.
>
> -Jeff
> This email is intended only for the individual or entity to which it is
> addressed.

Hi,

Don't take this the wrong way, but this isn't an email, it's a usenet
posting.

I'm also not the "individual or entity to which it is addressed" because
I read it from a news server and it was addressed to "comp.lang.python".

>This email may contain information that is privileged,
> confidential or otherwise protected from disclosure.

Then you would do well to not publish it in a public forum.

>Dissemination,
> distribution or copying of this e-mail or any attachments by anyone
> other than the intended recipient, or an employee or agent responsible
> for delivering the message to the intended recipient, is prohibited.

So if this /were/ actually an email you've just given permission for an
admin of any mail server the email passes through to disseminate or copy
it.

For those not aware:

Disseminate:

Verb:  disseminate - cause to become widely known; "spread information";
"circulate a rumor"; "broadcast the news"

>  If
> you are not the intended recipient of this message or the employee or
> agent responsible for delivery of this email to the intended recipient,
> please notify the sender by replying to this message and then delete it
> from your system. Any use, dissemination, distribution, or reproduction
> of this message by unintended recipients is strictly prohibited and may
> be unlawful.

Unlawful how? You've already given permission for an "agent responsible
for delivering the message" to broadcast it around the world.

Sorry for the rant, but I'm an email admin and I've just been told about
the change to UK law.

I'm giving our legal department even more grief.

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


Re: Learning Python book, new edition?

2007-01-12 Thread Steven Wayne
On 12 Jan 2007 11:06:29 GMT, Duncan Booth
<[EMAIL PROTECTED]> wrote:
> Steven Wayne <[EMAIL PROTECTED]> wrote:
>
>> Don't take this the wrong way, but this isn't an email, it's a usenet
>> posting.
>
> It is now, but it started as an email. If you examine its headers he sent 
> it to the list but the list administrator had set up software up to copy 
> the email to a newsgroup.

There's a list?

>   Fortunately, as you said, the email gave him 
> permission to do that otherwise the entire legal profession might have 
> collapsed under its own weight.

:-)

Not seeing a down side to that.

But it brings up and interesting point.

Is automatic email to newsgroup software now defunct?

What if the disclaimer were better written and it forbade such an action?


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


Re: Learning Python book, new edition?

2007-01-12 Thread Steven Wayne
On Fri, 12 Jan 2007 22:44:33 +1100, Steven D'Aprano
<[EMAIL PROTECTED]> wrote:
> On Fri, 12 Jan 2007 04:50:21 -0600, Steven Wayne wrote:
>
> [snip stupid disclaimer and response to it]
>
>> Unlawful how? You've already given permission for an "agent responsible
>> for delivering the message" to broadcast it around the world.
>> 
>> Sorry for the rant, but I'm an email admin and I've just been told about
>> the change to UK law.
>
> What change to UK law?

http://www.theregister.co.uk/2006/12/21/new_web_email_regulation/


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


Re: LaTeX tutorial updated [OT]

2007-11-07 Thread Wayne Brehaut
On Wed, 07 Nov 2007 09:00:12 -0800, John DeRosa <[EMAIL PROTECTED]>
wrote:

>On Wed, 07 Nov 2007 16:23:56 +0900, Byung-Hee HWANG <[EMAIL PROTECTED]>
>wrote:
>
>>On Wed, 2007-11-07 at 00:10 +, [EMAIL PROTECTED] wrote:
>>> On Nov 6, 12:30 pm, Nicola Talbot <[EMAIL PROTECTED]> wrote:
>>> > Hi,
>>> >
>>> > I've updated my "Using LaTeX to write a PhD thesis" tutorial. Both PDF
>
>My understanding is that the correct nomenclature is, "Master's
>thesis," and, "PhD dissertation."

This may be more common usage in some regions, but "thesis" is more
general and quite correct in either case, as the following indicate.

===

Thinkmap Visual Thesaurus (http://www.visualthesaurus.com/):

exposition
a systematic interpretation or explanation (usually written) of a
given topic; an account that sets forth the meaning or intent of a
writing or discourse

treatise
a formal exposition

thesis
dissertation 
a treatise advancing a new point of view resulting from research;
usually a requirement for an advanced academic degree

===
Oxford Refernce Online--requires subscription
(http://0-www.oxfordreference.com.aupac.lib.athabascau.ca/views/GLOBAL.html):

The Concise Oxford Dictionary of Literary Terms:
thesis 
an argument  or proposition, which may be opposed by an antithesis ;
or a scholarly essay defending some proposition, usually a
dissertation submitted for an academic degree.

---

Pocket Fowler's Modern English Usage
thesis 
meaning ‘a dissertation’, has the plural form theses , pronounced thee
-seez .

---

The Concise Oxford Dictionary of English Etymology:
thesis 
proposition, theme XVI ; (theme of) a dissertation XVII .
===

Merriam-Webster Online (http://www.m-w.com/):

thesis 
4: a dissertation embodying results of original research and
especially substantiating a specific view; especially : one written by
a candidate for an academic degree

dissertation 
an extended usually written treatment of a subject; specifically : one
submitted for a doctorate

===

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


Re: Questions on Using Python to Teach Data Structures and Algorithms

2007-11-07 Thread Wayne Brehaut
On Thu, 28 Sep 2006 17:23:25 +0200, "Ramon Diaz-Uriarte"
<[EMAIL PROTECTED]> wrote:

>Going back to the original question, a related question: does anybody
>know why there are so few books on data structures and algorithms that
>use Python?
>
>I remember that, at least ~ 12 years ago there were many (and very
>good) books that used Pascal for this topic. So when I did my own
>search for one in Python (just for my own consumption and
>enlightnment) and could only find the same one as the original poster
>of this thread [1], I was very surprised. No publishers have felt the
>need to fill this gap?

No, and you'll know why if you check for the number of university and
college computer science students  learning Python in their
introductory programming course (not the number of  institutions  that
teach a little bit in a physics course), and the number of textbooks
available to support that (and not free online or print tutorials).
There's just not a big enough market for (traditional) publishers to
be interested in publishing them or (traditional) authors in writing
them. 

Preiss (http://www.brpreiss.com/page1.html) translated his original
C++  text (1999)  into a number of other languages: Java (2000), C#
(2001),  Python (2003), and Ruby (2004). So he could easily afford to
Translate the early money-makers into less used languages because the
initial writing overhead was no longer an issue--and much of the
tyranslation was "automated". And he uses his free online versions to
help market the publishe'rs small (relative to C++ and Java) print
runs, so they can afford to service this very small market.

DSA--formerly (i.e., in the "Good Old Days") just Data Structures-- is
or was,  in the "usual" CS curriculum (a la ACM+IEEE)  at least, a
second-level course based on CS1; hence, "most efficiently" taught
using the students' introductory language (if it's at all suitable,
and texts are available) so only some finer points of the language
needed covering and one can concentrate on implementation of the data
structures themselves. 

So very  little CS1 in Python translates into very little--and
probably even less--CS2, etc., in Python.

wwwayne

>Best,
>
>R.
>
>[1] http://thread.gmane.org/gmane.comp.python.general/486698/focus=486698
> "Data Structures and Algorithms with Object Oriented Design Patterns"
>(http://www.brpreiss.com/books/opus7/html/book.html) and was surprised.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Questions on Using Python to Teach Data Structures and Algorithms

2007-11-07 Thread Wayne Brehaut
On Thu, 28 Sep 2006 17:32:06 +0200, Fredrik Lundh
<[EMAIL PROTECTED]> wrote:

>Ramon Diaz-Uriarte wrote:
>
>> Going back to the original question, a related question: does anybody
>> know why there are so few books on data structures and algorithms that
>> use Python?
>
>Probably because Python has "better than textbook" implementations of 
>core structures, and "better than textbook" implementations of many core 
>algorithms, so lots of things can be done more efficiently by combining 
>existing structures and algorithms than by using "textbook" algorithms.

But this answers a diiferent question: university and (academic)
college data structure courses don't care how efficient a particular
language's built-in data structures are, since the intent is for the
students to learn how to implement data structures in general, and
probably in a particular language--the "core" languasge used in their
core programs--and then be able to apply that knowledge and skill to
implementing at least "reasonably efficient" ones when they need to in
languages that don't have any to speak of built in.

And, since many students will go direct to business or industry, and
may even be apprenticing there in "co-op work terms" during their
education, most could care less how efficient Python's built-in data
structures are.

Also,  it's a very rare DSA text that intends its DS code to be used
directly--especially  in "serious" applications. Preiss's texts, noted
by the OP, are one exception, and many could be used "out of the box"
in industrial strength applications.

So far as "combining existing structures" is concerned, it's highly
unlikely that any such combination of linear structures could be more
efficient in both--if either--storage and running time than one
specifically designed and implemented for non-linear structures, such
as (many) trees and algorithms on them. For general graphs efficient
list processing may be sufficient for an adjacncy structure for the
graph itself, of course, but how does that translate to storing a
subtree found using a DFS, for example, and efficiently processing it
in some way?

For learning DSA it's more important to have a clear, well-written and
well-documented implementation in a language of interest (again,
especially, the core language in one's programs) than just "using" or
even inspecting and trying to learn subtle details of some particular
implementation of a related DS or A in some "other" language.

How many of those who devleoped and improved  the very efficient data
structures in Python learned and honed their skills in Python (vs. C
or Pascal, for example)?

wwwayne

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


Re: eof

2007-11-21 Thread Wayne Brehaut
Hi braver,

On Wed, 21 Nov 2007 15:17:14 -0800 (PST), braver
<[EMAIL PROTECTED]> wrote:

>I'd like to check, for a filehandle f, that EOF has been reached on
>it.  What's the way to do it?  I don't want to try/except on EOF, I
>want to check, after I read a line, that now we're in the EOF state.

It would be nicer to check the reference manual than ask here.  If you
have PythonWin 2.5.1 (r251:54863, May  1 2007, 17:47:05) [MSC v.1310
32 bit (Intel)] on win32.for example, using Help, Index, eof gives: 

eof 
Token used to determine end of file. This will be set to the empty
string (''), in non-POSIX mode, and to None in POSIX mode. New in
version 2.3. 

If you don't use Active State Python--and even of you do--it helps to
have these  three "official" references handy:

===
http://docs.python.org/ref/ref.html

Python Reference Manual
Guido van Rossum

Python Software Foundation 
Email: [EMAIL PROTECTED] 

Fred L. Drake, Jr., editor

Release 2.5
19th September, 2006
===
http://docs.python.org/lib/lib.html

Python Library Reference
Guido van Rossum

Python Software Foundation 
Email: [EMAIL PROTECTED] 

Fred L. Drake, Jr., editor

Release 2.5
19th September, 2006
===
http://docs.python.org/tut/tut.html

Python Tutorial
Guido van Rossum

Python Software Foundation 
Email: [EMAIL PROTECTED] 

Fred L. Drake, Jr., editor

Release 2.5
19th September, 2006
===

The tutorial gives simpler explanations and examples, including:

7. Input and Output 
7.2.1 Methods of File Objects 

>>> f.read()
'This is the entire file.\n'
>>> f.read()
''
===

If the end of the file has been reached, f.read() will return an empty
string (""). 

By browsing the index or TOC, or searching, or guessing, you should
conclude that you want 

3.9 File Objects

There, and checking for "EOF"  you'll note that both read( [size]) and
readline( [size]) include:

"An empty string is returned only when EOF is encountered
immediately."

HTH?

>In Ruby it's f.eof:

It also is not nice to talk Ruby here--nor Perl. Refer to C/C++ if
necessary.

wwwayne


>
>In Ruby:
>>> f = File.open("jopa")
>=> #
>>> f.read()
>=> "jopa\n"
>>> f.eof
>=> true
>
>Is there a Python analog?
>
>Cheers,
>Alexy
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: eof

2007-11-21 Thread Wayne Brehaut
On Wed, 21 Nov 2007 17:06:15 -0800 (PST), braver
<[EMAIL PROTECTED]> wrote:

>On Nov 22, 3:41 am, Wayne Brehaut <[EMAIL PROTECTED]> wrote:
>> If you have PythonWin 2.5.1 (r251:54863, May  1 2007, 17:47:05) [MSC v.1310
>> 32 bit (Intel)] on win32.for example, using Help, Index, eof gives:
>>

8< ===

>
> HTH?

>Nope!  I don't want to buffer input myself, and don't want to store
>look-ahead and push it back.  f.read()/readline() is not a non-
>destructive check, and thus won't do.

Your original statement was: "I'd like to check, for a filehandle f,
that EOF has been reached on it." You now appear to be "upping the
ante" as though you're more interested in attacking what you perceive
as an omission in Python than in doing what you originally stated.

>Well folks compare scripting languages all the time, and surely Ruby
>is closer to Python than C++.  

If I  didn't abhor smileys and text substitutes you might have caught
on that this was partly "just kidding", but not completely: since
Python is implemented in C/C++ it makes perfect sense to see what's
readily available there that might account for how one would do it in
Python if he really thought it necessary. (As others have noted, it's
not necessary.)

So what Python is "closer to" is not the point--and there's no
standard way of measuring that that I know of?

>Since Ruby can do f.eof, which is
>easily found in its references, and Python can't, or its EOF can't
>easily be found -- the one *equivalent* to a semantically clear
>Ruby's, or Pascal's IIRC, f.eof -- something's missing here...
>Why do I have to count sizes of lines read and compare it to some
>filesize 

Why would you think that it's you doing the counting? If you insist,
write your own trivial eof() and call it so you won't have to fret
about how it's discovering whether you're at EOF.

>or do other weird tricks just to see, in a way not changing
>my input stream, whether it's at the, well, EOF?

As others have already pointed out, "because it's seldom necessary in
Python". If you really think you need to do it the way you're implying
in Python, you're probably mistaken. You should do it the pythonic way
instead of complaining about not finding the exact equivalent to how
you would do it in some other language. 

"Python is not Ruby."

wwwayne


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


Re: JESUS in the QURAN

2007-12-10 Thread Wayne Brehaut
On Mon, 10 Dec 2007 11:20:49 -0800 (PST), aassime abdellatif
<[EMAIL PROTECTED]> wrote:

> 'And they devised, and God
>devised, and God devised, and God is the best of divisors.

Obvious, since God is One, and so He divides 1, and 0, and -1, and all
integers both positive and negative  (Peace Be Upon Them).

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


Re: J in the Q

2007-12-10 Thread Wayne Brehaut
On Mon, 10 Dec 2007 21:41:56 +0100, Bruno Desthuilliers
<[EMAIL PROTECTED]> wrote:

>Wayne Brehaut a écrit :
>(snip spam)
>> Obvious, since God is One, and so He divides 1, and 0, and -1, and all
>> integers both positive and negative  (Peace Be Upon Them).
>> 
>> wwwayne
>
>
>wwwayne,
>
>My isp did a good job at filtering out that spam. In fact, if it wasn't 
>for your answer, I wouldn't even know someone about it. Does that ring a 
>bell, or do I have to say it out loud ? PLEASE DONT ANSWER TO SPAMS !
>
>Nah.

I suppose you realize that now any troll lurking nearby knows how to
bypass your ISP's spam filter and p you off? 

Rule number 2: NEVER REPLY TO A REPLY TO A SPAMMER!

Please killfilter me so you won't be bothered by my posts. If you
didn't provide so much useful information I'd killfilter you too so I
wouldn't be bothered by your cranky retorts to all my posts.

Did you somehow miss the complete reposting of this guy's previous
message by Deltantor on  05 Dec 2007? Or is just me that youfeel the
need to chastise?

o/o

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


Re: Update of Gnuplot.py

2008-01-09 Thread Wayne Brehaut
On Wed, 9 Jan 2008 03:43:38 -0800 (PST), Tom La Bone
<[EMAIL PROTECTED]> wrote:

>
>Can someone suggest where to get a version of Gnuplot.py (for Windows) that
>has been updated to use numpy? Or, is there another interface available to
>use GnuPlot from Python? 
>
>Thanks.
>
>Tom

Gnuplot 1.7 uses numpy:

http://gnuplot-py.sourceforge.net

'''
Before you can use Gnuplot.py, you will need working versions of 

the gnuplot program, 
Python (version 1.5 or later), and 
the Numeric Python extension 
'''

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


One Bug of Python 3.0

2009-01-15 Thread Wayne Huang
I met a bug of CGIXMLRPCRequestHandler in Python3.0. Because of the bug, I
couldn't use RPC in Apache CGI.

The version of my Python 3.0 is "Python 3.0 (r30:67507, Dec  3 2008,
20:14:27) [MSC v.1500 32 bit (Intel)] win32".

The code of my client is follow.

s = xmlrpc.client.ServerProxy('http://localhost/cgi-bin/rpc.py')
print(s.system.listMethods())

The code of my server in Apache's cgi-bin is follow

#!C:/Python30/python.exe

from xmlrpc.server import *

handler=CGIXMLRPCRequestHandler()
handler.register_introspection_functions()
handler.handle_request()

When I run the client code,some error of parser raise.

I found it is the matter of 'Content-Length' in the HTTP Response of
CGIXMLRPCRequestHandler,it is a wrong number.

I don't know how to handle the problem.

Wait for your help.

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


Re: Email Program

2009-03-02 Thread Wayne Cannon
The Twisted package (http://twistedmatrix.com/) has some examples of 
interacting with e-mail servers.  Twisted supports interaction between 
asynchronous tasks.  --Wayne


J wrote:

Is it possible to make a GUI email program in Python that stores
emails, composes, ect?

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


Python open of c:\ path Problem

2008-08-23 Thread Wayne Watson
Title: Signature.html




Python doesn't like this:


junkfile = open('c:\tmp\junkpythonfile','w')


I get

    junkfile = open('c:\tmp\junkpythonfile','w')

IOError: [Errno 2] No such file or directory: 'c:\tmp\\junkpythonfile'


This problematic segment is just a hack of a similar statement which
has the same problem and a much longer path. I suspect the problem is
with the back slash.
-- 


   Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

 (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
  Obz Site:  39° 15' 7" N, 121° 2' 32" W, 2700 feet

 "Equilibrium is when all the fast things have
  happened, and all of the slow things have not."
  -- Richard Feynman

Web Page: <www.speckledwithstars.net/>



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

Re: Program to compute and print 1000th prime number

2009-11-07 Thread Wayne Brehaut
On Sat, 7 Nov 2009 19:34:47 +0100, Andre Engels
 wrote:

>On Sat, Nov 7, 2009 at 6:40 PM, Mensanator  wrote:
>
>>> Tongue in cheek solution:
>>>
>>> import urllib2
>>>
>>> url = 'http://primes.utm.edu/lists/small/1.txt'
>>> primes = []
>>> for line in urllib2.urlopen(url).read().splitlines():
>>>     values = line.split()
>>>     if len(values) == 10:
>>>         primes.extend(values)
>>> print primes[1000-1]
>>
>> Nice, but you can do better.
>>
> import gmpy
> n = 1
> for i in xrange(1000):
>>        n = gmpy.next_prime(n)
> print n
>> 7919
>
>With the help of the solutions given so far, I can do even better than that:
>
>n = 7919
>print n

>>> 7919
7919

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


Re: Tutorials on Jinja

2009-06-25 Thread Wayne Brehaut
On Wed, 24 Jun 2009 11:46:55 -0700 (PDT), Saurabh
 wrote:

>Hi All,
>
>I am trying to move my application on a MVC architecture and plan to
>use Jinja for the same. Can anyone provide me with few quick links
>that might help me to get started with Jinja?

Perhaps the most useful link is:

http://www.google.com/

from which you can easily find many more with a very basic search,
including:

http://jinja.pocoo.org/

Hope that helps?
wwwayne

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


  1   2   >