nit 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://
Christopher Koppler wrote:
> --
> Christopher
>
> In theory, I'm in love with Lisp,
> but I hop into bed with Python every chance I get.
That reminds me of something my old math teacher used to say... "My wife
is my cathedral, but I pray in every chapel.
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.o
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 th
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?
#x27;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
pment will continue in the same vein. (He may just be putting his
thoughts on paper, but it's the BDFL, so what is one supposed to think?)
I for one will NOT welcome our new static typing overlords. ;-)
--
Hans Nowak
http://zephyrfalcon.org/
--
http://mail.python.org/mailman/listinfo/python-list
" + x[18:]
>>> cPickle.loads(y)
Traceback (most recent call last):
File "", line 1, in ?
ValueError: insecure string pickle
--
Hans Nowak
http://zephyrfalcon.org/
--
http://mail.python.org/mailman/listinfo/python-list
nks for the tip, man!
--
Hans Nowak
http://zephyrfalcon.org/
--
http://mail.python.org/mailman/listinfo/python-list
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
Bill Mill wrote:
On Fri, 28 Jan 2005 11:09:16 -0500, Hans Nowak <[EMAIL PROTECTED]> wrote:
>
To add m as a new method to the *class*, do this:
>>> class test:
... def __init__(self, method):
... self.__class__.method = method
... self.method()
...
>>&
eason, "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
;>> 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
lp', '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
plex form with grids,
explorer like trees etc. in 2 minutes in standard python.
To be fair, this is more a property of a GUI builder than of a language...
--
Hans Nowak
http://zephyrfalcon.org/
--
http://mail.python.org/mailman/listinfo/python-list
ication" 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.py
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
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 other
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 knowled
Doug Holton wrote:
Hans Nowak wrote:
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.
Quote:
"th
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 o
ally 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
oo)
>>> FooCopy
>>> Foo
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
-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
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
eColor=(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
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
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
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:
>>
&
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
ject_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
derstand 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
t 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
ve 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
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
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
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}
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 proc
[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 e
[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[secti
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, al
this:
>>> import foo
Traceback (most recent call last):
File "", 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)
ht
;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
e 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
odule, 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
.
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
, 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
w 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 (zephyrfal
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
ses__()")
Traceback (most recent call last):
File "", line 1, in
File "safe_eval.py", line 12, in safe_eval
return eval(s)
File "", 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
[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 g
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
n-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
53 matches
Mail list logo