or an "it"?
I'd say "it".
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
se note that there is an extra "0" after "**26 <...>", which
> doesn't appear for the followling cases:*
This 0 is the last digit of `980`. If the string form is very long the
string itself is shortened by leaving out the middle part. It's
irre
'url2': {...
> }
>
> This dictionary will get _very_ big, so I want to write it somehow to a
> file after it has grown to a certain size.
>
> How would I achieve that?
If you want easy access to single 'url' keys then `shelve` might be an
alternative to pickling the whole thing as one big object.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
In <[EMAIL PROTECTED]>, oyekomova
wrote:
> I would like to know how to convert a csv file with a header row into a
> floating point array without the header row.
Take a look at the `csv` module in the standard library.
Ciao,
Marc 'BlackJack' Rintsch
--
http://m
part of `libtiff`:
http://www.remotesensing.org/libtiff/
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
In <[EMAIL PROTECTED]>, py wrote:
> i need to design a GUI for my python app. i heard of wxWidgets and was
> going to look into that, but then I saw wxPython. Why would I use
> wxPython over wxWidgets?
wxPython are the Python bindings to wxWidgets which is a C++ library.
Cia
t_array[index] - filter_value)
if num < 0:
num = 0
if num > 255 * 64:
num = 255 * 64
data.append(num // 64)
return data.tostring()
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
ld return NotImplemented. After
> all, the things you didn't think of are not (yet) implemented.
I think Steven thinks that it is possible that you compare to an object of
a different type which has the same attributes as expected by the
`__eq__()` method. If the first test is `isinstance()` for the "correct"
type you rule out those cases and give a false `False`.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
Mybe you can build your C code as shared library and use `ctypes` to call
the functions from Python:
http://starship.python.net/crew/theller/ctypes/
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
hrough all elements of `m` in the
`count()` method.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
is forbidden in
strings and it's not allowed to leave out a leading zero in numbers, nor
is it allowed to start a number with a unary `+`.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
In <[EMAIL PROTECTED]>, Donn Cave wrote:
> You can replace "mv" with os.rename() if you don't
> care that it will fail when the destination is on a different
> filesystem. Etc.
If you care than use `shutil.move()` instead.
Ciao,
Marc 'BlackJack&
s, and 3 to 5 carriers for each of the two teams, which comes
> out to be quite large.
That's 750 fighter objects. This is not a "large" amount of objects. So
I think it's premature optmization. Especially because you think of using
__slots__ without actually trying if the
this in my XF86Config and I'm in the `video` group::
Section "DRI"
Group "video"
Mode 0660
EndSection
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
nstances.
class Distribution:
def __init__(self):
self.__gr_on_transp = dict()
self.__ostatok_m = dict()
...
This creates *instance variables* which should be deepcopied without
problems.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
#x27;, '4']
In [4]: tuple(b[1:-1].split(','))
Out[4]: ('1', '2', '3', '4')
Ooops, you wanted ints in there:
In [5]: tuple(map(int, b[1:-1].split(',')))
Out[5]: (1, 2, 3, 4)
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
#x27;t fast enough?
>
> In [8]: %time img2 = Image.open('foo.tiff')
> CPU times: user 0.00 s, sys: 0.01 s, total: 0.01 s
> Wall time: 0.03
>
> In [9]: img2.size
> Out[9]: (2400, 4800)
It's fast enough to open the file and read the meta-data. The OP want
f mapping.has_key(ham): pass
# ->
if ham in mapping: pass
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
le:
func(item)
do(orchestra(score), pickle)
do(orchestra(conductor), sequence)
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
t; code?
I don't see how writing other languages and Python parsers and translators
into other representations tells you much about the spirit and idiomatic
*usage* of a language. Your proposal is not about syntax, it's about
semantics. ``obj[:]()`` is basically syntactic sugar for:
``ob
tp://en.wikipedia.org/wiki/Zilog_Z80
>> Essay: "C++ is better than C", agree or disagree? (four word maximum)
>
> STL compile error diagnostics.
So do you agree or disagree!? ;-)
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
e "map()" function for doing
> somethimg with each element of a sequence, if the order of a actions
> not important.
>
> it is easy to read and understandable.
And has the same issue as a list comprehension if all you want is the side
effect of the calls: a useless temporary list full of `None`\s is build.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
quot;.
No, the side effect is the printing of 'From Russia with love.'
IMHO there's a difference between this single `None` that can't be
prevented and abusing a list comprehension or `map()` just for side
effects and not for building a list with meaningful content.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
; ... Makes sense, too, but aren't all functions getting something?
So you may reduce this to just `values()`. On the other hand there is the
convention to name functions and methods as verbs that are "doing"
something.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
> * is the use of magic names encouraged and/or part of good coding
> practice.
What do you mean by "use"? Implement them to override behavior? Yes,
that's their purpose. Invent new magic names? No of course not, they are
special for a reason: preventing name clas
g.
`pylint` reports unused imported names. I don't follow PEP8 only if it's
not possible otherwise. But cyclic imports are bad anyway. :-)
And if the import is *really* expensive and only needed in some special
circumstances.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
;>> from sys import maxint
>>> c = count(maxint)
>>> c.next()
2147483647
>>> c.next()
-2147483648
What I find most disturbing here, is that it happens silently. I would
have expected an exception instead of the surprise.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
In <[EMAIL PROTECTED]>, per9000 wrote:
> On Jun 4, 9:11 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
>> In <[EMAIL PROTECTED]>, per9000 wrote:
>> >
>> > [...]
>> >
>> > So another question emerges:
>> >
In <[EMAIL PROTECTED]>, Peter Otten wrote:
> Marc 'BlackJack' Rintsch wrote:
>
>>>>> from itertools import count
>>>>> from sys import maxint
>>>>> c = count(maxint)
>>>>> c.next()
>> 2147483647
>>&g
By the way, here's what I get if I force the wrong library upon python2.5:
>
> /usr/local/lib/python2.4/lib-dynload $ python2.5
> Python 2.5 (r25:51908, Oct 3 2006, 08:48:09)
> [GCC 3.3.3 (SuSE Linux)] on linux2
Seems to be the same Python version, just build three days earlier and
with a different GCC version. Weird.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
pedia.org/wiki/Lojban
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
Except documenting what's going on and not over(ab)using the reflective
and dynamic nature of Python to the point where the source starts to get
unreadable and too magic, AFAIK there's no special "pythonic"
recommendation. :-)
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
In <[EMAIL PROTECTED]>, Steven
D'Aprano wrote:
> Is there a general Pythonic idiom for efficiently walking over part of a
> sequence without copying it first? Should there be?
What about using `itertools.islice()`:
for e in islice(a, 4):
pass
Ciao,
Marc
mes don't have types in Python, objects do.
`list()` takes an optional argument. Just make sure your derived type
does to and passes this to the base class `__init__()`. Then you can
create an instance like this:
a = MyList([[1, 2, 3], [4, 5, 6, 7]])
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
a
> way of actually running the function.
If you have a function or callable you call it with the "call operator",
which are parenthesis:
In [8]: int
Out[8]:
In [9]: int()
Out[9]: 0
For a random selection of an element from a list look at the
`random.choice()` function.
Ciao,
anguage for a reason. I'm surprised
> at how few Pythonistas are using it six years later.
It would just document intent here because it still gives `float` results
if used with at least one `float` as operands:
In [1]: 10.0 // 2
Out[1]: 5.0
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
depending of the size of the files and memory of
course.
One problem I see is that '\x0c' may not always be the page end. It may
occur in "rastered image" data too I guess.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
---
exceptions.TypeError Traceback (most recent call last)
/home/new/
TypeError: len() of unsized object
> any suggestions are appreciated,
Yes, don't try iterating over objects that are not iterable. ;-)
What you *can* do is iterating over lists, tuples or ot
it with a
named function of course.
> mylist = ['Fred','bill','PAUL','albert']
>
> mylist.sort(key=lambda el: el.lower())
So this becomes:
def keyfunc(el):
return el.lower()
mylist.sort(key=keyfunc)
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
e objects should *always* be "true". An error
is handled via exceptions.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
trings
that produce the data themselves, for example by attaching a counter to a
basename, or extracting the names from XML files, fetching them from a
database etc.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
ode might be okay but if there are external dependencies one can't
checkout on another computer and expect everything to work there.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
> self.__dict__['z'] = self.x * self.y
> return self.__dict__[name]
>
> I tried that, but I get AttributeError: 'A' object has no attribute
> '__dict__'.
That's because you used `__slots__`. One of the drawbacks of `__slots__`.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
In <[EMAIL PROTECTED]>, Jeff Rollin wrote:
> Why do I not see my messages with attached files in the newsgroup, and is
> there any way to configure this?
No, most news servers strip attachments from postings in non-binary
groups. It's a plain text medium.
Ciao,
Marc
ere am I going wrong?
Looking at the indention of the code I would say you just have an
`__init__()` and all other ``def``\s are local functions to that method.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
In <[EMAIL PROTECTED]>, Terry Reedy
wrote:
> | Should I import this to see how
> | many principles this behavior violates?
>
> ???
>
> If you meant 'report' (on SF), please do not.
I think he meant ``import this`` at the Python interpreter.
Ciao,
n't decode bytes in position 0-1:
> invalid data
>
> by in python interactive, it is right
>
>>>> s = u'张三'
>
> why?
Does the "coding comment" match the actual encoding of the source file?
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
think is happening?
Any chance that you have a module called `threading` that is not the one
in the standard library? Perhaps you named the script above `threading.py`!?
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
In <[EMAIL PROTECTED]>, Diez B. Roggisch wrote:
> No need to create the intermediate list, a generator expression works just
> fine:
>
> a = tuple(i for i in range(10))
But `range()` creates the intermediate list anyway. ;-)
a = tuple(xrange(10))
Ciao,
Marc &
ead in threads:
thread.join()
Much shorter, isn't it!? :-)
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
han bsddb might be useful here. An SQL one like
SQLite or maybe an object DB like zodb or Durus.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
t k,v
Why should it be? Why adding something that unreadable and magic instead
of the perfect readable ``for k, v in some_dict.iteritems():``?
And I don't see why it should be ``**``!?
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
All('object')
Out[17]:
[http://download.macromedia.com/pub/shockwave/cabs/flash/
swflash.cab#version=7,0,19,0" width="640" height="400">
http://www.macromedia.com/go/";
getflashplayer="getflashplayer" type="application/x-shockwave-flash"
width="640" height="400" bgcolor="#00" scale="showall">
]
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
In <[EMAIL PROTECTED]>,
[EMAIL PROTECTED] wrote:
> It seems like
>
> x = defaultdict(defaultdict(list))
>
> should do the obvious, but it doesn't.
It *does* the obvious. Parenthesis after a name means: call this object
*now*. Any other behavior wouldn't
quality and detail.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
ser may be
confused at this point and be already in an internal state that sees that
line in a completely different light than you do.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
d in your post is
`ASN.1`_. And there's a secure alternative to `pickle` called cerealizer_.
.. _`ASN.1`: http://pyasn1.sourceforge.net/
.. _cerealizer: http://home.gna.org/oomadness/en/cerealizer/
.. _ConfigObj: http://www.voidspace.org.uk/python/configobj.html
.. _JSON: http://www.json.or
In <[EMAIL PROTECTED]>, stef wrote:
> I just used configparser for the first time and discovered that it
> shuffled all my sections, and the contents of the sections too.
The data is stored in dictionaries.
> This makes human manipulation of the file impossible.
Why so?
Cia
list!? Somehow hard to believe.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
l" data types, Python is about
objects. `map()`, `reduce()`, list comprehension work on arbitrary
iterables so how do you expect SIMD instructions handle this? Even simple
lists contain objects and those don't have to be of the same type.
Ciao,
Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Bytter wrote:
> Marc 'BlackJack' Rintsch escreveu:
>> In <[EMAIL PROTECTED]>, Bytter wrote:
>>
>> > Is there any I&D ongoing about using SIMD [1] instructions, like SSE
>> > [2], to speed up Python, especially
with a "typed list". It's easy to take
an object and completely replace all its attributes so it behaves very
different.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
d at module level. It seems a
common error from people used to declare variables at that level in other
languages.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
; properties were defined/initalized:
That's because you iterate over the instance's `__dict__` and not over the
*class* `__dict__` like Neil does.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
string``. The definition of ``string / float``
is neat too. Something I really miss in everyday programming in Python,
not. ;-)
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
ents in the list. Is this also true if I am using a set or are
> sets represented by a hash table?
Sets are implemented as hash tables.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
in groupby(rows, second):
writer.start('tag2', col2=value)
for value in imap(third, rows):
writer.element('tag3', col3=value)
writer.end('tag2')
writer.end('tag1')
writer.end('document')
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
ut must be read and understood a couple of times, so it's more important
to have clear than short code. With `self` in place you always know which
names are local and which are attributes.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
efault encoding used by your operating system.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
o improve are also very welcome.
Don't use `eval()` if it is not absolutely necessary. Especially if the
input comes from a user it's a security hole. `float()` is the function
to use here.
`mean()` does not work as you try to divide a list by a number.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
CII sources still
work in Python 3000. And this change may be already in a Python 2.x
before P3K.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
t;)
Where's the problem!? ::
re.compile(r''''"''')
Ah, I see -- readability is the problem. :-)
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
x27;s possible to configure many checks in Pylint. For this check it's
possible to give a regular expression for names you don't care if they are
unused.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
& s2
> set([3, 4])
>>>>
>
> It's all in python already. And documented on the web too.
The OP already knows that but does not want to build a new `set`. He just
wants to know efficiently if the sets intersect without actually *doing*
the intersection.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
set_b = set_b, set_a
return any(item in set_a for item in set_b)
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
ne find the location of a built in module?
It's built into the interpreter executable.
In [85]: import _sre
In [86]: _sre
Out[86]:
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
c) way to
> get the behavior I want? (If you haven't guessed, I want a list of (no
> parameter) functions, each of which returns its index in the list.)
Default arguments are evaluated when the function is defined:
In [15]: x = [lambda x=i: x for i in xrange(10)]
In [16]: x[0]()
Out[16]
les, no switch statements...
>
> Is this the method that you would call "Mickey Mouse"?
Maybe, because you've left out all handling of quoting and escape
characters here. Consider this:
erik,viking,"ham, spam and eggs","He said ""Ni!""","line one
line two"
That's 5 elements:
1: eric
2: viking
3: ham, spam and eggs
4: He said "Ni!"
5: line one
line two
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
ch for to research this concept? Thanks.
It's mapping the tuple ('cat', 'paw') to 'some string'. Commas make
tuples. The parenthesis are just necessary for the literal empty tuple
and if the syntax would be ambiguous otherwise.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
"translation".
`PF.buffer` might be better a string or an `array.array`. And is `BLOCK`
really just a structure with *one* member? Looks a bit odd IMHO.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
rue:
function_name(*arguments)
just with a five second delay.
> Also, do background processes run inside while loops?
This question doesn't make much sense to me. Do ``while`` loops block
other threads? No of course not.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
> What would the following parse to?:
>
> erik,viking,ham, spam and eggs,He said "Ni!",line one
> line two
Why don't you try yourself? The `csv` module returns two records, the
first has six items:
1: erik
2: viking
3: ham
4: spam and eggs
5: He said "Ni!"
6: line one
'line two' is the only item in the next record then.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
should convert \x2019 to \x27 ( as
> defined in iso-8859-15 )
No it shouldn't because \x2019 is a "right single quotation mark" and not
an apostrophe.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
XHTML code I need it to?
>
Then either Firefox is broken or you don't declare your XHTML properly and
Firefox thinks it's HTML.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
zero bytes:
In [10]: a = '\000'
In [11]: a
Out[11]: '\x00'
In [12]: ord(a)
Out[12]: 0
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
Then
you can slap the Web 2.0 buzz label onto the system. ;-)
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
def read(size):
result = ''
while self.files:
data = self.current_file.read(size)
result += data
if len(data) != size:
self.current_file = self.files.pop()
size = size - len(data)
return resu
gt; -1
>
> At first look you can see that `cmp` does not return boolean value
> what not for all newbies is so obvious.
Sorry I fail to see your point!? What has ``==`` to do with `cmp()` here?
The return of `cmp()` is an integer that cannot and should not be seen as
boolean value.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, 11 Jul 2007 16:52:32 +, flit wrote:
> That seems to be a good idea, but I am afraid the web hosting does not
> have the csv modules..
The `csv` module is part of the standard library.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
t; y
> '000101100100'
For the padding I'd use the `zfill()` method.
In [15]: a = 0x0164
In [16]: gmpy.digits(a, 2).zfill(16)
Out[16]: '000101100100'
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
e of byte values. You have to write and read the "text"
files in binary mode or they break if taken across platform boundaries
because of the different line endings in Linux and Windows for instance.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
ad on the processor? Do both tests read
the data always from cache or has the very first loop had to fetch the CSV
file from disk?
$ python -m timeit -n 1000 -c 'import csv; data = [row for row in
csv.reader(open("test.csv", "rb"))]' 1000 loops, best of 3: 1.27 msec per
loop
$ python -m timeit -n 1000 -c 'import csv; data =
list(csv.reader(open("test.csv", "rb")))' 1000 loops, best of 3: 1.25 msec
per loop
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
e you have to keep in mind
that it uses lazy evaluation and that the compiler knows very much about
the program structure and data types and flow to do optimizations.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
te the code". Easier
than C because I don't have to deal with so much machine details, don't
have to manage memory, don't need extra indexes for looping over lists and
so on. And the "crashes" are much gentler, telling me what the error is
and where instead of a simpl
ps(('hello world',))
In [10]: len(a)
Out[10]: 80
In [11]: print a
hello world
Even with some additional boilerplate like XML declaration etc. there is
still a little bit room until 10 kB are reached. :-)
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
ap(a, b) # output:None
> print getOverlap(b, a) # output: None
>
> any easy way of doing this?
Yes. That's quite an easy homework you really should do yourself. ;-)
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
ou that using the slice
> notation will not?
Well, a deep copy of course. ;-)
In [6]: import copy
In [7]: a = [[1, 2], [3, 4]]
In [8]: b = a[:]
In [9]: c = copy.deepcopy(a)
In [10]: a[0][1] = 42
In [11]: a
Out[11]: [[1, 42], [3, 4]]
In [12]: b
Out[12]: [[1, 42], [3, 4]]
In [13]: c
nary data somehow. I'd
use base64. It's available as codec for `str.encode()`/`str.decode()`.
In [10]: '\x00\xff\xaa'
Out[10]: '\x00\xff\xaa'
In [11]: '\x00\xff\xaa'.encode('base64')
Out[11]: 'AP+q\n'
In [12]: _.decode('base64&
y_obj = my_dict.get(key) or my_dict.setdefault(key,myobject())
Reduces the unnecessary instantiation of `myobject` to "false" objects.
May be not good enough.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
))
In [49]: years
Out[49]:
['1999',
'2000',
'2001',
'2002',
'2003',
'2004',
'2005',
'2006',
'2007',
'2008',
'2009',
'2010']
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
601 - 700 of 1811 matches
Mail list logo