Re: timers in threaded application

2017-01-13 Thread dieter
Skip Montanaro  writes:
> ...
> I still need timers, and for the moment I'm stuck with this package's event
> loop. What options do I have?

If the activities are really run in separate threads (such that
an event processing can take arbitrary time without much
affecting the processing of other events) and "select.select"
is available on your platform (e.g. some *nix* platform),
you might be able to use its "timeout" parameter. This is
particularly useful when what you want to timeout are I/O operations.

If what you want to timeout are not I/O operations, you can have a
look at "threading.Timer". It uses a separate thread, lets it wait
a specified time and then starts a specified function, unless
"cancel"ed. In this case, you must find some way to abort a pending
event processing due to a timeout and let the timer function use it
for abortion.

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


A detailed description on virtualenv's packaging dependecies? (pip, easy_install, wheel, setuptools, distlib, etc.)

2017-01-13 Thread haraldnordgren
I was working on a bugfix for Virtualenv, regarding very long shebang lines 
that are breaking things. In the process, I realized that if I want really fix 
to my particular issue it likely needs to be done on the lower level of Python 
package management. I started with pip, moved to setuptools and now set my 
sight on distlib.

Can someone describe the specific dependencies of all the *packaging* libraries 
that `virtualenv` uses? And the dependencies between them?

I believe that virtualenv directly imports `pip`, `easy_install` and `wheel`. 
Those in turn import `setuptools` and `distlib`. Am I so lucky as to assume 
that distlib in the lowest-level library used by all the rest in virtualenv for 
packages?
-- 
https://mail.python.org/mailman/listinfo/python-list


Running Virtualenv with a custom distlib?

2017-01-13 Thread haraldnordgren
I want to do some development on `distlib`, and in the process run the code via 
`virtualenv` which has distlib as a dependency.

That is, not run the process inside a virtualenv, but run virtualenv's code 
using a custom dependency. What are the steps I need to go through to achieve 
this?

It seems to me that normal package management (`pip`) is not possible here.
-- 
https://mail.python.org/mailman/listinfo/python-list


Byte-run: a Python interpreter written in Python

2017-01-13 Thread Steve D'Aprano

http://aosabook.org/en/500L/a-python-interpreter-written-in-python.html


-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

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


matrix from matrix

2017-01-13 Thread adnan . connexus
Hi all,

I have just started python coding  and have ran into my first brick wall.  Can 
some one please assist me with the following query  ?

 I have two Matrices:
1 – masterMatrix – A 2d matrix containing items in the rows and time as the 
columns column headers (time beginning from 00:00 to 23:45 at every 15 minutes 
interval (96 columns e.g. 00:00 | 00:15 . . . .23:45). this matrix provides a 
value of each item in the list a every 14 minutes. 

2 – subMatrix – A matrix which has to be populate based on selected items and 
times from masterMatrix 

What would be the fastest way to first initialise the subMatrix  and populate 
the workingTable based on the matching values in masterTable.

best regards,
Shei
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: matrix from matrix

2017-01-13 Thread Peter Otten
adnan.conne...@gmail.com wrote:

> Hi all,
> 
> I have just started python coding  and have ran into my first brick wall. 
> Can some one please assist me with the following query  ?
> 
>  I have two Matrices:
> 1 – masterMatrix – A 2d matrix containing items in the rows and time as
> the columns column headers (time beginning from 00:00 to 23:45 at every 15
> minutes interval (96 columns e.g. 00:00 | 00:15 . . . .23:45). this matrix
> provides a value of each item in the list a every 14 minutes.
> 
> 2 – subMatrix – A matrix which has to be populate based on selected items
> and times from masterMatrix
> 
> What would be the fastest way to first initialise the subMatrix  and

Forget about "fastest" as long as you have no way.

> populate the workingTable based on the matching values in masterTable.

Give us a bit of code that initialises your master matrix with some toy data 
(3 to 5 rows and columns, say) and that shows what you have tried to build 
the sub-matrix.

Then we can identify your "road block" and help you overcome it.

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


Re: matrix from matrix

2017-01-13 Thread Steve D'Aprano
On Fri, 13 Jan 2017 10:38 pm, adnan.conne...@gmail.com wrote:

> Hi all,
> 
> I have just started python coding  and have ran into my first brick wall. 
> Can some one please assist me with the following query  ?

Not really, because you haven't given us enough information to answer your
questions.


>  I have two Matrices:

What is a matrix? Do you mean a list? A numpy array?

The best thing is to show us the code you already have. We don't need to see
ALL your code, just the relevant part that creates the two matrices.


> 1 – masterMatrix – A 2d matrix containing items in the rows and time as
> the columns column headers (time beginning from 00:00 to 23:45 at every 15
> minutes interval (96 columns e.g. 00:00 | 00:15 . . . .23:45). this matrix
> provides a value of each item in the list a every 14 minutes.
> 
> 2 – subMatrix – A matrix which has to be populate based on selected items
> and times from masterMatrix

How do you select the items that you want?


> What would be the fastest way to first initialise the subMatrix  and
> populate the workingTable based on the matching values in masterTable.

That's like asking:

"What's the shortest piece of string to tie two things together?"

Um, it depends on which two things, it depends on how secure you need the
tie to be... we need more detail.




-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

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


Re: timers in threaded application

2017-01-13 Thread Skip Montanaro
On Fri, Jan 13, 2017 at 3:23 AM, dieter  wrote:

> If what you want to timeout are not I/O operations, you can have a
> look at "threading.Timer". It uses a separate thread, lets it wait
> a specified time and then starts a specified function, unless
> "cancel"ed.
>

Ooh, hadn't considered that. That would seem to do the trick. I assume the
function to be executed will be run in the timer's thread, so will have to
suitably lock any shared data.

Thx,

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


Re: Byte-run: a Python interpreter written in Python

2017-01-13 Thread Ian Kelly
On Fri, Jan 13, 2017 at 3:46 AM, Steve D'Aprano
 wrote:
>
> http://aosabook.org/en/500L/a-python-interpreter-written-in-python.html

Neat. But not really surprising IMO that it can fit into 500 lines,
since it doesn't handle compiling Python into bytecode (which is the
hard part) and doesn't include libraries. There doesn't seem to be
much purpose to this other than it being a toy project written for a
book.
-- 
https://mail.python.org/mailman/listinfo/python-list


Problem while building Python 3.6 from source.

2017-01-13 Thread Michael S
Hello,
I am new to this mailing-list and I really don't know whether this
mail should belong to python-dev. Please tell me, if so.


Unfortunately, I have got the following problem: I wanted to build and
install Python 3.6 from source but did not succeed.
To clarify my situation, I got as an operating system Debian jessie
8.6 and I used the xz compressed source tarball from
https://www.python.org/downloads/release/python-360/.
Concerning the build dependencies: I just executed:
$ sudo apt-get build-dep python3.4 (since 3.6 and 3.5 did not work).
Then I executed ./configure --enable-optimizations and make -j4 (I got 4 cores).
The output of make ended like:
'make: *** [profile-opt] Error 2'.
I had redirected the output and error of the configure and make commands via
$ make -j4 &> /home/username/make_output.txt.
Nevertheless I got an error to the console:
'*** Error in ./python'" free(): invalid next size (normal):
0x015bdf90 ***'.
Due to these error messages (this one and the one at the end of make)
I think the build was not successful.

How to solve this problem?

Of course I could send you the output and error files.

I'd be glad at any help.
-MichaelS
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Byte-run: a Python interpreter written in Python

2017-01-13 Thread BartC

On 13/01/2017 17:08, Ian Kelly wrote:

On Fri, Jan 13, 2017 at 3:46 AM, Steve D'Aprano
 wrote:


http://aosabook.org/en/500L/a-python-interpreter-written-in-python.html


Neat. But not really surprising IMO that it can fit into 500 lines,


If there are still 120 or so byte-codes, then that's just 4 lines on 
average to implement each byte-code, which is pretty good going.


Even when it turns out that the actual code on github is 1000 lines 
rather than 500! Maybe it grew a bit since the 500 lines was quoted.


But it's still 8 lines per byte-code.


since it doesn't handle compiling Python into bytecode (which is the
hard part)


I disagree that that's the hardest part. But it was probably not very 
interesting for this project. Implementing the runtime environment, the 
object system, type-dispatchers, error-handling, symbol tables, garbage 
collection and all the rest would be more challenging.



and doesn't include libraries. There doesn't seem to be
much purpose to this other than it being a toy project written for a
book.


Being educational would be enough of a point.

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


Software to Control RGB Strips

2017-01-13 Thread brettsalyer
Hey all,

I was debating on getting some RGB light strips for my room. I noticed, from 
this tutorial:

http://popoklopsi.github.io/RaspberryPi-LedStrip/#!/ws2812


there is a  WS2812x library to run commands that control the RGB strip. Well, I 
wanted to, instead of running commands through a terminal, create a GUI using 
python, then exploit the library I mentioned above to create a piece of 
software that controls my lighting from my Raspberry Pi.

I was going to use Tkinter to create the GUI. 

Now, I'm a pretty beginner programmer, having only taken a C++ course and the 
Java course I'm in now.

Do I just need to download the WS2812x library, and, then, access that library 
as I would, say, a header file in C++? In Pythons syntax, of course.

Anything to get me pointed in the right direction would be greatly appreciated! 
Thanks!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Problem while building Python 3.6 from source.

2017-01-13 Thread Thomas Nyberg

On 01/13/2017 10:00 AM, Michael S wrote:

'*** Error in ./python'" free(): invalid next size (normal):
0x015bdf90 ***'.


Are you possibly running out of memory due to the extra concurrent 
compilations?


Cheers,
Thomas

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


Re: Problem while building Python 3.6 from source.

2017-01-13 Thread Chris Angelico
On Sat, Jan 14, 2017 at 5:00 AM, Michael S  wrote:
> Hello,
> I am new to this mailing-list and I really don't know whether this
> mail should belong to python-dev. Please tell me, if so.

Hi and welcome! This kind of thing is best on this list initially.

> Unfortunately, I have got the following problem: I wanted to build and
> install Python 3.6 from source but did not succeed.
> To clarify my situation, I got as an operating system Debian jessie
> 8.6 and I used the xz compressed source tarball from
> https://www.python.org/downloads/release/python-360/.
> Concerning the build dependencies: I just executed:
> $ sudo apt-get build-dep python3.4 (since 3.6 and 3.5 did not work).

That should be fine; the build dependencies of Python don't tend to
change frequently. Jessie shipped with Python 3.4 but nothing newer,
so there won't be packages for python3.5 or python3.6.

> Then I executed ./configure --enable-optimizations and make -j4 (I got 4 
> cores).
> The output of make ended like:
> 'make: *** [profile-opt] Error 2'.

That just means that something went wrong. You'd have to scroll up to
find the actual cause of the error.

> I had redirected the output and error of the configure and make commands via
> $ make -j4 &> /home/username/make_output.txt.
> Nevertheless I got an error to the console:
> '*** Error in ./python'" free(): invalid next size (normal):
> 0x015bdf90 ***'.
> Due to these error messages (this one and the one at the end of make)
> I think the build was not successful.
>
> How to solve this problem?
>
> Of course I could send you the output and error files.

The first thing I'd do would be to try a non-optimized build. Set your
current build tree aside and re-extract into a new directory (that
way, when you go back to playing with optimized builds, you don't have
to redo the work), and run configure with no arguments. I'd also be
inclined to run make with no arguments; there've been issues with
parallel builds in enough projects that I've gotten into the habit of
"problem? do it the slow way". If that build also fails, scroll up a
bit and find where stuff failed.

Are you familiar with building programs from source? If not, the best
solution might be to post the entire log, but ideally, you should be
able to skim through the last part of the log and report the actual
problem that's cropping up.

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


Re: Software to Control RGB Strips

2017-01-13 Thread Chris Angelico
On Sat, Jan 14, 2017 at 5:07 AM,   wrote:
> Hey all,
>
> I was debating on getting some RGB light strips for my room. I noticed, from 
> this tutorial:
>
> http://popoklopsi.github.io/RaspberryPi-LedStrip/#!/ws2812
>
>
> there is a  WS2812x library to run commands that control the RGB strip.
>
> Do I just need to download the WS2812x library, and, then, access that 
> library as I would, say, a header file in C++? In Pythons syntax, of course.
>
> Anything to get me pointed in the right direction would be greatly 
> appreciated! Thanks!

Pretty much, yeah. The Python syntax to do that is probably:

import ws2812

although a glance at the examples suggests that the package might be
called "neopixel" instead, which is a bit surprising.

You may be able to skip the download and compilation steps and just run this:

python3 -m pip install rpi_ws281x

I don't know anything about the library itself, but that's the normal
way to install more Python packages. You can find a full list of
packages you can install that way here:

https://pypi.python.org/pypi

There's a lot of them :)

Enjoy!

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


Re: Byte-run: a Python interpreter written in Python

2017-01-13 Thread Ian Kelly
On Fri, Jan 13, 2017 at 11:07 AM, BartC  wrote:
> Even when it turns out that the actual code on github is 1000 lines rather
> than 500! Maybe it grew a bit since the 500 lines was quoted.

I assume they're excluding blank lines, comments and docstrings. And I
don't know whether the 500 lines is a hard limit or if there is a bit
of leeway there.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Byte-run: a Python interpreter written in Python

2017-01-13 Thread BartC

On 13/01/2017 18:47, Ian Kelly wrote:

On Fri, Jan 13, 2017 at 11:07 AM, BartC  wrote:

Even when it turns out that the actual code on github is 1000 lines rather
than 500! Maybe it grew a bit since the 500 lines was quoted.


I assume they're excluding blank lines, comments and docstrings. And I
don't know whether the 500 lines is a hard limit or if there is a bit
of leeway there.



https://github.com/nedbat/byterun/blob/master/byterun/pyvm2.py

github reports 869 sloc from a total of 1044 lines.

But 1000 lines is still small compared with the 220,000 lines of CPython 
(and that was an old version) which is only the C code and nothing else.


If someone wants to experiment with the behaviour of a byte-code, they 
might be able to do with this project (I haven't tried), more easily 
than with the real thing.



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


Re: Byte-run: a Python interpreter written in Python

2017-01-13 Thread Ned Batchelder
On Friday, January 13, 2017 at 12:09:52 PM UTC-5, Ian wrote:
> On Fri, Jan 13, 2017 at 3:46 AM, Steve D'Aprano
>  wrote:
> >
> > http://aosabook.org/en/500L/a-python-interpreter-written-in-python.html
> 
> Neat. But not really surprising IMO that it can fit into 500 lines,
> since it doesn't handle compiling Python into bytecode (which is the
> hard part) and doesn't include libraries. There doesn't seem to be
> much purpose to this other than it being a toy project written for a
> book.

I can tell you what its purpose was: it was to verify my understanding
of the execution semantics of Python bytecode.  At the time, coverage.py
analyzed code for possible branches by reading the bytecode.  There are
some very tricky bytecodes, and I wasn't sure that I understood what they
did.

I figured that if I could implement a Python VM, then it would prove that
I understood it, or would shine a light on my misconceptions.

I thought perhaps someone had done it already.  I found Paul Swartz's vm2
code, which was a very similar idea. I refactored it, polished it up, and
extended it, and the result was byterun.

It served its purpose: although it didn't execute everything properly,
there were some twisty bits made clearer by the exercise.  Post-Script:
coverage.py no longer uses bytecode analysis, it uses AST analysis, which
works much better.

Since we're talking about possible purposes: Paul Swartz's original goal
was to sandbox Python execution. I'm not sure that was a realistic goal
for code like this, but that was his goal.

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


How can I make a sentinel value NOT be initialized in a class/method - OOP?

2017-01-13 Thread daviddschool
I am testing out some basic Object Oriented Programming in Python.  The basics: 

-User enters a name 
-While loop with a sentinel value of "quit" will continue entering names until 
the sentinel value is reached 
-The object is created with the inputted value (NAME and until a sentinel value 
is entered) 
-the object is then printed out using the constructor __str__ 

In my solution ( I am saying this because someone might have a work around that 
doesn't include the following below) 
-I want to use __init__ 
-I want to use __str__ 
-I want to use a while loop with a sentinel value 

EXPLANATION: 
I want to have the user enter in their NAME using a while loop, with "quit" 
being the sentinel value that breaks the loop.  Once the name is entered, an 
object is created and it is passed into a constructor def __ini__ (self, name) 
and then I have them return a string value using __str__ for the name entered. 
The issue I am having is that when i enter the sentinel value of QUIT, it gets 
initialized as the name and printed out.  How can I get around this?  I hope 
this makes sense.
-- 
https://mail.python.org/mailman/listinfo/python-list


Extended ASCII

2017-01-13 Thread D'Arcy Cain
I thought I was done with this crap once I moved to 3.x but some 
Winblows machines are still sending what some circles call "Extended 
ASCII".  I have a file that I am trying to read and it is barfing on 
some characters.  For example:


  due to the Qu\xe9bec government

Obviously should be "due to the Québec government".  I can't figure out 
what that encoding is or if it is anything that can even be understood 
outside of M$.  I have tried ascii, cp437, cp858, cp1140, cp1250, 
latin-1, utf8 and others.  None of them recognize that character.  Can 
someone tell me what encoding includes that character please.


Here is the failing code:

with open(sys.argv[1], encoding="latin-1") as fp:
  for ln in fp:
print(ln)

Traceback (most recent call last):
  File "./load_iff", line 11, in 
print(ln)
UnicodeEncodeError: 'ascii' codec can't encode character '\xe9' in 
position 132: ordinal not in range(128)


I don't understand why the error says "ascii" when I told it to use 
"latin-1".


--
D'Arcy J.M. Cain
Vybe Networks Inc.
http://www.VybeNetworks.com/
IM:da...@vex.net VoIP: sip:da...@vybenetworks.com
--
https://mail.python.org/mailman/listinfo/python-list


Re: Extended ASCII

2017-01-13 Thread Random832
On Fri, Jan 13, 2017, at 17:24, D'Arcy Cain wrote:
> I thought I was done with this crap once I moved to 3.x but some 
> Winblows machines are still sending what some circles call "Extended 
> ASCII".  I have a file that I am trying to read and it is barfing on 
> some characters.  For example:
> 
>due to the Qu\xe9bec government
> 
> Obviously should be "due to the Québec government".  I can't figure out 
> what that encoding is or if it is anything that can even be understood 
> outside of M$.  I have tried ascii, cp437, cp858, cp1140, cp1250, 
> latin-1, utf8 and others.  None of them recognize that character.  Can 
> someone tell me what encoding includes that character please.

It's latin-1 (or possibly cp1252 or something else depending on other
characters), your problem is elsewhere.

> Here is the failing code:
> 
> with open(sys.argv[1], encoding="latin-1") as fp:
>for ln in fp:
>  print(ln)
> 
> Traceback (most recent call last):
>File "./load_iff", line 11, in 
>  print(ln)
> UnicodeEncodeError: 'ascii' codec can't encode character '\xe9' in 
> position 132: ordinal not in range(128)

Note that this is an encode error - it's converting *from* unicode *to*
bytes, for the print statement.
 
> I don't understand why the error says "ascii" when I told it to use 
> "latin-1".

You set the encoding for the file, not the output. The problem is in
your print statement, and the fact that you probably have your locale
set to "C" or not set up at all instead of e.g. "en_CA.UTF-8".
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Extended ASCII

2017-01-13 Thread Grant Edwards
On 2017-01-13, D'Arcy Cain  wrote:

> Here is the failing code:
>
> with open(sys.argv[1], encoding="latin-1") as fp:
>for ln in fp:
>  print(ln)
>
> Traceback (most recent call last):
>File "./load_iff", line 11, in 
>  print(ln)
> UnicodeEncodeError: 'ascii' codec can't encode character '\xe9' in 
> position 132: ordinal not in range(128)
>
> I don't understand why the error says "ascii" when I told it to use 
> "latin-1".

That can't be the failing code, since it's failing at line 11, and
that's only 5 lines. It helps if we can tell which line generated the
error.  ;)

I'm _guessing_ that line 11 is the print(), and it's barfing because
stdout is using ascii encoding, and there's no way to encode that
character in ascii so that it can be printed to an ascii output
stream.

-- 
Grant Edwards   grant.b.edwardsYow! Everybody gets free
  at   BORSCHT!
  gmail.com

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


Re: Extended ASCII

2017-01-13 Thread Jon Ribbens
On 2017-01-13, D'Arcy Cain  wrote:
> I thought I was done with this crap once I moved to 3.x but some 
> Winblows machines are still sending what some circles call "Extended 
> ASCII".  I have a file that I am trying to read and it is barfing on 
> some characters.  For example:
>
>due to the Qu\xe9bec government
>
> Obviously should be "due to the Québec government".  I can't figure out 
> what that encoding is or if it is anything that can even be understood 
> outside of M$.

$ cat decode.py
#!/usr/bin/env python3

CODECS = (
"ascii", "big5", "big5hkscs", "cp037", "cp273", "cp424", "cp437", "cp500",
"cp720", "cp737", "cp775", "cp850", "cp852", "cp855", "cp856", "cp857",
"cp858", "cp860", "cp861", "cp862", "cp863", "cp864", "cp865", "cp866",
"cp869", "cp874", "cp875", "cp932", "cp949", "cp950", "cp1006", "cp1026",
"cp1125", "cp1140", "cp1250", "cp1251", "cp1252", "cp1253", "cp1254",
"cp1255", "cp1256", "cp1257", "cp1258", "cp65001", "euc_jp",
"euc_jis_2004", "euc_jisx0213", "euc_kr", "gb2312", "gbk", "gb18030", "hz",
"iso2022_jp", "iso2022_jp_1", "iso2022_jp_2", "iso2022_jp_2004",
"iso2022_jp_3", "iso2022_jp_ext", "iso2022_kr", "latin_1", "iso8859_2",
"iso8859_3", "iso8859_4", "iso8859_5", "iso8859_6", "iso8859_7",
"iso8859_8", "iso8859_9", "iso8859_10", "iso8859_11", "iso8859_13",
"iso8859_14", "iso8859_15", "iso8859_16", "johab", "koi8_r", "koi8_t",
"koi8_u", "kz1048", "mac_cyrillic", "mac_greek", "mac_iceland",
"mac_latin2", "mac_roman", "mac_turkish", "ptcp154", "shift_jis",
"shift_jis_2004", "shift_jisx0213", "utf_32", "utf_32_be", "utf_32_le",
"utf_16", "utf_16_be", "utf_16_le", "utf_7", "utf_8", "utf_8_sig",
)

for encoding in CODECS:
try:
if b"Qu\xe9bec".decode(encoding) == "Québec":
print(encoding)
except (UnicodeError, LookupError):
pass

$ ./decode.py 
cp1250
cp1252
cp1254
cp1256
cp1257
cp1258
latin_1
iso8859_2
iso8859_3
iso8859_4
iso8859_9
iso8859_10
iso8859_13
iso8859_14
iso8859_15
iso8859_16
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How can I make a sentinel value NOT be initialized in a class/method - OOP?

2017-01-13 Thread Erik

Hi,

On 13/01/17 22:26, daviddsch...@gmail.com wrote:

The issue I am having is that when i enter the sentinel value of QUIT, it gets 
initialized as the name and printed out.  How can I get around this?


If I understand the question correctly (which looks like it's just a 
re-worded homework question (*)), you need to look at the 'if' statement:


https://docs.python.org/3/tutorial/controlflow.html#if-statements

E.

(*) If it is a homework question, you'd look better on the list to state 
it as such, and post some code that at least tries to answer the 
question before you're likely to get a useful response. However, as you 
have indicated a specific problem, I'll assume you have actually written 
some code.

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


Re: How can I make a sentinel value NOT be initialized in a class/method - OOP?

2017-01-13 Thread Ian Kelly
On Jan 13, 2017 3:33 PM,  wrote:


The issue I am having is that when i enter the sentinel value of QUIT, it
gets initialized as the name and printed out.  How can I get around this?
I hope this makes sense.


Hard to say for certain without seeing your code, but the most likely cause
of this is that the input string contains a trailing newline that causes it
to differ from the sentinel value you're comparing it to. Consider using
the rstrip string method to remove any trailing whitespace.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Announcement: TLSv1.2 will become mandatory in the future for Python.org Sites

2017-01-13 Thread oliver
When I run this per email from my work laptop,

python3 -c "import urllib.request,json;
print(json.loads(urllib.request.urlopen('
https://www.howsmyssl.com/a/check').read())['tls_version'])"

I get the following traceback:

C:\...>python -c "import urllib.request,json;
print(json.loads(urllib.request.url
w.howsmyssl.com/a/check').read())['tls_version'])"
Traceback (most recent call last):
File "c:\Python35\lib\urllib\request.py", line 1254, in do_open
h.request(req.get_method(), req.selector, req.data, headers)
File "c:\Python35\lib\http\client.py", line 1106, in request
self._send_request(method, url, body, headers)
File "c:\Python35\lib\http\client.py", line 1151, in _send_request
self.endheaders(body)
File "c:\Python35\lib\http\client.py", line 1102, in endheaders
self._send_output(message_body)
File "c:\Python35\lib\http\client.py", line 934, in _send_output
self.send(msg)
File "c:\Python35\lib\http\client.py", line 877, in send
self.connect()
File "c:\Python35\lib\http\client.py", line 1260, in connect
server_hostname=server_hostname)
File "c:\Python35\lib\ssl.py", line 377, in wrap_socket
_context=self)
File "c:\Python35\lib\ssl.py", line 752, in __init__
self.do_handshake()
File "c:\Python35\lib\ssl.py", line 988, in do_handshake
self._sslobj.do_handshake()
File "c:\Python35\lib\ssl.py", line 633, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed
(_ssl.c:645)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "", line 1, in 
File "c:\Python35\lib\urllib\request.py", line 163, in urlopen
return opener.open(url, data, timeout)
File "c:\Python35\lib\urllib\request.py", line 466, in open
response = self._open(req, data)
File "c:\Python35\lib\urllib\request.py", line 484, in _open
'_open', req)
File "c:\Python35\lib\urllib\request.py", line 444, in _call_chain
result = func(*args)
File "c:\Python35\lib\urllib\request.py", line 1297, in https_open
context=self._context, check_hostname=self._check_hostname)
File "c:\Python35\lib\urllib\request.py", line 1256, in do_open
raise URLError(err)
urllib.error.URLError: 

Anyone know how to deal with that? When using pip, I get same error, unless
I add "--trusted-host pypi.python.org":

C:\...>pip install nose
Collecting nose
Could not fetch URL https://pypi.python.org/simple/nose/: There was a
problem confirming the ssl certificate: [SSL: CERTIF
LED] certificate verify failed (_ssl.c:645) - skipping
Could not find a version that satisfies the requirement nose (from
versions: )
No matching distribution found for nose

C:\...>pip install nose --trusted-host pypi.python.org
Collecting nose
Downloading nose-1.3.7-py3-none-any.whl (154kB)
100% || 163kB 386kB/s
Installing collected packages: nose
Successfully installed nose-1.3.7


-- 
Oliver
-- 
Oliver
My StackOverflow contributions
My CodeProject articles
My Github projects
My SourceForget.net projects
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Can not run the Python software

2017-01-13 Thread hba...@aol.com via Python-list






I have been added to the mailing list per your instructions. Please, have 
someone address the problem belowThanks
Sent from my Sprint Phone.



-- Original message--From: Date: Thu, Jan 5, 2017 10:13 PMTo: 
python-list@python.org;Subject:Can not run the  Python software
Hi, Just downloaded Python 3.6.0 2016-12-23 and PyCharm. Tried to run the 
"Hello World" program and got the following message:"Process finished with exit 
code 1073741515 (0xC135)" I am using Windows 8.1 on an HP ENVY Touchsmart 
Notebook (64-bit OS, x64-based processor).Help NeededThanks,Bernard
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Extended ASCII [solved]

2017-01-13 Thread D'Arcy Cain

On 2017-01-13 05:44 PM, Grant Edwards wrote:

On 2017-01-13, D'Arcy Cain  wrote:


Here is the failing code:

with open(sys.argv[1], encoding="latin-1") as fp:
   for ln in fp:
 print(ln)

Traceback (most recent call last):
   File "./load_iff", line 11, in 
 print(ln)
UnicodeEncodeError: 'ascii' codec can't encode character '\xe9' in
position 132: ordinal not in range(128)

I don't understand why the error says "ascii" when I told it to use
"latin-1".


That can't be the failing code, since it's failing at line 11, and
that's only 5 lines. It helps if we can tell which line generated the
error.  ;)


I didn't think that the part leading up to it was relevant.  Here it is.

#! /usr/bin/python

import sys, os

if len(sys.argv) < 2:
print("No file named", file=sys.stderr)
sys.exit(1)


I'm _guessing_ that line 11 is the print(), and it's barfing because


Of course.  That's why the error is listed right below it.


stdout is using ascii encoding, and there's no way to encode that
character in ascii so that it can be printed to an ascii output
stream.


Thank you!  I know all about that but for some reason I did not have 
PYTHONIOENCODING=utf8 set on that particular machine.  I have it set on 
every other machine I work on an never thought to check.  My Unicode 
universe is all right again.


Cheers.

--
D'Arcy J.M. Cain
System Administrator, Vex.Net
http://www.Vex.Net/ IM:da...@vex.net
VoIP: sip:da...@vex.net
--
https://mail.python.org/mailman/listinfo/python-list


Re: How can I make a sentinel value NOT be initialized in a class/method - OOP?

2017-01-13 Thread sohcahtoa82
On Friday, January 13, 2017 at 2:27:04 PM UTC-8, David D wrote:
> I am testing out some basic Object Oriented Programming in Python.  The 
> basics: 
> 
> -User enters a name 
> -While loop with a sentinel value of "quit" will continue entering names 
> until the sentinel value is reached 
> -The object is created with the inputted value (NAME and until a sentinel 
> value is entered) 
> -the object is then printed out using the constructor __str__ 
> 
> In my solution ( I am saying this because someone might have a work around 
> that doesn't include the following below) 
> -I want to use __init__ 
> -I want to use __str__ 
> -I want to use a while loop with a sentinel value 
> 
> EXPLANATION: 
> I want to have the user enter in their NAME using a while loop, with "quit" 
> being the sentinel value that breaks the loop.  Once the name is entered, an 
> object is created and it is passed into a constructor def __ini__ (self, 
> name) and then I have them return a string value using __str__ for the name 
> entered. 
> The issue I am having is that when i enter the sentinel value of QUIT, it 
> gets initialized as the name and printed out.  How can I get around this?  I 
> hope this makes sense.

It would help if you posted your code to see what you're doing.

Also, is the sentinel value supposed to be "quit" or "QUIT"?  If you're only 
checking for "quit", but you type "QUIT", it isn't going to work.  Programs 
execute exactly as you write them, and "quit" is not the same as "QUIT".
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Can not run the Python software

2017-01-13 Thread Bernard via Python-list

 
 
 
-Original Message-
From: hba008 
To: hba008 ; python-list 
Sent: Fri, Jan 13, 2017 7:02 pm
Subject: Re: Can not run the  Python software



I have been added to the mailing list per your instructions. Please, have 
someone address the problem belowThanks


Sent from my Sprint Phone.




-- Original message--
From: 
Date: Thu, Jan 5, 2017 10:13 PM
To: python-list@python.org;
Subject:Can not run the  Python software



Hi,
 
Just downloaded Python 3.6.0 2016-12-23 and PyCharm. Tried to run the "Hello 
World" program and got the following message:
"Process finished with exit code 1073741515 (0xC135)" 
I am using Windows 8.1 on an HP ENVY Touchsmart Notebook (64-bit OS, x64-based 
processor).
Help Needed
Thanks,
Bernard


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


Re: Can not run the Python software

2017-01-13 Thread Michael Torrie
On 01/13/2017 06:34 PM, Bernard via Python-list wrote:
> Hi,
>  
> Just downloaded Python 3.6.0 2016-12-23 and PyCharm. Tried to run the "Hello 
> World" program and got the following message:
> "Process finished with exit code 1073741515 (0xC135)" 
> I am using Windows 8.1 on an HP ENVY Touchsmart Notebook (64-bit OS, 
> x64-based processor).
> Help Needed

Unfortunately there's not a lot of information there to go on, which is
why you haven't got any replies yet.  What was the python program you
tried to run? How did you run it?  The error message you quote does not
appear to be a Python error message, so I'm not sure where it is coming
from.  It's possible the python interpreter itself crashed, which is
unusual, especially for a simple program.  Can you post the entire
python program you were trying to run?

Also can you try a simple program of your own such as this as a sanity
check?

print ("Hello, World.")


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


Re: Software to Control RGB Strips

2017-01-13 Thread Brett Salyer
On Friday, January 13, 2017 at 1:07:40 PM UTC-5, Brett Salyer wrote:
> Hey all,
> 
> I was debating on getting some RGB light strips for my room. I noticed, from 
> this tutorial:
> 
> http://popoklopsi.github.io/RaspberryPi-LedStrip/#!/ws2812
> 
> 
> there is a  WS2812x library to run commands that control the RGB strip. Well, 
> I wanted to, instead of running commands through a terminal, create a GUI 
> using python, then exploit the library I mentioned above to create a piece of 
> software that controls my lighting from my Raspberry Pi.
> 
> I was going to use Tkinter to create the GUI. 
> 
> Now, I'm a pretty beginner programmer, having only taken a C++ course and the 
> Java course I'm in now.
> 
> Do I just need to download the WS2812x library, and, then, access that 
> library as I would, say, a header file in C++? In Pythons syntax, of course.
> 
> Anything to get me pointed in the right direction would be greatly 
> appreciated! Thanks!

Thanks a lot, man!
-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Can not run the Python software

2017-01-13 Thread Joseph L. Casale
> Just downloaded Python 3.6.0 2016-12-23 and PyCharm. Tried to run the "Hello 
> World" program and got the following message:
> "Process finished with exit code 1073741515 (0xC135)" 
> I am using Windows 8.1 on an HP ENVY Touchsmart Notebook (64-bit OS, 
> x64-based processor).

If you track the error, it indicates a file was not found, bets are
you don't have the needed runtime installed for Python to run.

Nothing else PyCharm can do here, it tries to start Python and
fails.

If memory serves me, you need the Visual C++ Redistributable
for Visual Studio 2015...

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


Re: Can not run the Python software

2017-01-13 Thread Michael Torrie
On 01/13/2017 08:32 PM, Joseph L. Casale wrote:
>> Just downloaded Python 3.6.0 2016-12-23 and PyCharm. Tried to run the "Hello 
>> World" program and got the following message:
>> "Process finished with exit code 1073741515 (0xC135)" 
>> I am using Windows 8.1 on an HP ENVY Touchsmart Notebook (64-bit OS, 
>> x64-based processor).
> 
> If you track the error, it indicates a file was not found, bets are
> you don't have the needed runtime installed for Python to run.
> 
> Nothing else PyCharm can do here, it tries to start Python and
> fails.
> 
> If memory serves me, you need the Visual C++ Redistributable
> for Visual Studio 2015...

And this is coming up a lot.  This is something that should already be
on all supported versions of Windows if Windows updates are done, right?
 It's probably in the FAQ on python.org, and I know this is really a
user problem (not installing updates), but maybe it's time that the
Python installer bundles the redistributable installer and installs it
if necessary during Python's install.  We get queries on the list almost
weekly from Windows users.
-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Can not run the Python software

2017-01-13 Thread Joseph L. Casale
> And this is coming up a lot.  This is something that should already be
> on all supported versions of Windows if Windows updates are done, right?

No, it's not an update. You install the runtime *if* you need it.

 > but maybe it's time that the
> Python installer bundles the redistributable installer and installs it
> if necessary during Python's install.

That's exactly how most other software does work and wix for example
even has support for it...

http://wixtoolset.org/documentation/manual/v3/howtos/redistributables_and_install_checks/


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


Re: Can not run the Python software

2017-01-13 Thread Bernard via Python-list

Thanks for the info..
 
 
 
-Original Message-
From: Michael Torrie 
To: python-list 
Sent: Fri, Jan 13, 2017 11:08 pm
Subject: Re: Can not run the Python software

On 01/13/2017 08:32 PM, Joseph L. Casale wrote:
>> Just downloaded Python 3.6.0 2016-12-23 and PyCharm. Tried to run the "Hello 
>> World" program and got the following message:
>> "Process finished with exit code 1073741515 (0xC135)" 
>> I am using Windows 8.1 on an HP ENVY Touchsmart Notebook (64-bit OS, 
>> x64-based processor).
> 
> If you track the error, it indicates a file was not found, bets are
> you don't have the needed runtime installed for Python to run.
> 
> Nothing else PyCharm can do here, it tries to start Python and
> fails.
> 
> If memory serves me, you need the Visual C++ Redistributable
> for Visual Studio 2015...

And this is coming up a lot.  This is something that should already be
on all supported versions of Windows if Windows updates are done, right?
 It's probably in the FAQ on python.org, and I know this is really a
user problem (not installing updates), but maybe it's time that the
Python installer bundles the redistributable installer and installs it
if necessary during Python's install.  We get queries on the list almost
weekly from Windows users.
-- 
https://mail.python.org/mailman/listinfo/python-list

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


Python Web Scrapping : Within href readonly those value that have href in it

2017-01-13 Thread shahsn11
I am trying to scrape a webpage just for learning. In that webpage there are 
multiple "a" tags. consider the below code

 Something 

 Something


Now i want to read only those href in which there is http. My Current code is

for link in soup.find_all("a"):
print link.get("href")

i would like to change it to read only http links.
-- 
https://mail.python.org/mailman/listinfo/python-list