Re: Fractions as result from divisions

2009-07-08 Thread Hans Nowak

Ulrich Eckhardt wrote:

Bearophile wrote:

For example a novice wants to see 124 / 38 to return the 62/19
fraction and not 3 or 3.263157894736842 :-)


Python has adopted the latter of the three for operator / and the the second
one for operator //. I wonder if it was considered to just return a
fraction from that operation.


http://python-history.blogspot.com/2009/03/problem-with-integer-division.html

For example, in ABC, when you divided two integers, the result was an exact 
rational number representing the result. In Python however, integer division 
truncated the result to an integer.


In my experience, rational numbers didn't pan out as ABC's designers had hoped. 
A typical experience would be to write a simple program for some business 
application (say, doing one’s taxes), and find that it was running much slower 
than expected. After some debugging, the cause would be that internally the 
program was using rational numbers with thousands of digits of precision to 
represent values that would be truncated to two or three digits of precision 
upon printing. This could be easily fixed by starting an addition with an 
inexact zero, but this was often non-intuitive and hard to debug for beginners.


--
Hans Nowak (zephyrfalcon at gmail dot com)
http://4.flowsnake.org/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Do I need self and other?

2008-06-27 Thread Hans Nowak

Kurda Yon wrote:

Hi,

I found one example which defines the addition of two vectors as a
method of a class. It looks like that:

class Vector:
  def __add__(self, other):
data = []
for j in range(len(self.data)):
  data.append(self.data[j] + other.data[j])
return Vector(data)

In this example one uses self and other. Does one really need to
use this words? And, if yes, why? I have replaced self by x and
other by y and everything looks OK. Is it really OK or I can have
some problem in some cases?


You can use whichever (valid) names you want, but in general 'self' and 'other' 
are used for clarity.  In this case, they indicate the vector that is operated 
on (self) and another vector (other).  Using 'x' and 'y' would be less clear 
here.


--
Hans Nowak (zephyrfalcon at gmail dot com)
http://4.flowsnake.org/
--
http://mail.python.org/mailman/listinfo/python-list


Re: How do I create user-defined warnings?

2008-06-17 Thread Hans Nowak

Clay Hobbs wrote:

I already know how to make user-defined exceptions, like this one:

class MyException(Exception):
pass

But for a module I'm making, I would like to make a warning (so it just
prints the warning to stderr and doesn't crash the program).  I have
tried this:

class MyWarning(Warning):
pass

And it behaves like a normal error.  Please help me, I can't figure out
what I'm doing wrong.


Are you using the warning with 'raise'?  Don't do that, use warnings.warn 
instead:

In [1]: import warnings

In [2]: class MyWarning(Warning): pass
   ...:

In [3]: warnings.warn(MyWarning(bah humbug))
/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/IPython/FakeModule.py:1: 
MyWarning: bah humbug

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

--
Hans Nowak (zephyrfalcon at gmail dot com)
http://4.flowsnake.org/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Simple and safe evaluator

2008-06-12 Thread Hans Nowak

bvdp wrote:


Is there a simple/safe expression evaluator I can use in a python 
program. I just want to pass along a string in the form 1 + 44 / 3 or 
perhaps 1 + (-4.3*5) and get a numeric result.


I can do this with eval() but I really don't want to subject my users to 
the problems with that method.


In this use I don't need python to worry about complex numbers, 
variables or anything else. Just do the math on a set of values. Would 
eval() with some restricted list of permitted operators do the trick?


This solution may be overly simply (especially compared to the AST-based 
solution suggested earlier), but... if all you need is numbers and operators, 
*maybe* you can get away with stripping all letters from the input string (and 
possibly the underscore), and then evaluating it:



import re
import traceback

re_letters = re.compile([a-zA-Z_]+)

def safe_eval(s):
s = re_letters.sub(, s)
return eval(s)

# try it out...

 safe_eval(2+2)
4

 safe_eval(4 * (8 / 3.1) ** 7.2)
3685.5618352828474

 safe_eval((2).__class__.__base__.__subclasses__())
Traceback (most recent call last):
  File stdin, line 1, in module
  File safe_eval.py, line 12, in safe_eval
return eval(s)
  File string, line 1
(2)...()
^
SyntaxError: invalid syntax

...It's primitive, but it might work for your purposes.

--
Hans Nowak (zephyrfalcon at gmail dot com)
http://4.flowsnake.org/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Dynamically naming objects.

2008-06-07 Thread Hans Nowak

Kalibr wrote:

On Jun 7, 1:20 pm, Hans Nowak [EMAIL PROTECTED] wrote:

Kalibr wrote:

I've been developing a small script to fiddle with classes, and came
accross the following problem. Assuming I get some user input asking
for a number, how would I spawn 'n' objects from a class?
i.e. I have a class class 'user' and I don't know how many of them I
want to spawn.
Any ideas?

Sure. This will give you a list of n instances of user:

   [user() for i in range(n)]

Of course, you could also use a good old for loop:

   for i in range(n):
   u = user()
   ...do something with u...

Hope this helps!

--
Hans Nowak (zephyrfalcon at gmail dot com)http://4.flowsnake.org/


whoops, replied to author

What I wanted to ask before was won't 'u' be overwritten with a new
object each time the loop ticks over?


Yes, so you have to store it somewhere, if you want to keep the object around. 
The list comprehension mentioned above stores all the objects in a list, after 
which they can be accessed at will via indexing.



what I want to do is have, say 5 users in a game, so I'd have to spawn
5 objects. I can't do that because I have'nt hardcoded any object
names for them.

or does it somehow work? how would I address them if they all have the
name 'u'?


users = [user() for i in range(n)]

# use: users[0], users[1], etc

--
Hans Nowak (zephyrfalcon at gmail dot com)
http://4.flowsnake.org/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie question, list comprehension

2008-06-06 Thread Hans Nowak

Johannes Bauer wrote:

Hello group,

I'm currently doing something like this:

import time
localtime = time.localtime(1234567890)
fmttime = %04d-%02d-%02d %02d:%02d:%02d % (localtime[0], localtime[1], 
localtime[2], localtime[3], localtime[4], localtime[5])

print fmttime

For the third line there is, I suppose, some awesome python magic I 
could use with list comprehensions. I tried:


fmttime = %04d-%02d-%02d %02d:%02d:%02d % ([localtime[i] for i in 
range(0, 5)])


The % operator here wants a tuple with six arguments that are integers, not a 
list.  Try:


fmttime = %04d-%02d-%02d %02d:%02d:%02d % tuple(localtime[i] for i in 
range(6))


As it appearently passed the while list [2009, 02, 14, 0, 31, 30] as the 
first parameter which is supposed to be substituted by %04d. Is there 
some other way of doing it?


In this case, you can just use a slice, as localtime is a tuple:

fmttime = %04d-%02d-%02d %02d:%02d:%02d % localtime[:6]

Hope this helps! ^_^

--
Hans Nowak (zephyrfalcon at gmail dot com)
http://4.flowsnake.org/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Dynamically naming objects.

2008-06-06 Thread Hans Nowak

Kalibr wrote:

I've been developing a small script to fiddle with classes, and came
accross the following problem. Assuming I get some user input asking
for a number, how would I spawn 'n' objects from a class?

i.e. I have a class class 'user' and I don't know how many of them I
want to spawn.

Any ideas?


Sure. This will give you a list of n instances of user:

  [user() for i in range(n)]

Of course, you could also use a good old for loop:

  for i in range(n):
  u = user()
  ...do something with u...

Hope this helps!

--
Hans Nowak (zephyrfalcon at gmail dot com)
http://4.flowsnake.org/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python and Harry Potter?

2008-06-05 Thread Hans Nowak

Helmut Jarausch wrote:

Hi,
just to let you know ...

Today I've got an email from Amazon recommending me
Harry Potter and the Deathly Hallows

and they told me why they recommended this book,
because I've bought
Core PYTHON Programming

Didn't know, Harry Potter is a Python fan.


If you scan the alt.fan.harry-potter archives carefully, you will find at least 
one well-known Python core developer. :-)


--
Hans Nowak (zephyrfalcon at gmail dot com)
http://4.flowsnake.org/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Why does python not have a mechanism for data hiding?

2008-06-04 Thread Hans Nowak

Lie wrote:

On May 24, 9:14 pm, Fuzzyman [EMAIL PROTECTED] wrote:

For example, at Resolver Systems we expose the spreadsheet object
model to our users. It hasa public, documented, API - plus a host of
undocumented internally used methods.

We would really *much* rather hide these, because anything our
customers start using (whether documented or not) we will probably
have to continue supporting and maintaining.



Then don't document it, or separate internal documentation (which is
never to pass through the wall) and public documentation (which your
users use). Nobody would (apart from your dev team and anyone told by
your dev team, which means you may fire the person for lack of
discipline) know that there is such a thing and in consequence
wouldn't use it.

Don't tell your user not to use something, just don't tell them that
it exists and they won't use it.


I am not familiar with the actual software, but judging from we expose the 
spreadsheet object model to our users, I assume that users can discover the 
undocumented attributes, using Python's introspection features, like dir(obj), 
obj.__dict__, the inspect module, etc.  So in this case, not telling them that 
the attributes exist, will not stop them from finding out.


--
Hans Nowak (zephyrfalcon at gmail dot com)
http://4.flowsnake.org/
--
http://mail.python.org/mailman/listinfo/python-list


Re: accumulator generators

2008-05-30 Thread Hans Nowak

Cameron wrote:

On May 30, 1:04 pm, Diez B. Roggisch [EMAIL PROTECTED] wrote:

Cameron schrieb:




I was reading this a href=thishttp://www.paulgraham.com/icad.html;Paul
Graham article/a and he builds an accumuator generator function in
the appendix. His looks like this:
pre
def foo(n):
  s = [n]
  def bar(i):
s[0] += i
return s[0]
  return bar
/pre
Why does that work, but not this:
pre
def foo(n):
  s = n
  def bar(i):
s += i
return s
  return bar
/pre

Because python's static analysis infers s as being a variable local to
bar in the second case - so you can't modify it in the outer scope.

In the future, you may declare

def bar(i):
 nonlocal s
 ...

Diez


thanks for the response. Just to make sure I understand- Is the reason
it works in the first case because s[0] is undefined at that point (in
bar), and so python looks in the outer scope and finds it there?


You can refer to variables in enclosing scopes, just not redefine them in that 
same scope.  That's why in the first example, bar can refer to to s (defined in 
foo).  By assigning to s[0], it modifies the list, which is OK; trying to 
redefine the name 's' (like the second example tries to do) would not be OK.


Also see: http://zephyrfalcon.org/labs/python_pitfalls.html (pitfall #6).

--
Hans Nowak (zephyrfalcon at gmail dot com)
http://4.flowsnake.org/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Code execution in imported modules

2008-05-29 Thread Hans Nowak

Eric Wertman wrote:

So I'm working on some file parsing and building up a stack of regular
expressions that I need to use.  I was thinking of dropping them in an
external module.  I was wondering.. if I put them in a file called
regex.py like so :

import re

re1 = ..
re2 = ..

and then do:

rgx1 = re.compile(re1)
rgx2 = re.compile(re2)


and, in my script, parse.py py I do:

from regex import *

text = bunch of stuff...

m = rgx1.search(text)


Does the re get compiled when I import it, or every time I call it?
Since I'm calling it often, I'd like to compile it once.


It is compiled when you import the module.

--
Hans Nowak (zephyrfalcon at gmail dot com)
http://4.flowsnake.org/
--
http://mail.python.org/mailman/listinfo/python-list


Re: 2 different versions of python compiling files.

2008-05-22 Thread Hans Nowak

TkNeo wrote:

I am trying to upgrade from python 2.3 to 2.4 but not all machines can
be upgraded. Can you guys tell me if this scenario is possible.

1. Any machine that uses .py files that use libraries that require 2.4
will have 2.4 on it.
2. rest of the machines will have 2.3

now there is a shared drive. lets say i write a new library called
testlib.py and put it on the shared drive .. when a script uses it
from a 2.4 based machine, it will generate a testlib.pyc and leave it
on the shared drive. going forward that .pyc is used until the
original lib is changed. now lets say a 2.3 based machine is trying to
use that lib. it will try to use that pyc file which was compiled by
py2.4. will it work or crash ?


It should work, as long as the original .py file is still there.  Each Python 
version will check for a .pyc file *corresponding to that version* (e.g. Python 
2.4 will look for a .pyc file compiled with 2.4), and create one if it doesn't 
exist, overwriting any existing .pyc file in the process.


If the original .py file is *not* there, it will most likely not work.  If you 
try to import a .pyc file with the wrong version number, you get something like 
this:


 import foo
Traceback (most recent call last):
  File stdin, line 1, in ?
ImportError: Bad magic number in foo.pyc

I'm not sure what would happen if multiple Pythons try to write a .pyc file at 
the same time, though...


--
Hans Nowak (zephyrfalcon at gmail dot org)
http://4.flowsnake.org/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Classmethods are evil

2008-05-17 Thread Hans Nowak

Ivan Illarionov wrote:
After re-reading Python is not Java I finally came to conclusion that 
classmethods in Python are a very Bad Thing. 

I can't see any use-case of them that couldn't be re-written more clearly 
with methods of metaclass or plain functions.


I agree with your sentiments, although I'm not sure I would pick metaclasses 
over class methods... or over anything at all, for that matter. :-)



They have the following issues:
1. You mix instance-level and class-level functionality in one place 
making your code a mess.

2. They are slower than metaclass methods or plain functions.


The way I see it, a class method is really just sugar for a function operating 
on the class, living in the class namespace.  As such, they are basically 
redundant, and as you point out, they can always be replaced by a function 
outside the class (and in fact, this was what people did before they came along 
in 2.2).  Personally, I don't use them... but some people like them.  Different 
strokes, and all that...


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


Re: save dictionary for later use?

2008-05-16 Thread Hans Nowak

globalrev wrote:


pickle.dumps(mg)
pickle.load(mg)

'dict' object has no attribute 'readline'
dumps load(well i dont know but i get no complaint but running load
generates that error)


The 'loads' and 'dumps' methods use strings:

 import pickle
 d = {this: 42, that: 101, other: 17}
 s = pickle.dumps(d)
 s
(dp0\nS'this'\np1\nI42\nsS'other'\np2\nI17\nsS'that'\np3\nI101\ns.
 pickle.loads(s)
{'this': 42, 'other': 17, 'that': 101}

If you want to store to / restore from file, use 'dump' and 'load':

# write to file 'out'...
 f = open(out)
 f = open(out, wb)
 pickle.dump(d, f)
 f.close()

# restore it later
 g = open(out, rb)
 e = pickle.load(g)
 g.close()
 e
{'this': 42, 'other': 17, 'that': 101}

Also see http://docs.python.org/lib/pickle-example.html.

Hope this helps!

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


Re: can't delete from a dictionary in a loop

2008-05-16 Thread Hans Nowak

Dan Upton wrote:


for pid in procs_dict:
  if procs_dict[pid].poll() != None
   # do the counter updates
   del procs_dict[pid]

The problem:

RuntimeError: dictionary changed size during iteration


I don't know if the setup with the pids in a dictionary is the best way to 
manage a pool of processes... I'll leave it others, presumably more 
knowledgable, to comment on that. :-)  But I can tell you how to solve the 
immediate problem:


  for pid in procs_dict.keys():
  ...

Hope this helps!

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


Re: can't delete from a dictionary in a loop

2008-05-16 Thread Hans Nowak

[EMAIL PROTECTED] wrote:

On 16 mai, 23:34, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:

On 16 mai, 23:28, Hans Nowak [EMAIL PROTECTED] wrote:



Dan Upton wrote:

for pid in procs_dict:

(snip)

   for pid in procs_dict.keys():

I'm afraid this will do the same exact thing. A for loop on a dict
iterates over the dict keys, so both statements are strictly
equivalent from a practical POV.


Hem. Forget it. I should think twice before posting - this will
obviously make a big difference here.  Sorry for the noise.


:-)  It appears that you would be right if this was Python 3.0, though:

Python 3.0a5 (r30a5:62856, May 16 2008, 11:43:33)
[GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin
Type help, copyright, credits or license for more information.
 d = {1: 2, 3: 4, 5: 6}
 for i in d.keys(): del d[i]
...
Traceback (most recent call last):
  File stdin, line 1, in module
RuntimeError: dictionary changed size during iteration

Maybe 'for i in d' and 'for i in d.keys()' *are* functionally equivalent in 3.0, 
as d.keys() returns an object that iterates over d's keys... but I haven't read 
enough about it yet to be sure.  In any case, the problem goes away when we 
force a list:


 d = {1: 2, 3: 4, 5: 6}
 for i in list(d.keys()): del d[i]
...
 d
{}

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


Re: SImple python print question

2008-05-16 Thread Hans Nowak

[EMAIL PROTECTED] wrote:

Hey there,

I have a simple question about python print statement. Take the
following code snippet for example...

1 print -#- executing: %s % section,
2 tests[section] = test.testcase(name=config.get(section,'name'))
3 tests[section].runTest()
4 printStatus(tests[section])

Now the problem is that line 1 does not get printed until line 4. What
I thought would happen is that line 1 gets executed and the user sees
that the statement that the test case is executing. Then after the
test case executes a PASS or FAIL appears on the same line as the
-#- executing: 0053 statement.

e.g.
-#- executing: 0053 FAIL

Some tests take a long time to finish thus the screen is blank until
the entire test finishes and the above statement is outputted.

Thanks for any help.


'print' sends its output to sys.stdout, which is buffered, and may not be 
displayed immediately (because it's held in the buffer).  To force the output to 
be displayed, use flush():


  print -#- executing: %s % section,
  sys.stdout.flush()
  ...tests here...

Hope this helps!

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


Re: at what complexity, a comparison fails ?

2007-12-31 Thread Hans Nowak
Stef Mientki wrote:
 hello,
 
 I had a program that worked perfectly well.
 In this program modules were dynamically added,
 just by putting the file in a predefined directory.
 
 Now one of the interface mechanisms was to see if some parameter was 
 changed in a an instance,
 by comparing the value from the instance with its previous value
 
 This went all well, untill I added a too complex variable,
 then the program stopped working, without generating exceptions.
 
 So it seems that comparing a too complex value isn't allowed.
 the variable was something like:
 
  A = [ ndarray, ndarray, ..., [color,color,...], [float, 
 float, ... ] ]
 
 So what I need was something like:
if  A != A_prev :
... do something
A_prev = A
 
 And this crashes, or at least it doesn't work but also doesn't generate 
 exceptions.
 It does seems to work, if A only contains 1 array.
 
 Why am I not allowed to compare A and A_prev ??
 And in general, how complex might a list be to make a valid comparison,
 or what are the rules ?

I suspect that some of the objects in A have either undefined (or ill-defined) 
comparison methods, so that the overall list comparison does not do what you 
expect.  I'm not sure what ndarray and color are, but check their comparison 
methods (you know, __cmp__, __lt__, __eq__, etc).  (If that isn't clear, please 
see http://effbot.org/pyref/__lt__.htm.)

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


Re: Wax: problem subclassing TextBox

2006-10-18 Thread Hans Nowak
alex23 wrote:
 Hey everyone,
 
 I've just started looking at Wax and have hit a problem I can't
 explain. I want an app to respond to every character input into a
 TextBox.
 
 Here's a simple, working example:
 
 +++
 from wax import *
 
 class MainFrame(VerticalFrame):
   def Body(self):
 self.search = TextBox(self)
 self.search.OnChar = self.OnChar
 self.AddComponent(self.search, expand='h', border=5)
 
   def OnChar(self, event):
 print 'OnChar:', event.GetKeyCode()
 event.Skip()
 
 app = Application(MainFrame)
 app.Run()
 +++
 
 This displays a TextBox and entering abcd results in:
 
   OnChar: 97
   OnChar: 98
   OnChar: 99
   OnChar: 100
 
 Rather than defining the OnChar hook on the main frame, though, it
 makes more sense (to me) to be defined on the TextBox itself, so I
 tried subclassing it as follows:
 
 +++
 class NewTextBox(TextBox):
   def OnChar(self, event):
 print 'on char', event.GetKeyCode()
 event.Skip()
 
 class MainFrame(VerticalFrame):
   def Body(self):
 self.search = NewTextBox(self)
 self.AddComponent(self.search, expand='h', border=5)
 +++
 
 With the same input of 'abcd', I get the following:
   on char 97
   on char 97
   on char 98
   on char 98
   on char 99
   on char 99
   on char 100
   on char 100

Heh, that's a bug.  As a temporary solution, go to textbox.py and 
comment out the line in the __events__ dict that says 'Char': wx.EVT_CHAR.

I will need to fix the way Wax handles events like these; this will 
probably be solved in the next release.

-- 
Hans Nowak
http://zephyrfalcon.org/

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


Re: Arithmetic sequences in Python

2006-01-19 Thread Hans Nowak
Alex Martelli wrote:

 Do YOU have any good reason why
 sets should print out as set(...) and lists should NOT print out as
 list(...)?  Is 'list' somehow deeper than 'set', to deserve a special
 display-form syntax which 'set' doesn't get?  Or are you enshrining a
 historical accident to the level of an erroneously assumed principle?

(I haven't been following this thread much, so I can't tell if you're 
actually arguing for this change, or that you are just playing devil's 
advocate...)

I would have liked to say that lists are a fundamental data type, much 
more so than a set... but in reality that seems to be a matter of taste 
and priorities.  Pascal, for example, has a set literal, but no list 
literal; in fact, it doesn't even have a built-in list type.

-- 
Hans Nowak
http://zephyrfalcon.org/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Spelling mistakes!

2006-01-11 Thread Hans Nowak
Antoon Pardon wrote:

 Op 2006-01-10, Terry Hancock schreef [EMAIL PROTECTED]:
 
In unit testing, you write the code, then write code to test
the code, which must correctly identify the methods in the
code. So you have to type 'everything' twice.
 
 But you don't type attribute names twice in unit tests,
 because attributes are in general implementation details
 that are of no concern to the tester. So unit tests can
 not introduce the redundancy to find out a missed spelled
 attribute in some methods.

I wouldn't call attributes implementation details, at least not in 
Python.  And while it is true that unit tests might not find the 
misspelling *directly* (i.e. you rarely test if you have misspelled 
something), your tests should definitely show unexpected behavior and 
results, if that attribute is of any importance.  Otherwise there's a 
loophole in your tests. :-)

-- 
Hans Nowak
http://zephyrfalcon.org/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: - E04 - Leadership! Google, Guido van Rossum, PSF

2006-01-09 Thread Hans Nowak
Anton Vredegoor wrote:

 Now going back to my claim that elitism is bad, I think you are the
 perfect proof of my point. You live in luxurious (with respect to
 community, education and financial aspects of being a computer scientist
 or programmer) conditions and can just not understand why some people
 have problems entering that same environment and privileged conditions
 as yourself. This attitude is very common and needs only some kind
 Blair-alike kind of selfhypnosis in order to effectively not being aware
 of lying.

Tony Blair, or the Blair Witch project?

-- 
Hans Nowak
http://zephyrfalcon.org/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: - E04 - Leadership! Google, Guido van Rossum, PSF

2006-01-03 Thread Hans Nowak
Duncan Booth wrote:

 BTW, I don't know Ruby enough to understand the example at 
 http://lazaridis.com/case/lang/ruby/base.html:
 
 class Object
   def meta # adds variable meta to all objects in the system
 end

I don't think this is valid Ruby code, by the way...  It should probably 
be something like this:

   class Object
 attr_accessor :meta
   end

 Talker.meta = Class meta information
 john.meta = Instance meta information
 1234.meta = 'any Instance meta information
 
 puts Talker.meta
 puts john.meta
 puts 1234.meta  # an integer object
 
 With the above code what would 'puts someexpressionresultingin1234.meta' 
 output? i.e. is the attribute being set on all integers with the value 
 1234, or just on a specific instance of an integer.

At first glance, it seems the former is true:

irb(main):021:0 class Object
irb(main):022:1   attr_accessor :meta
irb(main):023:1 end
= nil
irb(main):026:0 1234.meta = fred
= fred
irb(main):027:0 (1000+234).meta
= fred
irb(main):028:0 x = 617
= 617
irb(main):029:0 x *= 2
= 1234
irb(main):031:0 x.meta
= fred
irb(main):032:0 3.meta
= nil

However, inspecting the object_id (comparable to Python's id()) shows 
that all these refer to the same object:

irb(main):035:0 1234.object_id
= 2469
irb(main):036:0 x.object_id
= 2469
irb(main):041:0 y = 1000
= 1000
irb(main):042:0 y.object_id
= 2001
irb(main):043:0 y += 234
= 1234
irb(main):044:0 y.object_id
= 2469

I am not an expert on Ruby internals, but it looks like these integers 
are cached.  As with Python, I don't know if one can count on this 
behavior to happen always.

-- 
Hans Nowak
http://zephyrfalcon.org/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python or Java or maybe PHP?

2006-01-02 Thread Hans Nowak
Alex Martelli wrote:

 A Ruby example of reimplementing while:
 
 def WHILE(cond)
 |   return if not cond
 |   yield
 |   retry
 | end
 i=0; WHILE(i3) { print i; i+=1 }
 
 Python's a bit less direct here, but:
 
 def WHILE(cond):
 if not cond(): return
 yield None
 yield WHILE(cond)

Maybe I misunderstand, but shouldn't this be:

def WHILE(cond):
 if not cond(): return
 yield None
 for x in WHILE(cond): yield x

After all, the original version only yields two things: None and a 
generator.

(Or is this behavior different in Python 2.5?  I hope not...)

-- 
Hans Nowak
http://zephyrfalcon.org/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python coding contest

2005-12-31 Thread Hans Nowak
André wrote:
 Christian Tismer wrote:

It seems to be very hard to improve. No idea if this is
possible: One might try to re-order the character string
a bit to change moduli, trying to get one more number in

(3,14,10)

to be one-digit. Haven't tried, yet, and chances are small.

congrats again and a happy new year - chris
 
 
 With the string of  _| I used, starting sub-indices for each
 3-character substrings are such that one need modulo 10 (or greater)
 for at least two of the three indices.  I have looked at a few other
 combinations and, after thinking about it, have convinced myself that
 it is unfortunately not possible to do.  I would love to be proven
 wrong!  Good idea though!

I don't know if this suggestion has been made already, but it seems to 
me that the end of the expression

   ...  for u in(3,14,10))

can be written as:

   ...  for u in 3,14,10)

which would shave off a character.  Tuples don't always need parentheses...

-- 
Hans Nowak
http://zephyrfalcon.org/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python coding contest

2005-12-31 Thread Hans Nowak
André wrote:
 Hans Nowak wrote:
 
André wrote:
 
 
I don't know if this suggestion has been made already, but it seems to
me that the end of the expression

   ...  for u in(3,14,10))

can be written as:

   ...  for u in 3,14,10)

which would shave off a character.  Tuples don't always need parentheses...

 
 I tried ... but, in this case, it appears that they do, unfortunately
 :-(

Ah, you are right.  It works for a list comprehension, but not for a 
genexp. :-(

-- 
Hans Nowak
http://zephyrfalcon.org/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: questions about py2exe and wax

2005-12-30 Thread Hans Nowak
iclinux wrote:
 Using py2exe, I can convert a GUI Application with PythonCard to a
 standalone windows program, and it works.
 Then  I try another GUI Toolkit named Wax, implement a GUI App, it
 works. And I convert that app by py2exe. But this time, when run, it
 show a messagebox that says:
 
 
 This application requires a version of wxPython greater than or equal
 to 2.6, but a matching version was not found.
 
 You currently have these version(s) installed:
 
 Would you like to download a new version of wxPython?
 
 any suggestion?

I got the same problem.  Apparently the wxversion-related code in 
wax/core.py that doesn't work well with py2exe.  Try commenting out the 
try..except clause in core.py; this worked for me.  (Of course, I'll 
have to think of a better solution for future releases of Wax...)

Feel free to contact me by private mail if you need more help.

Cheers,

-- 
Hans Nowak
http://zephyrfalcon.org/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: - E04 - Leadership! Google, Guido van Rossum, PSF

2005-12-28 Thread Hans Nowak
Robert Kern wrote:

 PyPy will not bring about the Singularity.

But if it did, imagine how cool that would look on the developers 
resumes... :-)

-- 
Hans Nowak
http://zephyrfalcon.org/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple question on Parameters...

2005-12-28 Thread Hans Nowak
KraftDiner wrote:
 I guess its all good...
 I just am not crazy about using fillColor[0]  id rather use fillColor.r

You don't have to use fillColor[0], you can use tuple unpacking to name 
the elements of the tuple.  E.g.

def renderABezierPath(self, path, closePath=True, outlineColor=(1.0, 
1.0, 1.0, 1.0), fillColor=(0.0, 0.0, 0.0, 0.25)):
 r, g, b, a = outlineColor
 fr, fg, fb, fa = fillColor
 ...do something with these values...


-- 
Hans Nowak
http://zephyrfalcon.org/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: program with raw_input prompt behaves differently after compile

2005-12-24 Thread Hans Nowak
tim wrote:

 I want to write a program that looks into a given folder, groups files 
 that have a certain part of the filename in common and then copy those 
 groups one at a time to another place, using the raw_input prompt to 
 continue or break.
 
  [...]
 
 It works fine when I run this from PythonWin IDE, but after compiling an 
 executable from it (py2exe) it exits whatever I type in the 'continue?' 
 prompt.
 What am I doing wrong?

Maybe this helps:

http://forums.devshed.com/python-programming-11/eof-error-with-raw-input-from-a-exe-text-color-187633.html

The solution described here was to compile the program as a console app, 
rather than a Windows app.

-- 
Hans Nowak
http://zephyrfalcon.org/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How Do I get Know What Attributes/Functions In A Class?

2005-02-19 Thread Hans Nowak
[EMAIL PROTECTED] wrote:
Hi,
I'm new to python.  Given a class, how can I get know what
attributes/functins in it without dig into the source?
Use the dir function:
 from smtplib import SMTP
 dir(SMTP)
['__doc__', '__init__', '__module__', 'close', 'connect', 'data', 
'debuglevel', 'docmd', 'does_esmtp', 'ehlo', 'ehlo_resp', 'expn', 
'file', 'getreply', 'has_extn', 'helo', 'helo_resp', 'help', 'login', 
'mail', 'noop', 'putcmd', 'quit', 'rcpt', 'rset', 'send', 'sendmail', 
'set_debuglevel', 'starttls', 'verify', 'vrfy']

To get more detailed information than just a list of names, see the 
inspect module.

--
Hans Nowak
http://zephyrfalcon.org/
--
http://mail.python.org/mailman/listinfo/python-list


Re: changing __call__ on demand

2005-02-14 Thread Hans Nowak
Stefan Behnel wrote:
Hi!
This somewhat puzzles me:
Python 2.4 (#1, Feb  3 2005, 16:47:05)
[GCC 3.3.4 (pre 3.3.5 20040809)] on linux2
Type help, copyright, credits or license for more information.
. class test(object):
...   def __init__(self):
... self.__call__ = self.__call1
...   def __call1(self):
... print 1
...   def __call__(self):
... print 2
...
. t = test()
. t()
2
If I take out the __call__ method completely and only set it in 
__init__, I get a TypeError saying that test is not callable.
Note that it works just fine if you don't use a new-style class:
 class Test:
... def __init__(self):
... self.__call__ = self.foobar
... def foobar(self, *args, **kwargs):
... print Called with:, args, kwargs
...
 t = Test()
 t()
Called with: () {}
 t(3, 4)
Called with: (3, 4) {}
 t(42, x=0)
Called with: (42,) {'x': 0}
--
Hans Nowak
http://zephyrfalcon.org/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Where are list methods documented?

2005-02-01 Thread Hans Nowak
Nick Craig-Wood wrote:
Since I'm a unix person, I would have typed
  pydoc -k sort
But it doesn't come up with anything useful :-(
FYI, you can get this info using the not-very-intuitive
  pydoc __builtin__.list.sort
e.g.
(C:\Python23\Lib) $ pydoc __builtin__.list.sort
Help on method_descriptor in __builtin__.list:
__builtin__.list.sort = sort(...)
L.sort(cmpfunc=None) -- stable sort *IN PLACE*; cmpfunc(x, y) - 
-1, 0, 1

(Rather terse...)
Info on the sort function (together with all the other list methods) is 
also available if you do

  pydoc list
...but for some reason, pydoc list.sort doesn't work on my machine 
(Python 2.3.4, Windows XP).

--
Hans Nowak
http://zephyrfalcon.org/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Dynamic class methods misunderstanding

2005-01-28 Thread Hans Nowak
Bill Mill wrote:
Hello all,
I have a misunderstanding about dynamic class methods. I don't expect
this behavior:
In [2]: class test:
   ...:  def __init__(self, method):
   ...: self.method = method
   ...: self.method()
   ...:
In [3]: def m(self): print self
   ...:
[...]
TypeError: m() takes exactly 1 argument (0 given)
-
Why doesn't m get the implicit self parameter in the self.method()
call? How would I make it a proper member of the class, so that a
self.method() call would work with the above m function?
m is a function.  When you assign it to self.method, it's still a 
function.  You don't create a new method that way; all you have is a new 
attribute called 'method' containing the function.

To add m as a new method to the *class*, do this:
 class test:
... def __init__(self, method):
... self.__class__.method = method
... self.method()
...
 def m(self): print self
...
 test(m)
__main__.test instance at 0x0192ED78
__main__.test instance at 0x0192ED78

To add m as a new method to the *instance*, use new.instancemethod, as 
Diez B. Roggisch already pointed out.

HTH,
--
Hans Nowak
http://zephyrfalcon.org/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Dynamic class methods misunderstanding

2005-01-28 Thread Hans Nowak
Bill Mill wrote:
On Fri, 28 Jan 2005 11:09:16 -0500, Hans Nowak [EMAIL PROTECTED] wrote:
snip

To add m as a new method to the *class*, do this:
 class test:
... def __init__(self, method):
... self.__class__.method = method
... self.method()
...
 def m(self): print self
...
 test(m)
__main__.test instance at 0x0192ED78
__main__.test instance at 0x0192ED78

When I run it, I only get one call to m, which is how I would expect
python to work; I assume the double printing here is a typo?
Actually, no.  I'm using the interactive interpreter, so doing test(m) 
results in two lines: the first one is printed by m, the second one is 
the __repr__ of the test instance that was created, displayed by the 
interpreter.  Compare:

 x = test(m)
__main__.test instance at 0x0192ED78
 x
__main__.test instance at 0x0192ED78
--
Hans Nowak
http://zephyrfalcon.org/
--
http://mail.python.org/mailman/listinfo/python-list


Re: how to write a tutorial

2005-01-23 Thread Hans Nowak
Xah Lee wrote:
the first paragraph of 9.1 A Word About Terminology is epitome of
masturbation. The entire 9.1 is not necessary.
Large part of 9.2 Python Scopes and Name Spaces is again
masturbatory.
So I can just take a copy of the tutorial to the bathroom next time. 
Thanks for the tip, man!

--
Hans Nowak
http://zephyrfalcon.org/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Funny Python error messages

2005-01-21 Thread Hans Nowak
Will Stuyvesant wrote:
Add your funny or surprising Python error messages to this
thread.  A requirement is that you should also show
(minimal) code that produces the message.  Put the code
below, so people can think about how to generate the message
first, a little puzzle if you like.
Perhaps this will even be a useful thread, to brighten the
life of the brave people doing the hard work of providing us
with error messages.
I always liked:
ValueError: insecure string pickle
This error message is not strange if you think of insecure, string 
and pickle as programming terms, but it's hugely mystifying to someone 
who isn't a programmer, since all of these words have different meanings 
in real life.

Some code to produce it:
 import cPickle
 x = cPickle.dumps([1,2,3,ratsj])
 y = x[:18] + ? + x[18:]
 cPickle.loads(y)
Traceback (most recent call last):
  File input, line 1, in ?
ValueError: insecure string pickle
--
Hans Nowak
http://zephyrfalcon.org/
--
http://mail.python.org/mailman/listinfo/python-list


Re: The Industry choice

2005-01-01 Thread Hans Nowak
Donn Cave wrote:
Quoth Hans Nowak [EMAIL PROTECTED]:
| Paul Rubin wrote:
|
| You should write unit tests either way, but in Python you're relying
| on the tests to find stuff that the compiler finds for you with Java.
|
| As I wrote on my weblog a while ago, I suspect that this effect is 
| largely psychological.  You jump through hoops, declaring types all over 
| the place, checking exceptions, working around the language's 
| limitations, etc.  So when your code compiles, it *feels* safer.  Like 
| you're at least part of the way towards ensuring correctness.  All that 
| work must be good for *something*, right?  Never mind that when writing 
| unit tests for a dynamic language, you don't check for these things at 
| all.  How often do you explicitly check types in Python unit tests? 
| IMHO, when using a dynamic language, you don't need most of the checks 
| that Java, C# and their ilk force upon you.

I have been fooling around with strongly, statically typed languages
for a couple of years, in my spare time - Objective CAML, Haskell,
O'Haskell.  This is a little different experience than what you two
are talking about - I don't think Java, C# and their ilk are quite as
rigorous, nor do they use type inference - but as much as it would
probably gag an FP enthusiast to say this, the basic idea is the same.
I can only believe that if you think the benefit of static typing is
psychological, either something is very different between the way you
and I write programs, or you're not doing it right.
I do think it makes more sense in functional languages like the ones you 
mention... that's one of the reasons I am trying to learn OCaml.  I 
don't think the type systems in OCaml, Haskell etc can quite be compared 
to what's used in Java, C#, C++ or Delphi.  So far, I am getting the 
impression that the type system in OCaml is actually there to help you, 
rather than something that gets in your way.

I concur that in my OCaml experiments so far, errors pointed out by the 
compiler made a lot more sense, because they pointed to actual problems, 
rather than being a case of you didn't declare this method as public 
static final.

Of course, it helps that, like Python, said languages (OCaml, Haskell) 
are higher-level than Java/C#/etc, so you can express things concisely 
and clearly.  That might be one of the reasons why static, strong typing 
in VHLLs has a much higher return on investment than it has in 
lower-level languages, where you have to write acres of code just to get 
something done (availability of libraries notwithstanding).

--
Hans Nowak
http://zephyrfalcon.org/
--
http://mail.python.org/mailman/listinfo/python-list


Re: UserDict deprecated

2005-01-01 Thread Hans Nowak
Uwe Mayer wrote:
Why is the UserDict module is deprecated after Python 2.2. The application
of it I have in mind is, i.e. multiple inheritance from file and dic -
which is not possible. 
I am curious, what would you do with a class that derives from both file 
and dict?

--
Hans Nowak
http://zephyrfalcon.org/
--
http://mail.python.org/mailman/listinfo/python-list


Re: UserDict deprecated

2005-01-01 Thread Hans Nowak
Uwe Mayer wrote:
Why is the UserDict module is deprecated after Python 2.2. The
application of it I have in mind is, i.e. multiple inheritance from
file and dic - which is not possible.
[...]
I was writing a class that read /writes some binary file format. I
implemented the functions from the file interface such that they are
refering to records. However, the file format has some header fields and
I'd wanted to grant access to those via the dict-interface.
Another example: working with PyQt I have an instance of a QListView and
wanted to use the list-interface to get and set individual records.
If it's just a matter of attribute access, implementing the relevant 
__getitem__ and __setitem__ methods will probably suffice.  I don't 
think that deriving from dict or list will do you much good here... most 
of the methods will be irrelevant, or won't do what you want, so you 
have to override them anyway.

--
Hans Nowak
http://zephyrfalcon.org/
--
http://mail.python.org/mailman/listinfo/python-list


Re: The Industry choice

2004-12-31 Thread Hans Nowak
Paul Rubin wrote:
You should write unit tests either way, but in Python you're relying
on the tests to find stuff that the compiler finds for you with Java.
As I wrote on my weblog a while ago, I suspect that this effect is 
largely psychological.  You jump through hoops, declaring types all over 
the place, checking exceptions, working around the language's 
limitations, etc.  So when your code compiles, it *feels* safer.  Like 
you're at least part of the way towards ensuring correctness.  All that 
work must be good for *something*, right?  Never mind that when writing 
unit tests for a dynamic language, you don't check for these things at 
all.  How often do you explicitly check types in Python unit tests? 
IMHO, when using a dynamic language, you don't need most of the checks 
that Java, C# and their ilk force upon you.

--
Hans Nowak
http://zephyrfalcon.org/
--
http://mail.python.org/mailman/listinfo/python-list


Re: what is lambda used for in real code?

2004-12-31 Thread Hans Nowak
Adam DePrince wrote:
In sort, we must preserve the ability to create an anonymous function
simply because we can do so for every other object type, and functions
are not special enough to permit this special case.
Your reasoning makes sense... lambda enables you to create a function as 
part of an expression, just like other types can be part of an 
expression.  However, by that same reasoning, maybe classes aren't 
special enough either to warrant a special case.  Where's the keyword to 
create an anonymous class? :-)

--
Hans Nowak
http://zephyrfalcon.org/
--
http://mail.python.org/mailman/listinfo/python-list


Re: copying classes?

2004-12-30 Thread Hans Nowak
Jeff Epler wrote:
Here's an example of attempting to deepcopy a class:
class X: pass
... 

import copy
X is copy.deepcopy(X)
Traceback (most recent call last):
  File stdin, line 1, in ?
  File /usr/lib/python2.2/copy.py, line 179, in deepcopy
raise error, \
copy.Error: un-deep-copyable object of type type 'class'
Weird.  I get (Python 2.3.4):
 class X: pass
...
 import copy
 X is copy.deepcopy(X)
True
However:
 class Foo:
... def bar(self, x, y, z): pass
...
 import copy
 FooCopy = copy.deepcopy(Foo)
 FooCopy
class __main__.Foo at 0x0142FE70
 Foo
class __main__.Foo at 0x0142FE70
It appears it doesn't copy the class at all, you just get the same class 
back.

--
Hans Nowak
http://zephyrfalcon.org/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Why tuples use parentheses ()'s instead of something else like 's?

2004-12-28 Thread Hans Nowak
[EMAIL PROTECTED] wrote:
Tuples are defined with regards to parentheses ()'s as everyone knows.
This causes confusion for 1 item tuples since (5) can be interpreted
as a tuple OR as the number 5 in a mathematical expression
such as x = (5) * (4+6).
No, (5) is always the number 5.  To make a one-element tuple, use (5,).
Wouldn't it have been better to define tuples with 's or {}'s or
something else to avoid this confusion??
Perhaps ()'s are a good idea for some other reason I don't know?
Actually, for non-empty tuples, the parentheses aren't really necessary, 
unless code is ambiguous.

 x = 1, 2, 3
 x
(1, 2, 3)
 y = 5,
 y
(5,)
but:
 print 8, 9  # not a tuple
8 9
 print (8, 9)
(8, 9)
HTH,
--
Hans Nowak
http://zephyrfalcon.org/
--
http://mail.python.org/mailman/listinfo/python-list


Re: What is on-topic for the python list [was Re: BASIC vs Python]

2004-12-21 Thread Hans Nowak
Doug Holton wrote:
Steve Holden wrote:
'Scuse me? This group has a long history of off-topic posting, and 
anyway who decided that CPython should be the exclusive focus? Even 
on-topic we can talk about Jython and PyPy as well as CPython.
I agree with your point, although Hans Nowak and others may not. 
Anything related to python or from the perspective of a current or 
potential python user is on-topic for this list.  We can talk about 
logo, jython, java or other topics whenever and whereever we want.  If 
you can't accept free speech and different perspectives, you're going to 
be disappointed.  But please do not react by trying to intimidate and 
troll others here.
Now you're trying to make it seem like I am against free speech on this 
list, and against people's rights to discuss whatever they want.  I 
never said that, and I in fact enjoy the fact that c.l.py posters are an 
eclectic bunch who have knowledge of, and like to talk about, a great 
number of topics.

Boo is not related to Python.  Aside from a superficial resemblence, 
it's not like Python at all.  In spite of that, you would have been 
welcome to post about it (and still are), if it wasn't for your earlier 
behavior... claiming to a newbie that Boo is virtually identical to 
Python 
(http://groups-beta.google.com/group/comp.lang.python/msg/0c266cf441a46081), 
then calling people who question that claim trolls, and pretending 
that you said Boo's syntax is virtually identical all along.  That is 
what got you into hot water with a few posters here (and more and more 
as you keep calling people names and putting words in their mouths). 
This is also what inspired my this is comp.lang.python, not 
comp.lang.boo remark.  People didn't take offense at the fact that you 
discussed Boo here, but at how you did it.

Funny; *you* are the one who keeps spreading misinformation, first of a 
technical nature, then about people.  Yet you have the nerve to call 
other people trolls?

--
Hans Nowak
http://zephyrfalcon.org/
--
http://mail.python.org/mailman/listinfo/python-list


Re: What is on-topic for the python list [was Re: BASIC vs Python]

2004-12-21 Thread Hans Nowak
Doug Holton wrote:
Hans Nowak wrote:
Now you're trying to make it seem like I am against free speech on 
this list, and against people's rights to discuss whatever they want.  
I never said that, and I in fact enjoy the fact that c.l.py posters 
are an eclectic bunch who have knowledge of, and like to talk about, a 
great number of topics.

You said that boo should not be mentioned on this newsgroup.  
Please point me to the post where I said that.  Since everything is 
stored in Google Groups, it should be easy for you to come up with an 
URL... if such a post existed.

--
Hans Nowak
http://zephyrfalcon.org/
--
http://mail.python.org/mailman/listinfo/python-list


Re: What is on-topic for the python list [was Re: BASIC vs Python]

2004-12-21 Thread Hans Nowak
Doug Holton wrote:
Hans Nowak wrote:
Quote:
this is comp.lang.python, not comp.lang.boo.

Which is obviously not the same as Boo should not be mentioned on 
this newsgroup.  
I used the exact same phrase in another note except using the term 
logo instead of boo, and that is the exact interpretation I 
immediately received from others - they felt I was censuring the 
discussion here, as I felt you were.
Maybe they felt that way because, in your case, it was followed by the 
innocent little sentence Please refrain from discussing topics not 
related to CPython.?

  The discussion with Logo and other languages in it was off-topic too,
  but it wasn't offensive to anyone.
I'm not going to dignify that or the rest of your note with a response.
No, by all means, let's ignore any pieces of a post that might lead to 
constructive discussion.

Well, it's been fun, but I really don't have time for this.  If we 
cannot end this thread with some kind of mutual understanding, then I 
will end it unilaterally.  You have the dubious honor of being the first 
person in my killfile since 1997.

--
Hans Nowak
http://zephyrfalcon.org/
--
http://mail.python.org/mailman/listinfo/python-list


Re: how to pass globals across modules (wxPython)

2004-12-20 Thread Hans Nowak
Martin Drautzburg wrote:
My wxPython program starts execution in mainFrame.py like this
[...]
class MainApp(wxApp):
def OnInit(self):
self.mainFrame = MainFrame(None)
self.mainFrame.Show()
self.SetTopWindow(self.mainFrame)
return True
def main():
global application
application=MainApp(0)
application.MainLoop()
if __name__ == '__main__':
main()
I need to access the application object from other modules, actually
the windows and frames that live therein and I don't know how to do
this.
If you just need to access the running application from other wxPython 
objects, then wx.GetApp() is your friend.

--
Hans Nowak
http://zephyrfalcon.org/
--
http://mail.python.org/mailman/listinfo/python-list


Re: Boo who? (was Re: newbie question)

2004-12-20 Thread Hans Nowak
Doug Holton wrote:
Istvan Albert wrote:
Doug Holton wrote:
the syntax of boo is indeed virtually identical to python.  

All that boo does is borrows a few syntactical constructs
from python. Calling it virtually identical
is *very* misleading.

The syntax is indeed virtually identical to python.  You are yet another 
person who has trolled before.  See your obvious trolling reply here, 
for example:
http://groups-beta.google.com/group/comp.lang.python/messages/c57cf0e48827f3de,a750c109b8ee57c3,cf89205a5e93051e,cfb1c7453e1f3c07,58a2dedd1059783e,8a1ee82cc328d023,7a51cdc9ffecbc72,38304f35cb42bb63,fc5e4ae1cbae0248,2de118caa7010b30?thread_id=5a7018d37b7bf4b8mode=threadnoheader=1q=boo#doc_a750c109b8ee57c3 

Do you have financial conflict of interest too like Fredrik?  Or is it 
just a psychological issue?  I have no stake in python or any other 
language changing or not changing.  You guys need to accept change 
rather than fear it.
Regardless of the merits of Boo, this is comp.lang.python, not 
comp.lang.boo.  The language may *look* like Python, but its inner 
workings are nothing like Python, as several people have correctly 
pointed out now.  (Just like Java's syntax may look like C or C++ in 
some areas, but the languages are nowhere near alike.)  Pointing out the 
difference is not trolling.

--
Hans Nowak
http://zephyrfalcon.org/
--
http://mail.python.org/mailman/listinfo/python-list