the
whole thing hangs. You wait for something on `o` and the process waits
for you to read from `e` → deadlock.
You have to use threads to read both `o` and `e` or the `select` module to
look which file has something to read.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
256 for x in xrange(width) for y in xrange(height)]
image.putdata(data)
image.save('test.png')
`data` can be any iterable with byte values.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
ting lists with a custom ordering,
> functional progamming merely a convenience, and can be done without.
``for`` loops are just a convenience, you can do without. ;-)
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
who are not interested in the language
themselves. There are platforms like guru.com or rentacoder.com for such
assignments.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
gt;>
> Well D code is compiled into machine code that runs via a VM.
About which D are we talking here? Not digital mars' successor to C++,
right!?
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
ional+OO programming language,
> where small statements like print, assert, raise etc. all become
> functions and statements like while, for, with etc. become anonymous
> closures.
Before someone starts to create such a thing he should take a look at Io
which has just objects and meth
e
ancestors. It should be easy to override `Object clone` in Io, so all
slots of the ancestor are shallow copied to the clone, but I guess this
might break existing code. At least for your own code you could introduce
a `realClone` slot.
Ciao,
Marc 'BlackJack' Rintsch
--
http:
On Sat, 22 Sep 2007 17:13:14 +0530, Amit Kumar Saha wrote:
> BTW, do we have something like array of objects here?
Like someone already said: lists.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
On Sat, 22 Sep 2007 06:58:57 -0700, Kay Schluehr wrote:
> On Sep 22, 1:15 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
>> On Sat, 22 Sep 2007 02:44:35 -0700, Kay Schluehr wrote:
>> > I checked out Io once and I disliked it. I expected Io's proto
average = float(num1 + num2 + num3 + num4 + num5) / 5
This is very strange. You have a list of floats (I guess), convert that
list to a string, split that string at commas, concatenate the *strings*
between commas and then try to convert it to a `float`!? This is likely
not what you want and
On Sat, 22 Sep 2007 13:00:27 -0700, Python Maniac wrote:
> On Sep 21, 11:39 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
>> On Fri, 21 Sep 2007 16:25:20 -0700, Python Maniac wrote:
>>
>> > Well D code is compiled into machine code that runs via
On Sat, 22 Sep 2007 21:17:38 +, Bryan Olson wrote:
> The operator module offers pow(). Is there any good reason for
> pow() as a built-in?
The `operator.pow()` is just the function for ``**``, it lacks the
optional third argument of the built in `pow()`.
Ciao,
Marc
n. It is really much like the class/instance
relationship in Python with just the line between class and instance
blurred.
> You can do this by overwriting the objects slots but then you end up
> writing your own object constructors and the templates accordingly, also
> named "
if arg == '-no':
# ...
If you need the element *and* an index:
for i, arg in enumarate(args):
# ...
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
ables.
> |
Where the heck does *this* come from? Neither Python 2.5.1 nor the
3.0alpha has this in `__builtin__`.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
you delete one attribute and miss renaming the others, and in
> general it's not good design to have arbitrary numbers of parameters.
Quite the same is true for numbers in tag names. If you (the OP) need to
number the rules better use an attribute for the numbers.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
t 'register_for_key_events()'
def _dummy_handler(self):
pass
_dummy_handler.dummy = True
on_key = _dummy_handler
on_whatever = _dummy_handler
class MyHandler(EvtHandler):
def on_key(self):
print 'Do something...'
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
n approximate float value was printed, but even
> with %.12f, the second gives exactly 1.000
Tuples are printed with calling `repr()` on the objects:
In [144]: str(0.1)
Out[144]: '0.1'
In [145]: repr(0.1)
Out[145]: '0.10001'
In [146]: '%.12f'
On Tue, 25 Sep 2007 03:30:05 -0700, Anand wrote:
> I'm Afraid to say, I can't use lxml or elementTree as it requires many
> legal approvals and there is high chances of not getting it through.
In what environment is it hard to get something BSD licensed through!?
Ciao,
osit3 = string.split(line, "\t")
>
> I have 4 strings to match line 3 and 3 to match the 3 on line 4...any
> thoughts?
First thought is to find out which of the two lines triggers the
exception. This information is part of the full traceback.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
#x27;b', 'c', 'd', 'e', 'f']
In [267]: 'c' in a
Out[267]: True
In [268]: 'c' in a == True
Out[268]: False
In [269]: ('c' in a) == True
Out[269]: True
In [270]: 'c' in (a == True)
--
ist` is not empty:
some_list.extend(list_of_backup_files)
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
On Thu, 27 Sep 2007 17:06:30 +, Duncan Booth wrote:
> Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
>
>> In [268]: 'c' in a == True
>> Out[268]: False
>>
>> In [269]: ('c'
guages.
Don't know if C#'s delegates qualify.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
d)
> still needs to be generated. Calling the lib from python or from C,
> there still
> needs to be a way to generate 100+ test routines. ;-)
Instead of reading the testcase tables and generating source for test
routines you simply can do the tests right away.
Ciao,
Marc 'BlackJa
y modules.
Oh come on, this is unnecessary nitpicking. Importing the module
`__init__` from a package using the name of the package is close enough to
justify the phrase "I import the package" IMHO.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
.
> Because when I read the text node in python and it is not
> included, I see no reason why it should be preserved.
But it should be included.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
don't seem
to share your definition of `variable` above.
To me a `variable` is made of a name, a memory address, a data type, and
a value. In languages like C the address and type are attached to the
name while in Python both are attached to the value.
Ciao,
Marc 'Bla
gt; the fastest method please help me.
>>
>> Research the "set" data type. :)
>>
> Probably not a very helpful suggestion given that ordering is stated to
> be very important.
A `set()` can be part of such a solution.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
On Sat, 06 Oct 2007 19:16:47 +1300, Lawrence D'Oliveiro wrote:
> In message <[EMAIL PROTECTED]>, Marc 'BlackJack' Rintsch
> wrote:
>
>> To me a `variable` is made of a name, a memory address, a data type, and
>> a value. In languages like C the address
o
>>>> b=Bar()
>>>> b.callMethods()
> _foo
>>>> del b
>>>>
>
> Foo looses the reference to its method but Bar on the other hand has a
> refloop and
> never gets deleted.
``del b`` just deletes the name `b`. It does not delete the
class
definition.
When you call `Child1.increment()` the class method will be called with
`Child1` as first argument. Now ``cls.a += 1`` is executed which is
somewhat like a short form of ``cls.a = cls.a + 1``. So this is reading
the attribute `a` from `Child1` and then bind the result to `Chil
*is* assigned to `L` and not
just mutated in place.
In [107]: class A:
.: a = list()
.:
In [108]: class B(A):
.: pass
.:
In [109]: B.a += [42]
In [110]: A.a
Out[110]: [42]
In [111]: B.a
Out[111]: [42]
If it was just mutation then `B.a` would have triggered
On Tue, 09 Oct 2007 22:43:16 +, Steven D'Aprano wrote:
> On Tue, 09 Oct 2007 19:46:35 +0000, Marc 'BlackJack' Rintsch wrote:
>
>> On Tue, 09 Oct 2007 18:08:34 +, Steven D'Aprano wrote:
>>
>>>>>> L = []
>>>>&
otes/hw/example2'))
>
> Why the difference?
Pickles are *binary* files, not text files, so make sure you always treat
them as binary, e.g. opening the files with mode 'rb' and 'wb' and don't
transmit them in text mode over FTP etc.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
function object is created and bound to the local name `wrapper`. The
name `func` in that new function object refers to the object bound to
`func` in the `require_int` namespace. Then the new function is returned
still carrying a reference to the `func` object that was passed into
`require_int`.
On Wed, 10 Oct 2007 15:21:06 +, Alan Isaac wrote:
> Marc 'BlackJack' Rintsch wrote:
>> Pickles are *binary* files, not text files
>
> Actually not:
> http://docs.python.org/lib/node316.html
>
> These were created with protocol 0.
Actually yes, the docs a
;8]
>>
>> Why use xrange if you convert it to a full list in place? No
>> advantage there.
>
> What is the dis-advantage of using xrange over range in this circumstance?
It's an unnecessary intermediate step.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
ll but the last string are already
concatenated and the last one does not fit into the allocated memory
anymore, so there is new memory allocates that can hold both strings ->
double amount of memory needed.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
On Thu, 11 Oct 2007 07:02:10 +, thebjorn wrote:
> On Oct 11, 8:53 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
>> Even if `str.join()` would not convert the generator into a list first,
>> you would have overallocation. You don't know th
me what I
> am doing wrong?
You are trying to use a method that does not exist. That `gdbm` object
doesn't have a `get()` method.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
"generation" of instance field '_name' and
> default getters and setters.
But why? Default getters and setters are unnecessary and if you need
something other than the default you need to write it anyway more
explicitly.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
On Thu, 11 Oct 2007 13:04:53 +, Artur Siekielski wrote:
> On Oct 11, 2:27 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
>> But why? Default getters and setters are unnecessary and if you need
>> something other than the default you need to write it an
ly to
`None` if the real value is not available at that time, and document at
least the public ones in the class' docstring. Tools like `pylint` check
for attributes that are introduced in other methods than `__init__()` and
give a warning.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
On Thu, 11 Oct 2007 09:58:48 -0700, Dan Stromberg wrote:
> On Thu, 11 Oct 2007 13:46:12 +0000, Marc 'BlackJack' Rintsch wrote:
>
>> On Thu, 11 Oct 2007 13:04:53 +, Artur Siekielski wrote:
>>
>>> 1. If I use instance field 'name' which is access
me.package.myclass import MyClass
> name = MyClass.__name__
>
> The value for name will be "MyClass"
>
> Is there a comparable way to get the fully qualified name (package, module,
> and class name) in Python?
Take a look at the `__module__` attribute of the class
.chdir(name)
for zip_name in glob.glob('*.gz'):
in_file = gzip.GzipFile(zip_name, 'r')
out_file.writelines(islice(in_file, 1, None))
in_file.close()
os.chdir(os.pardir)
out_file.close()
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
y!? Then of course I get A\xcc\x88 because that's what I
entered. In string literals in source code the backslash has a special
meaning but `raw_input()` does not "interpret" the input in any way.
> And what is it that your keyboard enters to produce an 'a' with an umlaut?
*I* just hit the ä key. The one right next to the ö key. ;-)
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
On Fri, 12 Oct 2007 19:09:46 -0700, 7stud wrote:
> On Oct 12, 2:43 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
>> You mean literally!? Then of course I get A\xcc\x88 because that's what I
>> entered. In string literals in source code the ba
st would contain more than one element all would be processed
but only the last is bound to `words`. You could leave out `chem_file` and
the loop and simply do:
words = input.read().split()
Same effect but less chatty. ;-)
The rest of the source seems to indicate that you don't really want to read
in the whole input file at once but process it line by line, i.e. chemical
element by chemical element.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
l showed you.
> Also, when I try output.write(tokens), I get "TypeError: coercing to
> Unicode: need string or buffer, list found".
`tokens` is a list but you need to write a unicode string. So you have to
reassemble the parts with '|' characters in between. Also shown b
behavior of PyDev?
I can confirm and it's something I would expect. It is obvious to *you*
that there is a `One` object in that list, but it would get very quickly
very complicated for an IDE to keep track of objects if not even
impossible.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
File "C:\wks\python-wks\reverse.py", line 2, in reverse
>>
>> if xs == []:
>>
>> RuntimeError: maximum recursion depth exceeded in cmp
>>
>>
>>
>> What's wrong? Why recursion never stops?
Becauese you test if `xs` is an empty list which is never true when you
call the function with a string. So it never ends. '' != []
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
On Mon, 15 Oct 2007 11:31:59 +0200, amdescombes wrote:
> Are there any classes that implement disk based dictionaries?
Take a look at the `shelve` module from the standard library.
Or object databases like ZODB or Durus.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.pytho
yield (nr_a, nr_b, ' '.join(items[:-1]), items[-1])
def main():
in_file = codecs.open('test.txt', 'r', 'utf-8')
tokens = in_file.read().split()
in_file.close()
for element in iter_elements(tokens):
print '|'.join(element)
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
get from java's BufferedImage.getRGB(x,y) ..
>
> i am wondering if someone can advise me on how i can do this
Just pack the RGB values into an `int` by shifting and or-ing. Untested:
red, green, blue = img.getpixel(x, y)
pixel_as_int = red << 16 | green << 8 | blue
Ciao,
ur worry: memory or time? The result string will be very
>>very very big.
>
> It's an interesting mental exercise to try to figure out just how large
> that string will be, without using Python.
>
> I get 30,888,889 bytes...
I think you have an off by one error here. (One number, not one byte) :-)
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
: [1, 2, 2005]
In [423]: month, day, year = map(int, '1/2/2005'.split('/'))
In [424]: a = datetime.date(year, month, day)
In [425]: b = datetime.date.today() - a
In [426]: b.days
Out[426]: 1017
Maybe you should read the docs next time. ;-)
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
On Tue, 16 Oct 2007 18:10:54 +1000, Ben Finney wrote:
> Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> writes:
>
>> On Tue, 16 Oct 2007 12:33:33 +0530, krishnakant Mane wrote:
>>
>> > firstly, I can't get a way to convert a string like "1/2/2
teSession(&Handle);
> status = DFFTSSetSessionOption(Handle, DFFTSOPT_ITERATIONS,
> &iteration, sizeof(iteration));
If this "handle" is always just treated as a pointer to an opaque data
structure you may just use a void pointer.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
On Tue, 16 Oct 2007 15:55:31 +, danfolkes wrote:
> Why does the message send only once?
>
> The node sends once, then fails after that.
Because the `Server` just seems to handle the first connection and is done
then. Insert some ``print``\s to see what's going on.
Ciao
ght be the license of the GUI
toolkit.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
; []
>>>> B.l.append('1')
>>>> B.l
> ['1']
>>>> B.__dict__
> {'__module__': '__main__', '__doc__': None}
>>>> B.l.__iadd__('2')
> ['1', '2']
Here you see tha
at design.
Simply not to introduce special cases I guess. If you write ``x.a += b``
then `x.a` will be rebound whether an `a.__iadd__()` exists or not.
Otherwise one would get interesting subtle differences with properties for
example. If `x.a` is a property that checks if the value satisfies some
constraints ``x.a += b`` would trigger the set method only if there is no
`__iadd__()` involved if there's no rebinding.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
or
>>
>> >>> o.x
>> ['a', 'b', 'c']
>
> Now that's really interesting. I added a print "before" and print
> "after" statement just before and after the self._x = value and these
> *do not get called* after the exception is raised when the third
> element is added.
Well, of course not. Did you really expect that!? Why?
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
key=operator.itemgetter(1),
reverse=True)
return map(operator.itemgetter(0), sorted_items)
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
ble (or more
> "pythonic") as opposed to using map / filter etc.?)
Some say yes.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
; hope that one day it will be simpler.
I'm using the following "dummy" class with a little extra functionality:
def Bunch(object):
def __init__(self, **kwargs):
self.__dict__.update(kwargs)
person = Bunch(name='Eric', age=42)
print person.name
point = Bunch(x=4711, y=23)
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
terms yes, strings in Python can contain any byte value. If you
want to put this into a database you need a BLOB column or encode it as
base64 or something similar more ASCII safe.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
g wrong with
> my opinions or do i need a "gotcha"?
The package system is not insufficient but could solve your problem
actually. Don't put all your modules simply in the same directory but in a
package so that your `whatever.pickle` does not clash with the standard
`pickle
be a tty or otherwise 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
lled, why? there is no code to call it.
There is: [EMAIL PROTECTED]()``. Parenthesis means *calling* `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
any 'official'
> thing on the subject.
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
This way you at least see that there is no real docs and
tools like `pylint` can point out the missing docs.
There are editors with good template support for the small amount of
boilerplate that's left.
Just in case you want to defend the default getters and setters: read up
on properties, i.e. the `property()` function, and the discussions in this
group about Python not being Java.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
.
You say you are *parsing* the file but this is an *encode* error. Parsing
means *decoding*.
You have to show some code and the actual traceback to get help. Crystal
balls are not that reliable. ;-)
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
my loop.
It should not run at all as it is indented inconsistently. If that
problem is corrected it will stop with a `NameError` because you try to
read `population` before anything was assigned to it.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
upper case letters, digits and periods. To
limit this to just one optional period the expression gets a little
longer: r'([A-Z]|\d)+\.?([A-Z]|\d)+'
Does not match your second example because there is a lower case letter in
it.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
say `is_active`, and a wrapper
that has a property with the same name that returns 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.
t_array_length = len(t_array)
remaining_length = len(result) - t_array_length
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:
d before assignment.
> Isn't the if statement supposed to keep python from going there since if
> they didn't enter any input, the length of the list should just be zero.
Which list? If the branch for ``choice == 1`` isn't executed then the
list will never be created an the name `nums` doesn't exist.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
; class Base:
> def __init__ (self):
> self.foo = Foo()
`Base` has no `foo` attribute 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
e a way I can find out the classes that have been derived 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'
e:
> lOptional.append(arg)
> return (lMandatory, 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,
itertools import ifilter
classes = set(ifilter(isclass, globals().itervalues()))
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
f `int` with the values 1 and 0 it's
possible to replace the dictionary by a list:
tmp = [[], []]
for arg in cls.arguments:
tmp[bool(arg)].append(arg)
return tmp[1], tmp[0]
Maybe that's nicer. Maybe not.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
iterate over the text file line by line and match or
search within the line? Untested:
needle = re.compile(r'create\s+or\s+replace\s+package(\s+body)?\s+',
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
defined so it should working. Or at least it's not the
problem 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
ong? Thanks in advance.
You feed decoded data to `TidyHTMLTreeBuilder`. As the `encoding`
argument suggests this class wants bytes not unicode. Decoding twice
doesn't work.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
#x27;tagA', None, [('tagB', None, ['bobloblaw], None)], None)...
>
> Fact is that my xml is much more 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
> Python 3.0a1 (py3k:57844, Aug 31 2007, 16:54:27) [MSC v.1310 32 bit
> (Intel)] on win32
>
>>>> type(0b1)
>
>>>> type(0o1)
>
>>>> type(0x1)
>
>>>> assert 0b1 is 0x1
>>>>
That this doesn't raise `Assertion
while the latter raises an `IndexError`.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
tual code, i.e. 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
)
> del_tree(subdir)
…and here you are calling the your function recursively which then calls
again `os.walk()` on that subdirectory. That's a little bit too much.
Just use `os.listdir()` (and `os.path.isdir()`) in your recursive 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
>> > look
OK | os.W_OK | os.X_OK)
>
> which explicitly (rather than 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
erting the *value* '019'.
Starting to number tables and the need to dynamically create table names is
usually sign of a bad schema design BTW.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
)
> CREATE INDEX ind3 ON test USING btree (id2)
> CREATE INDEX 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,
ass the
other local to the function.
> Any examples??
def 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
1001 - 1100 of 1811 matches
Mail list logo