Installing Python 3.5 fails

2015-09-30 Thread Tom Barnett



I do have a fresh successful install of Visual Studio 2015 Redistributables 
installed.

Then I reinstalled Python 3.5 and still now joy.

What am I missing?

Tom



Tom Barnett
Senior Systems Administrator
Prime, inc.
2740 N. Mayfair
Springfield, MO 65803
Ph. 417.866.0001  Fax 417.521.6863
* Before printing this e-mail,  please verify it is necessary.



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


Re: Installing Python 3.5 fails

2015-09-30 Thread Laura Creighton
In a message of Tue, 29 Sep 2015 21:40:08 -, Tom Barnett writes:
>
>
>
>I do have a fresh successful install of Visual Studio 2015 Redistributables 
>installed.
>
>Then I reinstalled Python 3.5 and still now joy.
>
>What am I missing?
>
>Tom

(It's another  missing api-ms-win-crt-runtime-l1-1-0.dll)

You are probably doing nothing wrong.  3.5 has a completely new installer.
Are you on Vista by any chance?

You may have this problem
https://bugs.python.org/issue25223
and maybe installing the universal crt update mentioned there will help
you.  

If not, open a separate issue in the tracker.

Sorry about this.

Laura

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


Re: Create a .lua fle from Python

2015-09-30 Thread jmp

On 09/29/2015 07:28 PM, Peter Otten wrote:

jmp wrote:

import bs4
import jinja2

xml = """
   
BuenosAires
30


Seatle
25

"""

lua_template = """
cities_temps ={
{%- for city, temp in cities.iteritems() %}
["{{city}}"] = {{temp}},
{%- endfor %}
}"""

xmlp = bs4.BeautifulSoup(xml, 'xml')
# from xml to python dictionary
data = {city.find('name').string:city.find('temperature').string for
city in xmlp.findAll('city')}
# from python dictionary to lua
print jinja2.Template(lua_template).render(cities=data)


will yield (python 2.7):

cities_temps ={
["BuenosAires"] = 30,
["Seatle"] = 25,
}


Is Ariel's xml file user-supplied? If so, how does your suggestion prevent
the resulting lua script from executing arbitrary code?


It does not. Like it doesn't fulfill the millions of possible 
requirements the OP could have written but did not. What if the OP want 
a thread safe, super fast, multi core solution distributed on multiple 
remote hosts ?


jm


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


Re: Check if a given value is out of certain range

2015-09-30 Thread alister
On Tue, 29 Sep 2015 18:44:33 -0500, Tim Chase wrote:

> On 2015-09-29 21:32, Mark Lawrence wrote:
>> On 29/09/2015 17:48, Rob Gaddi wrote:
>> >> Is there any similar elegant way to check if a value is out of
>> >> certain range?
>> >> Example - To check if x is either less than zero or greater than
>> >> ten? Right now I am using x < 0 or x > 10.
>> >
>> > not (0 <= x <= 10)
>> 
>> Yuck.
> 
> Not sure there's much "yuck" to be had there.  It's succinct, easy to
> read, and correct.  The only improvement might be if you have things to
> do in both cases, in which case remove the "not" and set the clauses
> accordingly:
> 
>   if 0 <= x <= 10:
> success_within_range(x)
>   else:
> fail_out_of_bounds(x)
> 
> -tkc

I would stick with the OP's current solution

Readability Counts!



-- 
BUFFERS=20 FILES=15 2nd down, 4th quarter, 5 yards to go!
-- 
https://mail.python.org/mailman/listinfo/python-list


failure in installing

2015-09-30 Thread Sagar Joshi
hey, there is a failure installing python3.5.0 in my PC can u help
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: failure in installing

2015-09-30 Thread Chris Angelico
On Wed, Sep 30, 2015 at 10:36 PM, Sagar Joshi  wrote:
> hey, there is a failure installing python3.5.0 in my PC can u help

yes

ChrisA

PS. If my response wasn't helpful enough, it's because your question
wasn't helpful enough. You'll need to give us a lot more information,
such as your platform, what went wrong, etc.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: failure in installing

2015-09-30 Thread Thomas 'PointedEars' Lahn
Sagar Joshi wrote:

> hey, there is a failure installing python3.5.0 in my PC can u help



-- 
PointedEars

Twitter: @PointedEars2
Please do not cc me. / Bitte keine Kopien per E-Mail.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: failure in installing

2015-09-30 Thread Mark Lawrence

On 30/09/2015 13:36, Sagar Joshi wrote:

hey, there is a failure installing python3.5.0 in my PC can u help



Not directly, as once again both my main and spare crystal balls are at 
the menders due to over use.


However should you decide to tell us what OS version you've got, exactly 
what you tried to do and exactly what went wrong I'm sure that somebody 
can help, even if it is stating that it's a known problem and has all 
ready been reported on the bug tracker.


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

Mark Lawrence

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


Re: failure in installing

2015-09-30 Thread Grant Edwards
On 2015-09-30, Sagar Joshi  wrote:

> hey, there is a failure installing python3.5.0 in my PC can u help

No.

Or yes.

It depends.

-- 
Grant Edwards   grant.b.edwardsYow! Somewhere in DOWNTOWN
  at   BURBANK a prostitute is
  gmail.comOVERCOOKING a LAMB CHOP!!
-- 
https://mail.python.org/mailman/listinfo/python-list


Oracle connect

2015-09-30 Thread pip7kids
Hi 
New to Python and just downloaded 3.5
Trying to connect to Oracle but failing - eg

import cx_oracle
connstr = 'userid/password@@99.999.9.99:PORT/SID' 
connection = cx_oracle.connect(connstr)   
cursor = connection.cursor()  
cursor.execute("SELECT * FROM MYTABLE WHERE ROWNUM <=100")
cursor.close()
connection.close()

Getting error No module named 'cx_oracle'

Any examples or should I use an earlier version of Python.

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


Re: Oracle connect

2015-09-30 Thread Larry Martell
On Wed, Sep 30, 2015 at 11:25 AM,   wrote:
> Hi
> New to Python and just downloaded 3.5
> Trying to connect to Oracle but failing - eg
>
> import cx_oracle
> connstr = 'userid/password@@99.999.9.99:PORT/SID'
> connection = cx_oracle.connect(connstr)
> cursor = connection.cursor()
> cursor.execute("SELECT * FROM MYTABLE WHERE ROWNUM <=100")
> cursor.close()
> connection.close()
>
> Getting error No module named 'cx_oracle'

Did you install cx_oracle? If not, do this:

pip install cx_Oracle

Also, there is a cx_oracle mailing list.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Check if a given value is out of certain range

2015-09-30 Thread John Gordon
In  alister 
 writes:

> I would stick with the OP's current solution

> Readability Counts!

I agree.  'if x < 0 or x > 10' is perfectly fine.

-- 
John Gordon   A is for Amy, who fell down the stairs
gor...@panix.com  B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"

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


Re: Check if a given value is out of certain range

2015-09-30 Thread Grant Edwards
On 2015-09-30, alister  wrote:
> On Tue, 29 Sep 2015 18:44:33 -0500, Tim Chase wrote:
>
>> On 2015-09-29 21:32, Mark Lawrence wrote:
>>> On 29/09/2015 17:48, Rob Gaddi wrote:
>>> >> Is there any similar elegant way to check if a value is out of
>>> >> certain range?
>>> >> Example - To check if x is either less than zero or greater than
>>> >> ten? Right now I am using x < 0 or x > 10.
>>> >
>>> > not (0 <= x <= 10)
>>> 
>>> Yuck.
>> 
>> Not sure there's much "yuck" to be had there.  It's succinct, easy to
>> read, and correct.  The only improvement might be if you have things to
>> do in both cases, in which case remove the "not" and set the clauses
>> accordingly:
>> 
>>   if 0 <= x <= 10:
>> success_within_range(x)
>>   else:
>> fail_out_of_bounds(x)
>> 
>> -tkc
>
> I would stick with the OP's current solution
>
> Readability Counts!

I'm baffled.

If the condition we are trying to check for is when "x is not within a
range of 0-10 inclusive" then this is as readable as it gets:

  not (0 <= x <= 10) (I)

That's pretty much a literal, word-for-word translation of the
requirement into code.

Sure, you can can apply De Morgans theorom to transform that into

   (x < 0) or (x > 10)   (II)

That's just as correct, but now the code is one step removed from the
requirement statement.

IMO, (I) is _more_ readable than (II)
   
-- 
Grant Edwards   grant.b.edwardsYow! Boy, am I glad it's
  at   only 1971...
  gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Linux Mint installation of Python 3.5

2015-09-30 Thread MRAB

On 2015-09-30 04:15, Chris Angelico wrote:

On Wed, Sep 30, 2015 at 1:00 PM, Mario Figueiredo  wrote:

Personally, I use the regular 'make install', but that's because I'm
on Debian - the system Python is 2.7.


Unfortunately Ubuntu based distros are going through a 2.x to 3.x
transition period. Both Pythons are installed and are system dependencies.

And their finicky dependency on Python really make these distros not
very friendly for Python development. If I do end up successfully
upgrading from 3.4 to 3.5, I will most likely forfeit my ability to
upgrade the Mint version in the future without a full system
installation. So the solution is to just maintain 3 different versions
of python my machine. Ridiculous.


Three different Python versions? Ehh, no big deal.

rosuav@sikorsky:~$ python2 --version
Python 2.7.9
rosuav@sikorsky:~$ python3.4 --version
Python 3.4.2
rosuav@sikorsky:~$ python3.5 --version
Python 3.5.0b1+
rosuav@sikorsky:~$ python3.6 --version
Python 3.6.0a0
rosuav@sikorsky:~$ pypy --version
Python 2.7.8 (2.4.0+dfsg-3, Dec 20 2014, 13:30:46)
[PyPy 2.4.0 with GCC 4.9.2]
rosuav@sikorsky:~$ jython --version
"my" variable $jythonHome masks earlier declaration in same scope at
/usr/bin/jython line 15.
Jython 2.5.3

And Steven D'Aprano probably can beat that by an order of magnitude.

Keep your multiple interpreters around; it doesn't hurt. Unless you're
seriously bothered by disk space issues, the biggest cost is keeping
track of which one you've installed some third-party package into.


Well, I have 16 of them!

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


Re: Linux Mint installation of Python 3.5

2015-09-30 Thread John Wong
On Tue, Sep 29, 2015 at 10:37 PM, Mario Figueiredo  wrote:

> Hello everyone,
>
> Under Linux Mint it is not a good idea to just go ahead and replace the
> system installed Python versions and their packages. And yet I wish to
> both update the 3.4 modules and install Python 3.5. I understand that
> for the first I just need to use virtualenv.
>

Late to the party but this goes for every system. Never a good idea to
replace system files.
There are tools out there to manage multiple versions of python, you can
give those a try, otherwise I prefer sticking native solution.

This may not be a Python discussion, but I don't think update-alterantives
works for python right? I've used that for Java. Not that this actually
applies for the usage parent is thinking
-- 
https://mail.python.org/mailman/listinfo/python-list


Error code 0x80070570

2015-09-30 Thread Rusiri Jayalath
Error code 0x80070570 appears when installing python 3.5.0 (32-bit) setup
for my windows 8.1 system. Please help me to solve this problem.

-- 

Thank You.







Best Regards,







Rusiri D. Jayalath
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Error code 0x80070570

2015-09-30 Thread Joel Goldstick
On Wed, Sep 30, 2015 at 1:36 PM, Rusiri Jayalath  wrote:

> Error code 0x80070570 appears when installing python 3.5.0 (32-bit) setup
> for my windows 8.1 system. Please help me to solve this problem.
>
> --
>
> Thank You.
>
>
>
>
>
>
>
> Best Regards,
>
>
>
>
>
>
>
> Rusiri D. Jayalath
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
> Microsoft seems to think its a disk problem, or a cd problem:

http://answers.microsoft.com/en-us/windows/forum/windows_8-windows_install/gets-the-error-code-0x80070570-during-the/34908e67-35d3-4291-9008-d7db862c29ff


-- 
Joel Goldstick
http://joelgoldstick.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Check if a given value is out of certain range

2015-09-30 Thread Marko Rauhamaa
Grant Edwards :

>   not (0 <= x <= 10) (I)
> [...]
>(x < 0) or (x > 10)   (II)
> [...]
> IMO, (I) is _more_ readable than (II)

IMO, they're equally readable (except that you should drop the redundant
parentheses from (II)).


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


Re: Check if a given value is out of certain range

2015-09-30 Thread sohcahtoa82
On Tuesday, September 29, 2015 at 1:33:23 PM UTC-7, Mark Lawrence wrote:
> On 29/09/2015 17:48, Rob Gaddi wrote:
> > On Tue, 29 Sep 2015 10:16:04 +0530, Laxmikant Chitare wrote:
> >
> >> Hi,
> >>
> >> I know there is an elegant way to check if a given value is within
> >> certain range.
> >> Example - To check if x is between zero and ten, I can do 0 < x 10.
> >>
> >> Is there any similar elegant way to check if a value is out of certain
> >> range?
> >> Example - To check if x is either less than zero or greater than ten?
> >> Right now I am using x < 0 or x > 10.
> >>
> >> Regards,
> >> Laxmikant
> >
> > not (0 <= x <= 10)
> >
> 
> Yuck.
> 
> -- 
> My fellow Pythonistas, ask not what our language can do for you, ask
> what you can do for our language.
> 
> Mark Lawrence

What is so "yuck" about that?  What would you do instead?  It seems like the 
best solution to me.  Easy to read, fast to execute.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Check if a given value is out of certain range

2015-09-30 Thread BartC

On 29/09/2015 05:46, Laxmikant Chitare wrote:

Hi,
I know there is an elegant way to check if a given value is within
certain range.
Example - To check if x is between zero and ten, I can do 0 < x 10.


That's not clear. Do you mean whether x is 1 to 9 inclusive? Because 
your contrary example below suggests you mean 0 to 10 inclusive.




Is there any similar elegant way to check if a value is out of certain
range?
Example - To check if x is either less than zero or greater than ten?
Right now I am using x < 0 or x > 10.


You might try just defining a function to do it:

 def out_of_range(x,a,b):
# use whatever code you like

then use it as: if out_of_range(x,0,10):

But it is necessary to define exactly what is meant by it (Python ranges 
seem to exclude the upper bound). So x<0 or x>10 might not be the most 
elegant, and x is evaluated twice, but it is the clearest.


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


Question about regular expression

2015-09-30 Thread massi_srb
Hi everyone,

firstly the description of my problem. I have a string in the following form:

s = "name1 name2(1) name3 name4 (1, 4) name5(2) ..."

that is a string made up of groups in the form 'name' (letters only) plus 
possibly a tuple containing 1 or 2 integer values. Blanks can be placed between 
names and tuples or not, but they surely are placed beween two groups. I would 
like to process this string in order to get a dictionary like this:

d = {
"name1":(0, 0),
"name2":(1, 0),
"name3":(0, 0),
"name4":(1, 4),
"name5":(2, 0),
}

I guess this problem can be tackled with regular expressions, but I have no 
idea bout how to use them in this case (I'm not a regexp guy). Can anyone give 
me a hint? any possible different approach is absolutely welcome.

Thanks in advance!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Question about regular expression

2015-09-30 Thread Emile van Sebille

On 9/30/2015 11:34 AM, massi_...@msn.com wrote:

Hi everyone,

firstly the description of my problem. I have a string in the following form:

s = "name1 name2(1) name3 name4 (1, 4) name5(2) ..."

that is a string made up of groups in the form 'name' (letters only) plus 
possibly a tuple containing 1 or 2 integer values. Blanks can be placed between 
names and tuples or not, but they surely are placed beween two groups. I would 
like to process this string in order to get a dictionary like this:

d = {
 "name1":(0, 0),
 "name2":(1, 0),
 "name3":(0, 0),
 "name4":(1, 4),
 "name5":(2, 0),
}

I guess this problem can be tackled with regular expressions,


Stop there!  :)

I'd use string functions.  If you can control the string output to drop 
the spaces and always output in namex(a,b)namey(c,d)... format, 
try starting with


>>> "name1 name2(1) name3 name4(1,4) name5(2)".split()
['name1', 'name2(1)', 'name3', 'name4(1,4)', 'name5(2)']

then create the dict from the result.

Emile


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


Re: Question about regular expression

2015-09-30 Thread Joel Goldstick
On Wed, Sep 30, 2015 at 2:50 PM, Emile van Sebille  wrote:

> On 9/30/2015 11:34 AM, massi_...@msn.com wrote:
>
>> Hi everyone,
>>
>> firstly the description of my problem. I have a string in the following
>> form:
>>
>> s = "name1 name2(1) name3 name4 (1, 4) name5(2) ..."
>>
>> that is a string made up of groups in the form 'name' (letters only) plus
>> possibly a tuple containing 1 or 2 integer values. Blanks can be placed
>> between names and tuples or not, but they surely are placed beween two
>> groups. I would like to process this string in order to get a dictionary
>> like this:
>>
>> d = {
>>  "name1":(0, 0),
>>  "name2":(1, 0),
>>  "name3":(0, 0),
>>  "name4":(1, 4),
>>  "name5":(2, 0),
>> }
>>
>> I guess this problem can be tackled with regular expressions,
>>
>
> Stop there!  :)
>
> I'd use string functions.  If you can control the string output to drop
> the spaces and always output in namex(a,b)namey(c,d)... format, try
> starting with
>
> >>> "name1 name2(1) name3 name4(1,4) name5(2)".split()
> ['name1', 'name2(1)', 'name3', 'name4(1,4)', 'name5(2)']
>
> then create the dict from the result.


In your original string, splitting on spaces gives this:

>>> s = "name1 name2(1) name3 name4 (1, 4) name5(2)"
>>> s.split(' ')
['name1', 'name2(1)', 'name3', 'name4', '(1,', '4)', 'name5(2)']
>>>

That might be useful to start.  The space between the namex and (1,...) is
problematic.  If your data could be that way, perhaps, preprocess the
string to remove space before '(', and the space between commas.

>>> s = "name1 name2(1) name3 name4(1,4) name5(2)"
>>> s.split(' ')
['name1', 'name2(1)', 'name3', 'name4(1,4)', 'name5(2)']

>>>

>From here writing the dictionary shouldn't be too hard.

I'm sure there is a better way as this does a couple of loops, but once you
get it working, you can optimize if necessary.

>
>
-- 
Joel Goldstick
http://joelgoldstick.com/stats/birthdays
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Question about regular expression

2015-09-30 Thread Tim Chase
On 2015-09-30 11:34, massi_...@msn.com wrote:
> firstly the description of my problem. I have a string in the
> following form:
> 
> s = "name1 name2(1) name3 name4 (1, 4) name5(2) ..."
> 
> that is a string made up of groups in the form 'name' (letters
> only) plus possibly a tuple containing 1 or 2 integer values.
> Blanks can be placed between names and tuples or not, but they
> surely are placed beween two groups. I would like to process this
> string in order to get a dictionary like this:
> 
> d = {
> "name1":(0, 0),
> "name2":(1, 0),
> "name3":(0, 0),
> "name4":(1, 4),
> "name5":(2, 0),
> }
> 
> I guess this problem can be tackled with regular expressions, b

First out of the gate, I suggest you follow Emile's advice and try
using string expressions.  However, if you *want* to do it with
regular expressions, you can.  It's ugly and might be fragile, but

#
import re
s = "name1 name2(1) name3 name4 (1, 4) name5(2) ..."
r = re.compile(r"""
\b   # start at a word boundary
(\w+)# capture the word
\s*  # optional whitespace
(?:  # start an optional grouping for things in the parens
 \(  # a literal open-paren
  \s*# optional whitespace
  (\d+)  # capture the number in those parens
  (?:# start a second optional grouping for the stuff after a comma
   \s*   # optional whitespace
   , # a literal comma
   \s*   # optional whitespace
   (\d+) # the second number
  )? # make the command and following number optional
 \)  # a literal close-paren
)?   # make that stuff in parens optional
""", re.X)
d = {}
for m in r.finditer(s):
a, b, c  = m.groups()
d[a] = (int(b or 0), int(c or 0))

from pprint import pprint
pprint(d)
#


I'd stick with the commented version of the regexp if you were to use
this anywhere so that others can follow what you're doing.

-tkc





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


Re: Error code 0x80070570

2015-09-30 Thread eryksun
On 9/30/15, Rusiri Jayalath  wrote:
> Error code 0x80070570 appears when installing python 3.5.0 (32-bit) setup
> for my windows 8.1 system. Please help me to solve this problem.

0x80070570 is ERROR_FILE_CORRUPT: the file or directory is corrupted
and unreadable. It could be an intermittent problem with your internet
connection when downloading the required packages. Try using the
non-web installer that already includes most of them [1].

I haven't seen this particular error reported on the issue tracker, so
you might want to submit a new issue. Include a zip of the
installation logs for the most recent failed attempt. They're in your
%TEMP% directory with names like "Python 3.5.0 (32-bit)_*.log".

FYI, the severity/facility code 0x8007 determines that 0x0570 is a
Win32 error code. See HRESULT [2] for an overview of how to decode
HRESULT and NTSTATUS [3] codes. See Win32 Error Codes [4] or System
Error Codes [5] for a list of Win32 errors.

[1]: https://www.python.org/ftp/python/3.5.0/python-3.5.0.exe
[2]: https://msdn.microsoft.com/en-us/library/cc231198
[3]: https://msdn.microsoft.com/en-us/library/cc231200
[4]: https://msdn.microsoft.com/en-us/library/cc231199
[5]: https://msdn.microsoft.com/en-us/library/ms681381
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Check if a given value is out of certain range

2015-09-30 Thread alister
On Wed, 30 Sep 2015 21:06:02 +0300, Marko Rauhamaa wrote:

> Grant Edwards :
> 
>>   not (0 <= x <= 10) (I)
>> [...]
>>(x < 0) or (x > 10)   (II)
>> [...]
>> IMO, (I) is _more_ readable than (II)
> 
> IMO, they're equally readable (except that you should drop the redundant
> parentheses from (II)).
> 
> 
> Marko

both are correct
the problem with 1 is the human brain is not particularity good with 
negatives*.
to do not (some function) you first of all have to work out some function 
& then invert it, a computer does this without difficulty the human brain 
gets confused which is why I personally consider ii is  more readable 
(YMMV especially if you are working with Boolean maths regularly) this 
example is relatively simple as things get more complex they become more 
error prone error.



*as an example you brain cannot correctly process the following.

Not (think of your left toe)

you are now thinking about it aren't you?


-- 
The UPS is on strike.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: ConnectionError handling problem

2015-09-30 Thread Cameron Simpson

On 29Sep2015 23:04, shiva upreti  wrote:

On Friday, September 25, 2015 at 12:55:01 PM UTC+5:30, Cameron Simpson wrote:

Ok. You original code says:

  try:
r=requests.post(url, data=query_args)
  except:
print "Connection error"

and presumably we think your code is hanging inside the requests.post call? You
should probably try to verify that, because if it is elsewhere you need to
figure out where (lots of print statements is a first start on that).
I would open two terminals. Run your program until it hangs in one.

[...various things to do to check _exactly_ where the hang is occurring...]


Yes I use ubuntu 14.04. I will try what you suggested. But I cant understand 
one thing, for whatever reason the script is hanging, why does it resumes 
almost instantaneously when I press CTRL+C.


Most likely the Ctrl-C interrupts whatever system call is hanging, causing it 
to return (failed, probably with errno EINTR). And the python program resumes 
because the OS system call has returned.


Cheers,
Cameron Simpson 
--
https://mail.python.org/mailman/listinfo/python-list


Re: ConnectionError handling problem

2015-09-30 Thread Laura Creighton
In a message of Thu, 01 Oct 2015 07:30:59 +1000, Cameron Simpson writes:
>Most likely the Ctrl-C interrupts whatever system call is hanging, causing it 
>to return (failed, probably with errno EINTR). And the python program resumes 
>because the OS system call has returned.
>
>Cheers,
>Cameron Simpson 

Shiva Upreti needs to post the current code, but last time I read it
the problem was that control-C is a KeyboardInterrupt, which the
program was catching, and then continuing the loop.

Laura

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


Re: Check if a given value is out of certain range

2015-09-30 Thread Mark Lawrence

On 30/09/2015 19:31, sohcahto...@gmail.com wrote:

On Tuesday, September 29, 2015 at 1:33:23 PM UTC-7, Mark Lawrence wrote:

On 29/09/2015 17:48, Rob Gaddi wrote:

On Tue, 29 Sep 2015 10:16:04 +0530, Laxmikant Chitare wrote:


Hi,

I know there is an elegant way to check if a given value is within
certain range.
Example - To check if x is between zero and ten, I can do 0 < x 10.

Is there any similar elegant way to check if a value is out of certain
range?
Example - To check if x is either less than zero or greater than ten?
Right now I am using x < 0 or x > 10.

Regards,
Laxmikant


not (0 <= x <= 10)



Yuck.

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

Mark Lawrence


What is so "yuck" about that?  What would you do instead?  It seems like the 
best solution to me.  Easy to read, fast to execute.



I have to parse those damn brackets and then figure out the inverted 
logic. Give me x < 0 or x > 10 any day of the week.  When you're an old, 
senile git like me, readability counts :-)


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

Mark Lawrence

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


Re: Error code 0x80070570

2015-09-30 Thread Denis McMahon
On Wed, 30 Sep 2015 23:06:13 +0530, Rusiri Jayalath wrote:

> Error code 0x80070570 appears when installing python 3.5.0 (32-bit)
> setup for my windows 8.1 system. Please help me to solve this problem.

This seems to be a windows error, not a python issue. Try google.

-- 
Denis McMahon, denismfmcma...@gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Question about regular expression

2015-09-30 Thread Denis McMahon
On Wed, 30 Sep 2015 11:34:04 -0700, massi_srb wrote:

> firstly the description of my problem. I have a string in the following
> form: .

The way I solved this was to:

1) replace all the punctuation in the string with spaces

2) split the string on space

3) process each thing in the list to test if it was a number or word

4a) add words to the dictionary as keys with value of a default list, or
4b) add numbers to the dictionary in the list at the appropriate position

5) convert the list values of the dictionary to tuples

It seems to work on my test case:

s = "fred jim(1) alice tom (1, 4) peter (2) andrew(3,4) janet( 7,6 ) james
( 7 ) mike ( 9 )"

d = {'mike': (9, 0), 'janet': (7, 6), 'james': (7, 0), 'jim': (1, 0), 
'andrew': (3, 4), 'alice': (0, 0), 'tom': (1, 4), 'peter': (2, 0), 'fred': 
(0, 0)}




-- 
Denis McMahon, denismfmcma...@gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Question about regular expression

2015-09-30 Thread Emile van Sebille

On 9/30/2015 12:20 PM, Tim Chase wrote:

On 2015-09-30 11:34, massi_...@msn.com wrote:



I guess this problem can be tackled with regular expressions, b

... However, if you *want* to do it with
regular expressions, you can.  It's ugly and might be fragile, but

#
import re
s = "name1 name2(1) name3 name4 (1, 4) name5(2) ..."
r = re.compile(r"""
 \b   # start at a word boundary
 (\w+)# capture the word
 \s*  # optional whitespace
 (?:  # start an optional grouping for things in the parens
  \(  # a literal open-paren
   \s*# optional whitespace
   (\d+)  # capture the number in those parens
   (?:# start a second optional grouping for the stuff after a comma
\s*   # optional whitespace
, # a literal comma
\s*   # optional whitespace
(\d+) # the second number
   )? # make the command and following number optional
  \)  # a literal close-paren
 )?   # make that stuff in parens optional
 """, re.X)
d = {}
for m in r.finditer(s):
 a, b, c  = m.groups()
 d[a] = (int(b or 0), int(c or 0))

from pprint import pprint
pprint(d)
#


:)



I'd stick with the commented version of the regexp if you were to use
this anywhere so that others can follow what you're doing.


... and this is why I use python.  That looks too much like a hex sector 
disk dump rot /x20.  :)


No-really-that's-sick-ly yr's,

Emile




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