Re: Fractions as result from divisions

2009-07-08 Thread Hans Nowak
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
' 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
...: 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

Re: Simple and safe evaluator

2008-06-12 Thread Hans Nowak
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

Re: Newbie question, list comprehension

2008-06-06 Thread Hans Nowak
: 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
. 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

Re: Python and Harry Potter?

2008-06-05 Thread Hans Nowak
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
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
) 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
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
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

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,

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 =

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

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

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

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

Re: Wax: problem subclassing TextBox

2006-10-18 Thread Hans Nowak
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
... 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
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

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

2006-01-09 Thread Hans Nowak
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

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

2006-01-03 Thread Hans Nowak
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
not...) -- Hans Nowak http://zephyrfalcon.org/ -- http://mail.python.org/mailman/listinfo/python-list

Re: python coding contest

2005-12-31 Thread Hans Nowak
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

Re: questions about py2exe and wax

2005-12-30 Thread Hans Nowak
, -- 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
, 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
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
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
: ... 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

Re: Where are list methods documented?

2005-02-01 Thread Hans Nowak
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
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

Re: how to write a tutorial

2005-01-23 Thread Hans Nowak
! -- Hans Nowak http://zephyrfalcon.org/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Funny Python error messages

2005-01-21 Thread Hans Nowak
: 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

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

Re: UserDict deprecated

2005-01-01 Thread Hans Nowak
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
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

Re: what is lambda used for in real code?

2004-12-31 Thread Hans Nowak
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

Re: copying classes?

2004-12-30 Thread Hans Nowak
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
= 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

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

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

Re: how to pass globals across modules (wxPython)

2004-12-20 Thread Hans Nowak
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

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

2004-12-20 Thread Hans Nowak
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