Re: FBI **B-U-S-T-A-R-D-S** pays a fine of 5.8 Million to Steven Hatfill + Judge Sanctions FBI Re: * * * kangaroo courts of amierca * * *
test -- http://mail.python.org/mailman/listinfo/python-list
Re: Numerical Linear Algebra in arbitrary precision
In article , Ken wrote: >Brand new Python user and a bit overwhelmed with the variety of >packages available. Any recommendation for performing numerical >linear algebra (specifically least squares and generalized least >squares using QR or SVD) in arbitrary precision? I've been looking at >mpmath but can't seem to find much info on built in functions except >for LU decomposition/solve. Arbitrary precision? As in automatically increasing precision to stay exact? You will find this impractical as the number of decimals will explode, or you will find it not at all. If you mean that you want to be able to select something with larger precision than single or double floats, numpy is the starting point. > >Appreciate any comments. > >Ken Groetjes Albert -- -- Albert van der Horst, UTRECHT,THE NETHERLANDS Economic growth -- being exponential -- ultimately falters. albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst -- http://mail.python.org/mailman/listinfo/python-list
Re: From Cain To Khazaria: The True Genealogy of the Jewish People, Documented From the Bible and From Jewish Writings
On Feb 27, 11:38 am, NanoThermite FBibustards wrote: > A copy of “The Great Impersonation” can be obtained for $37 (Postpaid) > from my website,www.anglo-saxonisrael.comvia Paypal, or by mail from > ANP POB 411373, Chicago IL 60641. > > From Cain To Khazaria: > > The True Genealogy of the Jewish People, Documented From the Bible and > From Jewish Writings > > (They're NOT Who You THINK They Are!) > > By Pastor Eli James > > Therefore, behold, I will proceed to do a marvellous work among this > people, even a marvellous work and a wonder: for the wisdom of their > wise men shall perish, and the understanding of their prudent men > shall be hid. - Isa. 29:14. > > Children of True Israel, there is a GIGANTIC COVER-UP going on in the > world of religion. It is a DECEPTION of such vast proportions that it > affects every moment of your life. It affects your income, your > health, your family, your residence, your faith, your business, your > welfare and even your sex life. Ultimately, it affects your immortal > soul, which, at this moment in time, is in serious jeopardy. This > cover-up has confounded the wisdom and judgment of millions of > otherwise good people. Most Christians simply do not realize that > there is an IMPOSTOR posing as Israel. > > I have written a 333-page book about this impostor. The book is > entitled, The Great Impersonation, How the Anti-Christ Has Deceived > the Whole World. This book details the two families that came out of > the Garden of Eden. Genesis 3:15 clearly predicts that these two > families will be in a state of continuous war with each other until > the Great Day of the Lord. Yet, no denomination, outside of Christian > Identity, teaches anything about this. Nor do they teach that the > whole world will be deceived by this “beast,” and largely succumb to > its deceptions. > > Jesus Christ, Himself, repeatedly warns us against the wiles of this > evil generation (race) of vipers (John 8:33-44), who are so evil that > He even refuses to try to convert them (Matt. 13:13-15). > > The purpose of this essay is to demonstrate two basic propositions: > 1.) The Jews ARE NOT related to any of the Twelve Tribes of Israel, > including the Tribe of Judah, and 2.) Judaism IS NOT related to the > Mosaic Law. In fact, it will be proven herein, beyond any doubt, that > Judaism is an IMPOSTOR RELIGION, just as the Jewish people are an > IMPOSTOR PEOPLE. These two great deceptions, combined into one > culture, namely Jewish culture, form the basis of the entity that the > bible calls “the beast that deceiveth the whole world.” (Rev. 12:9.) > > Obviously, it never occurs to the average good-hearted Christian that > the devil might come calling, wearing priestly garb; but that is > exactly the ploy that the devil is using. Not only that, the devil > employs entire denominations of priests, who both innocently and > deliberately, promote this gigantic deception. > > To put the situation somewhat indelicately, “Cupidity always defeats > stupidity, because stupidity cannot recognize cupidity.” A related > maxim is “The victim of the con game is always the last to know.” In > the meantime, the victim gets taken for all he is worth. > > Who Are the Jews? > > First, we must examine several Jewish claims, as to their “Semitic” > ancestry. Are these claims true or are they false? > > One of the more famous Jewish claims to Israelite heritage is the > rabbinical claim that the Jewish people are the exclusive descendants > of Abraham. This is based on Gen. 12:3. Let's read this passage and > see if it lives up to Jewish claims: > > And I will bless them that bless thee, and curse him that curseth > thee: and in thee shall all families of the earth be blessed. > > This passage is used by Jews and Christians to imply that, if we don't > bless the Jewish people, then we Christians will not be blessed. This > blessing is stated as CONDITIONAL. Being a conditional, it behooves > non-Abrahamites – the passage DOES NOT MENTION JEWS!! - to bless > Abraham if these non-Abrahamites wish to be blessed. The fact must be > pointed out that nowhere in Scripture is Abraham identified with the > Jewish people. In fact, such an identification is automatically > ANACHRONISTIC, meaning that Abraham, being the grandfather of Israel, > cannot be named after any of his descendants. Jacob was an Abrahamite, > but Abraham was certainly not an Israelite! No grandfather has ever > been named after his grandson. > > It is also true that nowhere in Scripture are the Israelites ever > called “Jews.” There is absolutely no such statement in either > Testament, that says, “Jacob is a Jew” or “Israel is a Jew,” or even > “Judah is a Jew.” In fact, we have several COUNTEREXAMPLES, which > prove the opposite to be true! II Kings 16:6 refers to the House of > Judah as “Jews,” but it refers to the House of Israel as “Israel.” > Now, if the Jews are Israel, as we are constantly told, why does this > passage contradict them? The fact is t
Re: How can I make an instance of a class act like a dictionary?
On Sun, 26 Feb 2012 23:24:31 -0800, John Salerno wrote: > Hi everyone. I created a custom class and had it inherit from the "dict" > class, and then I have an __init__ method like this: > I know I could do self.variable = create() and that works fine, but I > thought it would be better (and cleaner) simply to use the instance > itself as the dictionary, rather than have to go through an instance > variable. Check out the "Bunch" class: http://code.activestate.com/recipes/52308/ HTH, Dan -- http://mail.python.org/mailman/listinfo/python-list
Re: PyWart: Language missing maximum constant of numeric types!
Rick Johnson wrote: On Feb 25, 11:54 am, MRAB wrote: [...] That should be: if maxlength is not None and len(string) <= maxlength: Using "imaginary" infinity values defiles the intuitive nature of your code. What is more intuitive? def confine_length(string, maxlength=INFINITY): if string.length < maxlength: do_something() def confine_length(string, maxlength=None): if maxlength is not None and len(string) <= maxlength: do_something() This one: def confine_length(string, maxlength=None): """Confine the length. @param maxlength: the maximum length allowed, set it to None to allow any length. """ if maxlength is not None and len(string) <= maxlength: do_something() I'm just feeding the troll, I know ... :-/ JM -- http://mail.python.org/mailman/listinfo/python-list
Re: PyWart: Language missing maximum constant of numeric types!
On 2012-02-26, Wolfgang Meiners wrote: > but it really does not look intuitive. Hmm. My idea was that > None is a perfect Value for infinity since there is no > infinitely large number. But as i see it, you must have two > comparisons then. Maybe someone has a better idea? I do. A truncated string with a maxlength of INFINITY is just a string. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list
Re: FBI **B-U-S-T-A-R-D-S** pays a fine of 5.8 Million to Steven Hatfill + Judge Sanctions FBI Re: * * * kangaroo courts of amierca * * *
In sci.physics NanoThermite FBibustards wrote: > test fail. -- -- http://mail.python.org/mailman/listinfo/python-list
Re: [semi OT]: Smartphones and Python?
for which I could write Python programs. > Android is good bet, kivy has official support for it http://kivy.org/docs/guide/android.html -- http://mail.python.org/mailman/listinfo/python-list
setting the length of the backtrace output in pdb
Hi, this might be a rather silly question, but i cannot figure out how to make pdb give me more than 10 lines of output whenever i issue a backtrace command. Is there an easy way to do this? thanks matt -- http://mail.python.org/mailman/listinfo/python-list
windows executable calling python script
I am creating an installer for python projects, using CMake and NSIS. Now my goal is to be able to select at installer time the python executable that will run that project, and then associate them. I saw that setuptools is able to generate exe wrappers, but how does that work exactly? From what I've understood there is some compiled C code that somehow calls the python script, is that correct? Supposing I ship this executable in the same directory of the python script (with a known name), is there a way to make it run the right python interpreter? The best and easiest solution would be to generate the full installer with PyInstaller or similar, but unfortunately that doesn't work yet, and we would still need both approaches anyway. -- http://mail.python.org/mailman/listinfo/python-list
Re: pickle handling multiple objects ..
在 2012年2月26日星期日UTC+8下午9时00分31秒,Chris Angelico写道: > On Sun, Feb 26, 2012 at 11:04 PM, Peter Otten <[email protected]> wrote: > > This is however a bit errorprone. If you accidentally write the loading code > > as > > > > fruit, beverages, vegetables = pickle.load(f) > > > > you'll end up drinking potatoes. > > You mean vodka? :) > > Additionally, you'll get a weird crash out of your program if load() > returns something other than a sequence of length 3. Remember, > everything that comes from outside your code is untrusted, even if you > think you made it just two seconds ago. > > Of course, sometimes that exception is absolutely correct. If you wrap > all this in an exception handler that gives some reasonable behaviour > - which might even be "terminate the program with a traceback", which > is the default - then it's fine to let it throw on failure, and > anything else is just a waste of effort. But for maximum > extensibility, you would want to make it so that you can add more > elements to what you save without your code breaking on an old save > file - and that's where the dictionary is far better. A slight tweak, > though: > > data = pickle.load(f) > fruit = data.get("fruit",[]) > beverages = data.get("beverages",[]) > vegetables = data.get("vegetables",[]) > > With this, you guarantee that (a) unrecognized keys will be safely > ignored, and (b) absent keys will quietly go to their given defaults. > > ChrisA I love python for pickle and zip lib build in. I write programs that stay in the L1 or L2 cache of the CPU > 97% percent of chance of nontrivial executions. -- http://mail.python.org/mailman/listinfo/python-list
Re: [RELEASED] Release candidates for Python 2.6.8, 2.7.3, 3.1.5, and 3.2.3
Ben Finney benfinney.id.au> writes:
>
> Putting “RELEASED” in the subject, when they're not released and are
> instead *candidates for* release, is confusing and muddies the issue of
> what you even mean by “release”.
>
{alpha, beta, release candidate, final} \subsetof releases
--
http://mail.python.org/mailman/listinfo/python-list
Re: windows executable calling python script
On 02/27/2012 01:57 PM, Andrea Crotti wrote:
I am creating an installer for python projects, using CMake and NSIS.
Now my goal is to be able to select at installer time the python
executable that will run that project,
and then associate them.
I saw that setuptools is able to generate exe wrappers, but how does
that work exactly?
From what I've understood there is some compiled C code that somehow
calls the python script, is that correct?
Supposing I ship this executable in the same directory of the python
script (with a known name), is there a way
to make it run the right python interpreter?
The best and easiest solution would be to generate the full installer
with PyInstaller or similar, but unfortunately
that doesn't work yet, and we would still need both approaches anyway.
At the moment I ended up with something like this:
#include
#include
#include
#include
// the function takes as arguments only the python interpreter full path
int main(int argc, char *argv[])
{
if (argc < 2) {
fprintf(stderr, "Usage = ./run ");
exit(1);
}
/* TODO: make the path absolute? is it necessary? */
char *const to_run[1] = {"run.py"};
/* TODO: check if the path exists or not, and if it's executable */
execv(argv[1], to_run);
return 1;
}
which still doesn't work (I have to fix the execv) but when it will in
theory I will only need
to tell NSIS to create a link to that executable passing as argument the
right python executable.
After that it will run the run.py with in the local directory..
Easier ways (without py2exe and similars?)?
--
http://mail.python.org/mailman/listinfo/python-list
Re: [RELEASED] Release candidates for Python 2.6.8, 2.7.3, 3.1.5, and 3.2.3
Ben Finney wrote: Chris Angelico writes: On Sun, Feb 26, 2012 at 7:51 PM, Ben Finney wrote: If you're pleased to announce their immediate availability, then please do that! Isn't it perfectly accurate to say that the RCs are now available? Yes. What's not reasonable is to say that a candidate for release – i.e. something *prior to* release, by definition – is nevertheless released. Considering that "Release candidates" immediately followed "RELEASED" in the subject line, I don't see any confusion. Unless “release candidate” means nothing like what those words imply, it can't be both a release candidate *and* released. Either it's released, or it's not. If it's a release candidate, it's not released yet. If it's released, it's no longer a candidate for release. Saying it's simultaneously both is the confusion. What sort of release can you release ? A release candidate. If you can release a release candidate, a release candidate can be released, hence the released candidate release. More important, we all thank the release team for their efforts and hope they're having fun reading us :o) JM -- http://mail.python.org/mailman/listinfo/python-list
Re: Question about circular imports
Frank Millman wrote: Hi all I seem to have a recurring battle with circular imports, and I am trying to nail it once and for all. Let me say at the outset that I don't think I can get rid of circular imports altogether. It is not uncommon for me to find that a method in Module A needs to access something in Module B, and a method in Module B needs to access something in Module A. I know that the standard advice is to reorganise the code to avoid this, and I try to do this where possible, but for now I would like to address the question of how to handle the situation if this is otherwise unavoidable. Hi Frank, If you consider it unavoidable you've already lost. There is no reliable solution to circular import except refactoring the code to place all common code elsewhere: wavbase.py wavread.py (import wavbase) wavwrite.py (import wavbase) Any code required by both waread and wavwrite would end up in wavbase. Is there anything that prevent you from doing this ? JM -- http://mail.python.org/mailman/listinfo/python-list
Re: Python math is off by .000000000000045
On 2012-02-27, Steven D'Aprano wrote: > On Sun, 26 Feb 2012 16:24:14 -0800, John Ladasky wrote: > >> Curiosity prompts me to ask... >> >> Those of you who program in other languages regularly: if you visit >> comp.lang.java, for example, do people ask this question about >> floating-point arithmetic in that forum? Or in comp.lang.perl? > > Yes. > > http://stackoverflow.com/questions/588004/is-javascripts-math-broken > > And look at the "Linked" sidebar. Obviously StackOverflow users no > more search the internet for the solutions to their problems than do > comp.lang.python posters. > > http://compgroups.net/comp.lang.java.programmer/Floating-point-roundoff-error One might wonder if the frequency of such questions decreases as the programming language becomes "lower level" (e.g. C or assembly). -- Grant Edwards grant.b.edwardsYow! World War III? at No thanks! gmail.com -- http://mail.python.org/mailman/listinfo/python-list
Re: windows executable calling python script
On 02/27/2012 02:21 PM, Andrea Crotti wrote:
At the moment I ended up with something like this:
#include
#include
#include
#include
// the function takes as arguments only the python interpreter full path
int main(int argc, char *argv[])
{
if (argc < 2) {
fprintf(stderr, "Usage = ./run ");
exit(1);
}
/* TODO: make the path absolute? is it necessary? */
char *const to_run[1] = {"run.py"};
/* TODO: check if the path exists or not, and if it's executable */
execv(argv[1], to_run);
return 1;
}
which still doesn't work (I have to fix the execv) but when it will in
theory I will only need
to tell NSIS to create a link to that executable passing as argument
the right python executable.
After that it will run the run.py with in the local directory..
Easier ways (without py2exe and similars?)?
For the record I think I found a solution, now the wrapper works:
int main(int argc, char *argv[])
{
if (argc < 2) {
fprintf(stderr, "Usage = ./run ");
exit(1);
}
/* TODO: make the path absolute? is it necessary? */
char *const to_run[] = {"python", RUNNER, (char *) 0};
execv(argv[1], to_run);
return 1;
}
and I only need to tell NSIS to create a shortcut passing as argument
the path to the python executable,
nice and simple..
--
http://mail.python.org/mailman/listinfo/python-list
Re: Python math is off by .000000000000045
On 02/27/2012 08:02 AM, Grant Edwards wrote: > On 2012-02-27, Steven D'Aprano wrote: >> On Sun, 26 Feb 2012 16:24:14 -0800, John Ladasky wrote: >> >>> Curiosity prompts me to ask... >>> >>> Those of you who program in other languages regularly: if you visit >>> comp.lang.java, for example, do people ask this question about >>> floating-point arithmetic in that forum? Or in comp.lang.perl? >> >> Yes. >> >> http://stackoverflow.com/questions/588004/is-javascripts-math-broken >> >> And look at the "Linked" sidebar. Obviously StackOverflow users no >> more search the internet for the solutions to their problems than do >> comp.lang.python posters. >> >> http://compgroups.net/comp.lang.java.programmer/Floating-point-roundoff-error > > One might wonder if the frequency of such questions decreases as the > programming language becomes "lower level" (e.g. C or assembly). I think that most of the use cases in C or assembly of math are integer-based only. For example, counting, bit-twiddling, addressing character cells or pixel coordinates, etc. Maybe when programmers have to statically declare a variable type in advance, since the common use cases require only integer, that gets used far more, so experiences with float happen less often. Some of this could have to do with the fact that historically floating point required a special library to do floating point math, and since a lot of people didn't have floating-point coprocessors back then, most code was integer-only. Early BASIC interpreters defaulted to floating point for everything, and implemented all the floating point arithmetic internally with integer arithmetic, without the help of the x87 processor, but no doubt they did round the results when printing to the screen. They also did not have very much precision to begin with. Anyone remember Microsoft's proprietary floating point binary system and how there were function calls to convert back and forth between the IEEE standard? Another key thing is that most C programmers don't normally just print out floating point numbers without a %.2f kind of notation that properly rounds a number. Now, of course, every processor has a floating-point unit, and the C compilers can generate code that uses it just as easily as integer code. No matter what language, or what floating point scheme you use, significant digits is definitely important to understand! -- http://mail.python.org/mailman/listinfo/python-list
Re: emacs user interface design? a talk by Bret Victor
On Feb 26, 7:01 pm, NanoThermite FBibustards wrote: > @Xah Lee, he only tell one point, fast interpreter avoiding Edit- > Compile-Run cycle, and make it INTERACTIVE, the guy did not teach > nothing of design. The principle was first given by Margaret Hamilton > and Zeldin. > Bret's main point is that creators need immediate feedback. Okay, that's Forth. But he illustrated something else about the Forth way of working. When you try ideas out immediately, you discover things you wouldn't have thought of if you had written the whole program and then worked through debugging and integration. Another point he made is about crusaders (my word), people who see something wrong with the status quo and make it their business to change it based on principle. Chuck wasn't the crusader type (maybe he didn't look good in spandex). -- http://mail.python.org/mailman/listinfo/python-list
Re: multiprocessing, what am I doing wrong?
Still freezing sometimes, like 1 out of 10 times that I run it.
Here is updated code and a couple of outputs.
code
#!/usr/bin/env python
import sys
import Queue
import multiprocessing
import time
def FOO(a, b, c):
print 'foo', a, b, c
return (a + b) * c
class MyWorker(multiprocessing.Process):
def __init__(self, name, inbox, outbox):
super(MyWorker, self).__init__()
self.name = name
self.inbox = inbox
self.outbox = outbox
print >> sys.stderr, 'Created %s' % self.name; sys.stderr.flush()
def run(self):
print >> sys.stderr, 'Running %s' % self.name; sys.stderr.flush()
while True:
try:
args = self.inbox.get_nowait()
print >> sys.stderr, '%s got something to do' % self.name;
sys.stderr.flush()
except Queue.Empty:
break
self.outbox.put(FOO(*args))
if __name__ == '__main__':
# This file is being run as the main script. This part won't be
# run if the file is imported.
print >> sys.stderr, 'Creating todo queue'; sys.stderr.flush()
todo = multiprocessing.Queue()
for i in xrange(100):
todo.put((i, i+1, i+2))
print >> sys.stderr, 'Creating results queue'; sys.stderr.flush()
result_queue = multiprocessing.Queue()
print >> sys.stderr, 'Creating Workers'; sys.stderr.flush()
w1 = MyWorker('Worker 1', todo, result_queue)
w2 = MyWorker('Worker 2', todo, result_queue)
print >> sys.stderr, 'Starting Worker 1'; sys.stderr.flush()
w1.start()
print >> sys.stderr, 'Starting Worker 2'; sys.stderr.flush()
w2.start()
for i in xrange(100):
print result_queue.get()
output 1 (I ctrl-c'd it after it froze)
Creating todo queue
Creating results queue
Creating Workers
Created Worker 1
Created Worker 2
Starting Worker 1
Running Worker 1
Starting Worker 2
Running Worker 2
Traceback (most recent call last):
File "./multi.py", line 53, in
print result_queue.get()
File
"/home/frede00e/software/python/lib/python2.7/multiprocessing/queues.py",
line 91, in get
res = self._recv()
KeyboardInterrupt
### output 2
Creating todo queue
Creating results queue
Creating Workers
Created Worker 1
Created Worker 2
Starting Worker 1
Running Worker 1
Worker 1 got something to do
Starting Worker 2
foo 0 1 2
Worker 1 got something to do
foo 1 2 3
Worker 1 got something to do
foo 2 3 4
Worker 1 got something to do
foo 3 4 5
Worker 1 got something to do
foo 4 5 6
Worker 1 got something to do
foo 5 6 7
Worker 1 got something to do
foo 6 7 8
Worker 1 got something to do
foo 7 8 9
Worker 1 got something to do
foo 8 9 10
Worker 1 got something to do
foo 9 10 11
Worker 1 got something to do
foo 10 11 12
Worker 1 got something to do
foo 11 12 13
Worker 1 got something to do
foo 12 13 14
Worker 1 got something to do
foo 13 14 15
Worker 1 got something to do
foo 14 15 16
Worker 1 got something to do
foo 15 16 17
Worker 1 got something to do
foo 16 17 18
Worker 1 got something to do
foo 17 18 19
Running Worker 2
2
9
20
35
54
77
104
135
170
209
252
299
350
405
464
527
594
665
Traceback (most recent call last):
File "./multi.py", line 53, in
print result_queue.get()
File
"/home/frede00e/software/python/lib/python2.7/multiprocessing/queues.py",
line 91, in get
res = self._recv()
KeyboardInterrupt
On Fri, Feb 24, 2012 at 1:36 PM, MRAB wrote:
> On 24/02/2012 17:00, Eric Frederich wrote:
>
>> I can sill get it to freeze and nothing is printed out from the other
>> except block.
>> Does it look like I'm doing anything wrong here?
>>
>> [snip]
> I don't normally use multiprocessing, so I forgot about a critical
> detail. :-(
>
> When the multiprocessing module starts a process, that process
> _imports_ the module which contains the function which is to be run, so
> what's happening is that when your script is run, it creates and starts
> workers, the multiprocessing module makes a new process for each
> worker, each of those processes then imports the script, which creates
> and starts workers, etc, leading to an ever-increasing number of
> processes.
>
> The solution is to ensure that the script/module distinguishes between
> being run as the main script and being imported as a module:
>
>
> #!/usr/bin/env python
>
> import sys
> import Queue
> import multiprocessing
> import time
>
> def FOO(a, b, c):
>print 'foo', a, b, c
>return (a + b) * c
>
> class MyWorker(multiprocessing.**Process):
>def __init__(self, inbox, outbox):
>super(MyWorker, self).__init__()
>self.inbox = inbox
>self.outbox = outbox
>print >> sys.stderr, '1' * 80; sys.stderr.flush()
>def run(self):
>print >> sys.stderr, '2' * 80; sys.stderr.flush()
>while True:
>try:
>args = self.inbox.get_nowait()
>except Queue.Empty:
>break
>self.outbox.put(FOO(*args))
>
>
Re: Python math is off by .000000000000045
jmfauth wrote: On 25 fév, 23:51, Steven D'Aprano wrote: On Sat, 25 Feb 2012 13:25:37 -0800, jmfauth wrote: (2.0).hex() '0x1.0p+1' (4.0).hex() '0x1.0p+2' (1.5).hex() '0x1.8p+0' (1.1).hex() '0x1.1999ap+0' jmf What's your point? I'm afraid my crystal ball is out of order and I have no idea whether you have a question or are just demonstrating your mastery of copy and paste from the Python interactive interpreter. It should be enough to indicate the right direction for casual interested readers. I'm a casual interested reader and I have no idea what your post is trying to say. ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list
Re: pickle handling multiple objects ..
On Sun, Feb 26, 2012 at 6:00 AM, Chris Angelico wrote: > Additionally, you'll get a weird crash out of your program if load() > returns something other than a sequence of length 3. Remember, > everything that comes from outside your code is untrusted, even if you > think you made it just two seconds ago. While that's true, if your pickle is untrusted then a ValueError from unpacking is the least of your worries. You should never attempt to load an untrusted pickle in the first place, as doing so allows it to execute arbitrary code on your system. Cheers, Ian -- http://mail.python.org/mailman/listinfo/python-list
Re: Question about circular imports
On Sun, Feb 26, 2012 at 3:42 AM, Frank Millman wrote:
> Hi all
>
> I seem to have a recurring battle with circular imports, and I am trying to
> nail it once and for all.
>
> Let me say at the outset that I don't think I can get rid of circular
> imports altogether. It is not uncommon for me to find that a method in
> Module A needs to access something in Module B, and a method in Module B
> needs to access something in Module A. I know that the standard advice is to
> reorganise the code to avoid this, and I try to do this where possible, but
> for now I would like to address the question of how to handle the situation
> if this is otherwise unavoidable.
>
> The problem is clearly explained in the Python Programming FAQ -
>
> "Circular imports are fine where both modules use the "import " form
> of import. They fail when the 2nd module wants to grab a name out of the
> first ("from module import name") and the import is at the top level. That's
> because names in the 1st are not yet available, because the first module is
> busy importing the 2nd."
>
> [SNIP]
>
> I can think of two solutions - one is cumbersome, the other may not be good
> practice.
Solution 3: don't do the circular imports at the top level. It's
perfectly fine to do the imports locally inside the functions that
need them, which resolves the circularity since normally the functions
won't be called until the module is fully imported. It does add some
overhead to the functions, basically the cost of a dict lookup.
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
Re: How can I make an instance of a class act like a dictionary?
On Feb 27, 1:39 am, Chris Rebert wrote: > On Sun, Feb 26, 2012 at 11:24 PM, John Salerno wrote: > > Hi everyone. I created a custom class and had it inherit from the > > "dict" class, and then I have an __init__ method like this: > > > def __init__(self): > > self = create() > > > The create function creates and returns a dictionary object. Needless > > to say, this is not working. When I create an instance of the above > > class, it is simply an empty dictionary rather than the populated > > dictionary being created by the create function. Am I doing the > > inheritance wrong, or am I getting the above syntax wrong by assigning > > the return value to self? > > Assignment to `self` has no effect outside the method in question; > Python uses call-by-object (http://effbot.org/zone/call-by-object.htm > ) for argument passing. > Even in something like C++, I believe assignment to `this` doesn't work. > > > I know I could do self.variable = create() and that works fine, but I > > thought it would be better (and cleaner) simply to use the instance > > itself as the dictionary, rather than have to go through an instance > > variable. > > Call the superclass (i.e. dict's) initializer (which you ought to be > doing anyway): > super(YourClass, self).__init__(create()) > > Cheers, > Chris > --http://rebertia.com Thanks. This ended up working: def __init__(self): self = super().__init__(create_board()) Is that what you meant for me to do? Why did assigning to self work in this case, but not the original case? -- http://mail.python.org/mailman/listinfo/python-list
Re: How can I make an instance of a class act like a dictionary?
On Mon, Feb 27, 2012 at 3:09 PM, John Salerno wrote: > On Feb 27, 1:39 am, Chris Rebert wrote: >> On Sun, Feb 26, 2012 at 11:24 PM, John Salerno wrote: >> > Hi everyone. I created a custom class and had it inherit from the >> > "dict" class, and then I have an __init__ method like this: >> >> > def __init__(self): >> > self = create() >> >> > The create function creates and returns a dictionary object. Needless >> > to say, this is not working. When I create an instance of the above >> > class, it is simply an empty dictionary rather than the populated >> > dictionary being created by the create function. Am I doing the >> > inheritance wrong, or am I getting the above syntax wrong by assigning >> > the return value to self? >> >> Assignment to `self` has no effect outside the method in question; >> Python uses call-by-object (http://effbot.org/zone/call-by-object.htm >> ) for argument passing. >> Even in something like C++, I believe assignment to `this` doesn't work. >> >> > I know I could do self.variable = create() and that works fine, but I >> > thought it would be better (and cleaner) simply to use the instance >> > itself as the dictionary, rather than have to go through an instance >> > variable. >> >> Call the superclass (i.e. dict's) initializer (which you ought to be >> doing anyway): >> super(YourClass, self).__init__(create()) >> >> Cheers, >> Chris >> --http://rebertia.com > > Thanks. This ended up working: > > def __init__(self): > self = super().__init__(create_board()) > > Is that what you meant for me to do? Why did assigning to self work in > this case, but not the original case? It didn't do anything and still isn't doing anything. In Python, names are assigned to objects self -> ^ foo ---| Reassigning a name does not change the value, so self = create() Just makes an object2 self -> foo ---> The reason it's working here is because the super().__init__() call modifies the existing object in place. It returns None, so you're setting self = None but that doesn't matter because of what I explained before about how assigning to self doesn't actually change anything. > -- > http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Python urllib2 problem: Name or service not known
Hi all,
Some time ago I've written some python code to read video data off an
IP camera connected via a router to a laptop. Now I try to run this
code on a different laptop and router combination, but now I can't
access the camera.
Some minimal example code:
import urllib2
url = urllib2.urlopen("http://192.168.1.3/-wvhttp-01-/image.cgi";)
This fails and returns the error:
http://mail.python.org/mailman/listinfo/python-list
Re: [RELEASED] Release candidates for Python 2.6.8, 2.7.3, 3.1.5, and 3.2.3
Benjamin Peterson writes:
> Ben Finney benfinney.id.au> writes:
> >
> > Putting “RELEASED” in the subject, when they're not released and are
> > instead *candidates for* release, is confusing and muddies the issue of
> > what you even mean by “release”.
> >
>
> {alpha, beta, release candidate, final} \subsetof releases
So you've chosen to muddy what is meant by “release” in announcements to
the public. That's disappointing, but thank you for acknowledging it.
I appreciate the work that goes toward releases of Python, but I do wish
you'd use clear terminology in announcements.
--
\ “If history and science have taught us anything, it is that |
`\ passion and desire are not the same as truth.” —E. O. Wilson, |
_o__) _Consilience_, 1998 |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list
PEP 414 has been accepted
PEP 414 has been accepted: http://mail.python.org/pipermail/python-dev/2012-February/116995.html This means that from Python 3.3 onwards, you can specify u'xxx' for Unicode as well as just 'xxx'. The u'xxx' form is not valid syntax in Python 3.2, 3.1 or 3.0. The idea is to make porting code from 2.x to 3.x easier than before. Get porting! Regards, Vinay Sajip -- http://mail.python.org/mailman/listinfo/python-list
America's CONTEMPTUOUS KANGAROO courts VERSUS ISRAELI courts (in JEW-vs-JEW case)
America's KANGAROO courts VERSUS ISRAELI courts (in JEW-vs-JEW case atleast) This message is in part to the FBI racists as well as well as to the RACIST KANGAROO courts of AMERICA. In the Jew rapist, Roman Polansky versus Semantha Geimi (Gentile Minor Girl) the JEW RAPIST Roman Polansky sits FREE in Switzerland and also France. In the Jew rapist, Moshe Katsav who was also ISRAELI PRESIDENT versus ISRAELI JEW WOMEN , He is in JAIL, without the NAMES of the JEW WOMEN EVEN BEING RELEASED. Truly, AMERICAN FBI BUSTARDS and JUDICIAL BUSTARDS in the CONTEMPTUOUS SUPREME COURT (which has CONTEMPTED ITSELF by INCOMPETENCE, IGNORANCE etc) have contempted themselves. Now, this case is NOT NEW. It is a VERY OLD CASE. It was filed in LOS ANGELES COUNTY. That is why 9-11 is a jew job and israeli job and the COWARD YANK BUSTaRDS do not have the COURAGE to ATTACK ISRAEL and do the right thing. The court case record of RAPIST ROMAN POLANSKY http://www.thesmokinggun.com/file/roman-polanski-grand-jury-transcript A SWEET SHORT VIDEO for FBI bustards http://www.youtube.com/watch?v=4UqcY8lGUUE&feature=g-vrec&context=G27 http://anglo-saxonisrael.com/site/GreatImpersonation-8 -- http://mail.python.org/mailman/listinfo/python-list
Transfer files via bluetooth for Blackberry devices
Hi! I am newby on python. I am looking for a utility or a library for transfer files via bluetooth to blackberry. I am seeing that with obex may be is an option. Can you give me any advices on that?. Really appreciated Thanks! -- http://mail.python.org/mailman/listinfo/python-list
Re: Python urllib2 problem: Name or service not known
On Mon, 27 Feb 2012 12:48:27 -0800, Alex Borghgraef wrote: > Hi all, > > Some time ago I've written some python code to read video data off an IP > camera connected via a router to a laptop. Now I try to run this code on > a different laptop and router combination, but now I can't access the > camera. [...] Check your web proxy and firewall. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Python math is off by .000000000000045
On 02/27/2012 10:28 AM, Ethan Furman wrote: > jmfauth wrote: >> On 25 fév, 23:51, Steven D'Aprano > [email protected]> wrote: >>> On Sat, 25 Feb 2012 13:25:37 -0800, jmfauth wrote: >>> (2.0).hex() '0x1.0p+1' >>> (4.0).hex() '0x1.0p+2' >>> (1.5).hex() '0x1.8p+0' >>> (1.1).hex() '0x1.1999ap+0' jmf >>> What's your point? I'm afraid my crystal ball is out of order and I have >>> no idea whether you have a question or are just demonstrating your >>> mastery of copy and paste from the Python interactive interpreter. >> >> It should be enough to indicate the right direction >> for casual interested readers. > > I'm a casual interested reader and I have no idea what your post is > trying to say. He's simply showing you the hex (binary) representation of the floating-point number's binary representation. As you can clearly see in the case of 1.1, there is no finite sequence that can store that. You end up with repeating numbers. Just like 1/3, when represented in base 10 fractions (x1/10 + x2/100, x3/1000, etc), is a repeating sequence, the number base 10 numbers 1.1 or 0.2, or many others that are represented by exact base 10 fractions, end up as repeating sequences in base 2 fractions. This should help you understand why you get errors doing simple things like x/y*y doesn't quite get you back to x. -- http://mail.python.org/mailman/listinfo/python-list
Re: Question about circular imports
On 2/27/2012 1:16 AM, Frank Millman wrote: To avoid the tedious reference, follow this with read = sound.formats.wavread # choose the identifier you prefer I tested something like this with stdlib, but there must be some important difference I did not notice. It make be in the contents of __init__.py. @Terry and OKB I tried that, but it does not work. a.py /b __init__.py c.py d.py a.py - from b import c c.py - import b.d d.py - import b.c How about import b.d as d, etc? If I run a.py, it returns with no error. c.py - import b.d d = b.d d.py - import b.c c = b.c If I run a.py, I get Traceback (most recent call last): File "F:\tests\a.py", line 1, in from b import c File "F:\tests\b\c.py", line 1, in import b.d File "F:\tests\b\d.py", line 2, in c = b.c AttributeError: 'module' object has no attribute 'c' I get the same if I try 'import b.c as c'. Try import b; c = b.c -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Question about circular imports
On Mon, Feb 27, 2012 at 6:01 PM, Terry Reedy wrote: > On 2/27/2012 1:16 AM, Frank Millman wrote: >>> >>> >>> To avoid the tedious reference, follow this with >>> read = sound.formats.wavread # choose the identifier you prefer > > > I tested something like this with stdlib, but there must be some important > difference I did not notice. It make be in the contents of __init__.py. I don't know what you tried, but I can easily replicate Frank's results with an empty __init__.py. > How about import b.d as d, etc? > Try import b; c = b.c Why would any of these make a difference? The AttributeError indicates that at the time d tries to grab the module in b's "c" attribute, the attribute does not exist (because it has not finished importing). Alternate syntaxes for getting the "c" attribute from b are not going to change that. Python does some magic so that you can do "import b.c" inside d while b.c is still importing without resulting in infinite recursion, but the success of the import does not signify that b.c is actually available yet. Cheers, Ian -- http://mail.python.org/mailman/listinfo/python-list
Re: multiprocessing, what am I doing wrong?
On 27/02/2012 16:57, Eric Frederich wrote:
Still freezing sometimes, like 1 out of 10 times that I run it.
Here is updated code and a couple of outputs.
[snip]
I don't know what the problem is. All I can suggest is a slightly
modified version.
If a worker that says it's terminating without first saying that it's
got nothing, then I can only assume that the worker had some uncaught
exception.
#!/usr/bin/env python
import sys
import Queue
import multiprocessing
import time
def FOO(a, b, c):
print 'foo', a, b, c
return (a + b) * c
class MyWorker(multiprocessing.Process):
def __init__(self, name, inbox, outbox):
super(MyWorker, self).__init__()
self.name = name
self.inbox = inbox
self.outbox = outbox
print >> sys.stderr, 'Created %s' % self.name; sys.stderr.flush()
def run(self):
print >> sys.stderr, 'Running %s' % self.name; sys.stderr.flush()
try:
while True:
try:
args = self.inbox.get_nowait()
print >> sys.stderr, '%s got something to do' %
self.name; sys.stderr.flush()
except Queue.Empty:
print >> sys.stderr, '%s got nothing' % self.name;
sys.stderr.flush()
break
self.outbox.put(FOO(*args))
finally:
print >> sys.stderr, '%s is terminating' % self.name;
sys.stderr.flush()
if __name__ == '__main__':
# This file is being run as the main script. This part won't be
# run if the file is imported.
print >> sys.stderr, 'Creating todo queue'; sys.stderr.flush()
todo = multiprocessing.Queue()
for i in xrange(100):
todo.put((i, i + 1, i + 2))
print >> sys.stderr, 'Creating results queue'; sys.stderr.flush()
result_queue = multiprocessing.Queue()
print >> sys.stderr, 'Creating Workers'; sys.stderr.flush()
w1 = MyWorker('Worker 1', todo, result_queue)
w2 = MyWorker('Worker 2', todo, result_queue)
print >> sys.stderr, 'Starting Worker 1'; sys.stderr.flush()
w1.start()
print >> sys.stderr, 'Starting Worker 2'; sys.stderr.flush()
w2.start()
for i in xrange(100):
print result_queue.get()
--
http://mail.python.org/mailman/listinfo/python-list
Re: Udacity CS 101
On Feb 25, 4:20 pm, Josh English wrote: > Has anyone here looked at Udacity's open CS101 course > (http://www.udacity.com/overview/Course/cs101) that started this week? The > goal of the seven week course is to build a web crawler. > > So far, I'm not impressed with the speed or content of the course. I was > wondering what anyone here may think of it. You have to remember that this course assumes no prior computer programming knowledge. I agree, it is starting out very basic. Give it some more time. These guys have PhDs from MIT and/or have taught at Stanford. They know what they are doing. -- http://mail.python.org/mailman/listinfo/python-list
wcout issue
Hello, After upgrading from Python 2.6 to 3.2 in our application we noticed that after calling Py_Initialize, our output from std::wcout has extra spaces in it: wcout << L"Just a test\n"; now prints out: J u s t a t e s t Any clue why? Ben Held -- http://mail.python.org/mailman/listinfo/python-list
Re: America's CONTEMPTUOUS KANGAROO courts VERSUS ISRAELI courts (in JEW-vs-JEW case)
On Feb 28, 12:43 am, small Pox wrote: > America's KANGAROO courts VERSUS ISRAELI courts (in JEW-vs-JEW case > atleast) > > This message is in part to the FBI racists as well as well as to the > RACIST KANGAROO courts of AMERICA. > > In the Jew rapist, Roman Polansky versus Semantha Geimi (Gentile Minor > Girl) the JEW RAPIST Roman Polansky sits FREE in Switzerland and also > France. > > In the Jew rapist, Moshe Katsav who was also ISRAELI PRESIDENT versus > ISRAELI JEW WOMEN , He is in JAIL, without the NAMES of the JEW WOMEN > EVEN BEING RELEASED. > > Truly, AMERICAN FBI BUSTARDS and JUDICIAL BUSTARDS in the CONTEMPTUOUS > SUPREME COURT (which has CONTEMPTED ITSELF by INCOMPETENCE, IGNORANCE > etc) have contempted themselves. > > Now, this case is NOT NEW. It is a VERY OLD CASE. It was filed in LOS > ANGELES COUNTY. > > That is why 9-11 is a jew job and israeli job and the COWARD YANK > BUSTaRDS do not have the COURAGE to ATTACK ISRAEL and do the right > thing. > > The court case record of RAPIST ROMAN > POLANSKYhttp://www.thesmokinggun.com/file/roman-polanski-grand-jury-transcript > > A SWEET SHORT VIDEO for FBI > bustardshttp://www.youtube.com/watch?v=4UqcY8lGUUE&feature=g-vrec&context=G27http://anglo-saxonisrael.com/site/GreatImpersonation-8 Idiot -- http://mail.python.org/mailman/listinfo/python-list
Re: Question about circular imports
Frank Millman wrote: >> >> To avoid the tedious reference, follow this with >> read = sound.formats.wavread # choose the identifier you prefer >> > > @Terry and OKB > > I tried that, but it does not work. > > a.py > /b > __init__.py > c.py >d.py > > a.py - > from b import c > c.py - > import b.d > d.py - > import b.c > > If I run a.py, it returns with no error. > > c.py - > import b.d > d = b.d > d.py - > import b.c > c = b.c > > If I run a.py, I get > > Traceback (most recent call last): > File "F:\tests\a.py", line 1, in > from b import c > File "F:\tests\b\c.py", line 1, in > import b.d > File "F:\tests\b\d.py", line 2, in > c = b.c > AttributeError: 'module' object has no attribute 'c' > > I get the same if I try 'import b.c as c'. Interesting, you're right. Note that it will work in c.py but not in d.py Anyway, testing this just reinforced my distaste for circular imports. Just trying to think about how it ought to work with a importing c but then c and d importing each other makes my brain hurt. Refactoring the files so that common code is in a separate library imported by both is easier to understand, and has the nice side bonus that it works. -- --OKB (not okblacke) Brendan Barnwell "Do not follow where the path may lead. Go, instead, where there is no path, and leave a trail." --author unknown -- http://mail.python.org/mailman/listinfo/python-list
Re: America's CONTEMPTUOUS KANGAROO courts VERSUS ISRAELI courts (in JEW-vs-JEW case)
On Mon, Feb 27, 2012 at 8:13 PM, Tonico wrote: > Idiot Please don't reply to spam. You're just making it show up in the inboxes of those of us who already have these idiots kill-filed. -- http://mail.python.org/mailman/listinfo/python-list
Question about sub-packages
Hi all This is a follow-up to my recent question about circular imports, but on a different subject, hence the new thread. My application has grown to the point that it makes sense to split it up into sub-packages. >From a certain point of view, each package can be said to have an API, not just for third-party users of the application, but for other sub-packages within the application. In other words, there are a number of functions that can be called and a number of objects that can be instantiated from outside the sub-package. It struck me that, even though I can publish the API, it still requires external users to know enough of the internals of the package to know which modules to import and which objects to reference. This has two disadvantages - it makes it more difficult to understand the API, and it makes it more difficult for me to restructure the package internally. An alternative is to have a dedicated API within the sub-package, in the form of one-line functions that are called externally, and then perform whatever action is required internally and return results as appropriate. This is easier for users of the sub-package, and allows me to restructure the internals of the package without causing problems. If this makes sense, my next thought was, where is the best place to put this API. Then I thought, why not put it in the __init__.py of the sub-package? Then all that the users of the package have to do is import the package, and then place calls on it directly. I did a quick test and it seems to work. Is this a good idea, or are there any downsides? Thanks Frank Millman -- http://mail.python.org/mailman/listinfo/python-list
Error importing __init__ declared variable from another package
Hi, I have a simple configuration of modules as beneath, but an import error is reported: /engine (__init__ is empty here) engine.py /sim __init__.py The module engine.py imports a variable instantiated in sim.__init__ as follows: from sim import var_name var_name.func() The following error messaged is received on the func() call above (Eclipse PyDev): "undefined variable from import: func" Any idea why this is causing an error? -- http://mail.python.org/mailman/listinfo/python-list
