Re: Question about Source Control

2014-03-19 Thread Chris Angelico
On Wed, Mar 19, 2014 at 5:41 PM, Frank Millman  wrote:
> I have decided to stick with Mercurial, simply because that is what I used
> in my previous attempt and I felt comfortable with it.

That's the best reason for choosing, really.
https://github.com/Rosuav/Gypsum/commit/0f973
> Also I believe that
> Python itself uses it, so if it is good enough for them ...

Mercurial is used by a good number of high-profile projects. You're
probably thinking of CPython, the implementation, but
Python-the-language is built on top of Mercurial too, with such as the
PEP repo and the web site (although I understand the latest version of
the web site is managed in git). Both git and hg are used by plenty of
solid projects, including the Linux kernel (git's original purpose),
themselves (git's development is managed in git, hg's is managed in
hg), and plenty of other big projects. This is one reason why I always
push people to either of those two, rather than to an unknown or
proprietary system that might have problems.

> I realise now that my initial problem had nothing to do with SCM/VCS, and
> everything to do with my lack of knowledge of basic networking protocols. As
> I understand it now, if I want to share the repository over a network, I can
> choose between SSH and HTTP. I like the following quote from Joel Spolsky -
>
> "The quick-and-dirty way to make a central repository is to use Mercurial's
> built in web-server. ... I'm going to configure the server to allow anybody
> in the world to do anything they want to it. ... Needless to say, this is
> rather unsafe, but if you're on a nice protected LAN at work and there's a
> good firewall and you trust everybody on your LAN, this is reasonably OK."
>
> This describes my situation well, so to keep things simple I will start with
> this.

Yep! People complain loudly about the insecurity of protocols like
FTP, but properly-firewalled networks with all members trusted are
more common than you might think - all you need is a basic home-grade
NAT router and a sysadmin whose competence exceeds the sensitivity of
your content.

> To recap my basic setup, I have machine A which holds the source directory,
> machine B which is used to edit the program, and machines B and C which are
> both used to run the program.
>
> Initially, to prove that I understand the concept, I propose to install
> Mercurial on all three machines. Machine A will hold the central repository,
> which I will clone onto machines B and C. After editing on B, I will 'push'
> to A, and then from C 'pull' from A to get the latest version.

Right. That's a nice standard setup. There'll be plenty of tutorials
that can walk you through setting that up. (Don't forget, btw, that
most Linux distributions will include Mercurial - just "apt-get
install mercurial" or "yum install mercurial".)

> If this works, I will simplify it to make my life easier. My first thought
> was to remove the clone from machine C and set up an nfs share pointing to
> the working directory on machine A, so I don't need the 'pull' step. Then I
> thought, why not just point to the working directory on machine B, so then I
> can test the changes on C directly, without even having to 'push'. I realise
> that this is defeating the object of version control, but I think it makes
> sense. I will still use version control to maintain a full history of the
> project on machine A.

It doesn't defeat the object of version control as long as you always
make logical, conceptual commits. However, it does introduce a
dependency (the NFS share) and the associated messes of file locking
and so on, so I personally would prefer to deploy a file-transfer
system, maybe like the one I described earlier, or maybe something
more like FTP. But do whatever makes sense for you.

> Over the last few years I have frequently 'trashed' whole sections
> of my code and rewritten them, which I suspect would not endear me to
> someone attempting to collaborate with me. However, the broad framework is
> starting to settle down now, so I am starting to think about putting it out
> there.

That's not in itself a problem. This commit made quite a few changes,
all at once:

https://github.com/Rosuav/Gypsum/commit/0f973

It does mean that anyone who's collaborating with you will need to
keep a close eye on what goes on, but that's true of any fast-moving
project. As things get more stable, it'll be easier to join in.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: 'complex' function with string argument.

2014-03-19 Thread wxjmfauth

z = a + b*i with a, b, elements of R
z = r*exp(i*phi)with r, phi, elements of R
z = [[a, -b], [b, a]]   with a, b, elements of R

This is, in my mind, more questionable:

>>> complex(2, 1+1j)
(1+1j)
>>> 
>>> print(complex.__doc__)
complex(real[, imag]) -> complex number

Create a complex number from a real part and an optional imaginary part.
This is equivalent to (real + imag*1j) where imag defaults to 0.

jmf
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Balanced trees

2014-03-19 Thread Marko Rauhamaa
Steven D'Aprano :

> If you are in a position to randomize the data before storing it in
> the tree, an unbalanced binary tree is a solid contender.

Applications that can assume randomly distributed data are exceedingly
rare and even then, you can't easily discount the possibility of
worst-case ordering.

In fact, Dan himself said unbalanced trees performed so badly he
couldn't test them satisfactorily.


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: 'complex' function with string argument.

2014-03-19 Thread Marko Rauhamaa
wxjmfa...@gmail.com:

> This is, in my mind, more questionable:
>
 complex(2, 1+1j)
> (1+1j)

I find it neat, actually.


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list


unable to import rlcompleter readline

2014-03-19 Thread muru kessan
hi guys,
i want the python interactive shell to be auto complete and i found that by
adding the following lines in PYTHONSTARTUP file it is possible

import rlcompleter, readline
readline.parse_and_bind('tab: complete')

but i get the following error in git bash shell
Note: i run windows8 as Operating System

Python 2.7 (r27:82525, Jul  4 2010, 07:43:08) [MSC v.1500 64 bit (AMD64)]
on win
32
Type "help", "copyright", "credits" or "license" for more information.
Traceback (most recent call last):
  File "C:\muru work 05-nov-2013\python\start.py", line 6, in 
import rlcompleter, readline
ImportError: No module named readline

Any help would be appreciated

Thanks,
muru
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: unable to import rlcompleter readline

2014-03-19 Thread Tim Golden
On 19/03/2014 08:55, muru kessan wrote:
> hi guys,
> i want the python interactive shell to be auto complete and i found that
> by adding the following lines in PYTHONSTARTUP file it is possible
> 
> import rlcompleter, readline
> readline.parse_and_bind('tab: complete')
> 
> but i get the following error in git bash shell
> Note: i run windows8 as Operating System
> 
> Python 2.7 (r27:82525, Jul  4 2010, 07:43:08) [MSC v.1500 64 bit
> (AMD64)] on win
> 32
> Type "help", "copyright", "credits" or "license" for more information.
> Traceback (most recent call last):
>   File "C:\muru work 05-nov-2013\python\start.py", line 6, in 
> import rlcompleter, readline
> ImportError: No module named readline

readline is commonly provided on *nix systems, but not on Windows. You
can install a plug-compatible version here:

  https://pypi.python.org/pypi/pyreadline/2.0

(ie pip install pyreadline)

or just use IPython which project maintains it:

  http://ipython.org/

NB installing pyreadline will override the way in which Python interacts
with the standard Windows console's up/down/history recall features.
(Assuming it hasn't changed since I last used it a few years ago).

TJG
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: 'complex' function with string argument.

2014-03-19 Thread wxjmfauth
Le mercredi 19 mars 2014 09:51:20 UTC+1, Marko Rauhamaa a écrit :
> wxjmfa...@gmail.com:
> 
> 
> 
> > This is, in my mind, more questionable:
> 
> >
> 
>  complex(2, 1+1j)
> 
> > (1+1j)
> 
> 
> 
> I find it neat, actually.
> 
> 
> 
> 
> 
> Marko

>>> # tricky: yes, neat: no
>>> complex(1+1j, 2)
(1+3j)
>>>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: 'complex' function with string argument.

2014-03-19 Thread Marko Rauhamaa
wxjmfa...@gmail.com:

> Le mercredi 19 mars 2014 09:51:20 UTC+1, Marko Rauhamaa a écrit :
>> wxjmfa...@gmail.com:
>>  complex(2, 1+1j)
>> > (1+1j)
>> 
>> I find it neat, actually.
>
 # tricky: yes, neat: no
 complex(1+1j, 2)
> (1+3j)

So complex(a, b) is documented to produce a+bj when a and b are integers
or floats. What's more natural than saying it produces a+bj when a and b
are complex numbers? It's a straightforward generalization that in no
way violates the more limited documentation.


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list


PNYIKOS DOWN AND UNDER!

2014-03-19 Thread THRINAXODON JM

===
>BREAKING NEWS
===
>
RICHARD LEAKEY JUST DIED DUE TO HEART FAILURE!
>
THE REASONS DESCRIBED BY THE MEDICAL TEAM IS THAT HIS WORK WAS
DISPROVEN, BY NONE OTHER THAN YOUR OWN BASTARD, THRINAXODON.
>
THIS CAUSED LEAKEY'S HEART TO EXPLODE!
>
THRINAXODON DANCED WITH JOY AS HE WAS GRANTED $600,000,000,000.000!
>
TO WASTE YOUR TIME EVEN FURTHER, CHECK OUT THESE LINKS BELOW.
===
EVIDENCE THAT HUMANS LIVED IN THE DEVONIAN:

https://groups.google.com/group/sci.bio.paleontology/browse_thread/threa
d/6f501c469c7af24f# 
 




https://groups.google.com/group/sci.bio.paleontology/browse_thread/threa
d/3aad75c16afb0b82# 
 




==
==

http://thrinaxodon.wordpress.com/ 

===

THRINAXODON ONLY HAD THIS TO SAY:

"I..I...I...Can't believe it. This completely disproved Darwinian
orthodoxy."

===

THE BASTARDS AT THE SMITHSONIAN, AND THE LEAKEY FOUNDATION ARE ERODING
WITH FEAR.

===
THESE ASSHOLES ARE GOING TO DIE:
THOMAS AQUINAS;
ALDOUS HUXLEY;
BOB CASANVOVA;
SkyEyes;
DAVID IAIN GRIEG;
MARK ISAAK;
JOHN HARSHAM;
RICHARD NORMAN;
DR. DOOLITTLE;
CHARLES DARWIN;
MARK HORTON;
ERIK SIMPSON;
HYPATIAB7;
PAUL J. GANS;
JILLERY;
WIKI TRIK;
THRINAXODON;
PETER NYIKOS;
RON OKIMOTO;
JOHN S. WILKINS
===

THRINAXODON WAS SCOURING ANOTHER DEVONIAN FOSSIL BED, AND FOUND A
HUMAN SKULL, AND A HUMAN FEMUR. HE ANALYSED THE FINDS, AND SAW THAT
THEY WERE NOT NORMAL ROCKS. THESE WERE FOSSILIZED BONES. THEY EVEN HAD
TOOTH MARKS ON THEM. SO, THRINAXODON BROUGHT THEM TO THE LEAKEY
FOUNDATION, THEY UTTERLY DISMISSED IT, AND SAID, "We want to keep
people thinking that humans evolved 2 Ma." THRINAXODON BROUGHT HIS
SWORD, AND SAID, "SCIENCE CORRECTS ITSELF." RICHARD LEAKEY SAID, "That
is a myth, for people to believe in science." THRINAXODON PLANS TO
BRING DOOM TO SCIENCE, ITSELF.



THRINAXODON IS NOW ON REDDIT

--
---Thrinaxodon

--
https://mail.python.org/mailman/listinfo/python-list


Re: 'complex' function with string argument.

2014-03-19 Thread Ian Kelly
On Wed, Mar 19, 2014 at 4:09 AM, Marko Rauhamaa  wrote:
> wxjmfa...@gmail.com:
>
>> Le mercredi 19 mars 2014 09:51:20 UTC+1, Marko Rauhamaa a écrit :
>>> wxjmfa...@gmail.com:
>>>  complex(2, 1+1j)
>>> > (1+1j)
>>>
>>> I find it neat, actually.
>>
> # tricky: yes, neat: no
> complex(1+1j, 2)
>> (1+3j)
>
> So complex(a, b) is documented to produce a+bj when a and b are integers
> or floats. What's more natural than saying it produces a+bj when a and b
> are complex numbers? It's a straightforward generalization that in no
> way violates the more limited documentation.

When is it ever useful though?  I only see a use for passing a as
complex if b is omitted, and I don't see any use for passing b as
complex.  If there's no use case, then it's just a confusing edge case
that will catch unsuspecting programmers who thought the data they
were passing in was real-valued when actually it wasn't.  It would be
better to raise an exception in either of the cases above, in my
opinion.  If you really want to form a complex a+bj from two other
complex numbers, there is always the explicit (a + b * 1j).

That said, complex numbers have been around since 1.4 or so, and
there's probably not much chance to change it now.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: 'complex' function with string argument.

2014-03-19 Thread Marko Rauhamaa
Ian Kelly :

> On Wed, Mar 19, 2014 at 4:09 AM, Marko Rauhamaa  wrote:
>> So complex(a, b) is documented to produce a+bj when a and b are integers
>> or floats. What's more natural than saying it produces a+bj when a and b
>> are complex numbers? It's a straightforward generalization that in no
>> way violates the more limited documentation.
>
> When is it ever useful though? [...] It would be better to raise an
> exception in either of the cases above, in my opinion.

I don't think it matters one way or another.

Medieval mathematicians had to address an analogous issue when they had
to decide if

   x + 0

was meaningful. After all, adding nothing doesn't make any sense and
should raise a ValueError exception...


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: 'complex' function with string argument.

2014-03-19 Thread Skip Montanaro
On Wed, Mar 19, 2014 at 5:33 AM, Ian Kelly  wrote:
> When is it ever useful though?

About as often as int(0), float(0), or float(0.0) which all work as
expected, though probably don't turn up in a lot of code.

Skip
-- 
https://mail.python.org/mailman/listinfo/python-list


[ANN]: distlib 0.1.8 released on PyPI

2014-03-19 Thread Vinay Sajip
I've released version 0.1.8 of distlib on PyPI [1]. For newcomers,
distlib is a library of packaging functionality which is intended
to be usable as the basis for third-party packaging tools.

The main changes in this release are as follows:

* Fixed issue #45: Improved thread-safety in SimpleScrapingLocator.
* Fixed issue #42: Handling of pre-release legacy version numbers
  now mirrors setuptools logic.
* Added exists, verify, update, is_compatible and is_mountable methods
  to the Wheel class (the update method fixed issue #41).
* Added a search method to the PackageIndex class.
* Fixed a bug in the Metadata.add_requirements method.
* Allowed versions with a single numeric component and a local version
  component (tracking changes to PEP 440).* Corrected spelling of environment 
variable used for the stub launcher
  on OS X.
* Avoided using pydist.json in 1.0 wheels (bdist_wheel writes a non-
  conforming pydist.json).

* Improved computation of ABI tags on Python versions where SOABI is not
  available, and improved computation of compatibility tags on OS X to
  allow for multiple architectures and older OS X versions.


A more detailed change log is available at [2]. Please try it out, and
if you find any problems or have any suggestions for improvements, please
give some feedback using the issue tracker! [3]

Regards,

Vinay Sajip

[1] https://pypi.python.org/pypi/distlib/0.1.8 
[2] http://pythonhosted.org/distlib/overview.html#change-log-for-distlib 
[3] https://bitbucket.org/pypa/distlib/issues/new

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Printing characters outside of the ASCII range

2014-03-19 Thread diccon . tesson
Your handling Pick Multi value fields aren't you ;)
Just hit the same issue, thanks all here for various solutions.
Interfacing with OpenQM / Scarlet DME here.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Balanced trees

2014-03-19 Thread Steven D'Aprano
On Wed, 19 Mar 2014 10:49:33 +0200, Marko Rauhamaa wrote:

> Steven D'Aprano :
> 
>> If you are in a position to randomize the data before storing it in the
>> tree, an unbalanced binary tree is a solid contender.
> 
> Applications that can assume randomly distributed data are exceedingly
> rare 

Please re-read what I wrote. I didn't say "if your data comes to you 
fully randomized". I said "if you are in a position to randomize the data 
before storing it". In other words, if you actively randomize the data 
yourself.


> and even then, you can't easily discount the possibility of
> worst-case ordering.

Of course you can. If you have a million items, then the odds that those 
million items happen to be sorted (the worst-case order) are 1 in a 
million factorial. That's a rather small number, small enough that we can 
discount it from ever happening, not in a million lifetimes of the 
Universe.

Of course, you would be right to point out that one would also like to 
avoid *nearly* worst-case ordering. Nevertheless, there are Vastly more 
ways that the data will be sufficiently randomized as to avoid degenerate 
performance than the worst-case poor performance.

> In fact, Dan himself said unbalanced trees performed so badly he
> couldn't test them satisfactorily.

You're misrepresenting what Dan said. What he actually said was that 
unbalanced trees perform second only to dicts with random data, only with 
sorted data do they perform badly. His exact words were:

"For a series of random keys, it would do quite well (probably second only
to dict), but for a series of sequential keys it would take longer than
anyone would reasonably want to wait"



-- 
Steven D'Aprano
http://import-that.dreamwidth.org/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Balanced trees

2014-03-19 Thread Marko Rauhamaa
Steven D'Aprano :

> Please re-read what I wrote. I didn't say "if your data comes to you
> fully randomized". I said "if you are in a position to randomize the
> data before storing it". In other words, if you actively randomize the
> data yourself.

Yes, you could implement a "hash table" that way.


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Balanced trees

2014-03-19 Thread Roy Smith
In article <53299eac$0$29994$c3e8da3$54964...@news.astraweb.com>,
 Steven D'Aprano  wrote:

> If you have a million items, then the odds that those 
> million items happen to be sorted (the worst-case order) are 1 in a 
> million factorial. That's a rather small number, small enough that we can 
> discount it from ever happening, not in a million lifetimes of the 
> Universe.

If the items are coming from some inherently random process, then I 
agree.  But, not all data sources are random.

Imagine you had a web site, and wanted to store various bits of data 
from the stream of input requests.  You decided that the data structure 
you were going to use was a balanced tree.  If your keys were, say, a 
hash of the client's IP address, then it's a pretty good guess they're 
random.  But, what if the keys were the time the request was received?  
Those are obviously not random, and using them as a keys in a balanced 
tree would give you sub-optimum performance.

This is not a hypothetical scenario.  Songza uses MongoDB as our 
database.  The indexes are balanced trees.  One of our biggest 
collections has a multi-component key, one of the components being the 
request time truncated to the hour.  Insertion time into that collection 
has an obvious sawtooth shape, with performance degrading as each hour 
progresses and jumping back up as the time rolls over to the next hour.  
This is due (we believe :-)) to the constant rebalancing of the index 
trees.

Almost-sorted data sets are very common.  For example, here's a pipeline 
I run a lot (from memory, could have gotten some detail wrong):

grep pattern lofgile | awk '{print $7}' | sed 's/:[0-9][0-9]$//' | sort 
| uniq -c

Field 7 is the timestamp for when a request came in.  What I'm doing 
here is counting how many requests of a certain type came in during each 
minute of the day.  Logging isn't exactly in chronological order, so I 
need to sort the times before I count them.  But, it's in *almost* 
chronological order; a sort which had pathologically bad behavior on 
almost sorted data would be unusable here.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Printing characters outside of the ASCII range

2014-03-19 Thread Mark Lawrence

On 19/03/2014 13:11, diccon.tes...@gmail.com wrote:

Your handling Pick Multi value fields aren't you ;)
Just hit the same issue, thanks all here for various solutions.
Interfacing with OpenQM / Scarlet DME here.



The context is conspicious by its absence.  In future would you please 
be kind enough to provide some.


--
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.


Mark Lawrence

---
This email is free from viruses and malware because avast! Antivirus protection 
is active.
http://www.avast.com


--
https://mail.python.org/mailman/listinfo/python-list


Re: Printing characters outside of the ASCII range

2014-03-19 Thread Zachary Ware
On 19/03/2014 13:11, diccon.tes...@gmail.com wrote:
> Your handling Pick Multi value fields aren't you ;)
> Just hit the same issue, thanks all here for various solutions.
> Interfacing with OpenQM / Scarlet DME here.

For future posts, please be sure to quote what you're replying to.
Google Groups makes things easy to find and reply to, but this is a
mailing list.  When we receive a mail with just a subject line and a
cryptic message, we're likely to think it spam and ignore future mail
from that sender.  It's also a bit less than ideal to reply to years
old threads.

On Wed, Mar 19, 2014 at 9:19 AM, Mark Lawrence  wrote:
> The context is conspicious by its absence.  In future would you please be
> kind enough to provide some.

In a fit of curiosity, I went looking:
https://mail.python.org/pipermail/python-list/2012-November/634803.html
 I'm almost surprised it wasn't any older than that :)

Ironically, on my way down the November 2012 archive page, I noticed a
long thread about "Obnoxious postings from Google Groups".

-- 
Zach
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: 'complex' function with string argument.

2014-03-19 Thread wxjmfauth
Le mercredi 19 mars 2014 12:04:06 UTC+1, Skip Montanaro a écrit :
> On Wed, Mar 19, 2014 at 5:33 AM, Ian Kelly  wrote:
> 
> > When is it ever useful though?
> 
> 
> 
> About as often as int(0), float(0), or float(0.0) which all work as
> 
> expected, though probably don't turn up in a lot of code.
> 
> 
> 
> Skip

Your comment is equivalent to this:

>>> complex(1+2.0j)
(1+2j)
>>> complex(0+0.0j)
0j

Both, the constructor and the docstring, are not so clean.

What to say about the __repr__ ? Are not a and b
supposed to be floats? (elements of R)

>>> 0
0
>>> 0.0
0.0
>>> 0j
0j
>>> 1.0 + 2.0j
(1+2j)
>>> 1.
1.0
>>> 1
1
>>> (1 + 2.0j).real
1.0
>>> type((1 + 2.0j).real)


jmf

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Printing characters outside of the ASCII range

2014-03-19 Thread Mark Lawrence

On 19/03/2014 14:43, Zachary Ware wrote:

Ironically, on my way down the November 2012 archive page, I noticed a
long thread about "Obnoxious postings from Google Groups".



Thankfully the number of grotty postings from gg has dropped 
considerably.  Sadly our resident unicode expert quite deliberately 
continues to use it in a manner which is designed to annoy.


--
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.


Mark Lawrence

---
This email is free from viruses and malware because avast! Antivirus protection 
is active.
http://www.avast.com


--
https://mail.python.org/mailman/listinfo/python-list


Re: Kivy contest 2014

2014-03-19 Thread audiowerk
Hi!

Is there already a date when the theme will be announced?

Am Sonntag, 16. März 2014 18:42:16 UTC+1 schrieb qua-non:
>
> Hi folks,
>
> Kivy will be holding it's programming contest for 2014 starting April 15th.
>
> For details please visit http://kivy.org/#contest
>
> If you are interested in sponsoring the contest, please contact us at 
> con...@kivy.org .
>
>
> [image: Inline image 1]
>  
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Balanced trees

2014-03-19 Thread Ethan Furman

On 03/18/2014 06:15 PM, Steven D'Aprano wrote:

On Tue, 18 Mar 2014 15:21:28 -0700, Dan Stromberg wrote:


On Tue, Mar 18, 2014 at 3:03 PM, Marko Rauhamaa 
wrote:

Dan Stromberg :
For a proper comparison, I'd like a fixed, identical dataset and set of
operations run against each data structure.

How about this test program:


I used to do essentially this, but it was time-prohibitive and produced
harder-to-read graphs - harder to read because the enormous values of
the bad trees were dwarfing the values of the good trees.


A log graph may be the solution to that: graph the log of the time rather
than time itself.


I don't think that will solve the problem of not wanting to wait three days for 
the test to finish.  ;)

--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list


Re: 'complex' function with string argument.

2014-03-19 Thread Ian Kelly
On Wed, Mar 19, 2014 at 5:04 AM, Skip Montanaro  wrote:
> On Wed, Mar 19, 2014 at 5:33 AM, Ian Kelly  wrote:
>> When is it ever useful though?
>
> About as often as int(0), float(0), or float(0.0) which all work as
> expected, though probably don't turn up in a lot of code.

The analogous call to those is complex(1+2j), which I have no problem
with, not complex(1+2j, 3+4j).
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: 'complex' function with string argument.

2014-03-19 Thread Ian Kelly
On Wed, Mar 19, 2014 at 4:53 AM, Marko Rauhamaa  wrote:
> Ian Kelly :
>
>> On Wed, Mar 19, 2014 at 4:09 AM, Marko Rauhamaa  wrote:
>>> So complex(a, b) is documented to produce a+bj when a and b are integers
>>> or floats. What's more natural than saying it produces a+bj when a and b
>>> are complex numbers? It's a straightforward generalization that in no
>>> way violates the more limited documentation.
>>
>> When is it ever useful though? [...] It would be better to raise an
>> exception in either of the cases above, in my opinion.
>
> I don't think it matters one way or another.
>
> Medieval mathematicians had to address an analogous issue when they had
> to decide if
>
>x + 0
>
> was meaningful. After all, adding nothing doesn't make any sense and
> should raise a ValueError exception...

I wasn't aware that algebra had ValueErrors.  Describing an operation
as "undefined" isn't the same thing.  Anyway, if mathematicians
discover that the definitions of the past were flawed or incomplete,
then they redefine them.  Case in point, if we were still using
Brahmagupta's rules for zero, then 0/0 would be 0.

Python though has backward compatibility to worry about.  Because of
this, it is much simpler to add wanted behavior than to remove
unwanted behavior. If an operation can be generalized but the
generalization has no apparent use case, it *may* be better to
disallow it, with the possibility of adding it later when a user pops
up and says "Hey, this would actually be useful to me", than to allow
it from the beginning, and then have no option to remove it later when
it turns out to be merely a nuisance.

Compare for example the 2-argument int constructor.  Normally this is
meant to be called like int("42", 13), where it will interpret the
digits passed as base 13 and return 54.  We might generalize that and
say that if the user passes int(42, 13), it should also return 54,
seeing that the repr of 42 provides the digits "42".  It is more
likely though that this call merely indicates a bug in the user's
code, and fortunately in this case what Python actually does is to
raise a TypeError.

Anyway, curious though this tangent is, further discussion is unlikely
to produce any useful outcome, so I'll just leave it there.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Kivy contest 2014

2014-03-19 Thread Alexander Taylor
The theme will be announced when the contest officially starts, the 15th 
April.

On Wednesday, 19 March 2014 09:27:14 UTC, audiowerk wrote:
>
> Hi!
>
> Is there already a date when the theme will be announced?
>
> Am Sonntag, 16. März 2014 18:42:16 UTC+1 schrieb qua-non:
>>
>> Hi folks,
>>
>> Kivy will be holding it's programming contest for 2014 starting April 
>> 15th.
>>
>> For details please visit http://kivy.org/#contest
>>
>> If you are interested in sponsoring the contest, please contact us at 
>> con...@kivy.org.
>>
>>
>> [image: Inline image 1]
>>  
>-- 
https://mail.python.org/mailman/listinfo/python-list


Problem with pickle and restarting a program

2014-03-19 Thread Peace
In my GUI, the user enters two values: cellNumber(Integer) and 
SerialNumber(String)

I have the following piece of code in my view/controller:

The following function is called after the user enters the 
cellnumber and serial number##
def ListenForDetails(status):
cellNumber = status[0]
SerialNumber = status[1]
ModelInfo().CellList[cellNumber].receiveSerialNumber(SerialNumber)

--In my controller thread-
class Controller(Thread):
def __init__(self):
Thread.__init__(self)
self.start()

def run(self):
global SynchronizationVariable
while SynchronizationVariable != 1:
time.sleep(0.01)
while 1:
StateChanged = False
for cells in ModelInfo().CellList:
rc = cells.PollCells()
if rc == 0:
StateChanged = True
if StateChanged:
ModelInfo().save()
time.sleep(1)

---In my model.py 
script-

class CellInfo(): #This class encapsulates all the information present in a cell
def __init__(self,cellNo):
self.SerialNo = ""
self.cellNo = cellNo

def receiveSerialNumber(self, SerialNumber):
self.SerialNo = SerialNumber

def PollCells(self):
RC = self.StateMachine[self.CurrentState](self)
return RC

...all state machine functions here...


"""Model Info below"""
class ModelInfo(): #This class creates a list of cells.
def __init__(self):
print("Setting up a list of cells to iterate on")
self.CellList = [] #List of all the cell Objects
for index in xrange(0,24):
print(self.CellList)
self.CellList.append(CellInfo(index))

def save(self):
with open("RestoreInfo.p", "wb") as f:
pickle.dump(self,f)

Model = ModelInfo() #Constructs an empty model

"""IN MAIN (In the controller script)"""
if __name__ == '__main__':
if os.path.isfile( "RestoreInfo.p" ):
with open("RestoreInfo.p", "rb") as f:
model = pickle.load( f );
else:
model = model.ModelInfo();


The serial number field always remains empty even though I enter from the GUI 
and the receiveSerialNumber function is called and I explicitly initialize it 
to the variable in the model.
I'm trying to save the state of the program so that next time I open the 
application it resumes from where it left off. The problem is when I restart 
the application, the serial number is empty. What am I doing wrong here? 
Whenever I get a change in state (the RC value), I pickle and save to a file 
(restoreinfo.p). When I restart the application, the serial number is no longer 
there even though I enter it. Could you please let me know what is going wrong? 
Thank you.
-- 
https://mail.python.org/mailman/listinfo/python-list


Problem in fetching blob or clob data with python and cx_oracle

2014-03-19 Thread goswami . anjan
It seems that when I attempt to download blob or clob data using fetchmany, it 
can not keep track of the LOB variable in subsequent fetch. The problem is over 
if I fetch one row at a time but it is not optimal. Can anyone give me an idea 
how to efficiently fetch columns with clob or blob data from oracle DB using 
python.

Thank you,
Anjan
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Balanced trees

2014-03-19 Thread Rhodri James
On Tue, 18 Mar 2014 21:45:52 -, Dan Stromberg   
wrote:



blist.sorteddict was able to do 65536 operations on a dictionary
before taking more than 120 seconds to complete  - it took 77.3
seconds to do 65536 operations.


65536 is a suspiciously round number.  You might want to double-
check that there's no 16-bit overflow causing something unexpected.

--
Rhodri James *-* Wildebeest Herder to the Masses
--
https://mail.python.org/mailman/listinfo/python-list


Re: Balanced trees

2014-03-19 Thread Dan Stromberg
On Wed, Mar 19, 2014 at 7:16 PM, Rhodri James  wrote:
> 65536 is a suspiciously round number.  You might want to double-
> check that there's no 16-bit overflow causing something unexpected.

It's because I'm using powers of 2.  All the numbers in the report are
round in hex.
-- 
https://mail.python.org/mailman/listinfo/python-list


[Python-Dev] Issues about relative& absolute import way for Portingfrom python2.4 to python2.7

2014-03-19 Thread ??????
Dear,


I just wrote a sample like this:
testPy/
 __init__.py
 client.py
 SoamFactory.c
 SoamFactory.so
 soamapi.py
 sample/testP.py
export PYTHONPATH=$(TEST_LOCATION):$(TEST_LOCATION)/testPy
Here's the source codes:
__init__.py:
import client
client.py
import soamapi
class Client(soamapi.SessionCallback):


  def __init__(self):
print "class Client"
super(Client, self).__init__()
soamapi.initialize()


  def create_session(self):
sec_cb = soamapi.DefaultSecurityCallback()
self.connection = soamapi.connect(sec_cb)

soamapi.py
import SoamFactory


class ConnectionSecurityCallback(object):  
  def __init__(self):
print "class ConnectionSecurityCallback"


  def __del__(self):
pass


  def test_P(self):
print "test_P in class ConnectionSecurityCallback"


class DefaultSecurityCallback(ConnectionSecurityCallback):
  def __init__(self):
super(DefaultSecurityCallback, self).__init__()
print "class DefaultSecurityCallback"


  def __del__(self):
super(DefaultSecurityCallback, self).__del__()


  def test(self):
print "test in class DefaultSecurityCallback"


class SessionCallback(object):
  def __init__(self):
pass
  
  def __del__(self):
pass


def connect(security_callback):
  return SoamFactory.SoamFactory_connect(security_callback)


def initialize():
  SoamFactory.SoamFactory_initialize()


print "call soamapi"

SoamFactory.c
#include "Python.h"
#include "PythonLoop.c"


PyObject* SOAM_API_MODULE = NULL;
PyObject* pyModule = NULL;


static PyObject* SoamFactory_initialize(PyObject* self, PyObject* args){
PyEval_InitThreads();
init();
Py_RETURN_NONE;
}


static PyObject* SoamFactory_connect(PyObject* self, PyObject* args){
PyObject* pySecCallback = NULL;
int ok = PyArg_ParseTuple(args, "O", &pySecCallback);
if (!ok){
printf("parse tuple error!\n");
Py_RETURN_NONE;
}
if (! PyObject_IsInstance(pySecCallback, connectSecCallback)){
printf("pySecCallback is not an instance of 
ConnectionSecurityCallback!\n");
Py_RETURN_NONE;
}
printf("Successful!\n");
Py_RETURN_NONE;
}


static PyMethodDef SoamFactory[] = {
{"SoamFactory_connect", SoamFactory_connect, METH_VARARGS, "connection 
function"},
{"SoamFactory_initialize", SoamFactory_initialize, METH_VARARGS, 
"SoamFactory_initialize"},
{NULL, NULL}
};


void initSoamFactory(){
PyEval_InitThreads();
Py_Initialize();
pyModule = Py_InitModule("SoamFactory", SoamFactory);
SOAM_API_MODULE = PyImport_ImportModule("soamapi");
}

sample/testP.py
import testPy


print ""
submitter = testPy.client.Client()
submitter.create_session()
print ""



When I ran it on python2.4, it worked well, and the result was
call soamapi
after import soamapi--client.py

class Client
class ConnectionSecurityCallback
class DefaultSecurityCallback
Successful!
   
 
But when I ran it on python2.7, it worked beyond my expectation, the result was 
call soamapi
call soamapi

class Client
class ConnectionSecurityCallback
class DefaultSecurityCallback
pySecCallback is not an instance of ConnectionSecurityCallback!




I found that soamapi was imported twice, and I investigated this is related to 
absolute&relative import way.  PyImport_ImportModule in python2.7 uses absolute 
import way, it will look up sys.path to get soamapi module, and when testP.py 
file import testPy module, it will find local module soamapi under testPy 
package, and binds module's name to package, as testPy.soamapi.
There are two ways to correct it for python2.7, 1) Don't use import testPy, use 
import client directly to avoid using relative; 2) Use from __future__ import 
absolute_import to enable absolute import feature.


But there are two Pre-conditions:
1) Should not modify testP.py;
2) Should be ran on both python2.4 and 2.7.


I don't know how to fix it. Is there any official way about how to porting this 
scenario or better idea?


Thanks,
Vatel-- 
https://mail.python.org/mailman/listinfo/python-list