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
' 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
...:
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
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
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
:
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
.
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
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
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
) 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
when you import the module.
--
Hans Nowak (zephyrfalcon at gmail dot com)
http://4.flowsnake.org/
--
http://mail.python.org/mailman/listinfo/python-list
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
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,
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 =
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
[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
[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
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
these; this will
probably be solved in the next release.
--
Hans Nowak
http://zephyrfalcon.org/
--
http://mail.python.org/mailman/listinfo/python-list
... 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
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
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
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
not...)
--
Hans Nowak
http://zephyrfalcon.org/
--
http://mail.python.org/mailman/listinfo/python-list
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:
... for u in 3,14,10)
which would shave off a character. Tuples don't always need
,
--
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
, 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
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
the
inspect module.
--
Hans Nowak
http://zephyrfalcon.org/
--
http://mail.python.org/mailman/listinfo/python-list
:
... 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
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
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:
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
!
--
Hans Nowak
http://zephyrfalcon.org/
--
http://mail.python.org/mailman/listinfo/python-list
: insecure string pickle
--
Hans Nowak
http://zephyrfalcon.org/
--
http://mail.python.org/mailman/listinfo/python-list
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
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
to override them anyway.
--
Hans Nowak
http://zephyrfalcon.org/
--
http://mail.python.org/mailman/listinfo/python-list
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
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
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
= 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
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
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
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
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
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
49 matches
Mail list logo