Parallel python in the cloud

2014-05-23 Thread Charles Gagnon
We were happily using PiCloud for several long calculations and we very happy 
with with it. With their realtime cores, we could take really large 
calculations set and run through fairly quickly.

Now that PiCloud is going away, we ran a few tests on Mutlyvac but so far, we 
are struggling to accomplish the same thing we had on PiCloud.

I have several "pieces" of my puzzle but can't seem to be able to put it 
together. I've seen and tried StarCluster and also various parallel python 
options but all options seem challenging to put together.

The goal is to mimic PiCloud, ie. loop through a function:

def some_NP_func(x, y):
   ...
   return z

some_cloud.call(some_NP_func, a1, a2)

Which computes the function on the cloud. We use this often in for loops with 
arrays of arguments. The other scenario is:

some_cloud.map(some_NP_intense_func, [...], [...])

Which iterates through and returns results. We need to run a lot of this in 
batch from a scheduler so I always try to avoid interactive environment (how 
does iPython parallel work in batch?).

What is the preferred approach or method right now for heavy parallel 
computation like this?


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


Re: Advice for choosing correct architecture/tech for a hobby project

2014-05-23 Thread Aseem Bansal
I know that there are many online ways to do what I am trying to do but this 
was something I wanted to make. 

I have learnt Python myself and wanted to learn a way to make apps in Python. 
GUI development in Python has given a lot of headache while trying to find an 
appropriate framework with the addons(community, designer tool, documentation, 
open source etc.). The only nearly viable solution that I found was Kivy but 
the current project idea that I had was this bookmarker project which needed to 
have a way to add bookmarks easily through browser so I settled on the most 
popular web framework present. 


On Friday, May 23, 2014 2:58:51 AM UTC+5:30, Ethan Furman wrote:
> On 05/22/2014 11:54 AM, Aseem Bansal wrote:
> 
> >
> 
> > I am working on a hobby project - a Bookmarker 
> > https://github.com/anshbansal/Bookmarker.
> 
> 
> 
> Take a look at delicio.us -- it seems to be a similar type of experience.
> 
> 
> 
> --
> 
> ~Ethan~

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


Re: Advice for choosing correct architecture/tech for a hobby project

2014-05-23 Thread Aseem Bansal
The project is not a browser but a app for managing the bookmarks. Only 
managing by categories. A replacement for the bookmarks made in webbrowser. I 
wanted to make bookmarks easier to use. Hierarchical structure of bookmarks 
gives a lot of problems. I wanted to solve that for my use.

On Friday, May 23, 2014 1:19:22 AM UTC+5:30, Mark H. Harris wrote:
> On 5/22/14 1:54 PM, Aseem Bansal wrote:
> 
> > I am working on a hobby project - a Bookmarker{snip}
> 
> 
> 
> hi,  no django is not really the correct tool-set. Django is for 
> 
> server-side content management, but who knows, you might come up with a 
> 
> great hack (I don't want to discourage you).  But, a straight python 
> 
> trimmed down app would probably be better...  what led you to django?
> 
> 
> 
> It seems from your descriptions, which don't make sense by the way, that 
> 
> you are attempting to create your own 'browser' within your app (web 
> 
> api) and you want to use a standard browser (like firefox or chrome) to 
> 
> 'front-end' the apps bookmarks. So, your app needs to be able to read 
> 
> your browser's bookmarks file.
> 
> 
> 
> Browsers most certainly can read http:// https:// file:// etc. (and many 
> 
> more). Your api may not be able to read local file://  urls, but I'm 
> 
> skeptical about that (most web api(s) have no trouble with file:// either).
> 
> 
> 
> Provide some more info, somebody will help.
> 
> 
> 
> 
> 
> marcus
-- 
https://mail.python.org/mailman/listinfo/python-list


Python 3 support for Fabric (was: How keep Python 3 moving forward)

2014-05-23 Thread Ben Finney
Roy Smith  writes:

> Thanks for the pointer.  I installed and ran caniusepython3.  It tells 
> me:
>
> > Of those 19 projects, 17 have no direct dependencies blocking their 
> > transition:
> > […]
> >   fabric

Fabric was for a long time held back by its dependency on the Paramiko
library. But that library is now Python 3 compatible, and Fabric is
moving steadily in the direction of Python 3 support.

The latest is a change in the documentation to explicitly remove the
last dependency hurdle https://github.com/fabric/fabric/pull/1137>.

Now the only blockers are internal; Fabric 2.0 is AFAICT going to be the
Python 3 compatible version of Fabric, and it is coming along well.

-- 
 \   “Some people have a problem, and they think “I know, I'll use |
  `\ Perl!”. Now they have some number of problems but they're not |
_o__) sure whether it's a string or an integer.” —Benno Rice, 2011 |
Ben Finney

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


Re: trying to find nose.tools.assert_raises_regexp

2014-05-23 Thread qhfgva
I knew it had to be something like that.  Thanks.  Time to upgrade.

On Friday, May 23, 2014 6:07:08 PM UTC-6, Ned Batchelder wrote:
> On 5/23/14 6:09 PM, qhfgva wrote:
> 
> > $ python
> 
> > Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
> 
> > [GCC 4.4.3] on linux2
> 
> > Type "help", "copyright", "credits" or "license" for more information.
> 
>  import nose.tools
> 
>  nose.__version__
> 
> > '1.3.3'
> 
>  nose.tools.assert_raises_regexp
> 
> > Traceback (most recent call last):
> 
> >File "", line 1, in 
> 
> > AttributeError: 'module' object has no attribute 'assert_raises_regexp'
> 
> >
> 
> >
> 
> > I see people using code like the following
> 
> >
> 
> > from nose.tools import assert_equals, assert_raises_regexp
> 
> >
> 
> > (the above line is from diy-lisp - a python project on githup)
> 
> >
> 
> > but I'm not able to find a version of nose that explicitly mentions this 
> > function.
> 
> >
> 
> > perplexed...
> 
> >
> 
> 
> 
> nose.tools auto-creates these names from the names in unittest, with 
> 
> this code: 
> 
> https://github.com/nose-devs/nose/blob/master/nose/tools/trivial.py#L46
> 
> 
> 
> You don't have assert_raises_regexp because your unittest module doesn't 
> 
> have assertRaisesRegexp.  That method is new in 2.7, but you are using 
> 
> 2.6.5, so it doesn't exist.
> 
> 
> 
> -- 
> 
> Ned Batchelder, http://nedbatchelder.com



On Friday, May 23, 2014 6:07:08 PM UTC-6, Ned Batchelder wrote:
> On 5/23/14 6:09 PM, qhfgva wrote:
> 
> > $ python
> 
> > Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
> 
> > [GCC 4.4.3] on linux2
> 
> > Type "help", "copyright", "credits" or "license" for more information.
> 
>  import nose.tools
> 
>  nose.__version__
> 
> > '1.3.3'
> 
>  nose.tools.assert_raises_regexp
> 
> > Traceback (most recent call last):
> 
> >File "", line 1, in 
> 
> > AttributeError: 'module' object has no attribute 'assert_raises_regexp'
> 
> >
> 
> >
> 
> > I see people using code like the following
> 
> >
> 
> > from nose.tools import assert_equals, assert_raises_regexp
> 
> >
> 
> > (the above line is from diy-lisp - a python project on githup)
> 
> >
> 
> > but I'm not able to find a version of nose that explicitly mentions this 
> > function.
> 
> >
> 
> > perplexed...
> 
> >
> 
> 
> 
> nose.tools auto-creates these names from the names in unittest, with 
> 
> this code: 
> 
> https://github.com/nose-devs/nose/blob/master/nose/tools/trivial.py#L46
> 
> 
> 
> You don't have assert_raises_regexp because your unittest module doesn't 
> 
> have assertRaisesRegexp.  That method is new in 2.7, but you are using 
> 
> 2.6.5, so it doesn't exist.
> 
> 
> 
> -- 
> 
> Ned Batchelder, http://nedbatchelder.com



On Friday, May 23, 2014 6:07:08 PM UTC-6, Ned Batchelder wrote:
> On 5/23/14 6:09 PM, qhfgva wrote:
> 
> > $ python
> 
> > Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
> 
> > [GCC 4.4.3] on linux2
> 
> > Type "help", "copyright", "credits" or "license" for more information.
> 
>  import nose.tools
> 
>  nose.__version__
> 
> > '1.3.3'
> 
>  nose.tools.assert_raises_regexp
> 
> > Traceback (most recent call last):
> 
> >File "", line 1, in 
> 
> > AttributeError: 'module' object has no attribute 'assert_raises_regexp'
> 
> >
> 
> >
> 
> > I see people using code like the following
> 
> >
> 
> > from nose.tools import assert_equals, assert_raises_regexp
> 
> >
> 
> > (the above line is from diy-lisp - a python project on githup)
> 
> >
> 
> > but I'm not able to find a version of nose that explicitly mentions this 
> > function.
> 
> >
> 
> > perplexed...
> 
> >
> 
> 
> 
> nose.tools auto-creates these names from the names in unittest, with 
> 
> this code: 
> 
> https://github.com/nose-devs/nose/blob/master/nose/tools/trivial.py#L46
> 
> 
> 
> You don't have assert_raises_regexp because your unittest module doesn't 
> 
> have assertRaisesRegexp.  That method is new in 2.7, but you are using 
> 
> 2.6.5, so it doesn't exist.
> 
> 
> 
> -- 
> 
> Ned Batchelder, http://nedbatchelder.com

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


Re: How keep Python 3 moving forward

2014-05-23 Thread Roy Smith
In article ,
 Ethan Furman  wrote:

> On 05/23/2014 04:57 PM, Roy Smith wrote:
> >
> > Thanks for the pointer.  I installed and ran caniusepython3.  It tells
> > me:
> 
> [snip]
> 
> > That's a big list.  A few of those we could probably work around or
> > replace with a different module without too much pain.  But, between
> > gevent, boto, fabric, and suds, any idea of migrating is a total
> > non-starter for us.  I imagine they're all working on ports, but I'll
> > check back in a year and see how things stand.
> 
> Don't imagine.  Send 'em an email!  Let them know there is one more user 
> who'd like a Python 3 port.

But, you're assuming I want that.  I don't.  What I have now works.

I'm not trying to be difficult here.  I'm just looking at all the things 
I could be doing with my time that will improve my product and/or help 
grow the business.  "Transition to Python 3" isn't even on the list.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How keep Python 3 moving forward

2014-05-23 Thread Ethan Furman

On 05/23/2014 04:57 PM, Roy Smith wrote:


Thanks for the pointer.  I installed and ran caniusepython3.  It tells
me:


[snip]


That's a big list.  A few of those we could probably work around or
replace with a different module without too much pain.  But, between
gevent, boto, fabric, and suds, any idea of migrating is a total
non-starter for us.  I imagine they're all working on ports, but I'll
check back in a year and see how things stand.


Don't imagine.  Send 'em an email!  Let them know there is one more user who'd 
like a Python 3 port.

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


Re: Windows automatic rebooting due to faulty code

2014-05-23 Thread Irmen de Jong
On 24-5-2014 0:54, Michael Torrie wrote:
> On 05/23/2014 09:26 AM, Ronak Dhakan wrote:
>> Even I am surprised, python errors should stay in python. But I am
>> sure that the reboot is triggered exactly when I run some faulty
>> code. And usually I change the code after reboot, so I haven't
>> checked whether the same code is able to repeat the reboot. This
>> happens even in simple code of 10-15 lines for drawing a polygon.
>>
>> There was a problem while creating the post asking the question. Here
>> it is now:
>> https://groups.google.com/d/msg/comp.lang.python/WINUrOfAey4/pvbnapLrRcsJ
> 
> Almost certainly you are experiencing a hardware fault.  Possibly bad
> RAM.  Windows will not let user-space code crash the operating system.
> Though user-space code could trigger something in the kernel that then
> faults.  This is likely what's happening here.  But the real cause is
> probably hardware. If it's not RAM, then it might be video hardware
> failing.
> 

Or the computer has been infected by malware.



-I.

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


Re: trying to find nose.tools.assert_raises_regexp

2014-05-23 Thread Ned Batchelder

On 5/23/14 6:09 PM, qhfgva wrote:

$ python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.

import nose.tools
nose.__version__

'1.3.3'

nose.tools.assert_raises_regexp

Traceback (most recent call last):
   File "", line 1, in 
AttributeError: 'module' object has no attribute 'assert_raises_regexp'


I see people using code like the following

from nose.tools import assert_equals, assert_raises_regexp

(the above line is from diy-lisp - a python project on githup)

but I'm not able to find a version of nose that explicitly mentions this 
function.

perplexed...



nose.tools auto-creates these names from the names in unittest, with 
this code: 
https://github.com/nose-devs/nose/blob/master/nose/tools/trivial.py#L46


You don't have assert_raises_regexp because your unittest module doesn't 
have assertRaisesRegexp.  That method is new in 2.7, but you are using 
2.6.5, so it doesn't exist.


--
Ned Batchelder, http://nedbatchelder.com

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


Re: How keep Python 3 moving forward

2014-05-23 Thread Roy Smith
In article ,
 Mark Lawrence  wrote:

> An article by Brett Cannon that I thought might be of interest 
> http://nothingbutsnark.svbtle.com/my-view-on-the-current-state-of-python-3

Thanks for the pointer.  I installed and ran caniusepython3.  It tells 
me:

> Finding and checking dependencies ...
> [WARNING] rpclib not found
> 
> You need 19 projects to transition to Python 3.
> Of those 19 projects, 17 have no direct dependencies blocking their 
> transition:
> 
>   beanstalkc
>   dateglob
>   diamond
>   django-multi-sessions
>   django-timedeltafield
>   dnspython
>   ecks
>   fabric
>   gevent (which is blocking grequests)
>   hash_ring
>   httmock
>   jellyfish
>   boto (which is blocking mrjob)
>   paste
>   pyephem
>   python-cjson
>   suds

That's a big list.  A few of those we could probably work around or 
replace with a different module without too much pain.  But, between 
gevent, boto, fabric, and suds, any idea of migrating is a total 
non-starter for us.  I imagine they're all working on ports, but I'll 
check back in a year and see how things stand.
-- 
https://mail.python.org/mailman/listinfo/python-list


TextBlob on Windows

2014-05-23 Thread subhabangalore
Dear Group,

It seems there is a nice language processing library named TextBlob, like NLTK. 
But I am being unable to install it on my Windows(MS-Windows 7 machine. I am 
using Python 2.7

If anyone of the esteemed members may kindly suggest me the solution.

I tried the note in following URL
http://stackoverflow.com/questions/20562768/trouble-installing-textblob-for-python

but did not help much.

Thanking in Advance,
Regards,
Subhabrata Banerjee. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Windows automatic rebooting due to faulty code

2014-05-23 Thread Michael Torrie
On 05/23/2014 09:26 AM, Ronak Dhakan wrote:
> Even I am surprised, python errors should stay in python. But I am
> sure that the reboot is triggered exactly when I run some faulty
> code. And usually I change the code after reboot, so I haven't
> checked whether the same code is able to repeat the reboot. This
> happens even in simple code of 10-15 lines for drawing a polygon.
> 
> There was a problem while creating the post asking the question. Here
> it is now:
> https://groups.google.com/d/msg/comp.lang.python/WINUrOfAey4/pvbnapLrRcsJ

Almost certainly you are experiencing a hardware fault.  Possibly bad
RAM.  Windows will not let user-space code crash the operating system.
Though user-space code could trigger something in the kernel that then
faults.  This is likely what's happening here.  But the real cause is
probably hardware. If it's not RAM, then it might be video hardware
failing.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: All-numeric script names and import

2014-05-23 Thread Michael Torrie
On 05/23/2014 03:28 AM, Chris Angelico wrote:
> On Fri, May 23, 2014 at 7:22 PM, Wolfgang Maier
>  wrote:
>> I see, so what you should propose then is a change to import, so that when
>> it can't find a module it will try to import an alternative that's
>> pronounced the same way. Then you could simply do:
>>
>> import one
>>
>> and you're fine :)
> 
> This strikes me as a very dangerous proposal. Imagine what would
> happen when you try to "import chip" in New Zealand and it goes out
> looking for "chup.py". Or the devastating results of "yes.py" and
> "no.py" being indistinguishable on politicians' builds of Python...

If you use a proper web framework, then you can define your urls to be
anything you want.  Just set up the appropriate mapping and away you go.

Furthermore you can use apache directives to alias /1/ to something more
importable.

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


trying to find nose.tools.assert_raises_regexp

2014-05-23 Thread qhfgva
$ python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) 
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import nose.tools
>>> nose.__version__
'1.3.3'
>>> nose.tools.assert_raises_regexp
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'module' object has no attribute 'assert_raises_regexp'


I see people using code like the following

from nose.tools import assert_equals, assert_raises_regexp

(the above line is from diy-lisp - a python project on githup)

but I'm not able to find a version of nose that explicitly mentions this 
function.

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


how to create a frame object when embedding python?

2014-05-23 Thread Robert Snoeberger

Hi python-list,

I'm embedding Python in an application and I have encountered two crashes while 
calling built-in functions that expect a top-level frame. See the following bug 
reports: http://bugs.python.org/issue21563 and 
http://bugs.python.org/issue21418. The problem is that the workflow for 
embedding the Python interpreter does not involve creation of a frame. 
RubyPython, a language interface to call Python from Ruby, has the same 
problem, http://rubypython.rubyforge.org/#known-problems. Since there is not a 
top-level frame object, some built-in functions do not work properly. In most 
cases, this problem is easily worked-around because globals and locals can be 
passed as optional arguments. The crashes, however, are more unfortunate. 

As an example, I can crash RubyPython by calling the built-in function execfile 
with a single argument.

irb(main):001:0> require('rubypython')
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/blankslate-3.1.2/lib/blankslate.rb:51: 
warning: undefining `object_id' may cause serious problems
=> true
irb(main):002:0> RubyPython.start
=> true
irb(main):003:0> binmod = RubyPython.import('__builtin__')
=> 
irb(main):004:0> binmod.execfile('foo.py')

The fourth line crashed the ruby interpreter. This is an example where an 
application might want to give full access to the functions in a Python module. 
It would be nice to find a way to prevent the crash without restricting the API.

I am curious if anyone has suggestions for creating a top-level frame?

Thank you,
Rob  



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


How keep Python 3 moving forward

2014-05-23 Thread Mark Lawrence
An article by Brett Cannon that I thought might be of interest 
http://nothingbutsnark.svbtle.com/my-view-on-the-current-state-of-python-3


--
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: Windows automatic rebooting due to faulty code

2014-05-23 Thread Terry Reedy

On 5/23/2014 12:08 PM, Ronak Dhakan wrote:

It is a small file to draw an approximate circle using Turtle.

> The reboot does not happen consistently. Here is the code:
> http://pastebin.com/8T3aRCEd

from swampy.TurtleWorld import *
world = TurtleWorld()

This is not the turtle module in the stdlib. It is most like the source 
of your reboot problem. Report your problem to the author. Also try 
running your example in the Windows console. (Not nearly as nice, I 
know.) There might possibly be a bad interaction with Idle.


--
Terry Jan Reedy

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


Re: hashing strings to integers

2014-05-23 Thread Terry Reedy

On 5/23/2014 6:27 AM, Adam Funk wrote:


that.  The only thing that really bugs me in Python 3 is that execfile
has been removed (I find it useful for testing things interactively).


The spelling has been changed to exec(open(...).read(), ... . It you use 
it a lot, add a customized def execfile(filename, ... to your site 
module or local utils module.


Execfile was a separate statement *only) because exec was a statememt. 
Once exec was was changed to a function taking arguments, that 
justification disappeared.


Terry Jan Reedy

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


Re:Windows rebooting due to faulty code

2014-05-23 Thread Dave Angel
Ronak Dhakan  Wrote in message:
> I am learning python, and sometimes when I run a file with a faulty code, 
> windows gives a message that the system is rebooting and gives me 1 minute to 
> save my work. Does anyone know how can I fix this? Most of the time a faulty 
> code gives errors in python, but this is unique. I create files like Exercise 
> 1.2.py and run it through IDLE.
> 

It is very unlikely that running a program will cause a proper
 Windows system to reboot.  The one example I can think of is the
 restart.exe program,  which is deliberately doing it.
 

It is even much less likely that it could be triggered by
 beginner's code written in python without 3rd party add-ons.
 

Therefore I'd conclude you've either got a corrupted system,  or
 you're tripping on a Windows bug.

The first things I'd do, if stuck on Windows for some reason,  is
 to check your system for Windows updates,  then for viruses,
 hackers, 
and such.
-- 
DaveA

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


Re: Windows automatic rebooting due to faulty code

2014-05-23 Thread CHIN Dihedral
On Saturday, May 24, 2014 12:08:24 AM UTC+8, Ronak Dhakan wrote:
> It is a small file to draw an approximate circle using Turtle. The reboot 
> does not happen consistently. Here is the code: http://pastebin.com/8T3aRCEd
> 
> 
> 
> I was thinking whether there is a way to run python in a virtual environment.

Check colinux or VMWARE.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Windows automatic rebooting due to faulty code

2014-05-23 Thread Joel Goldstick
On May 23, 2014 12:12 PM, "Ronak Dhakan"  wrote:
>
> It is a small file to draw an approximate circle using Turtle. The reboot
does not happen consistently. Here is the code: http://pastebin.com/8T3aRCEd
>
> I was thinking whether there is a way to run python in a virtual
environment.
> --
> https://mail.python.org/mailman/listinfo/python-list
Try on different machine. Maybe hardware or driver issue
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Windows automatic rebooting due to faulty code

2014-05-23 Thread Ronak Dhakan
It is a small file to draw an approximate circle using Turtle. The reboot does 
not happen consistently. Here is the code: http://pastebin.com/8T3aRCEd

I was thinking whether there is a way to run python in a virtual environment.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Windows automatic rebooting due to faulty code

2014-05-23 Thread Rustom Mody
On Friday, May 23, 2014 9:06:32 PM UTC+5:30, Chris Angelico wrote:

> > There was a problem while creating the post asking the question. Here it is 
> > now: 
> > https://groups.google.com/d/msg/comp.lang.python/WINUrOfAey4/pvbnapLrRcsJ

> Solution: Get off Google Groups. Subscribe to python-list@python.org
> and read it all in your email client, or read comp.lang.python in a
> real newsreader. That'll fix several other problems too.

Or read and follow:
https://wiki.python.org/moin/GoogleGroupsPython

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


Re: Windows automatic rebooting due to faulty code

2014-05-23 Thread Chris Angelico
On Sat, May 24, 2014 at 1:26 AM, Ronak Dhakan  wrote:
> Even I am surprised, python errors should stay in python. But I am sure that 
> the reboot is triggered exactly when I run some faulty code. And usually I 
> change the code after reboot, so I haven't checked whether the same code is 
> able to repeat the reboot. This happens even in simple code of 10-15 lines 
> for drawing a polygon.
>

Aim for consistency and reproducibility. Figure out something that
always brings Windows down. More importantly... *tell us what modules
you are using*. What draws a polygon here? What are you working with?
That's kinda critical here, especially if (as I suspect) it's not part
of the Python standard library.

> There was a problem while creating the post asking the question. Here it is 
> now: https://groups.google.com/d/msg/comp.lang.python/WINUrOfAey4/pvbnapLrRcsJ
>

Solution: Get off Google Groups. Subscribe to python-list@python.org
and read it all in your email client, or read comp.lang.python in a
real newsreader. That'll fix several other problems too.

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


Re: Windows automatic rebooting due to faulty code

2014-05-23 Thread Ronak Dhakan
On Friday, May 23, 2014 8:34:31 PM UTC+5:30, Chris Angelico wrote:
> On Sat, May 24, 2014 at 12:56 AM, Ronak Dhakan wrote:
> 
> > I am learning python, and sometimes when I run a file with a faulty, 
> > windows gives a message that the system is rebooting and gives me 1 minute 
> > to save my work. Does anyone know how can I fix this? Most of the time a 
> > faulty code gives errors in python, but this is unique. I create files like 
> > Exercise 1.2.py and run it through IDLE.
> 
> >
> 
> 
> 
> I'm very much surprised that any Python coding error could do this.
> 
> What code triggers this? Is it consistent?
> 
> 
> 
> More likely it's something else in your system. Pure coincidence.
> 
> 
> 
> ChrisA

Even I am surprised, python errors should stay in python. But I am sure that 
the reboot is triggered exactly when I run some faulty code. And usually I 
change the code after reboot, so I haven't checked whether the same code is 
able to repeat the reboot. This happens even in simple code of 10-15 lines for 
drawing a polygon.

There was a problem while creating the post asking the question. Here it is 
now: https://groups.google.com/d/msg/comp.lang.python/WINUrOfAey4/pvbnapLrRcsJ
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: shebang & windows: call an extensionless git hook

2014-05-23 Thread Albert-Jan Roskam
- Original Message -
> From: Chris Angelico 
> To: 
> Cc: Python 
> Sent: Friday, May 23, 2014 4:01 PM
> Subject: Re: shebang & windows: call an extensionless git hook
> 
> On Fri, May 23, 2014 at 11:53 PM, Albert-Jan Roskam
> 
>  wrote:
>>  Ok, I just found out that the script works as-is under Windows (I need to 
> save it as 'pre-commit', not as 'pre-commit.py'. That's 
> great, though I still don't understand how Windows (or Git) knows how to do 
> with it.
>> 
> 
> Are you running git from inside bash? If so, it's probably parsing the
> shebang and simulating a Unixesque environment, as part of the whole
> "let's try to make Unix stuff mostly work" policy. I'm amazed 
> at how
> well it actually works; from drive letters to execution differences,
> everything's somehow finagled into operation.

Hi,
 
I just used cmd.exe and did some commits. And it just worked. Not sure about 
TortoiseGit. (*note to self: check this next week!*)
Maybe Git does something with the 'mode python' shebang (and python is on 
PATH). 
 
regards,
Albert-Jan  
-- 
https://mail.python.org/mailman/listinfo/python-list


Windows rebooting due to faulty code

2014-05-23 Thread Ronak Dhakan
I am learning python, and sometimes when I run a file with a faulty code, 
windows gives a message that the system is rebooting and gives me 1 minute to 
save my work. Does anyone know how can I fix this? Most of the time a faulty 
code gives errors in python, but this is unique. I create files like Exercise 
1.2.py and run it through IDLE.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Windows automatic rebooting due to faulty code

2014-05-23 Thread Chris Angelico
On Sat, May 24, 2014 at 12:56 AM, Ronak Dhakan  wrote:
> I am learning python, and sometimes when I run a file with a faulty, windows 
> gives a message that the system is rebooting and gives me 1 minute to save my 
> work. Does anyone know how can I fix this? Most of the time a faulty code 
> gives errors in python, but this is unique. I create files like Exercise 
> 1.2.py and run it through IDLE.
>

I'm very much surprised that any Python coding error could do this.
What code triggers this? Is it consistent?

More likely it's something else in your system. Pure coincidence.

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


Windows automatic rebooting due to faulty code

2014-05-23 Thread Ronak Dhakan
I am learning python, and sometimes when I run a file with a faulty, windows 
gives a message that the system is rebooting and gives me 1 minute to save my 
work. Does anyone know how can I fix this? Most of the time a faulty code gives 
errors in python, but this is unique. I create files like Exercise 1.2.py and 
run it through IDLE.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: shebang & windows: call an extensionless git hook

2014-05-23 Thread Chris Angelico
On Fri, May 23, 2014 at 11:53 PM, Albert-Jan Roskam
 wrote:
> Ok, I just found out that the script works as-is under Windows (I need to 
> save it as 'pre-commit', not as 'pre-commit.py'. That's great, though I still 
> don't understand how Windows (or Git) knows how to do with it.
>

Are you running git from inside bash? If so, it's probably parsing the
shebang and simulating a Unixesque environment, as part of the whole
"let's try to make Unix stuff mostly work" policy. I'm amazed at how
well it actually works; from drive letters to execution differences,
everything's somehow finagled into operation.

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


Re: shebang & windows: call an extensionless git hook

2014-05-23 Thread Albert-Jan Roskam
- Original Message -
> From: Albert-Jan Roskam 
> To: Python 
> Cc: 
> Sent: Thursday, May 22, 2014 6:58 PM
> Subject: shebang & windows: call an extensionless git hook
> 
> Hi,
> 
> I wrote the git pre-commit hook below. It is supposed to reject commits that 
> contain large files (e.g. accidental commits by inexperienced users, think of 
> "git add .")
> 
> 
> Anyway, I tried this under Linux, but the target platform is Windows. As per 
> Git 
> design the hook name *must* be "pre-commit" (no .py extension). How 
> will Windows know that Python should be run? And (should it be relevant): how 
> does Windows know which Python version to invoke? I read about custom 
> shebangs 
> with Pylauncher. Is that my only option? (see: 
> https://bitbucket.org/vinay.sajip/pylauncher, 
> http://legacy.python.org/dev/peps/pep-0397/)

Ok, I just found out that the script works as-is under Windows (I need to save 
it as 'pre-commit', not as 'pre-commit.py'. That's great, though I still don't 
understand how Windows (or Git) knows how to do with it. And under Windows 
chmod +x does not exist, which means the hook is always ready to be used. This 
is exactly what I want in this case, but in general this poses a security risk
 
regards,
Albert-Jan
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: SQLAlchemy - web framework ?

2014-05-23 Thread Amirouche Boubekki
Héllo,


2014-05-13 1:34 GMT+02:00 flebber :
> If I want to use SQLAlchemy as my ORM what would be the best option for a
web framework?

I think the best option would be Pyramid but I don't know SQLAchemy or
Pyramid that much, but:

- Django doesn't support SQLAlchemy as is
- I don't recommend Flask, even if it has some «good intentions» (Jinja2 >>
Django Template, Web Browser Debugger)
- I don't know web.py, turbogears
- I only know that tornado is an async framework and *it seems to me *that
Python+Async is still not mainstream
- This year, I was working on non-web related stuff, so I'm not fully up to
date.

> It appears the general advice regarding Django is to do it the Django way
and use the django ORM and change it out for SQLAlchemy.

You will loose a lot of the benefits of using Django. My point of view is
that removing one thing in Django (even the template system) will lead me
to remove *a lot of things*... writing a new framework. Not necessarily
because they are coupled, but because there is kind of a lot of stuff I
dislike in Django... But I still use Django, trying to avoid land mines and
working around inefficiencies...

> That to me limited knowledge leaves flask, pyramid and turbogears 2. So
if I wanted to not build it all myself as with flask then potentially
pyramid, turbogears is the best option?

Like I said, I don't recommend flask and I know nobody using turbogears for
new projects.

> Is this true? I have completed the TG2 intro tutorial and have built
several small things with flask although I feel offput by doing anything
bigger in flask.

They are templates projects that help bootstrap bigger projects. But
anyway, last time I checked Flask has less resources (documentation,
example code, example project, coobooks, documented pratices...)

> See what I have done is got my python knowledge to a fair point where I
can do useful things, good knowledge of web HTML/CSS, built a few small
projects in flask to get an idea for python web, completed django
tutorials, turogears tutorials and now looking to design out a bigger
project I want to set myself and i am trying to compile the parts so I can
see what I will need to use and gather info to cover what othe things I
will need to know.

The thing that, again, goes in the direction of choosing Django, is that
it's a big noosphere == lot of ressources of different kind code, video,
articles, books == lot of people from different background and interests ==
lot of ideas. Getting to learn things is easier in this conditions.

If you choose another framework, you will invest extra time while referring
to documentation written for Django. Since you seem to be starting Python,
it will be easier to avoid this extra step of translation. Even if
«translation» is a very common pratice of programming, so working on that
skill is interesting.

> Do I have a false fear of flask and doing bigger projects?

Many people claim they use Flask on big projects, but AFAIK there is no big
open source projects written with Flask. So you can't be sure about what it
means to use Flask in big project anyway. Mozilla use extensively Django,
checkout mozilla@github .

> So at this point I know I want SQLAlchemy, will use postgres(although
mysql/maria would work fine).

SQLAlchemy is better than Django's equivalent. Like said I don't fully know
SQLAlchemy. But the SQL language mapping in Python is nicer in SQLAlchemy.
The project is dedicated to supporting RDBMS so there is better support,
tooling, I think.

Some people will say it's a matter of taste, look'n'feel and compare it to
"ice cream flavors". IMO it's not comparable to "ice cream flavor" but
different people have different needs, background and context so favor one
library instead of another without strong engineering or scientific
grounds. Money, business, HR & marketing will have more significance.

flebber  writes:
>
> > One of the main parts that is tripping myself up is that I need to
> > consistently import xml files into my database.
>
> XML documents represent a hierarchical tree of data. Relational
> databases are not good at representing hierarchical documents.
>

- It's not always hierarchical data.
- RDBMS can handle hierarchical data anyway especially PostgresSQL

When I was at Libération (a french national newspaper, kind of the french
Guardian). We ported the previous CMS based on a custom PHP framework to
Django. Basically there was 3 parts:

- Frontend: main website, mainly for reading digital articles or articles
from paper version. There is several frontends for the same backend.
- Backend: forms and whatnot for journalist to manage the content of the
website
- Automatic processing: this needs little human interventions but are still
fully part of the CMS

The CMS import stuff, many kind among which articles bundled in XML. A
"django application", a python package integrated with django that creates
a mini-framework for implementing "import rules" called
djang

Re: hashing strings to integers

2014-05-23 Thread Chris Angelico
On Fri, May 23, 2014 at 8:36 PM, Adam Funk  wrote:
> BTW, I just tested that & it should be "big" for consistency with the
> hexdigest:

Yes, it definitely should be parsed big-endianly.

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


Re: hashing strings to integers (was: hashing strings to integers for sqlite3 keys)

2014-05-23 Thread Chris Angelico
On Fri, May 23, 2014 at 8:27 PM, Adam Funk  wrote:
> I've also used hashes of strings for other things involving
> deduplication or fast lookups (because integer equality is faster than
> string equality).  I guess if it's just for deduplication, though, a
> set of byte arrays is as good as a set of int?

Want a better way to do that? Use a set or dict and let Python do the
hashing. It'll be every bit as fast as explicit hashing, plus you get
the bonus of simplicity.

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


Re: hashing strings to integers

2014-05-23 Thread Adam Funk
On 2014-05-23, Adam Funk wrote:

> On 2014-05-22, Peter Otten wrote:

>> In Python 3 there's int.from_bytes()
>>
> h = hashlib.sha1(b"Hello world")
> int.from_bytes(h.digest(), "little")
>> 538059071683667711846616050503420899184350089339
>
> Excellent, thanks for pointing that out.  I've just recently started
> using Python 3 instead of 2, & appreciate pointers to new things like
> that.

BTW, I just tested that & it should be "big" for consistency with the
hexdigest:

Python 3.3.2+ (default, Feb 28 2014, 00:52:16) 
[GCC 4.8.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import hashlib
>>> h0 = hashlib.sha1(bytes('pants', 'UTF-8')).digest()
>>> h1 = hashlib.sha1(bytes('pants', 'UTF-8')).hexdigest()
>>> int.from_bytes(h0, 'big')
1315090007003469710610607131160586168131917298749
>>> int.from_bytes(h0, 'little')
352462323236431222976527983157432783788229548774
>>> int(h1, 16)
1315090007003469710610607131160586168131917298749

Thanks.


-- 
The kid's a hot prospect. He's got a good head for merchandising, an
agent who can take you downtown and one of the best urine samples I've
seen in a long time.   [Dead Kennedys t-shirt]
-- 
https://mail.python.org/mailman/listinfo/python-list


hashing strings to integers (was: hashing strings to integers for sqlite3 keys)

2014-05-23 Thread Adam Funk
On 2014-05-22, Peter Otten wrote:

> Adam Funk wrote:

>> Well, J*v* returns a byte array, so I used to do this:
>> 
>> digester = MessageDigest.getInstance("MD5");
>> ...
>> digester.reset();
>> byte[] digest = digester.digest(bytes);
>> return new BigInteger(+1, digest);
>
> In Python 3 there's int.from_bytes()
>
 h = hashlib.sha1(b"Hello world")
 int.from_bytes(h.digest(), "little")
> 538059071683667711846616050503420899184350089339

Excellent, thanks for pointing that out.  I've just recently started
using Python 3 instead of 2, & appreciate pointers to new things like
that.  The only thing that really bugs me in Python 3 is that execfile
has been removed (I find it useful for testing things interactively).


>> I dunno why language designers don't make it easy to get a single big
>> number directly out of these things.
>  
> You hardly ever need to manipulate the numerical value of the digest. And on 
> its way into the database it will be re-serialized anyway.

I now agree that my original plan to hash strings for the SQLite3
table was pointless, so I've changed the subject header.  :-)

I have had good reason to use int hashes in the past, however.  I was
doing some experiments with Andrei Broder's "sketches of shingles"
technique for finding partial duplication between documents, & you
need integers for that so you can do modulo arithmetic.

I've also used hashes of strings for other things involving
deduplication or fast lookups (because integer equality is faster than
string equality).  I guess if it's just for deduplication, though, a
set of byte arrays is as good as a set of int?


-- 
Classical Greek lent itself to the promulgation of a rich culture,
indeed, to Western civilization.  Computer languages bring us
doorbells that chime with thirty-two tunes, alt.sex.bestiality, and
Tetris clones. (Stoll 1995)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: All-numeric script names and import

2014-05-23 Thread Chris Angelico
On Fri, May 23, 2014 at 7:22 PM, Wolfgang Maier
 wrote:
> I see, so what you should propose then is a change to import, so that when
> it can't find a module it will try to import an alternative that's
> pronounced the same way. Then you could simply do:
>
> import one
>
> and you're fine :)

This strikes me as a very dangerous proposal. Imagine what would
happen when you try to "import chip" in New Zealand and it goes out
looking for "chup.py". Or the devastating results of "yes.py" and
"no.py" being indistinguishable on politicians' builds of Python...

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


Re: All-numeric script names and import

2014-05-23 Thread Wolfgang Maier

On 23.05.2014 11:02, Chris Angelico wrote:

On Fri, May 23, 2014 at 6:58 PM, Wolfgang Maier
 wrote:

Latin, you DID use Arabic numbers :)



I may have used an Arabic numeral, but I named my script very
definitely in English. Isn't it obvious? It's read "one dot pie",
which is clearly English! :)



I see, so what you should propose then is a change to import, so that 
when it can't find a module it will try to import an alternative that's 
pronounced the same way. Then you could simply do:


import one

and you're fine :)

Cheers,
Wolfgang


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


Re: All-numeric script names and import

2014-05-23 Thread Chris Angelico
On Fri, May 23, 2014 at 6:58 PM, Wolfgang Maier
 wrote:
> Latin, you DID use Arabic numbers :)
>

I may have used an Arabic numeral, but I named my script very
definitely in English. Isn't it obvious? It's read "one dot pie",
which is clearly English! :)

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


Re: All-numeric script names and import

2014-05-23 Thread Wolfgang Maier

On 23.05.2014 05:26, Chris Angelico wrote:

On Fri, May 23, 2014 at 12:08 PM, Rustom Mody  wrote:

$ cat ا.py
x = 1
def foo(x): print("Hi %s!!" % x)


Yeah, no thanks. I am not naming my scripts in Arabic. :)



Latin, you DID use Arabic numbers :)

Cheers,
Wolfgang

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


Re: Advice for choosing correct architecture/tech for a hobby project

2014-05-23 Thread Ian Kelly
On Thu, May 22, 2014 at 1:49 PM, Mark H Harris  wrote:
> On 5/22/14 1:54 PM, Aseem Bansal wrote:
>>
>> I am working on a hobby project - a Bookmarker{snip}
>
>
> hi,  no django is not really the correct tool-set. Django is for server-side
> content management

That's a common misconception. Django is a feature-rich web framework
aimed at developing database-driven web apps.  It's a popular choice
for implementing content management systems but is not at all limited
to that scope.  It should be fine for the sort of app that the OP is
writing, although a bit on the heavy side.
-- 
https://mail.python.org/mailman/listinfo/python-list