New submission from Carmine Paolino paolino.carm...@alice.it:
Trying to run this simple script:
for i in range(10):
print(i*0.2)
when i is 3, the result given is 0.6001.
What could the problem be?
--
components: Interpreter Core
messages: 138311
nosy: cancelliere
Carmine Paolino paolino.carm...@alice.it added the comment:
When I try to run 3*0.2 in Python shell or using an IDLE document, the result
given is 0.6001.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12332
Carmine Paolino paolino.carm...@alice.it added the comment:
Thank you for your help.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12332
Paolino wrote:
class NotInitializedObjects(type):
def __init__(cls,*_):
realInit=cls.__init__
def __newInit__(self,*pos,**key):
def _init():
realInit(self,*pos,**key)
self._init=_init
cls.__init__=__newInit__
def __getattribute__(self,attr
AttributeError
Paolino
___
Yahoo! Mail: gratis 1GB per i messaggi e allegati da 10MB
http://mail.yahoo.it
--
http://mail.python.org/mailman/listinfo/python-list
^2][T^-2]
v=[L][T^-1]
f=[T^-1]
p=[m][L][T^-1]
..
in the mass,lenght,time space are
[1,2,-2]
[0,1,-1]
[0,0,-1]
[1,1,-1]
say matrix D
then
D*[x1,x2,x3,x4]=[0,0,0] (looking for adimensionals)
So you are looking for an eigenvector formed by only integers.
Ciao Paolino
(boundMethod.im_func)
class cls(object):
def __init__(self):
print methodId(self.meth1)
print methodId(self.meth2)
def meth1(self):
pass
def meth2(self):
pass
c = cls()
print methodId(c.meth1)
print methodId(c.meth2)
I think this is giving what you expected.
Regards Paolino
a decorator for automatize the 'super' call,but I
failed.
Next solution is implementing the observer pattern on methods call.
I'm pretty sure there are bugs and ideas to be corrected in the next
code,any help and comment appreciated.
Regards Paolino
real keys comparisons via '==' among the
keys of the bin identified by the hash of the key.
Regard Paolino
___
Yahoo! Messenger: chiamate gratuite in tutto il mondo
http://it.beta.messenger.yahoo.com
--
http://mail.python.org/mailman/listinfo
self,other:list.__init__(self,other)
l=L([1,2,3])
l=Mixin(l)
l.mixinMethod()
Regards Paolino
___
Yahoo! Mail: gratis 1GB per i messaggi e allegati da 10MB
http://mail.yahoo.it
--
http://mail.python.org/mailman/listinfo
Paolino
--
http://mail.python.org/mailman/listinfo/python-list
case: Handling all other exceptions:
# nice-to-have:
try:
something()
except *, e:
print some error occurred: , type(e), str(e)
except Exception:# catch them all.
Then use moudule 'traceback' to inspect
Paolino
Dont' know where are you going with that but if what you need is
cancelling some attributes when inheriting then probably this is a
cleaner approach:
class Meta(type):
def __init__(cls, name, bases, dic):
def attributeError(*_):
raise AttributeError
for base in bases:
,attr):
value=type.__getattribute__(klass,attr)
print attr,'==',value
return value
class Foo(object):
__metaclass__=Meta
a=2
Foo.a
Paolino
--
http://mail.python.org/mailman/listinfo/python-list
not accep dict['int_name'] in SQL variable but when i
convert this variable to the str , python accepts but i cannot insert
that into database because database only accept int in `BH `
thanks.
Try use:
SQL = INSERT INTO (`AH`, `BH` ) VALUES
('%s,%d)%(dict['str_name'],dict['int_name'])
Paolino
Uwe Mayer wrote:
posted mailed
Hi,
AFAICT there seems to be a bug on FreeBSD's Python 2.3.4 open function. The
documentation states:
Modes 'r+', 'w+' and 'a+' open the file for updating (note that 'w+'
truncates the file). Append 'b' to the mode to open the file in binary
mode, on
I thought rewriting __hash__ should be enough to avoid mutables problem but:
class H(set):
def __hash__(self)
return id(self)
s=H()
f=set()
f.add(s)
f.remove(s)
the add succeeds
the remove fails eventually not calling hash(s).
Thanks for help
Paolino
Matteo Dell'Amico wrote:
Paolino wrote:
I thought rewriting __hash__ should be enough to avoid mutables problem
but:
class H(set):
def __hash__(self)
return id(self)
s=H()
f=set()
f.add(s)
f.remove(s)
the add succeeds
the remove fails eventually not calling hash(s).
Why don't
Bengt Richter wrote:
On Wed, 10 Aug 2005 16:51:55 +0200, Paolino [EMAIL PROTECTED] wrote:
I have a self organizing net which aim is clustering words.
Let's think the clustering is about their 2-grams set.
Words then are instances of this class.
class clusterable(str):
def __abs__(self
(__name__) #'no errors'
but 'desc' is not defined in this namespace.
Paolino
___
Yahoo! Mail: gratis 1GB per i messaggi e allegati da 10MB
http://mail.yahoo.it
--
http://mail.python.org/mailman/listinfo/python-list
have to be done for builtin
objects I suppose.
This is a little hard for me.Has it something to do with extensions also?
Regards Paolino
___
Yahoo! Mail: gratis 1GB per i messaggi e allegati da 10MB
http://mail.yahoo.it
This confuses me also,looks like empty lists share same object.
Paolino
___
Yahoo! Mail: gratis 1GB per i messaggi e allegati da 10MB
http://mail.yahoo.it
--
http://mail.python.org/mailman/listinfo/python-list
Paolino wrote:
Jiri Barton wrote:
Hi everyone,
I have a problem with initialization.
a, b = [[]]*2
a.append(1)
b
[1]
Why is this? Why does not this behave like the below:
a, b = [[]]*2
a==b
True
Ooops I should write 'a is b'
And, just to add to my confusion:
[[]]*2
([medium-word for word in words])
Thanks for ideas, Paolino
___
Yahoo! Mail: gratis 1GB per i messaggi e allegati da 10MB
http://mail.yahoo.it
--
http://mail.python.org/mailman/listinfo/python-list
# this is said to be the key for descriptors
# to be called
mod.m # doesn't work
Thanks Paolino
___
Yahoo! Messenger: chiamate gratuite in tutto il mondo
http://it.beta.messenger.yahoo.com
--
http://mail.python.org/mailman/listinfo/python-list
Peter Otten wrote:
Paolino wrote:
Why descriptor mechanism doesn't apply to modules?
Because modules are instances of the module class and the descriptor has to
be defined in the class in order to work with the instance. E. g.:
Got it,thanks.
Then there is no way of having
usable,and has an almost perfect surface layer.
But this is not enough.It needs to be strong and elegant in the insides
to survive.More, isn't the Namespaces do more of them a Python Zen Law ?
Thanks again for putting things in a saner and more open way then I did.
Regards Paolino
Terry Reedy wrote:
Paolino [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:
I don't think the global keyword is useful actually.
What's so special in a module nemespace to be priviledged like that.
The specialness of globals and locals was part
or at least non-linerities that makes 'global'
an interesting strangeness to talk about.
And that namespaces should start being easy sooner or later.
Regards Paolino
___
Yahoo! Mail: gratis 1GB per i messaggi e allegati da 10MB
Peter Hansen wrote:
Paolino wrote:
[EMAIL PROTECTED] wrote:
def enclosing():
var=[]
var[0]=2
def enclosed():
var[0]=4
which is like saying python is not working
It's ok to mark non locals,but why var=4 is not searched outside and
var[0]=4 yes?
Because var=4 rebinds the name var
Bengt Richter wrote:
Ok, to make the statement execute, execute function:
function()
a=function.foo
a
'something'
vars(function)
{'foo': 'something'}
Yep too stupid I've been :) Thanks
___
Yahoo! Mail:
George Sakkis wrote:
Paolino wrote:
Even worse I get with methods and function namespaces.
What is even worse about them?
For my thinking, worse is to understand how they derive their pattern
from generic namespaces.
Methods seems not to have a writeble one,while functions as George
Paul Rubin wrote:
Paolino [EMAIL PROTECTED] writes:
What I'm needing as a global (in globals() or at the module level or
in the module namespace) is 'translate'.The rest of bindings
(all,badcars and table) is something which is 'polluting' the module
namespace.
do you want
__all__
Paolino wrote:
Now this is the non polluting version :
class translate:
import string
all=string.maketrans('','')
badcars=all.translate(all,string.letters+string.digits)
@staticmethod
def __call__(text,table=string.maketrans(badcars,'_'*len(badcars))):
return
')
IiIiCmR1bW15ID0gJycnCgpzb21ldGhpbmcKaGVyZQonJycKIiIiCmltcG9ydCBkb2N0ZXN0OyBk
b2N0ZXN0LnRlc3Rtb2QoKQo=
Paolino
___
Yahoo! Mail: gratis 1GB per i messaggi e allegati da 10MB
http://mail.yahoo.it
--
http://mail.python.org/mailman/listinfo/python-list
class ns(namespace):
def gulp(*args):pass
This solution makes me think the keyword 'namespace' is missing:
namespace ns:
foo='something'
def gulp(*args):
pass
Solutions and comments appreciated.
Regards Paolino
___
Yahoo! Messenger
Robert Kern wrote:
Paolino wrote:
While it's not so bad we can bind names in the module namespace, (ex
writing scripts ?) ,writing modules is someway bound to not polluting
that namespace (really IMO).
I'm afraid that I can't parse that sentence.
I show you a piece of code I need
Steven D'Aprano wrote:
def translate(text):
import string
all=string.maketrans('','')
badcars=all.translate(all,string.letters+string.digits)
table=string.maketrans(badcars,'_'*len(badcars))
return text.translate(table)
No pollution.
And no efficience.Recalculating
as George and
Rob remembered have one which is not read only.Why?
(Also my aim is to learn from postings not to show others'
implementations are better or worse in the sense I prefer, times are
gone for me for that. )
Paolino
():
function.foo='something'
a=function.foo
Traceback (most recent call last):
File stdin, line 1, in ?
AttributeError: 'function' object has no attribute 'foo'
How should I read it? The namespace is half done inside the function?
Thanks Paolino
___
Yahoo
why (x**2 with(x))(x**3 with(x)) is not taken in consideration?
If 'with' must be there (and substitue 'lambda:') then at least the
syntax is clear.IMO Ruby syntax is also clear.
___
Yahoo! Mail: gratis 1GB per i messaggi e
Robert Kern wrote:
[EMAIL PROTECTED] wrote:
At top of a module I have an integer like so...
foo = 4
In a function in that module I know I need to do 'global foo' to get at
the value 4.
...
I presume you are trying code like the following:
foo = 4
bar = {}
def fun1():
foo =
before coding can be bad for
experimental coding.
-Logic optimization can influence interfaces.
-Time optimization is a leverage to get paid in open source
software.Never think about that for free.
Paolino
___
Yahoo! Mail
in contrast,but once you got them and
made your library I think they are also usable.
I do believe, without deferreds in the core ,python will have bad times
surviving the net, but that's really an opinion.
Have fun, Paolino
--
http://mail.python.org/mailman/listinfo/python-list
Farshid Lashkari wrote:
Hi,
I have an object and I want to check if it is a bound or unbound method,
or neither. I tried using the types module, but it seems as though
types.UnboundMethodType and types.MethodType are equal. How else can I
determine this? BTW, I'm using Python 2.3
is good to be read also.
Paolino
___
Yahoo! Mail: gratis 1GB per i messaggi e allegati da 10MB
http://mail.yahoo.it
--
http://mail.python.org/mailman/listinfo/python-list
is good to be read also.
Paolino
--
http://mail.python.org/mailman/listinfo/python-list
that would be good too .
Hmm try this:
http://www.itasoftware.com/careers/eng/job1.php
For really useful things probably you want to reach some projects like
twisted ,but there you need more experience IMO. Good luck and welcome
to Python.
Paolino
--
http://mail.python.org/mailman/listinfo
Tito wrote:
Hi all:
Is there a metalanguage capability in Python (I know there are many) to
call a function having its name in a string?
Something like:
__call__(foo)
instead of:
foo()
Regards,
Tito
eval('foo()') should do, but it's said a bad practice ;)
--
David Isaac wrote:
Newbie question:
I have been generally open to the proposal that list comprehensions
should replace 'map', but I ran into a need for something like
map(None,x,y)
when len(x)len(y). I cannot it seems use 'zip' because I'll lose
info from x. How do I do this as a list
snoe wrote:
I have a suspicion that there's an easier way to do this than
explicitly adding a Project.pickleme() call to the beginning of all of
my set/add methods.
So is there a way to wrap methods for this type of functionality or is
there another way of doing this, maybe without using
snoe wrote:
I have a suspicion that there's an easier way to do this than
explicitly adding a Project.pickleme() call to the beginning of all of
my set/add methods.
So is there a way to wrap methods for this type of functionality or is
there another way of doing this, maybe without using
comprehension? (Or,
more generally, what is the best way to do this without 'map'?)
[Paolino]
Probably zip should change behaviour,and cover that case or at least
have another like 'tzip' in the __builtins__ .Dunno, I always thought
zip should not cut to the shortest list.
Heck
Thanos Tsouanas wrote:
Hello.
I would like to have a quick way to create dicts from object, so that a
call to foo['bar'] would return obj.bar.
The following works, but I would prefer to use a built-in way if one
exists. Is there one?
class dictobj(dict):
class
Little less ugly:
In [12]:class A(object):
: def __str__(self):return self.__str__()
: def str(self):return 'ciao'
: def setStr(self):self.__str__=self.str
:
In [13]:a=A()
In [14]:a.setStr()
In [15]:str(a)
Out[15]:'ciao'
The point is str(ob) builtin
Thanos Tsouanas wrote:
On Sat, Jul 23, 2005 at 12:06:57PM +0200, Paolino wrote:
use getattr(self.obj,key) possibly, as __getattribute__ gets total
control on attribute access
Thanks, but what do you mean by 'total control'?
Probably nothing to do with your question :(
But:
class
Terry Reedy wrote:
I'd like to catch AttributeError on the module level,so that I can
declare default bindings for useds defore definition.How is this to
be done?
'defore' is obviously 'before', but what is 'useds'? In and case...
Unresolved bindings,possibly like
_rdf_type
Traceback (most
I'd like to catch AttributeError on the module level,so that I can
declare default bindings for useds defore definition.How is this to be
done?Thanks for help.
Paolino
--
http://mail.python.org/mailman/listinfo/python-list
58 matches
Mail list logo