/pub/a/2006/01/11/from-microsoft-to-openoffice.html
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
are
making the very same mistake. XML may look somewhat simple but
producing correct XML and parsing it isn't. Sooner or later you stumble
across something that breaks producing or parsing the naive way.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
()` might be handy.
And you have to think about digits in the source if that's allowed.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
mode.
Windows alters line endings and stops at a specific byte (forgot the
value) otherwise.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
(do_something, old)
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
On Tue, 11 Dec 2007 17:58:37 -0800, mariox19 wrote:
If I am supposed to send messages to Tkinter objects only from the
main thread, how can I get the letters to appear 1 per second?
Take a look at the `after()` method on widgets.
Ciao,
Marc 'BlackJack' Rintsch
--
http
On Tue, 11 Dec 2007 20:08:21 -0300, Gabriel Genellina wrote:
data = [row for row in csv.reader(..)]
A bit shorter::
data = list(csv.reader(..))
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
and unusable as you can. Spend the time you planned
for writing documentation for this task. ;-)
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
76 char_ptr = 0
...
109 def get_toks( text ):
110 while line_ptr last_line:
...
So when is a global var global?
When you declare it ``global`` *in the function*. ``global`` on module
level has no effect. IMHO that should emit at least a warning…
Ciao,
Marc 'BlackJack' Rintsch
in xrange(11))
And just for completeness: The given data in the example can be stored in a
list of lists of course:
data = [[randint(0, 10) for dummy in xrange(11)] for dummy in xrange(11)]
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
:
In [469]: a = collections.defaultdict(int)
In [470]: callable(a.default_factory)
Out[470]: True
In [471]: a.default_factory(42)
Out[471]: 42
`a.default_factory` is callable but hardly a method of `a` or `defaultdict`
but a data attribute that happens to be callable.
Ciao,
Marc 'BlackJack
,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
-- everything on an
object is an attribute. ;-)
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
On Sat, 08 Dec 2007 00:34:06 -0800, MonkeeSage wrote:
I think he means callable attributes (methods) and non-callable
attributes (variables).
But not every callable attribute is a method.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
. It is just some unary pluses chained. Maybe
unexpected but no syntax error.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
but the
throw it away part. If you don't keep it, the loop above is even more
efficient than building a dictionary with *all* lines of the file, just to
pick one value afterwards.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
: salutation(t))
In Python 2.5 there's an alternative way with the `functools.partial()`
function:
from functools import partial
# ...
msg = Button(win,
text='Write Something',
command=partial(salutation, tree))
Ciao,
Marc 'BlackJack' Rintsch
the language.
That name is already taken in the programming language domain. There's a
Tiny C compiler for 6510 based targets:
http://www.kdef.com/geek/vic/quetz.html
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
postgresql returns to me.
I hope you don't use Python to access the database, get a tuple back,
convert it to a string and then try to break up that string into a list!?
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
to
explain confused newbies why they can write::
print('hello!')
but this acts strange:
print('hello, my name is ', name)
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
of class '__main__.Parrot'
In [84]: type(Parrot.cmethod)
Out[84]: type 'instancemethod'
In [85]: Parrot.__dict__['cmethod']
Out[85]: classmethod object at 0x9b26434
In [86]: type(Parrot.__dict__['cmethod'])
Out[86]: type 'classmethod'
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org
that decision.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
cat, dog # not always required, but frequently needed
return ', '.join((cat, dog))
Ouch that's bad design IMHO. The need to use ``global`` is a design
smell, if needed *frequently* it starts to stink.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python
that knows?
AFAIK strings of length 1 and strings that would be valid Python
identifiers are treated this way.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
On Sat, 24 Nov 2007 02:54:27 -0800, samwyse wrote:
On Nov 24, 4:07 am, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote:
On Sat, 24 Nov 2007 01:55:38 -0800, samwyse wrote:
I've had the same thought, along with another. You see, on of my pet
peeves about all OO languages that that when
On Sat, 24 Nov 2007 14:09:04 +0100, Ton van Vliet wrote:
On 24 Nov 2007 08:48:30 GMT, Marc 'BlackJack' Rintsch [EMAIL PROTECTED]
wrote:
On Sat, 24 Nov 2007 09:12:34 +0100, Ton van Vliet wrote:
Just bringing up something I sometimes miss from good-old Turbo-Pascal
here, which has
On Sat, 24 Nov 2007 08:27:56 -0800, samwyse wrote:
On Nov 24, 7:50 am, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote:
On Sat, 24 Nov 2007 02:54:27 -0800, samwyse wrote:
On Nov 24, 4:07 am, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote:
On Sat, 24 Nov 2007 01:55:38 -0800, samwyse wrote
and fails if there's
anything non-ASCII in the string. The `encode()` method is your friend.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
()` is::
comma_separate = ','.join
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
if whitespace is
preserved. What matters is the actual text in the source, not the
formatting. That's left to the browser.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
):
x, y, z = self.__unpack__(x,y,z)
return math.sqrt(x**2 + y**2 + z**2)
What about ``from`` instead of ``by``? That's already a keyword so we
don't have to add a new one.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
.
In the example `min()` finds the object with the lowest `id()`. To change
that you can implement the `__cmp__()` method on your `Block` objects.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
On Mon, 19 Nov 2007 10:50:28 -0800, Jens wrote:
Generating documentation form code is a nice thing, but this pydoc.py
is driving me insane - isn't there are better way?
Epydoc!?
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
`tagOrId` coming from? That's a `NameError` here.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
):
print a + b
a = A()
a.func(3, 5)
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
with those functions.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
realistic imaging for whatever
purpose, 3D is the way to go. If you are after traffic-simulations, it's
unneeded complexity.
Not if their solution includes flying buses and taxis. Or this pneumatic
delivery system for people from `Futurama`. ;-)
Ciao,
Marc 'BlackJack' Rintsch
--
http
no effect on the object bound to that name before.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
to the following perl's search string?
m/^\S{1,8}\.\S{0,3}/
It is ``re.match(r'\S{1,8}\.\S{0,3}', string)``. There's something called
documentation…
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
with it for some reason I can't explain...
chunksize = 26
f = open('datafile.dat', 'rb')
for chunk in iter(lambda: f.read(chunksize), ''):
compute_data(chunk)
f.close()
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
seconds here.
[EMAIL PROTECTED]:~$ time python test.py
real0m38.758s
user0m25.290s
sys 0m1.580s
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
of names and the `pickle` module to store
Python objects in files.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
attributes into computed attributes without changing the API of the
objects.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
in code or they even use this gotcha for
immutable default values. As long a the value isn't changed the default
value is just referenced from the class then and not every instance.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
] ││
│ │││└───┬┘│
│ └───┬┴┴┘ │
│ [S5] │
│ └┘
Program
Sounds pretty much like homework to me.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo
On Sat, 10 Nov 2007 17:39:04 +, Marc 'BlackJack' Rintsch wrote:
On Sat, 10 Nov 2007 18:53:08 +0200, Donn Ingle wrote:
print b.ref.attribute # print haschanged
print j.ref.attribute #prints original value
## If it changed and an attribute of the Class, then
## why is it back to original
On Fri, 09 Nov 2007 02:51:10 -0800, Michel Albert wrote:
Obviously this won't work as you cannot access a slice of a csv-file.
Would it be possible to subclass the csv.reader class in a way that
you can somewhat efficiently access a slice?
An arbitrary slice? I guess not as all records
? Use a crystal ball for the very long distance call? Call
Dr. Frankenstein for help? =:o)
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
it into a Python environment. This doesn't mean it
will fit into the language or scales beyond the small toy examples. What
about function names in tracebacks? What about nesting these anonymous
multiline functions? What about the impact on the grammar?
Ciao,
Marc 'BlackJack' Rintsch
--
http
On Thu, 08 Nov 2007 22:53:16 -0800, r.grimm wrote:
(1).__cmp__(10)
-1
As the dot is an operator like ``+`` or ``/`` you can also add spaces to
avoid the ambiguity:
In [493]: 1 . __cmp__(10)
Out[493]: -1
In [494]: 1 .__cmp__(10)
Out[494]: -1
Ciao,
Marc 'BlackJack' Rintsch
--
http
, other.value)
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, 07 Nov 2007 18:35:51 +, kyosohma wrote:
I've never had to put the command into a list or tuple...but you're
welcome to try it that way.
You don't *have* to but if you do the module takes care of quoting the
arguments if necessary.
Ciao,
Marc 'BlackJack' Rintsch
--
http
the 'datetime.date.today()'.
Build a `datetime.date` object from the timestamp you get from the stat
call:
In [438]: !touch test.py
In [439]: datetime.date.fromtimestamp(os.stat('/home/bj/test.py').st_ctime)
Out[439]: datetime.date(2007, 11, 6)
Ciao,
Marc 'BlackJack' Rintsch
--
http
On Tue, 06 Nov 2007 01:45:02 -0800, awel wrote:
On 6 nov, 09:00, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote:
On Mon, 05 Nov 2007 23:33:16 -0800, awel wrote:
I am trying to to make a script to move all the files that has been
created at today's to another folder but my problem
the call I made and the result I got. How can I
be more clear and precise!?
Ok but I run in Windows and I cannot understand your '!touch test.py'
Ah, sorry this was just to create and/or make sure that the file exists
and has today's date.
Ciao,
Marc 'BlackJack' Rintsch
--
http
. If that module has an
``import inspect`` it imports *itself*!
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
and not a string. The object itself decides what
`repr(obj)` returns. Soup objects represent themselves as UTF-8 encoded
strings.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
')`` part which
fails because the 'end' is already gone.
Is there a way to get pyparsing to parse a grammar like this?
Negative lookahead maybe:
grammar = (OneOrMore(NotAny(Literal('end')) + Word(alphas))
+ Literal('end'))
Ciao,
Marc 'BlackJack' Rintsch
--
http
with `numpy`. It should be faster to shift
and or a whole array instead of every pixel one by one in pure Python.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
.
And what should ``'string'.find('str')`` return? How do you distinguish
the not found at all case from the found at the very beginning case!?
The simple test you want can be written this way:
if 'something' in check:
do(something_else)
Ciao,
Marc 'BlackJack' Rintsch
--
http
and look up the docs for the `startswith()` method on
strings.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
record of the data at a time?
Have you tried `iterparse()`?
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
intention. He wanted to give the
optional third argument of `getattr()` as keyword argument.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
, seq):
return zip(seq, map(func,seq))
table(len, ('', (), []))
table(lambda x:x.__len__(), ('',[],()))
What was the point again ?
Beautiful is better than ugly!? ;-)
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
.
Don't do that. Catch the specific exception you want to handle with an
``except`` and not simply *all*.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
something(lines):
for line in lines:
print lines
And the call it with the object.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
exactly
the same as normal functions.
As Steven D'Aprano showed they behave like normal functions. Even pure
Python functions can have arguments without names:
def spam(*args):
pass
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
().spammify(eggs)`` instead of a plain
function call.
And functions are first class objects in Python. That sounds quite OO to
me. You can think of a module with functions as a singleton.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
* stat.f_blocks
Out[188]: 10741866496L
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
schema design BTW.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
ind4 ON test USING btree (w)
CREATE INDEX ind5 ON test USING btree (d)
This isn't a Python question. You'll get more and probably better
feedback in a group, mailing list or forum dealing with PostgreSQL.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
. if the code is wrong it
nonetheless adds assertions that don't fail. I always thought one writes
assertions to test what the code should do and not what it actually does!?
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
function.
#os.rmdir(path)
print Removing: %s % (path, )
#--snap
Or `shutil.rmtree()`. :-)
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
On Sat, 27 Oct 2007 17:57:06 +, [EMAIL PROTECTED] wrote:
On Oct 27, 6:27 pm, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote:
On Sat, 27 Oct 2007 17:10:13 +, [EMAIL PROTECTED] wrote:
http://eigenclass.org/hiki/xmpfilter
looks cool , anything like this for python? any reason that we
implicitly) spells it out?
And the equivalent of ``os.chmod(filename, 0777)`` looks like what!?
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
deep... and I'm not sure how to
resolve it
Resolve *what*? The problem isn't clear yet; at least to me. Above you
say what you get. What exactly do you want? Examples please.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
:27) [MSC v.1310 32 bit
(Intel)] on win32
snip
type(0b1)
type 'int'
type(0o1)
type 'int'
type(0x1)
type 'int'
assert 0b1 is 0x1
That this doesn't raise `AssertionError` is an implementation detail.
It's not guaranteed the two objects are really the same.
Ciao,
Marc 'BlackJack
+',
re.IGNORECASE)
for i, line in enumerate(lines):
if needle.match(line):
print 'match in line %d' % (i + 1)
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
you think it is. The code above, the dots replaced with nothing,
will of course run forever until the stack limit is reached.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
not unicode. Decoding twice
doesn't work.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
, lOptional)
I think there is a better way, but I can't see how...
Drop the prefixes. `l` is for list? `d` is for what!? Can't be
dictionary because the code doesn't make much sense.
Where is `cls` coming from?
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo
, globals().itervalues()))
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
the value of the
wrapped objects attribute.
Or lazy computation of an attribute. Breaks expectations for the first
access -- long calculation for simple attribute access -- but meets it for
every subsequent access.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python
if t_array_length len(result):
result = (result[:t_array_length]
+ func_b(remaining_length)[:remaining_length])
return tuple(result)
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
On Tue, 23 Oct 2007 11:48:08 +0200, Loic Mahe wrote:
even shorter:
def funcA(tarray):
s = min(len(tarray), 3)
return [2, 3, 4][0:s] + [e for e in funcB(3-s)[0:3-s]]
Why the list comprehension!?
Ciao,
Marc 'Blackjack' Rintsch
--
http://mail.python.org/mailman/listinfo
'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
but *instances* of `Base` have.
class Derived(Base):
def __init__(self):
Base.__init__(self)
Base.foo.x = 5
Instances of `Derived` have a `foo` attribute inherited from `Base`. So
the last line should be ``self.foo.x = 5``.
Ciao,
Marc 'BlackJack' Rintsch
--
http
from
Base?
Take a look at the `issubclass()` function.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
On Tue, 23 Oct 2007 21:51:20 +, mrstephengross wrote:
Ok, I see how to use issubclass(). How can I get a list of classes
present in the file?
import module
from inspect import getmembers, isclass
classes = getmembers(module, isclass)
Ciao,
Marc 'BlackJack' Rintsch
--
http
anonymous. How can we accomplish
this wrapping?
The `codecs` module has more than just the `codecs.open()` function. Try
something like this::
sys.stdout = codecs.getwriter('utf-8')(sys.stdout)
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
* `A`. Then `A`
returns
`why` and that is then used as decorator function, i.e. called with
`T.test` as argument.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
.
Maybe (almost) nobody feels the need to generate Python source code. The
language is so dynamic that there are almost always ways to avoid
source code generation.
Maybe you can generate a token stream and use `tokenize.untokenize()` to
generate the source code!?
Ciao,
Marc 'BlackJack
501 - 600 of 1496 matches
Mail list logo