,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
* 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
to believe there's something
wrong with 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
)+\.?([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
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` anymore.
Ciao,
Marc 'BlackJack
= 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
. 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
for the += case only? B.l.__iadd__ obviously exists.
Because there is always a rebinding involved.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
` 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
?
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
(operator.itemgetter(0), sorted_items)
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
say yes.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
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,
Marc 'BlackJack' Rintsch
--
http
.
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
= 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/2005 in
a genuan date object which is needed for calculation
, 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
'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
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.python.org/mailman
= 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
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
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 by Paul.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-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
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 backslash has a special
meaning but `raw_input
'):
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
,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
not exist. That `gdbm` object
doesn't have a `get()` method.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
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 anyway more
explicitly.
I see some
`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 +, Marc 'BlackJack' Rintsch wrote:
On Thu, 11 Oct 2007 13:04:53 +, Artur Siekielski wrote:
1. If I use instance field 'name' which is accessed directly by other
classes,
and later I decide
.__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.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python
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 the final string size
beforehand so intermediate
, 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
`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`.
Ciao,
Marc 'Blackjack' Rintsch
--
http
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 are wrong. It's a binary file with bytes
? 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
` and then bind the result to `Child1`.
`Child1` doesn't have an attribute `a`, so it is looked up in the parent
class. But the result is then bound to `Child1`. So you are reading from
`Foo` and writing to `Child1`. That's it.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman
()
.:
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 an `AttributeError`.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman
On Tue, 09 Oct 2007 22:43:16 +, Steven D'Aprano wrote:
On Tue, 09 Oct 2007 19:46:35 +, Marc 'BlackJack' Rintsch wrote:
On Tue, 09 Oct 2007 18:08:34 +, Steven D'Aprano wrote:
L = []
id(L)
3083496716L
L += [1]
id(L)
3083496716L
It's the same L, not rebound at all
bound to the last non-`None` result in the interpreter.
Drop all those `__del__()` methods as they prevent the garbage collector
from collecting cycles.
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 and type are attached to the
name while in Python
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 'BlackJack' Rintsch
--
http
important.
A `set()` can be part of such a solution.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
be included.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
. 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
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 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo
.
Don't know if C#'s delegates qualify.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
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
,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
,
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' in a) == True
Out[269]: True
In [270]: 'c' in (a == True
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,
Marc 'BlackJack
initializations and the presumed class definition
boilerplate comes at the price of introducing them on your own.
The mechanism is already there in Io, no need to invent, just use it.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
*and* an index:
for i, arg in enumarate(args):
# ...
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
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
the rules better use an attribute for the numbers.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
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
:
In [144]: str(0.1)
Out[144]: '0.1'
In [145]: repr(0.1)
Out[145]: '0.10001'
In [146]: '%.12f' % 0.1
Out[146]: '0.1000'
In [147]: '%.50f' % 0.1
Out[147]: '0.1555111512312578270211815834045410'
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org
, 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
guru.com or rentacoder.com for such
assignments.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
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
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 methods.
http://www.iolanguage.com/
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo
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://mail.python.org/mailman/listinfo/python-list
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 prototype OO
being just a more flexible variant
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 should fail in most cases anyway.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
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 a VM.
About which D are we talking here
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 'BlackJack
)]
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
in
maintained internally in the dict.
A copy!? That has to be a deep copy. Which would make `dict`\s alot
slower and use more memory. Plus you can't store objects that can't be
copied anymore. That doesn't sound like a good trade off to me.
Ciao,
Marc 'BlackJack' Rintsch
--
http
` → 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
to
individual files and store them in a ZIP archive.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
of functions::
F.append(lambda x, i=i: x + i)
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
).
And you also left out some information like the number of rows/columns and
the size of the data.
Have you already thought about using a database?
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
of the readline() function?
t = string.readline() # Limit this somehow?
Do you want to limit how much of *one* line is read or the number of lines!?
The latter can be done with `itertools.islice()`.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
On Mon, 17 Sep 2007 01:23:20 +, Summercool wrote:
On Sep 16, 10:36 am, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote:
The `*.pyc` files are usually only created when you import a module, not
when a module is run directly.
how come a program that runs directly doesn't need
On Sun, 16 Sep 2007 00:40:13 +, Steven D'Aprano wrote:
On Sun, 16 Sep 2007 00:05:58 +, Marc 'BlackJack' Rintsch wrote:
In *general* the compiler can't tell, but in specific cases it could. A
(hypothetical) optimizing compiler would tell the difference between:
for item in alist
.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
On Sun, 16 Sep 2007 13:31:57 +, Steven D'Aprano wrote:
On Sun, 16 Sep 2007 10:58:07 +, Marc 'BlackJack' Rintsch wrote:
On Sun, 16 Sep 2007 09:50:39 +, Steven D'Aprano wrote:
The point is rather moot, since CPython (and probably other Pythons) do
almost no optimizations
On Sun, 16 Sep 2007 10:17:18 -0400, Colin J. Williams wrote:
Marc 'BlackJack' Rintsch wrote:
`getFoo()` is discouraged by PEP 8. […]
Perhaps PEP 8 needs rethinking. I prefer getFoo().
Yeah, *your* preference is a very good reason to rethink PEP 8… ;-)
Ciao,
Marc 'BlackJack
turn the show hidden file to on.
The `*.pyc` files are usually only created when you import a module, not
when a module is run directly.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
in the standard library instead
of doing this yourself. :-)
If you insist on doing it yourself take a look at the built-in `ord()`
function.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
... not integers...
any fast method?
Convert them to strings before joining:
In [145]: foo = [1, 2, 3]
In [146]: ','.join(map(str, foo))
Out[146]: '1,2,3'
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
,
it doesn't work...I just get spam back when I print s1. Any ideas?
Yes, read the documentation to find out that `replace()` does not alter the
string -- strings in Python are immutable -- but returns a new, changed
string.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org
]` where `i` is in `x:y` and this may lead
to different results wether it iterates over a copy or the original.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
[]
else:
return f(l[1:]) + l[:1]
f([1,2,3])
[]
[3, 2, 1] # how this come here? how python save variables from each
recursion?
There is not just one `l` but one distinct `l` in each call.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo
caller:
r2 f(2): return 2 * 1
Again this is evaluated and returned to its caller:
r1 f(3): return 3 * 2
And here we have the final result that is returned from the first call to
`f()`.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
. But is
code really a memory problem? I've never thought OMG memory is getting
low, I wish I could unload a module to get some space. In my experience
it's always data that eats my RAM.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
at function definitions. You don't
have to work to find out what type of variables it takes.
This should either be obvious or in the docstring.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
expression to computable one.
My RPN only implements: + - x %
Why does this homework assignment limit the stack so severely!? ;-)
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
several convenient properties:
1. It can handle any Unicode code point.
...
As mentioned before, by definition, any Unicode encoding encodes all
unicode char set. The mentioning of above as a convenient property
is inane.
You are being silly here.
Ciao,
Marc 'BlackJack' Rintsch
and the `os.strerror()` function.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
On Tue, 11 Sep 2007 05:09:58 -0700, Tim wrote:
On Sep 10, 3:31 pm, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote:
On Mon, 10 Sep 2007 11:38:50 -0700, Tim wrote:
How do I memcpy from a pointer to an array of floats in python?
I get errors: NameError: global name 'row' is not defined
`shared_memory_pointer`.
shared_memory_pointer =
windll.kernel32.MapViewOfFile(hMapObject, FILE_MAP_ALL_ACCESS,
0, 0, TABLE_SHMEMSIZE)
And here you bind a different object to that name, so the first binding
has no effect.
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org
'BlackJack' Rintsch
--
http://mail.python.org/mailman/listinfo/python-list
601 - 700 of 1496 matches
Mail list logo