On Friday, 27 April 2012 18:09:57 UTC+1, smac...@comcast.net wrote:
> Hello,
>
> For scrapping purposes, I am having a bit of trouble writing a block
> of code to define, and find, the relative position (line number) of a
> string of HTML code. I can pull out one string that I want, and then
> th
Notebook
Actions
Cell
Actions
Format
Output
Insert
Move
Run
Autoindent:
Kernel
Actions
Kill kernel upon exit:
Help
Python IPython Links
NumPy SciPy
MPL SymPy
run selected cell Shift-Enter :
run selected cell in-place Ctrl-Enter :
show keyboard shortcuts Ctrl-m h :
Configuration
Tooltip on tab:
Smar
smac2...@comcast.net wrote:
>
>For scrapping purposes, I am having a bit of trouble writing a block
>of code to define, and find, the relative position (line number) of a
>string of HTML code. I can pull out one string that I want, and then
>there is always a line of code, directly beneath the one
On 4/27/2012 9:55 PM, Paul Rubin wrote:
John Nagle writes:
I may do that to prevent the stall. But the real problem was all
those DNS requests. Parallizing them wouldn't help much when it took
hours to grind through them all.
True dat. But building a DNS cache into the application seem
John Nagle writes:
>I may do that to prevent the stall. But the real problem was all
> those DNS requests. Parallizing them wouldn't help much when it took
> hours to grind through them all.
True dat. But building a DNS cache into the application seems like a
kludge. Unless the number of
On 4/27/2012 9:20 PM, Paul Rubin wrote:
John Nagle writes:
The code that stored them looked them up with "getaddrinfo()", and
did this while a lock was set.
Don't do that!!
Added a local cache in the program to prevent this.
Performance much improved.
Better to release the lock while
John Nagle writes:
> The code that stored them looked them up with "getaddrinfo()", and
> did this while a lock was set.
Don't do that!!
>Added a local cache in the program to prevent this.
> Performance much improved.
Better to release the lock while the getaddrinfo is running, if you can
On Sat, Apr 28, 2012 at 1:35 PM, John Nagle wrote:
> On CentOS, "getaddrinfo()" at the
> glibc level doesn't always cache locally (ref
> https://bugzilla.redhat.com/show_bug.cgi?id=576801). Python
> doesn't cache either.
How do you manage your local cache? The Python getaddrinfo function
doesn't
On 4/27/2012 6:25 PM, Adam Skutt wrote:
On Apr 27, 2:54 pm, John Nagle wrote:
I have a multi-threaded CPython program, which has up to four
threads. One thread is simply a wait loop monitoring the other
three and waiting for them to finish, so it can give them more
work to do. When the
Adam Skutt writes:
> On Apr 27, 12:56 pm, Steven D'Aprano +comp.lang.pyt...@pearwood.info> wrote:
> > On Thu, 26 Apr 2012 04:42:36 -0700, Adam Skutt wrote:
> > > Steven D'Aprano wrote:
> > >> The Borg design pattern, for example, would be an excellent
> > >> candidate for ID:identity being treat
On Apr 27, 2:54 pm, John Nagle wrote:
> I have a multi-threaded CPython program, which has up to four
> threads. One thread is simply a wait loop monitoring the other
> three and waiting for them to finish, so it can give them more
> work to do. When the work threads, which read web pages a
On 27/04/2012 23:30, Dennis Lee Bieber wrote:
Oh, continuation thought...
If the workers are calling into C-language operations, unless those
operations release the GIL, it doesn't matter what the OS or Python
thread switch timings are. The OS may interrupt the thread (running
C
I am trying to hook into the TableEditor on Controldesk using Python.
Unfortunately there are no good examples of how to write the code
anywhere I have looked.
Does anyone know where to look? OR does anyone have code?
Thanks
Chuck
--
http://mail.python.org/mailman/listinfo/python-list
On Apr 27, 2:40 pm, Steven D'Aprano wrote:
> On Fri, 27 Apr 2012 10:33:34 -0700, Adam Skutt wrote:
> >> Why should the caller care whether they are dealing with a singleton
> >> object or an unspecified number of Borg objects all sharing state? A
> >> clever interpreter could make many Borg instan
John Nagle writes:
>I know that the CPython thread dispatcher sucks, but I didn't
> realize it sucked that bad. Is there a preference for running
> threads at the head of the list (like UNIX, circa 1979) or
> something like that?
I think it's left up to the OS thread scheduler, Windows in yo
On 4/27/2012 20:54, John Nagle wrote:
I have a multi-threaded CPython program, which has up to four
threads. One thread is simply a wait loop monitoring the other
three and waiting for them to finish, so it can give them more
work to do. When the work threads, which read web pages and
then parse
On 27/04/2012 6:55 PM, Stefan Behnel wrote:
Peter Faulks, 27.04.2012 10:36:
On 27/04/2012 5:15 PM, Stefan Behnel wrote:
Peter Faulks, 26.04.2012 19:57:
I want to extend an embedded interpreter so that calls to print() are
automagically sent to a C++ gui (windows exe) via a callback function in
comcast.net> writes:
>
> Hello,
>
[snip]
> Any thoughts as to how to define a function to do this, or do this
> some other way? All insight is much appreciated! Thanks.
>
Did you not see my reply to your previous thread?
And why do you want the line number?
Jon.
--
http://mail.python.or
On 2012-04-27, Grant Edwards wrote:
> On 2012-04-27, Grant Edwards wrote:
>> On 2012-04-27, Paul Rubin wrote:
>>> python writes:
What to decode hex '0xC0A8' and return signed short int.
>>>
>>> Is this right?
>>>
>>> n = int('0xC0A8', 16)
>>> if n >= 0x:
>>>n -= 0x1000
On 2012-04-27, Grant Edwards wrote:
> On 2012-04-27, Paul Rubin wrote:
>> python writes:
>>> What to decode hex '0xC0A8' and return signed short int.
>>
>> Is this right?
>>
>> n = int('0xC0A8', 16)
>> if n >= 0x:
>>n -= 0x1
>
> Yes, as long as the input value doesn't ex
On 27/04/2012 20:32, Ian Kelly wrote:
On Fri, Apr 27, 2012 at 12:56 PM, Paul Rubin wrote:
python writes:
What to decode hex '0xC0A8' and return signed short int.
Is this right?
n = int('0xC0A8', 16)
if n>= 0x:
n -= 0x1
No.
n = int('0xC0A8', 16)
if n>= 0x800
On Fri, Apr 27, 2012 at 12:56 PM, Paul Rubin wrote:
> python writes:
>> What to decode hex '0xC0A8' and return signed short int.
>
> Is this right?
>
> n = int('0xC0A8', 16)
> if n >= 0x:
> n -= 0x1
No.
n = int('0xC0A8', 16)
if n >= 0x8000:
n -= 0x1
--
http://mail.
Steven D'Aprano writes:
>> Is this right?
>>
>> n = int('0xC0A8', 16)
>> if n >= 0x:
>>n -= 0x1
> No.
Oops, I meant n >= 0x7fff. Checking the sign bit.
Grant Edwards writes:
> Yes, as long as the input value doesn't exceed 0x1. This is
> probably better:
>
> n
On 2012-04-27, Paul Rubin wrote:
> python writes:
>> What to decode hex '0xC0A8' and return signed short int.
>
> Is this right?
>
> n = int('0xC0A8', 16)
> if n >= 0x:
>n -= 0x1
Yes, as long as the input value doesn't exceed 0x1. This is
probably better:
n = int(
On 4/27/12 7:18 PM, Debashish Saha wrote:
You will want to ask numpy questions on the numpy mailing list.
http://www.scipy.org/Mailing_Lists
When you do, I recommend stating a clear question in addition to the code and
the traceback (although those are very much appreciated). But just to get
On Fri, 27 Apr 2012 11:56:45 -0700, Paul Rubin wrote:
> python writes:
>> What to decode hex '0xC0A8' and return signed short int.
>
> Is this right?
>
> n = int('0xC0A8', 16)
> if n >= 0x:
>n -= 0x1
No.
>>> struct.unpack('>h',b'\xC0\xA8')
(-16216,)
>>> n = int('0xC0
python writes:
> What to decode hex '0xC0A8' and return signed short int.
Is this right?
n = int('0xC0A8', 16)
if n >= 0x:
n -= 0x1
--
http://mail.python.org/mailman/listinfo/python-list
I have a multi-threaded CPython program, which has up to four
threads. One thread is simply a wait loop monitoring the other
three and waiting for them to finish, so it can give them more
work to do. When the work threads, which read web pages and
then parse them, are compute-bound, I've had
> Hello,
>
> For scrapping purposes, I am having a bit of trouble writing a block
> of code to define, and find, the relative position (line number) of a
> string of HTML code. I can pull out one string that I want, and then
> there is always a line of code, directly beneath the one I can pull
> o
On Fri, 27 Apr 2012 10:33:34 -0700, Adam Skutt wrote:
>> Why should the caller care whether they are dealing with a singleton
>> object or an unspecified number of Borg objects all sharing state? A
>> clever interpreter could make many Borg instances appear to be a
>> singleton. A really clever on
> > I have spent some time searching for a bug in my code, it was due to
> > different work of "is" with () and []:
> () is ()
> > True
> [] is []
> > False
> >
> > (Python 2.7.2+ (default, Oct 4 2011, 20:03:08)
> > [GCC 4.6.1] )
> >
> > Is this what it should be or maybe yielding unifie
On Sat, Apr 28, 2012 at 3:51 AM, Adam Skutt wrote:
> Yes, there is a way. You add a function deref() to the language. In
> CPython, that simply treats the passed value as a memory address and
> treats it as an object, perhaps with an optional check. In Jython,
> it'd access a global table of nu
On Fri, Apr 27, 2012 at 11:38 AM, Chris Angelico wrote:
> On Sat, Apr 28, 2012 at 3:33 AM, Adam Skutt wrote:
>> I think you misunderstood me. Define a Borg class where somehow
>> identity is the same for all instances. Inherit from that class and
>> add per-instance members. Now, identity can'
On Apr 27, 1:06 pm, Steven D'Aprano wrote:
> On Thu, 26 Apr 2012 04:42:36 -0700, Adam Skutt wrote:
> > On Apr 26, 5:10 am, Steven D'Aprano > +comp.lang.pyt...@pearwood.info> wrote:
> >> But I was actually referring to something more fundamental than that.
> >> The statement "a is b" is a *direct*
from __future__ import division
from numpy import*
import numpy as np
import matplotlib.pyplot as plt
from scipy.special import jv
from scipy.special import yn
h_cross=1
m=1
E=np.linspace(0.1,10,100)
V0=-100
R=2
K=(2*E)**0.5
K_P=(2*(E-V0))**0.5
'''r=np.linspace(-10,10,1000)
def V(r):
if
On Fri, Apr 27, 2012 at 11:33 AM, Adam Skutt wrote:
> On Apr 27, 12:56 pm, Steven D'Aprano +comp.lang.pyt...@pearwood.info> wrote:
>> On Thu, 26 Apr 2012 04:42:36 -0700, Adam Skutt wrote:
>> > You're going to have to explain the value of an "ID" that's not 1:1 with
>> > an object's identity, for
On Apr 27, 1:12 pm, Steven D'Aprano wrote:
> On Thu, 26 Apr 2012 04:42:36 -0700, Adam Skutt wrote:
> > On Apr 26, 5:10 am, Steven D'Aprano > +comp.lang.pyt...@pearwood.info> wrote:
> >> Solution to *what problem*?
>
> > This confusion that many people have over what 'is' does, including
> > yours
On Fri, 27 Apr 2012 10:15:32 -0700, Adam Skutt wrote:
> If I write a program in Python that treats variables as if they were
> values, it will be incorrect.
I'm sorry, it is unclear to me what distinction you are making between
variables and values. Can you give simple examples of both incorrect
On Sat, Apr 28, 2012 at 3:33 AM, Adam Skutt wrote:
> I think you misunderstood me. Define a Borg class where somehow
> identity is the same for all instances. Inherit from that class and
> add per-instance members. Now, identity can't be the same for all
> instances. As a result, you've just v
On Apr 27, 12:56 pm, Steven D'Aprano wrote:
> On Thu, 26 Apr 2012 04:42:36 -0700, Adam Skutt wrote:
> > You're going to have to explain the value of an "ID" that's not 1:1 with
> > an object's identity, for at least the object's lifecycle, for a
> > programmer. If you can't come up with a useful
On 4/27/2012 4:55 AM, Stefan Behnel wrote:
I want the script
itself to update a window in the host application (via the extension) every
time the script calls print().
Then replace sys.stdout (and maybe also sys.stderr) by another object that
does what you want whenever its write() method is c
Steven, your posts are leaking out of their respective thread(s). Is
this intentional?
~Temia
--
When on earth, do as the earthlings do.
--
http://mail.python.org/mailman/listinfo/python-list
On Apr 27, 11:01 am, Kiuhnm wrote:
> On 4/27/2012 1:57, Adam Skutt wrote:
> > On Apr 26, 6:34 pm, Kiuhnm wrote:
> >>> If you
> >> understand that your 'a' is not really an object but a reference to it,
> >> everything becomes clear and you see that '==' always do the same thing.
>
> > Yes, object
On Thu, 26 Apr 2012 04:42:36 -0700, Adam Skutt wrote:
> On Apr 26, 5:10 am, Steven D'Aprano +comp.lang.pyt...@pearwood.info> wrote:
>> Solution to *what problem*?
>>
> This confusion that many people have over what 'is' does, including
> yourself.
I have no confusion over what "is" does. The "i
Hello,
For scrapping purposes, I am having a bit of trouble writing a block
of code to define, and find, the relative position (line number) of a
string of HTML code. I can pull out one string that I want, and then
there is always a line of code, directly beneath the one I can pull
out, that begin
On Thu, 26 Apr 2012 04:42:36 -0700, Adam Skutt wrote:
> On Apr 26, 5:10 am, Steven D'Aprano +comp.lang.pyt...@pearwood.info> wrote:
>> But I was actually referring to something more fundamental than that.
>> The statement "a is b" is a *direct* statement of identity. "John is my
>> father." "id(
Adam Skutt wrote:
[ ... ]
> In the real world, if we were doing the math with pen and paper, we'd
> stop as soon as we hit such an error. Equality is simply not defined
> for the operations that can produce NaN, because we don't know to
> perform those computations. So no, it doesn't conceptually
On Thu, 26 Apr 2012 04:42:36 -0700, Adam Skutt wrote:
> You're going to have to explain the value of an "ID" that's not 1:1 with
> an object's identity, for at least the object's lifecycle, for a
> programmer. If you can't come up with a useful case, then you haven't
> said anything of merit.
I
On Fri, Apr 27, 2012 at 10:07 AM, Steven D'Aprano
wrote:
> How about you give an actual working example of what you mean by a code
> block and how you use it?
He wrote a full blog post about it last week:
http://mtomassoli.wordpress.com/2012/04/20/code-blocks-in-python/
--
http://mail.python.or
On Fri, Apr 27, 2012 at 9:39 AM, Adam Skutt wrote:
> On Apr 27, 8:07 am, Kiuhnm wrote:
>> Useful... maybe, conceptually sound... no.
>> Conceptually, NaN is the class of all elements which are not numbers,
>> therefore NaN = NaN.
>
> NaN isn't really the class of all elements which aren't numbers
On Fri, 27 Apr 2012 17:03:19 +0200, Kiuhnm wrote:
> On 4/27/2012 16:09, Steven D'Aprano wrote:
>> On Fri, 27 Apr 2012 13:24:35 +0200, Kiuhnm wrote:
>>
>>> I'd like to change the syntax of my module 'codeblocks' to make it
>>> more pythonic.
>>>
>>> Current Syntax:
>>>
>>> with res << func(ar
On Apr 27, 8:07 am, Kiuhnm wrote:
> Useful... maybe, conceptually sound... no.
> Conceptually, NaN is the class of all elements which are not numbers,
> therefore NaN = NaN.
NaN isn't really the class of all elements which aren't numbers. NaN
is the result of a few specific IEEE 754 operations t
On 4/27/2012 16:07, Steven D'Aprano wrote:
On Fri, 27 Apr 2012 14:17:48 +0200, Kiuhnm wrote:
Define your terms: what do you mean by "equal"?
a and b are equal iff
Nope. What I meant is that we can talk of equality whenever...
a = a
a = b => b = a
a = b and b = c => a = c
If some of this
On 4/27/2012 16:09, Steven D'Aprano wrote:
On Fri, 27 Apr 2012 13:24:35 +0200, Kiuhnm wrote:
I'd like to change the syntax of my module 'codeblocks' to make it more
pythonic.
Current Syntax:
with res << func(arg1) << 'x, y':
print(x, y)
with res << func(arg1) << block_n
On 4/27/2012 1:57, Adam Skutt wrote:
On Apr 26, 6:34 pm, Kiuhnm wrote:
On 4/26/2012 20:54, Adam Skutt wrote:
On Apr 26, 12:02 pm, Kiuhnmwrote:
On 4/26/2012 16:00, Adam Skutt wrote:
On Apr 26, 9:37 am, Kiuhnm wrote:
The fact that you think that that's "differing behaviour" is what ma
On Fri, 27 Apr 2012 13:24:35 +0200, Kiuhnm wrote:
> I'd like to change the syntax of my module 'codeblocks' to make it more
> pythonic.
>
> Current Syntax:
>
> with res << func(arg1) << 'x, y':
> print(x, y)
>
> with res << func(arg1) << block_name << 'x, y':
> print
On Fri, 27 Apr 2012 14:17:48 +0200, Kiuhnm wrote:
>>> Define your terms: what do you mean by "equal"?
>>
>> a and b are equal iff
>
> Nope. What I meant is that we can talk of equality whenever...
>
>> a = a
>> a = b => b = a
>> a = b and b = c => a = c
>> If some of this properties are violated
On 04/27/12 07:23, Chris Angelico wrote:
On Fri, Apr 27, 2012 at 10:17 PM, John O'Hagan wrote:
results = [x = expensive_call(i) for i in iterable if condition(x)]
Nest it:
results = [x for x in (expensive_call(i) for i in iterable) if condition(x)]
While it's what I do in cases like this,
On Fri, Apr 27, 2012 at 10:17 PM, John O'Hagan wrote:
> results = [x = expensive_call(i) for i in iterable if condition(x)]
Nest it:
results = [x for x in (expensive_call(i) for i in iterable) if condition(x)]
ChrisA
--
http://mail.python.org/mailman/listinfo/python-list
On 4/27/2012 14:07, Kiuhnm wrote:
On 4/27/2012 13:09, Steven D'Aprano wrote:
On Thu, 26 Apr 2012 18:02:31 +0200, Kiuhnm wrote:
On 4/26/2012 16:00, Adam Skutt wrote:
C# and Python do have a misfeature: '==' is identity comparison only if
operator== / __eq__ is not overloaded. Identity comparis
On Fri, 27 Apr 2012 19:57:31 +1000
Chris Angelico wrote:
> On Fri, Apr 27, 2012 at 7:49 PM, Miles Rout wrote:
> > We have if inside list comprehensions? I didn't know that, could you provide
> > an example?
>
> You mean like:
>
> [x*2+1 for x in range(10) if x%3]
>
Speaking of list comprehen
On Fri, Apr 27, 2012 at 10:07 PM, Kiuhnm
wrote:
> Conceptually, NaN is the class of all elements which are not numbers,
> therefore NaN = NaN. The conceptually correct way would be to check for
> 'NaN' explicitly.
Conceptually, "single-digit-numbers" is the class of all elements
which are integer
Issue get solved by updating following packages
$ easy_install -U DecoratorTools
$ easy_install -U turbojson
--
http://mail.python.org/mailman/listinfo/python-list
On 4/27/2012 13:09, Steven D'Aprano wrote:
On Thu, 26 Apr 2012 18:02:31 +0200, Kiuhnm wrote:
On 4/26/2012 16:00, Adam Skutt wrote:
C# and Python do have a misfeature: '==' is identity comparison only if
operator== / __eq__ is not overloaded. Identity comparison and value
comparison are disjoi
On Fri, Apr 27, 2012 at 8:37 PM, Tim Wintle wrote:
> Or like:
>
print [ 0 if b%2==1 else 1 for b in range(10)]
> [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]
That's nothing to do with the list comp, that's just the expression-if
syntax that you can use anywhere.
ChrisA
--
http://mail.python.org/mailman/
I'd like to change the syntax of my module 'codeblocks' to make it more
pythonic.
Current Syntax:
with res << func(arg1) << 'x, y':
print(x, y)
with res << func(arg1) << block_name << 'x, y':
print(x, y)
New Syntax:
with res == func(arg1) .taking_block (x, y):
On Thu, 26 Apr 2012 11:31:39 -0700, John Nagle wrote:
> I would suggest that "is" raise ValueError for the ambiguous cases.
> If both operands are immutable, "is" should raise ValueError. That's the
> case where the internal representation of immutables shows through.
You've already made this
On 4/27/12 12:07 AM, Paul Rubin wrote:
Nobody writes:
All practical languages have some implementation-defined behaviour, often
far more problematic than Python's.
The usual reason for accepting implementation-defined behavior is to
enable low-level efficiency hacks written for specific machi
On Fri, 2012-04-27 at 19:57 +1000, Chris Angelico wrote:
> On Fri, Apr 27, 2012 at 7:49 PM, Miles Rout wrote:
> > We have if inside list comprehensions? I didn't know that, could you provide
> > an example?
>
> You mean like:
>
> [x*2+1 for x in range(10) if x%3]
Or like:
>>> print [ 0 if b%2=
On Thu, 26 Apr 2012 18:02:31 +0200, Kiuhnm wrote:
> On 4/26/2012 16:00, Adam Skutt wrote:
>> C# and Python do have a misfeature: '==' is identity comparison only if
>> operator== / __eq__ is not overloaded. Identity comparison and value
>> comparison are disjoint operations, so it's entirely inap
On 4/27/2012 11:49, Miles Rout wrote:
On 27/04/2012 5:57 a.m., Kiuhnm wrote:
On 4/26/2012 19:48, Paul Rubin wrote:
Roy Smith writes:
x = [a for a in iterable while a]
from itertools import takewhile
x = takewhile(bool, a)
I see that as a 'temporary' solution, otherwise we wouldn't need 'i
On Fri, Apr 27, 2012 at 7:49 PM, Miles Rout wrote:
> We have if inside list comprehensions? I didn't know that, could you provide
> an example?
You mean like:
[x*2+1 for x in range(10) if x%3]
?
ChrisA
--
http://mail.python.org/mailman/listinfo/python-list
On 27/04/2012 5:57 a.m., Kiuhnm wrote:
On 4/26/2012 19:48, Paul Rubin wrote:
Roy Smith writes:
x = [a for a in iterable while a]
from itertools import takewhile
x = takewhile(bool, a)
I see that as a 'temporary' solution, otherwise we wouldn't need 'if'
inside of list comprehensions either
On Apr 26, 10:56 pm, "OKB (not okblacke)"
wrote:
> Adam Skutt wrote:
> > If I write a function that does a value comparison, then it should
> > do value comparison on _every type that can be passed to it_,
> > regardless of whether the type is a primitive or an object, whether
> > it has value or
Peter Faulks, 27.04.2012 10:36:
> On 27/04/2012 5:15 PM, Stefan Behnel wrote:
>> Peter Faulks, 26.04.2012 19:57:
>>> I want to extend an embedded interpreter so that calls to print() are
>>> automagically sent to a C++ gui (windows exe) via a callback function in
>>> the DLL.
>>>
>>> Then I'll be a
On 27/04/2012 5:15 PM, Stefan Behnel wrote:
Peter Faulks, 26.04.2012 19:57:
I want to extend an embedded interpreter so that calls to print() are
automagically sent to a C++ gui (windows exe) via a callback function in
the DLL.
Then I'll be able to do this:
test.py
import printoverload
Peter Faulks, 26.04.2012 19:57:
> I want to extend an embedded interpreter so that calls to print() are
> automagically sent to a C++ gui (windows exe) via a callback function in
> the DLL.
>
> Then I'll be able to do this:
>
> test.py
> import printoverload
>
> printoverload.set_stdout(
Peter Faulks, 26.04.2012 21:28:
> "All you have to do is assign to print". Sounds great! Can some kind soul
> hit me with a clue stick? Were do I look in the API?
Here's the (Py3) Cython code for it:
print = my_print_function
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
78 matches
Mail list logo