Re: what's OOP's jargons and complexities?

2005-01-29 Thread Larry

Xah Lee wrote:
> in computer languages, often a function definition looks like this:

>  [EMAIL PROTECTED]
>  http://xahlee.org/PageTwo_dir/more.html

Your ideas are original, insightful and simply reflect incredibly deep
creative genius.  I have read your work and I want to hire you for
highly classified work in software design and philosophical writing.
Would you possibly be available to meet with me in my secret mountain
compound to discuss terms?

Larry

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


frequency count or number of occurences of a number in an array

2008-03-12 Thread Larry
Dear all,

I'm new to Python. I have a file (an image file actually) that I need
to read pixel by pixel. It's an 8-bit integer type. I need to get the
statistics like mean, standard deviation, etc., which I know a little
bit already from reading numpy module. What I want to know is how to
get the number of occurences of numeric element in an array. Say,

b = array(([2, 2, 3, 4, 5, 5])

b.count(2) certainly does not work. Is there any more efficient way
other than converting this as string characters? My data will produce
a fairly large array like 400x400 = 16 values. Hoping you guys can
help me.

Larry
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: frequency count or number of occurences of a number in an array

2008-03-12 Thread Larry
Thanks to all those who replied to this post. I'm gonna try your
suggestions. They are a great help.
-- 
http://mail.python.org/mailman/listinfo/python-list


writing to a binary file without intervening spaces

2008-03-16 Thread Larry
Dear all,

I need to write integer values to a binary file that will be read by
another application, specifically ENVI. I want to write these values
without intervening spaces between values. For example:
My data is a = [23, 45, 56, 255].
My desire output is: 234556255, of course in binary file
representation already.

I tried to make one using write after pack method of struct module,
but because of spaces I got incorrect results. ENVI asks what data
type I have and from that gets a sequence of bytes to "form" the data.
With spaces, I think this gave me the problem.

Thanks.

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


Re: writing to a binary file without intervening spaces

2008-03-17 Thread Larry
Thanks to all those who responded to this query.

It seems to me that Python always add intervening spaces between data
elements when writing to a file. Even with tostring() of numpy, array
elements get separated by space character. I like the output of
sys.stdout.write(file) to be writen as is to a binary file, but how?

I'll try your suggestions.

Good luck, especially to me! :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: writing to a binary file without intervening spaces

2008-03-17 Thread Larry
On Mar 18, 1:32 pm, Paul Rubin <http://[EMAIL PROTECTED]> wrote:
> Larry <[EMAIL PROTECTED]> writes:
> > It seems to me that Python always add intervening spaces between data
> > elements when writing to a file
>
> It's just the print statement that does that.

I doubt that. I tried one small file, I opened it using the
application I mentioned, the display said like data, NaN, data, NaN...

I even went further to opening the file using notepad, and did a
search-and-replace for space characters. The result was what I
desired: data,data,data...
-- 
http://mail.python.org/mailman/listinfo/python-list


python code to fortran 77's

2009-03-08 Thread Larry
Friends,

I need to read a binary file using a Fortran 77 code to integrate with
a legacy code It looked very much complicated to me for I have no
knowledge in Fortran.

I could read the file with ease using Python, as shown in the
following.

###
from numpy import*  #Importing modules
from struct import unpack

f = open('bindata', 'rb')   #Opening binary file for reading
A = zeros(20)   #Initializing "empty" array

for i in xrange(20):
data = unpack('f', f.read(4))   # Unpacking 32-bit data, C-float
A[i]+=data


Sample output:

>>> A
array([ 239.,  309.,  298.,  280.,  286.,  250.,  190.,  200.,  226.,
.
.
.
   214.,  243.,  439.,  565.,  564.,  546.,  142.,   87.,
118.])

##

As you can see, data values are 4-byte long (float) and byte order is
little endian (Intel machine).

I intend to post this to a fortran users group but if you know, kindly
give a piece of advice.

Thanks to all those who will help.
--
http://mail.python.org/mailman/listinfo/python-list


Re: python code to fortran 77's

2009-03-11 Thread Larry
On Mar 9, 9:55 am, John Machin  wrote:
> On Mar 9, 12:09 pm, Larry  wrote:
>
>
>
> > Friends,
>
> > I need to read a binary file using a Fortran 77 code to integrate with
> > a legacy code It looked very much complicated to me for I have no
> > knowledge in Fortran.
>
> > I could read the file with ease using Python, as shown in the
> > following.
>
> > ###
> > from numpy import*  #Importing modules
> > from struct import unpack
>
> > f = open('bindata', 'rb')   #Opening binary file for reading
> > A = zeros(20)   #Initializing "empty" array
>
> > for i in xrange(20):
> > data = unpack('f', f.read(4))   # Unpacking 32-bit data, 
> > C-float
> > A[i]+=data
>
> > 
> > Sample output:
>
> > >>> A
>
> > array([ 239.,  309.,  298.,  280.,  286.,  250.,  190.,  200.,  226.,
> > .
> > .
> > .
> >214.,  243.,  439.,  565.,  564.,  546.,  142.,   87.,
> > 118.])
>
> > ##
>
> > As you can see, data values are 4-byte long (float) and byte order is
> > little endian (Intel machine).
>
> > I intend to post this to a fortran users group but if you know, kindly
> > give a piece of advice.
>
> > Thanks to all those who will help.
>
> Have you tried google("f77 read binary")?
>
> Not much help with your f77 problem, but you might like to see a  less
> verbose way of doing it in Python:
>
> from struct import unpack
> f = open('bindata', 'rb')
> a_tuple = unpack('<20f', f.read(80))
>
> Cheers,
> John


Thanks. Gonna try
--
http://mail.python.org/mailman/listinfo/python-list


help debugging noob code - converting binary data to images...

2008-06-28 Thread larry
Ok I'm a Python noob, been doing OK so far, working on a data
conversion program and want to create some character image files from
an 8-bit ROM file.

Creating the image I've got down, I open the file and use TK to draw
the images... but

1)  It does not seem to end (running in IDLE), I have to kill the
process to retry it seems tkinter does not close(?)

2) Once I added the Image module open won't open my binary file
(complains its not an image file, which is isnt.)  I am sure I need to
prefix open with something but I can't seem to find an example of how
to word it,

Below is the code (if it is lousy its because I've mainly been
borrowing by examples as I go...) Any suggestions are gretly
appreciated.

#!/usr/local/bin/python

from Tkinter import *
from string import *
from Image import *

root = Tk()
root.title('Canvas')

#open commodore Cset rom
cset  = open("chargen","r")

canvas = Canvas(width=16, height=16, bg='white')
canvas.pack(expand=YES, fill=BOTH)

# character size factor
size = 2

# read all 512 characters from ROM
for cchar in range(0, 511, 1):
#draw line
while charline < 8:
position = 0
x = cset.read(1)
ch = ord(x)
# draw pixels
while position < 8:
if ch & ( 2 ** position ):
xp = 1+(7-position)*size
yp = 1+charline*size
canvas.create_rectangle(xp,yp,xp+size,yp+size,
fill='black', width=0)
position += 1
charline += 1
#save character image
outfile = "/home/mydir/work/char"+zfill(cchar,3)+".png"
canvas.save(outfile,"png")
#clear canvas for next char...
canvas.create_rectangle(1,1,size*8,size*8, fill='white', width=0)
root.mainloop()
--
http://mail.python.org/mailman/listinfo/python-list


Re: help debugging noob code - converting binary data to images...

2008-06-29 Thread larry
Wonderful, thank you!  Will try them out this evening.

The image module syntax looks more like what I was expecting than
TKinter.  All the online drawing examples I found yesterday used
TKinter; image was only shown to manipulate pre-made images.

Larry
--
http://mail.python.org/mailman/listinfo/python-list


Re: help debugging noob code - converting binary data to images...

2008-06-29 Thread larry
success, had to fill in a few blanks with some more googling, here is
the finished script  (used all for loops this time, saved a few more
lines):

==

#!/usr/local/bin/python

import string
import Image, ImageDraw

size = 2

im = Image.new("1",[8*size,8*size],1)
draw = ImageDraw.Draw(im)

cset  = open("chargen","r")


for cchar in range(0, 512, 1):
for charline in range(0, 8, 1):
x = cset.read(1)
ch = ord(x)
for position in range(0, 8, 1):
if ch & ( 2 ** position ):
xp = (7-position)*size
yp = charline*size
draw.rectangle(((xp,yp),(xp+size-1,yp+size-1)),
fill=0 )
outfile = "/home/mydir/work/char"+string.zfill(cchar,3)+".png"
im.save(outfile,"png")
draw.rectangle(((0,0),(size*8,size*8)),fill=1)

im.show()

==

It does the variable sizes like I wanted and it now sure is fast.

If I wanted to display an image without saving how do I do that, on
the image module it does not pop up a canvas..  the im.show() on the
bottom does not seem to work.

Thanks again!
--
http://mail.python.org/mailman/listinfo/python-list


Re: Question re: objects and square grids

2013-05-15 Thread Larry Hudson

On 05/15/2013 05:53 PM, Andrew Bradley wrote:



I apologize if these questions are too rudimentary--I am trying to wrap my head 
around how this
language works in a more general sense so I can start applying it to things.
-Andrew


Check out the book "Making Games with Python & Pygame" at 
http://inventwithpython.com/pygame/
It's a book you can buy or you can download the pdf or e-reader versions for 
free.

Also on the same site, "Invent Your Own Computer Games with Python"

Both are pretty good introductions to Python programming, "Invent..." is for non-graphic games, 
and may be the better to start with.  Don't try to get too advanced too fast -- you'll only get 
frustrated and discouraged.  But definitely do keep at it -- it's well worth the effort.


 -=- Larry -=-

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


Re: Prepending string "@" to usernames

2013-05-24 Thread Larry Hudson

On 05/24/2013 03:53 PM, Thomas Murphy wrote:




Here's where I got to:


raw_address = "cookielover93 TheGermanHatesSaurkraut WhatsThatBoy932834"
address_library = [raw_address.split()]
print address_library

for address in address_library:
 final_address = "@" + str(address)
print final_address


However my output is:

[['cookielover93', 'TheGermanHatesSaurkraut', 'WhatsThatBoy932834']]
@['cookielover93', 'TheGermanHatesSaurkraut', 'WhatsThatBoy932834']


I know I'm iterating wrong. May I ask how?

--
Sincerely,
Thomas Murphy
Code Ninja
646.957.6115



No, you're not iterating wrong, but you do have two errors:

1:  split() returns a list.  You are putting this list (as a single element) inside a list. 
Drop the square brackets.  Make it:  address_library = raw_address.split()


2:  In your for loop, you want the print _inside_ the loop not outside.  IOW, indent the print 
line.  The way you have it written it will only print the _last_ string.


 -=- Larry -=-

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


Re: Beginner question

2013-06-04 Thread Larry Hudson

On 06/03/2013 08:39 PM, eschneide...@comcast.net wrote:

Is there a more efficient way of doing this? Any help is gratly appreciated.


import random
def partdeux():
 print('''A man lunges at you with a knife!
Do you DUCK or PARRY?''')
 option1=('duck')
 option2=('parry')
 optionsindex=[option1, option2]
 randomizer=random.choice(optionsindex)
 while randomizer==option1:
 if input() in option1:
 print('he tumbles over you')
 break
 else:
 print('he stabs you')
 break
 while randomizer==option2:
 if input() in option2:
 print('you trip him up')
 break
 else:
 print('he stabs you')
 break
partdeux()



Yes, you are making this much more complicated than necessary.  It seems that what you are 
trying to do is input the option, then randomly print a success or failure message for that 
option.  I suspect you didn't plan it, but it also prints the "stab" message for invalid entries.


Like any program, it can be approached in many different ways.  Here is one 
possibility.
(Just the function def, add the import and function call as well.  Also I am not adding any 
comments.  See if you can follow the logic here yourself.)


--
def partdeux():
print('A man lunges at you with a knife!')
option = input('Do you DUCK or PARRY?  ').lower()
success = random.randint(0, 1)
if success:
if option == 'duck':
print('He tumbles over you')
return
if option == 'parry':
print('You trip him up')
return
print('He stabs you')


BTW, ignore the response from Carlos.  I can see from the print() functions in your original 
that you're using Python 3.  His answer is only valid for Python 2.


 -=- Larry -=-

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


Re: lstrip problem - beginner question

2013-06-04 Thread Larry Hudson

On 06/04/2013 08:21 AM, mstagliamonte wrote:

Hi everyone,

I am a beginner in python and trying to find my way through... :)

I am writing a script to get numbers from the headers of a text file.

If the header is something like:
h01 = ('>scaffold_1')
I just use:
h01.lstrip('>scaffold_')
and this returns me '1'

But, if the header is:
h02: ('>contig-100_0')
if I use:
h02.lstrip('>contig-100_')
this returns me with: ''
...basically nothing. What surprises me is that if I do in this other way:
h02b = h02.lstrip('>contig-100')
I get h02b = ('_1')
and subsequently:
h02b.lstrip('_')
returns me with: '1' which is what I wanted!

Why is this happening? What am I missing?

Thanks for your help and attention
Max



The lstrip() function is the wrong one to use here.  The command 
help(str.lstrip) gives:

lstrip(...)
S.lstrip([chars]) -> str

Return a copy of the string S with leading whitespace removed.
If chars is given and not None, remove characters in chars instead.

IOW, it does NOT strip the given string, but all the characters in the given 
string.
So in your second example it (correctly) removes everything and gives you an empty string as the 
result.


One possible alternative is to use slicing:

h02 = '>contig-100_0'
h03 = '>contig-100_'
result = h02[len(h03):]

Or some similar variation, possibly adding a startswith() function for some simple error 
checking.  Of course, other approaches are possible as well,


 -=- Larry -=-

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


Re: Python Game Development?

2013-06-07 Thread Larry Hudson

On 06/07/2013 09:28 AM, Eam onn wrote:

On Friday, June 7, 2013 5:21:36 PM UTC+1, Ian wrote:

On Fri, Jun 7, 2013 at 9:53 AM,   wrote:




Do you know of any tutorial for PyGame? Preferably a video tutorial but any 
tutorial at all is fine! I can't seem to find any, even on pygame.org!!!



Check out:

http://inventwithpython.com/pygame/

for the book "Making Games with Python & Pygame"

You can buy it, read it on-line for free, or download the pdf or eReader 
versions for free.

(Totally irrelevant side-comment:  PyGame and all the games from this book come pre-loaded on 
the Raspberry Pi.)


 -=- Larry -=-

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


Re: Changing filenames from Greeklish => Greek (subprocess complain)

2013-06-10 Thread Larry Hudson

On 06/09/2013 03:37 AM, Νικόλαος Κούρας wrote:



I mean utf-8 could use 1 byte for storing the 1st 256 characters. I meant up to 
256, not above 256.


NO!!

0 - 127, yes.
128 - 255 -> one byte of a multibyte code.

That's why the decode fails, it sees it as incomplete data so it can't do 
anything with it.



A surrogate pair is like itting for example Ctrl-A, which means is a 
combination character that consists of 2 different characters?
Is this what a surrogate is? a pari of 2 chars?

You're confusing character encodings with the way NON-CHARACTER keys on the KEYBOARD are encoded 
(function keys, arrow keys and such).  These are NOT text characters but KEYBOARD key codes. 
These are NOT text codes and are entirely different and not related to any character encoding. 
How programs interpret and use these codes depends entirely on the individual programs.  There 
are common conventions on how many are used, but there are no standards.


Also the control-codes are the first 32 values of the ASCII (and ASCII-compatible) character set 
and are not multi-character key codes like the keyboard non-character keys.


However, there are a few keyboard keys that actually produce control-codes.  A 
few examples:

Return/Enter -> Ctrl-M
Tab -> Ctrl-I
Backspace -> Ctrl-H



So character 'A' <-> 65 (in decimal uses in charset's table)  <-> 01011100 (as binary 
stored in disk) <-> 0xEF (as hex, when we open the file with a hex editor)

You are trying to put too much meaning to this.  The value stored on disk, in memory, or 
whatever is binary bits, nothing else.  How you describe the value, in decimal, in octal, in 
hex, in base-12, or... is totally irrelevant.  These are simply different ways of describing or 
naming these numeric values.


It's the same as saying 3 in English is three, in Spanish is tres, in German is drei...  (I 
don't know Greek, sorry.)  No matter what you call it, it is still the numeric integer value 
that is between 2 and 4.


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


Re: Changing filenames from Greeklish => Greek (subprocess complain)

2013-06-11 Thread Larry Hudson

On 06/10/2013 01:11 AM, Νικόλαος Κούρας wrote:

Τη Δευτέρα, 10 Ιουνίου 2013 10:51:34 π.μ. UTC+3, ο χρήστης Larry Hudson έγραψε:


I mean utf-8 could use 1 byte for storing the 1st 256 characters. I meant up to 
256, not above 256.



0 - 127, yes.
128 - 255 -> one byte of a multibyte code.


you mean that in utf-8 for 1 character to be stored, we need 2 bytes?
I still havign troubl e understanding this.


Utf-8 characters are encoded in different sizes, NOT a single fixed number of 
bytes.
The high _bits_ of the first byte define the number of bytes of the individual 
character code.

(I'm copying this from Wikipedia...)
0xxx -> 1 byte
110x -> 2 bytes
1110 -> 3 bytes
0xxx -> 4 bytes
10xx -> 5 bytes
110x -> 6 bytes

Notice that in the 1-byte version, since the high bit is always 0, only 7 bits are available for 
the character code, and this is the standard 0-127 ASCII (and ASCII-compatible) code set.



Since 2^8 = 256, utf-8 would need 1 byte to store the 1st 256 characters but 
instead its using 1 byte up to the first 127 value and then 2 bytes for 
anyhtign above.  Why?

As I indicated above, one bit is reserved as a flag to indicate that the code is one-byte code 
and not a multibyte code, only 7 bits are available for the actual 1-byte (ASCII) code.


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


Re: Encoding questions (continuation)

2013-06-11 Thread Larry Hudson

On 06/10/2013 06:56 AM, Νικόλαος Κούρας wrote:


ps. i tried to post a reply to the thread i opend via thunderbird mail
client, but not as a reply to somne other reply but as  new mail send to
python list.
because of that a new thread will be opened. How can i tell thunderbird
to reply to the original thread and not start a new one?

By replying to an email in that thread.


Yes thats obvious.
What is not obvious is how you reply back to a thread by giving extra info when 
you are not replying to a mail formt tha thread or when you ahve deleted the 
reply for a member

sending the mail to python-list@python.org will just open anew subject intead 
of replyign to an opened thread.


In Thunderbird, click on "Followup" not "Reply".

Reply sends e-mail to the poster but doesn't post it to the list.

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


Re: Sorting a set works, sorting a dictionary fails ?

2013-06-11 Thread Larry Hudson

On 06/10/2013 01:29 AM, Νικόλαος Κούρας wrote:

Trying this:

months = { 'Ιανουάριος':1, 'Φεβρουάριος':2, 'Μάρτιος':3, 'Απρίλιος':4, 
'Μάϊος':5, 'Ιούνιος':6, \
   'Ιούλιος':7, 'Αύγουστος':8, 'Σεπτέμβριος':9, 'Οκτώβριος':10, 
'Νοέμβριος':11, 'Δεκέμβριος':12 }

for key in sorted( months.values() ):
print('''
 %s 
''' % (months[key], key) )


output this:

[Mon Jun 10 11:25:11 2013] [error] [client 79.103.41.173]   File 
"/home/nikos/public_html/cgi-bin/pelatologio.py", line 310, in , 
referer: http://superhost.gr/
[Mon Jun 10 11:25:11 2013] [error] [client 79.103.41.173] ''' % 
(months[key], key) ), referer: http://superhost.gr/
[Mon Jun 10 11:25:11 2013] [error] [client 79.103.41.173] KeyError: 1, referer: 
http://superhost.gr/

KeyError 1 ??!! All i did was to tell python to sort the dictionary values, 
which are just integers.


Come on now, wake up!!  You do know how to use Python dictionaries don't you?

You can find the dictionary _values_ by using the _key_, but you CAN NOT get the key from the 
value.  (For one thing, keys must be unique but values don't need to be.)  You are trying to use 
the values as keys, but the keys here are all strings, there are NO keys that are integers.  Of 
course this is a dictionary key error.


I think someone already told you this previously, but I'll repeat it, perhaps more verbosely, 
but at least in different words


The items() function gives you a list of key/value pairs as tuples.  (Not exactly, Python 3 give 
you an iterator not an actual list, but anyway...)
You want to sort this list based on the second element of these tuples (the values).  A simple 
call to the sorted() function will sort based on the first element (the keys).  But you can 
alter this function by using the key parameter, and here you can do it with a short lambda 
function.  (And don't confuse the sorted() key parameter with dictionary keys -- two entirely 
different things that just happen to use the same word.)  See if you can follow this short example:


>>> d = {'Jan':1, 'Feb':2, 'Mar':3, 'Apr':4, 'May':5} #  A short example 
dictionary
>>> list(d.items())   #  Display unsorted list
[('Jan', 1), ('Apr', 4), ('Mar', 3), ('Feb', 2), ('May', 5)]
>>> sorted(d.items()) #  Display list sorted by keys (month 
names)
[('Apr', 4), ('Feb', 2), ('Jan', 1), ('Mar', 3), ('May', 5)]#  Not what you 
want
>>> keys = sorted(d.items(), key=lambda n: n[1])#  Sort by values (the 2nd 
element of items)
>>> for month in keys:#  Print this sorted list
print('Month {} is {}'.format(month[1], month[0]))

Month 1 is Jan
Month 2 is Feb
Month 3 is Mar
Month 4 is Apr
Month 5 is May

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


Re: PyGame tutorial?

2013-06-12 Thread Larry Hudson

On 06/11/2013 08:47 AM, Eam onn wrote:

Is there a PyGame tutorial out there? I've seen TheNewBoston's tuts, but he 
didn't finish his. MetalX100 did a VERY good tutorial. I've been having trouble 
with some player movement because he isn't moving smoothly, he jumps. If I add 
5 pixels to his X position if I press a button, jumps to the next 5 pixels 
instead of smoothly moving. If I just add 5 pixels normally, he moves smooth.

Thanks! Any help is appreciated!


I posted this link before, but here it is again...

http://inventwithpython.com/pygame/

for the book "Making Games with Python & Pygame"

You can buy the dead-tree version, Or you can read it on-line for free, Or download the pdf or 
ebook versions for free.


 -=- Larry -=-

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


Re: Encoding questions (continuation)

2013-06-12 Thread Larry Hudson

On 06/11/2013 01:09 PM, Νικόλαος Κούρας wrote:

Τη Τρίτη, 11 Ιουνίου 2013 10:52:02 π.μ. UTC+3, ο χρήστης Larry Hudson έγραψε:

On 06/10/2013 06:56 AM, Νικόλαος Κούρας wrote:



i think your suggestions works only if you have a mail handy in TB and you hit 
follow-up what if you dont have the mail handy?

Followup or Reply brings up the "Compose" window (with the message you're replying to already 
quoted).  Now you can either type your reply directly, OR if you have it already available you 
can copy/paste it.  THEN you click on "Send".  If it's a Followup it will be posted to the list, 
if it is a Reply it sends it as e-mail.


BTW, you can *AND SHOULD* edit the quoted text to remove all the unnecessary irrelevant crap, so 
you are quoting ONLY what you are actually replying to.  All the rest is junk and annoying.  But 
definitely keep the parts you are replying to give context to your reply message.


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


Re: Encoding questions (continuation)

2013-06-12 Thread Larry Hudson

On 06/12/2013 01:20 AM, Larry Hudson wrote:

On 06/11/2013 01:09 PM, Νικόλαος Κούρας wrote:

Τη Τρίτη, 11 Ιουνίου 2013 10:52:02 π.μ. UTC+3, ο χρήστης Larry Hudson έγραψε:

On 06/10/2013 06:56 AM, Νικόλαος Κούρας wrote:


I forgot to specify I'm talking about using Thunderbird Newsgroups, not the E-mail part.  If 
you're not using the Thunderbird Newsgroups, try it.  It makes things much MUCH easier.  (And it 
eliminates the annoying double-spacing from Google Groups!)


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


Re: A certainl part of an if() structure never gets executed.

2013-06-14 Thread Larry Hudson

On 06/14/2013 09:56 AM, Nick the Gr33k wrote:

On 14/6/2013 7:31 μμ, Steven D'Aprano wrote:

On Fri, 14 Jun 2013 16:07:56 +0300, Nick the Gr33k wrote:





Returning True is the same thing as returning a variable's truthy value?

NO!  'True' and 'False' are the two values of the boolean type.  The 'and' and 'or' logical 
operators do NOT return a boolean type of True or False.  (Although, the 'not' DOES return a 
boolean.)


Also they do NOT return "a variable's truthy value", they return the variable itself.  Now, that 
returned variable can then be interpreted as a boolean value for other operations in the same 
way that (virtually) all data types can be interpreted as a boolean.  Let me emphasize... they 
are INTERPRETED as having a boolean VALUE, but they are NOT a boolean TYPE.




 >>> (a and b and c)
'ijkl'

This in my head should have been evaluated to True also since all 3 strings 
hold truthy values

You need to get it into your thick head that you are mistaken, like everyone is trying to tell 
you.  What YOU think about it is WRONG!  Throw that thinking away and start LISTENING to what 
you are being told are the facts.



Why on earth this boolean expression evaluates to the value of the last 
variable? This is what
can't at all seem to follow.

BECAUSE THAT IS THE WAY PYTHON IS DEFINED, whether or not you agree with it.  You are WRONG!  It 
is time for you to accept the fact that you are mistaken and start trying to learn how Python IS 
defined -- NOT how YOU think it should be defined.




What i'm trying to say that both these exprs are Boolean Expressions therefore 
should return
Boolean values not variable's values, even if they are truthy.

I repeat:  what YOU think Python should do is completely irrelevant.  If you keep insisting on 
trying to use Python they way you THINK it should work instead of the way it is DEFINED to work, 
you'll lose that argument every time.


The whys of how Python works is, frankly, not important -- interesting and useful perhaps, but 
essentially irrelevant.  Just keep writing Python in the way it is defined, and learning the 
whys will come along.



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


Re: Fatal Python error: Py_Initialize: can't initialize sys standard streams

2013-06-15 Thread Larry Hudson

On 06/15/2013 03:10 PM, alex23 wrote:

On Jun 16, 7:29 am, lucabrasi...@gmail.com wrote:




Here's a report of a similar issue with Blender (which also provides a
local install of Python under Windows):
http://translate.google.com.au/translate?hl=en&sl=fr&u=http://blenderclan.tuxfamily.org/html/modules/newbb/viewtopic.php%3Ftopic_id%3D36497&prev=/search%3Fq%3Dinkscape%2BCodecRegistryError

(Sorry for the ugly url, it's a Google translation of a french
language page)


Somewhat OT, but have you ever looked at tinyurl.com?  Very useful for this 
sort of thing.

 -=- Larry -=-

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


Re: Variables versus name bindings [Re: A certainl part of an if() structure never gets executed.]

2013-06-17 Thread Larry Hudson

On 06/17/2013 08:50 AM, Simpleton wrote:

On 17/6/2013 2:58 μμ, Michael Torrie wrote:

a = 5
b = a

a <---> memory address
b <---> memory address

I like to think a and b as references to the same memory address

Not quite:  a and b _are_ memory addresses,  At the same time, a and b are references to the 
data (the objects) stored in those memory locations.


The distinction is probably more important in languages like C/C++, where the _language_ gives 
you direct access to, and can manipulate, these memory addresses (through pointers).  Python 
handles it differently and does not give you this sort of ability, it all occurs "under the 
hood".  Yes, the id() function will tell you the addresses, but you can't do anything with them 
other than perhaps compare them.  It's really pretty much useless information.


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


Re: newbie EOL while scanning string literal

2013-06-25 Thread Larry Hudson

On 06/25/2013 05:05 PM, willlewis...@gmail.com wrote:

thanks man you answered my questions very clear, btw do you know of a place 
where I can learn python I know some tutorials but are 2. something and I'm 
using 3.3 and I've been told they are different.


One fairly obvious place is on the python.org site itself.  Try:

http://docs.python.org/3/tutorial/index.html

That should give you a good start.

BTW, EOL means end-of-line.  Similarly, EOF is end-of-file.

    -=- Larry -=-



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


Contact information for Jim Hugunin?

2013-07-24 Thread Larry Hastings



Does anybody have an email address (or anything, really) for Jim 
Hugunin?  He left Google in May and appears to have dropped off the face 
of the internet.  Please email me privately.


I swear I will use the information only for good and never for evil,


//arry/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Encapsulation, inheritance and polymorphism

2012-07-18 Thread Larry Hudson

On 07/17/2012 04:24 AM, Lipska the Kat wrote:
...

Thanks for your time and I'll try to do a bit better with the reading thing 
before asking more
questions... not sure about this obsession with code indentation though :-|



I think it's inaccurate to call this indentation an obsession, it's part of Python's defined 
syntax.  It's used INSTEAD OF punctuation or keywords (like {} or BEGIN END).  If you're already 
used to indenting your code consistently, you'll be surprised at how quickly it becomes a 
non-issue when you start using Python.


It's a bit dated, but you might find http://www.linuxjournal.com/article/3882 to be an 
interesting read.


 -=- Larry -=-
--
http://mail.python.org/mailman/listinfo/python-list


Re: the meaning of rユ.......�¾

2012-07-24 Thread Larry Hudson

On 07/23/2012 06:22 AM, Dave Angel wrote:

On 07/23/2012 09:06 AM, Chris Angelico wrote:

On Mon, Jul 23, 2012 at 10:55 PM, Roy Smith  wrote:

Some day, we're going to have programming languages that take advantage
of the full unicode character set.  Right now, we're working in ASCII
and creating silly digrams/trigrams like r'' for raw strings (and triple-quotes 
for multi-line
strings).  Not to mention <=, >=, ==, !=.  And in languages other than
python, things like ->, => (arrows for structure membership), and so on.

REXX predates Unicode, I think, or at least its widespread adoption,
but it has a non-ASCII operator:

http://www.rexswain.com/rexx.html#operators

But personally, I've always used backslash. It's nothing to do with
ASCII and everything to do with having it on the keyboard. Before you
get a language that uses full Unicode, you'll need to have fairly
generally available keyboards that have those keys.

ChrisA



Keyboards with 110,000 keys on them; wonderful.  And much larger
characters on the screen, so that all those can be distinguished.  And
of course all fonts have to support all those characters.

Back to 20 character lines.



Somewhat different than this discussion, and I'm not familiar with it myself, but I've read 
about the "Space Cadet Keyboard".  It's described (among other places) at:


http://catb.org/jargon/html/S/space-cadet-keyboard.html

 -=- Larry -=-

OT:  This "Jargon File" can be an entertaining read.  I found "The Story of Mel" particularly 
fascinating.


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


Re: looking for a neat solution to a nested loop problem

2012-08-06 Thread Larry Hudson

On 08/06/2012 11:11 AM, Emile van Sebille wrote:
   


  for i in range(N,N+100):
  for j in range(M,M+100):
  do_something(i % 100 ,j % 100)

Emile


How about...

for i in range(100):
for j in range(100):
do_something((i + N) % 100, (j + M) % 100)

 -=- Larry -=-


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


Re: Keep getting this in PyDev "TypeError: quiz() takes exactly 1 argument (0 given)"

2012-08-10 Thread Larry Hudson

On 08/10/2012 01:28 PM, Chuck wrote:

Thanks for the help guys!  I finally got it working.  Shouldn't I technically 
call quiz() through the constructor, though?  Otherwise, the constructor is 
pointless.  I just put in pass for now.


For this particular example, frankly, a class doesn't make sense.  Just write it as a set of 
independent functions.  A class would make more sense if you wanted to make this a generic Quiz 
class, then you could change the actual quiz simply by passing an appropriate dictionary to it 
when it's instantiated.  But even that could be done with simple functions as well.



(Also, I always thought that if __name__ == '__main__': went IN the class.  Why 
wouldn't it be apart of the class?  )


No way!  That's nonsense also.  You need to go through some introductory tutorials.  Just keep 
in mind that Python and Java are VERY different languages.  (I don't know Java myself, my 
(hobby) programming background has been with C, and I'm still just starting to learn Python, too.)




Thanks again!



 -=- Larry -=-

PS.  On another subject...  You need to check your newsreader -- all your responses have been 
double-posted.


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


Re: Why not use juxtaposition to indicate function application

2012-03-16 Thread Larry Hudson

On 03/16/2012 05:45 AM, Ray Song wrote:

I confess i've indulged in Haskell and found
 f a
more readable than
 f(a)

And why aren't functions curried (partially applied function is another 
function which takes the rest arguments) by default?


Thanks in advance for any suggestions.

--
Ray


My suggestion is that your question is irrelevant -- Python and Haskell are two different 
languages each with different syntax rules and coming from different backgrounds.  I would say 
that trying to make any language look like some other is, at best, misguided.  Simply learn, and 
get used to, the language you're using AS IT IS DEFINED, not as you think it should be.  If you 
want to combine the features of two different languages, write a new one -- don't expect that 
existing languages are going to change due to someone's whim.  To expect otherwise is simply a 
waste of time.


As to readability, I would suggest that that's more a function of what you're used to than any 
inherent language syntax rules.


If my comments seem harsh -- sorry 'bout that.  I'm old, and sometimes tend to 
be a curmugeon.

And as a completely irrelevant aside concerning readability:
Is anyone familiar with the IOCCC (International Obfuscated C Coding Contest)?  The object is to 
write the most obscure, but functional, C code possible.  I haven't looked at any of this for 
many years myself, but I just Googled it to see that this contest is still going on.  Anyone 
familiar with C might find it amusing to take a look...


 -=- Larry -=-
--
http://mail.python.org/mailman/listinfo/python-list


Re: Dynamic Zero Padding.

2011-06-07 Thread Larry Hudson

On 06/07/2011 03:01 PM, harrismh777 wrote:

Ethan Furman wrote:

--> print("Testing %0*i" % (width, 1))



The '*' acts as a place holder for the width argument.


very nice...



It works for precision as well as width.

wid = 10
prec = 3
num = 123.456789
print "%0*.*f" % (wid, prec, num)

gives you ->  000123.457

(It's the same as the printf() function in C.)

 -=- Larry -=-
--
http://mail.python.org/mailman/listinfo/python-list


Re: Of Functions, Objects, and Methods-I NEED HELP PLEASE

2011-06-09 Thread Larry Hudson

On 06/08/2011 01:09 PM, Cathy James wrote:

I am almost there, but I need a little help:

I would like to

a) print my dogs in the format  index. name: breed as follows:

0. Mimi:Poodle
1.Sunny: Beagle
2. Bunny: German Shepard
I am getting

(0, ('Mimi', 'Poodle')) . Mimi : Poodle instead-what have I done wrong?

b) I would like to append to my list, but my line dogs.dogAppend() is
giving a TypeError:

for i in enumerate (self.dogAppend()):
TypeError: 'list' object is not callable

Any help?

#MY CODE BELOW:

import sys


Not needed in the class definition, move it to the "if __name__..." section.
Actually, it's not needed at all.  That part could be rewritten to avoid the need for sys.exit() 
entirely.



class Dog():
 def __init__(self, name, breed):
 self.name = name
 self.breed = breed

 def dogAppend(self):
 self.dogAppend = []
 self.dogAppend.append((self.name,self.breed))
 return self.dogAppend


1:  Think about what you're trying to do here...  You seem to want _each_ instance of Dog to 
hold the whole list.  Do you want Dog to be an individual Dog or do you  want it to be a list of 
Dogs?  You can't do both in a single class.
2:  This won't work to append to your list anyway... each time you call dogAppend() it will 
clear out any existing list and result in a list of one element, a tuple of (name, breed).  You 
can do exactly the same thing with a single line:  return [(self.name, self.breed)]



 def display (self):
 for i in enumerate (self.dogAppend()):
 print (i,".",  self.name, ": " + self.breed)


Misusing enumerate.  Check the docs.
http://docs.python.org/py3k/library/functions.html?highlight=enumerate#enumerate
Besides that, there are easier ways to print the contents of a list.


if __name__ == "__main__":
 dogs = Dog(name=input (" Enter Dog Name: "), breed=input ("Enter
Dog Breed: "))
 while not dogs:
 print("Goodbye!!")
 sys.exit()
 else:


else does not belong with while.


 #dogs.dogAppend()
 dogs.display()


Here's one possible replacement.  There are many other approaches as well.
(This leaves the individual dogs as a (name, breed) tuple.  It could be modified for other 
definitions of a dog. -- Exercise left for the reader...);-)


class DogKennel:
def __init__(self):
self.dogs = []  #  list of dogs

def addDog(self):
name = input("Enter dog name:  ")
if name == "":
return False
breed = input("Enter dog breed:  ")
if breed == "":
return False
self.dogs.append((name, breed))   #  Append this dog tuple to the list
return True

def display(self):
i = 1
for dog in self.dogs:
print("%d.  %s: %s" % (i, dog[0], dog[1]))
i += 1;

if __name__ == "__main__":
dogs = DogKennel()
while (dogs.addDog()):
pass
dogs.display()

 -=- Larry -=-
--
http://mail.python.org/mailman/listinfo/python-list


Re: Of Functions, Objects, and Methods-I NEED HELP PLEASE

2011-06-09 Thread Larry Hudson

On 06/08/2011 11:59 PM, Larry Hudson wrote:

On 06/08/2011 01:09 PM, Cathy James wrote:

I am almost there, but I need a little help:

I would like to


... 


Here's one possible replacement. There are many other approaches as well.
(This leaves the individual dogs as a (name, breed) tuple. It could be modified 
for other
definitions of a dog. -- Exercise left for the reader...) ;-)


... 

In thinking about this some more, I thought a dictionary instead of a list would be a better fit 
for this example.  For one thing, it allows accessing the dogs by name instead of an arbitrary 
index number.  But remember that a dictionary is unordered -- it won't be displayed in the same 
order that the entries were made.


Here's this approach, rewritten (and slightly expanded) using a dictionary.

class DogKennel:
def __init__(self):
"""Dog names/breeds kept in a dictionary"""
self.dogs = {}

def addDog(self):
"""Add a single dog to the dictionary"""
name = input("Enter dog's name:  ")
if name == "":  #   Abort with empty input
return False
breed = input("Enter dog's breed: ")
if breed == "": #   Abort here if needed also
return False
self.dogs[name] = breed
return True

def makeKennel(self):
"""Add multiple dogs (a pack?) to the dictionary"""
while self.addDog():
pass

def getDog(self, name=""):
"""Get the dog's breed by its name"""
if name in self.dogs:
return self.dogs[name]
else:
return None

def display(self):
"""Display all the dogs in the kennel (the dictionary)"""
i = 1
for dog in self.dogs.keys():
print("%2d.  %s: %s" % (i, dog, self.dogs[dog]))
i += 1

#   Note this is a normal function, NOT a member function of DogKennel.
#   It probably should go in the __main__ section to keep it separate from
#   the DogKennel class.  (This would be significant only if you're going
#   to import the DogKennel class into other programs.)
def yesno(prompt = ""):
"""Get a yes or no answer.  Returns True if yes, False if no"""
if prompt != "":
prompt = prompt + " (y/n)  "
while True:
ans = input(prompt).upper()
if ans != "":   #   Answer is not empty
if ans[0] == 'Y':   #   1st char is 'Y'?
return True
if ans[0] == 'N':   #   1st char is 'N'?
return False
#   Otherwise loop back for another go

if __name__ == "__main__":
dogs = DogKennel()
dogs.makeKennel()
dogs.display()
if yesno("Add more dogs?"):
dogs.makeKennel()
print("The kennel now contains")
dogs.display()
while True:
name = input("Which dog do you want?  ")
if name == "":
break
breed = dogs.getDog(name)
if breed != None:
print(name, "is a", breed)

#---
I hope studying this (and my previous) examples help you understand things 
better.
Keep at it...  It will sink in with a little effort. :-)
I also hope my rather verbose answers give you a little insight about the sort of things you 
need to consider when designing your programs.


 -=- Larry -=-
--
http://mail.python.org/mailman/listinfo/python-list


Announcing a new podcast: Radio Free Python

2011-08-23 Thread Larry Hastings



Radio Free Python is a new monthly podcast focused on Python and its 
community.


Episode 1 has just been released!  It features a panel discussion with 
the PythonLabs team:


   * Barry Warsaw,
   * Fred Drake,
   * Guido van Rossum,
   * Roger Masse,
   * and Tim Peters.


You can find it at http://www.radiofreepython.com/ as of this very minute.

Enjoy!


/larry/
-- 
http://mail.python.org/mailman/listinfo/python-list


Python language changes that first shipped in something besides CPython?

2011-03-08 Thread Larry Hastings



I'm doing a talk at PyCon about changes to the Python language.  I'm 
wondering: are there any Python language changes that first shipped in 
an implementation of Python besides CPython?


The sort of answer I'm looking for: "set literals first shipped in 
Jython 2.2, six months before they shipped in CPython 2.3".  (Note that 
that specific answer is wrong in every important detail.)



/larry/
--
http://mail.python.org/mailman/listinfo/python-list


Nested inner classes and inheritance -> namespace problem

2011-04-13 Thread Larry Hastings


The problem: if you're currently in a nested class, you can't look up 
variables in the outer "class scope".


For example, this code fails in Python 3:

   class Outer:
  class Inner:
class Worker:
  pass

  class InnerSubclass(Inner):
class Worker(Inner.Worker):
  pass

It fails at the definition of Worker inside InnerSubclass.  Python 3 
can't find "Inner", in order to get to "Inner.Worker".


Adding "global Inner" just above that line doesn't help--it's not a global.
Adding "nonlocal Inner" just above that line doesn't help either--I 
suppose it's the /wrong kind/ of nonlocal.  nonlocal is for nested 
functions, and this uses nested classes.


You can tell me YAGNI, but I tripped over this because I wanted it.  
It's not a contrived example.  I actually use inner classes a lot; I 
suppose I'm relatively alone in doing so.


Yes, I could make the problem go away if I didn't have nested inner 
classes like this.  But I like this structure.  Any idea how I can make 
it work while preserving the nesting and inheritance?


Thanks,


/larry/
//
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Nested inner classes and inheritance -> namespace problem

2011-04-13 Thread Larry Hastings


On 04/13/2011 07:37 PM, Eric Snow wrote:

I suppose you could try something like this:

class Outer:
  global Inner
  class Inner:
class Worker:
  pass

  class InnerSubclass(Inner):
class Worker(Inner.Worker):
  pass

However, that pollutes your global namespace.  If you are worried 
about that you could try: [...]


It also means that Inner is not actually /in/ Outer, and the whole point 
was to have the class accessed as Outer.Inner.  But I can get what I 
wanted, if immediately after the definition of Outer I have:


   Outer.Inner = Inner
   del Inner


Thanks for the suggestion of "global Inner"!  That makes this approach 
palatable.



/larry/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Using Python 2

2017-09-08 Thread Larry Martell
On Fri, Sep 8, 2017 at 8:42 AM, Marko Rauhamaa  wrote:
> Chris Angelico :
>> But as others have said, upgrading to 3.4+ is not as hard as many
>> people fear, and your code generally improves as a result
>
> That's somewhat irrelevant. Point is, Python 2 will quickly become a
> pariah in many corporations during or after 2018, and we are going to
> see emergency measures similar to the Y2K craze twenty years ago.
>
> The risk to Python will be whether the occasion is exploited by fanboys
> of competing programming languages. The migration from Python 2 might be
> to something else than Python 3 in some circles.

A lot of companies I work for say they don't have the time and/or
money and/or they don't want to risk breaking things. If python 2 ever
is not available I guess then they will have to find the time and
money.
-- 
https://mail.python.org/mailman/listinfo/python-list


Python dress

2017-09-12 Thread Larry Martell
Not too many females here, but anyway:

https://svahausa.com/collections/shop-by-interest-1/products/python-code-fit-flare-dress

(And if any guys want to wear this, there's nothing wrong with that.)
-- 
https://mail.python.org/mailman/listinfo/python-list


trace not working with rpy2

2017-09-13 Thread Larry Martell
When I invoke my script with trace it fails with:

/usr/local/lib/python2.7/site-packages/rpy2/rinterface/__init__.py:186:
RRuntimeWarning: Fatal error: unable to open the base package

and the trace file has:

__init__.py(1):  __init__.py(19): from rpy2.robjects.robject import
RObjectMixin, RObject
cannot find system Renviron

I have tried running trace with both of these options, but I still get
the same error.

--ignore-module=rpy2
--ignore-dir=/usr/local/lib/python2.7/site-packages/rpy2

Anyone know how I can get around this error so I can use trace?
-- 
https://mail.python.org/mailman/listinfo/python-list


rmtree message

2017-09-13 Thread Larry Martell
I have a script that creates a tmp dir, create a lot of files in it,
and when done, does a rmtree on the dir. When it does that I get this
message:

shell-init: error retrieving current directory: getcwd: cannot access
parent directories: No such file or directory

But no exception is thrown. How can I determine why I get this message?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Old Man Yells At Cloud

2017-09-17 Thread Larry Martell
On Sun, Sep 17, 2017 at 9:34 AM,   wrote:
> Experienced Python programmers use the logging module for debugging, write 
> once, delete (maybe) never.

I use pdb for debugging (but I also log a lot which helps with prod
system when users report a problem).
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Old Man Yells At Cloud

2017-09-17 Thread Larry Martell
On Sun, Sep 17, 2017 at 11:44 AM, Dennis Lee Bieber
 wrote:
> The only pocket calculators I know of that have "integers" are those
> with a "programmer's mode" -- ie; binary (displayed in
> binary/octal/decimal/hex) but needing to be converted back to "normal" if
> one wants to use them with non-binary values. See nearly any of the more
> capable HP units. Binary division stays binary (integer).

I have a HP-41C that I bought in 1976 for $300. It's sitting on my
desk right next to my keyboard. Still use it today. It's awesome.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: rmtree message

2017-09-17 Thread Larry Martell
On Wed, Sep 13, 2017 at 5:39 PM, Sean DiZazzo  wrote:
> On Wednesday, September 13, 2017 at 12:06:20 PM UTC-7, larry@gmail.com 
> wrote:
>> I have a script that creates a tmp dir, create a lot of files in it,
>> and when done, does a rmtree on the dir. When it does that I get this
>> message:
>>
>> shell-init: error retrieving current directory: getcwd: cannot access
>> parent directories: No such file or directory
>>
>> But no exception is thrown. How can I determine why I get this message?
>
> I usually see that message when I am in a directory in the shell but it has 
> already been deleted by another process.
>
> Make sure the directory exists.  Is another part of your script deleting the 
> root directory while rmtree is running?  Or something of the like.

Turned out the script's cwd was in a dir that was being removed. I
chdir'ed out of there and that resolved the issue.

Thanks to all who responded.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Old Man Yells At Cloud

2017-09-19 Thread Larry Martell
On Mon, Sep 18, 2017 at 11:23 PM, Dan Sommers  wrote:
> How relevant is the "people use calculators to do arithmetic" argument
> today?  Okay, so I'm old and cynical, but I know [young] people who
> don't (can't?) calculate a gratuity without an app or a web page.

I use a calculator all the time - not for calculating a tip though.
Sometimes I use bc (when I can't find my calculator in the morass of
my desk).

True story - the other day I was in a store and my total was $10.12. I
pulled out a $20, and the cashier (probably age 23 or so) immediately
entered $20 as the amount tendered. Then I said "Let me see if I have
the $0.12." I did not, but I had $0.15 so I handed her $20.15. She
literally froze in place with a classic deer in the headlights stare.
I said "$10.03" She said "What?" I said "$10.03 is my change." She
said "What?" I said "Just give me $10." She did not reply, opened the
drawer below her register, rummaged around and came out with one of
those giant key calculators, and with a look of dogged determination,
did the calculation, looked at me and said proudly "$10.03 is your
change."
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Old Man Yells At Cloud

2017-09-19 Thread Larry Martell
On Tue, Sep 19, 2017 at 10:30 AM, D'Arcy Cain  wrote:
> On 09/19/2017 06:46 AM, Larry Martell wrote:
>>
>> True story - the other day I was in a store and my total was $10.12. I
>
>
> One time I was at a cash with three or four items which were taxable. The
> cashier rung each one up and hit the total button.  She turned to me and
> said something like "$23.42 please."  She was surprised to see that I was
> already standing there with $23.42 in my hand.  "How did you do that" she
> asked.  She must have thought it was a magic trick.

I was just in a clothing store this weekend and there was a rack of
clothes that was 50%. The sales clerk said everything on that rack was
an additional 25% off, so it's 75% off the original price. I asked is
it 75% off the original price or 25% off the 50% of the price. Said
it's the same thing. I said no it's not. She insisted it was. I said
no, let's take a simple example. If it was $100 and it was 75% off it
would be $25. But if it's 50% off and then 25% off that it will be
$37.50. She looked totally dumbfounded.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Even Older Man Yells at Whippersnappers

2017-09-19 Thread Larry Martell
On Tue, Sep 19, 2017 at 1:38 PM, ROGER GRAYDON CHRISTMAN  wrote:
>  I recall giving a quiz to my college students sometime back around
> the late nineties which had a little bit of arithmetic involved in the answer.
> It's been too long ago to still have the exact details, but I remember
> a couple solutions that would be of the form:
>
> 5 + 10 + 1*2
>
> And then the student would write he was unable to actually
> compute that without a calculator.   And yes, I deliberately
> designed the questions to have such easy numbers to work with.

It was my birthday the other day. People at worked asked how old I
was. I replied:

((3**2)+math.sqrt(400))*2

Quite a few people somehow came up with 47. And these are technical people.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Even Older Man Yells at Whippersnappers

2017-09-19 Thread Larry Martell
On Tue, Sep 19, 2017 at 2:41 PM, Chris Angelico  wrote:
> On Wed, Sep 20, 2017 at 4:33 AM, Larry Martell  
> wrote:
>> On Tue, Sep 19, 2017 at 1:38 PM, ROGER GRAYDON CHRISTMAN  
>> wrote:
>>>  I recall giving a quiz to my college students sometime back around
>>> the late nineties which had a little bit of arithmetic involved in the 
>>> answer.
>>> It's been too long ago to still have the exact details, but I remember
>>> a couple solutions that would be of the form:
>>>
>>> 5 + 10 + 1*2
>>>
>>> And then the student would write he was unable to actually
>>> compute that without a calculator.   And yes, I deliberately
>>> designed the questions to have such easy numbers to work with.
>>
>> It was my birthday the other day. People at worked asked how old I
>> was. I replied:
>>
>> ((3**2)+math.sqrt(400))*2
>>
>> Quite a few people somehow came up with 47. And these are technical people.
>
> *headscratch* Multiple people got 47? I'm struggling to figure that
> out. If they interpret the first part as multiplication (3*2 => 6),
> that would get 26*2 => 52; if they don't understand the square
> rooting, they'd probably just give up; if they ignore the parentheses,
> that could give 9 + 20*2 => 49; but I can't come up with 47.

They could not explain it either.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Even Older Man Yells At Whippersnappers

2017-09-19 Thread Larry Martell
On Tue, Sep 19, 2017 at 12:12 PM, Rhodri James  wrote:
> 
> Eh, my school never 'ad an electronics class, nor a computer neither. Made
> programming a bit tricky; we 'ad to write programs on a form and send 'em
> off to next county.  None of this new-fangled VHDL neither, we 'ad to do our
> simulations with paper and pencil.
> 

We dreamed of writing programs on a form. We had to make Hollerith
punch cards by hand using a dull knife. You tell that to the kids of
today and they won't believe you.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Even Older Man Yells At Whippersnappers

2017-09-20 Thread Larry Martell
On Wed, Sep 20, 2017 at 5:09 AM, Gregory Ewing
 wrote:
>
> Never mind that fake assembly rubbish, learn a real assembly
> language! And hand-assemble it and toggle it into the front
> panel switches like I did!

1979, I was working at Bausch and Lomb in Rochester NY. We had a 16
bit Data General Nova 'Minicomputer'. It had 4 registers, called
accumulators. It had 16 front panel toggle switches, one for each bit,
one that said 'deposit', and one that said run. It had a dial with
stops for AC0, AC1, AC2, AC3 (for the 4 accumulators), PC (program
counter), address and contents.

When you powered up the machine it did not boot. You had to hand enter
a short bootstrap program in binary. Do to this you had to turn the
dial to address, key in a 16 bit address, click deposit, turn the dial
to contents, key in a 16 bit line of assembly code, click deposit, and
repeat this for each line of code (there were like 5 or 6). Then key
in the address of where you wanted to run from turn the dial to PC,
deposit, and click run. Any mistake and it would not boot. Often took
3 or 4 tries.

After a few weeks of this I was sick of it. I had the boot code burned
into an EEPROM (which I had to send out to be programmed). Then I
build a very small wire wrapped board with the EEPROM and an
oscillator and few TTL chips. I tapped into the 5V power on the CPU
board and used the leading edge of that to trigger a one shot which
'woke up' my circuit, and caused it to clock out the code from the
EEPROM and load it to the appropriate place, set the program counter
and start the program. I drilled holes in the CPU board and mounted
this with little plastic standoffs.

I did this all on my own, coming in on the weekends, without company
approval, and when it was working I showed my boss. He was blown away
and he was sure we could patent this and sell it. He had me formalize
the design, write it up, have an actual PCB made, go to the company
lawyers, the whole 9 yards. Then Data General announced the new
version of the Nova  with auto boot.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Beginners and experts (Batchelder blog post)

2017-09-27 Thread Larry Martell
On Wed, Sep 27, 2017 at 12:41 PM, leam hall  wrote:
> The question is, what should a person "know" when hiring out as a
> programmer? What is 'know" and what should be "known"? Specifically with
> Python.

Fake it till you make it!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Beginners and experts (Batchelder blog post)

2017-09-28 Thread Larry Martell
On Thu, Sep 28, 2017 at 5:08 PM, Chris Angelico  wrote:
> Yep. Pick anyone on this list that you believe is an expert, and ask
> him/her for a story of a long debug session that ended up finding a
> tiny problem. I can pretty much guarantee that every expert programmer
> will have multiple such experiences, and it's just a matter of
> remembering one with enough detail to share the story.

The software development process can be summed up thusly:

I can’t fix this
Crisis of confidence
Questions career
Questions life
Oh it was a typo, cool
-- 
https://mail.python.org/mailman/listinfo/python-list


zlib OverflowError: 'size does not fit in an int'

2017-12-04 Thread Larry Martell
Trying to zip a large file is failing with OverflowError: 'size does
not fit in an int'. Googling I found this:

https://bugs.python.org/issue23306

and this:

https://hg.python.org/cpython/rev/2192edcfea02

which seems to make me think this was fixed this was fixed on Jul 23 2016.

I am running CentOS 7 and I have python version:

Python 2.7.5 (default, Sep 15 2016, 22:37:39)

Which I guess does not have this fix. How can I get a version with
that fix (that doesn't break CentOS)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: zlib OverflowError: 'size does not fit in an int'

2017-12-04 Thread Larry Martell
On Mon, Dec 4, 2017 at 7:15 PM, Chris Angelico  wrote:
> On Tue, Dec 5, 2017 at 10:46 AM, Larry Martell  
> wrote:
>> Trying to zip a large file is failing with OverflowError: 'size does
>> not fit in an int'. Googling I found this:
>>
>> https://bugs.python.org/issue23306
>>
>> and this:
>>
>> https://hg.python.org/cpython/rev/2192edcfea02
>>
>> which seems to make me think this was fixed this was fixed on Jul 23 2016.
>>
>> I am running CentOS 7 and I have python version:
>>
>> Python 2.7.5 (default, Sep 15 2016, 22:37:39)
>>
>> Which I guess does not have this fix. How can I get a version with
>> that fix (that doesn't break CentOS)
>
> First thing I'd consider is a Python 3.x version. Is there one in your
> CentOS repositories? If not, worst case, you can compile one from
> source or get one from some other repo, and it can't possibly break
> your system because it won't mess with anything you're using.
>
> If you absolutely HAVE to stick with 2.7, you may do well to compile
> from source and NOT install - just run the binary from the source
> directory.

This is a django app, using version 1.9, installed on many sites that
do not have external internet access, so any changes are onerous.
Possible, but a PITA. I will look into building from source.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: zlib OverflowError: 'size does not fit in an int'

2017-12-04 Thread Larry Martell
On Mon, Dec 4, 2017 at 7:36 PM, Thomas Jollans  wrote:
> On 05/12/17 01:21, Larry Martell wrote:
>> On Mon, Dec 4, 2017 at 7:15 PM, Chris Angelico  wrote:
>>> On Tue, Dec 5, 2017 at 10:46 AM, Larry Martell  
>>> wrote:
>>>> Trying to zip a large file is failing with OverflowError: 'size does
>>>> not fit in an int'. Googling I found this:
>>>>
>>>> https://bugs.python.org/issue23306
>>>>
>>>> and this:
>>>>
>>>> https://hg.python.org/cpython/rev/2192edcfea02
>>>>
>>>> which seems to make me think this was fixed this was fixed on Jul 23 2016.
>>>>
>>>> I am running CentOS 7 and I have python version:
>>>>
>>>> Python 2.7.5 (default, Sep 15 2016, 22:37:39)
>>>>
>>>> Which I guess does not have this fix. How can I get a version with
>>>> that fix (that doesn't break CentOS)
>>>
>>> First thing I'd consider is a Python 3.x version. Is there one in your
>>> CentOS repositories? If not, worst case, you can compile one from
>>> source or get one from some other repo, and it can't possibly break
>>> your system because it won't mess with anything you're using.
>>>
>>> If you absolutely HAVE to stick with 2.7, you may do well to compile
>>> from source and NOT install - just run the binary from the source
>>> directory.
>>
>> This is a django app, using version 1.9, installed on many sites that
>> do not have external internet access, so any changes are onerous.
>> Possible, but a PITA. I will look into building from source.
>>
>
> FWIW, there is also an SCL with a newer version of Python 2.7 (loathe as
> I am to point it out)
>
> See also: https://pythonclock.org/

Where is there a link on that page to download a new version of 2.7?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: SystemError: error return without exception set

2017-12-07 Thread Larry Martell
On Thu, Dec 7, 2017 at 10:36 AM, Natalie Leung
 wrote:
> I am trying to use Python to communicate and send commands in MSC Marc. A 
> part of the code looks something like this:
>
> from py_mentat import*
>
> directory = '[specified the file path to my model]'
> marcModel = '[name of my model]'
>
> py_echo(0)
> openModel = '*new_model yes *open_model "'+ directory + marcModel +'"'
> py_send(openModel)
>
>
> The code stops at "py_send(openModel)" with an error message that reads: 
> Traceback (most recent call last): File "[my file path]", line 11, in 
> py_send(openModel)
> SystemError: error return without exception set
>
> I tried running the code on different platforms (e.g. Command Prompt, Wing 
> 101, python.exe) and I get the same result. What could be the problem?

Faced with this I would use the debugger to break on the py_send line
and then step into that function, and then step through it, e.g.:

python -m pdb your_script.py
b 8 [ or whatever the py_send line is)
c [to continue to the BP)
s [to step into py_send]

then step through the function and something more informative may be revealed.
-- 
https://mail.python.org/mailman/listinfo/python-list


scipy

2017-12-08 Thread Larry Martell
Trying to install scipy on ubuntu-trusty-64 running Python 2.7.6. It's
failing with:

$ sudo pip install scipy
Downloading/unpacking scipy
  Downloading scipy-1.0.0.tar.gz (15.2MB): 15.2MB downloaded
  Running setup.py (path:/tmp/pip_build_root/scipy/setup.py) egg_info
for package scipy
/usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown
distribution option: 'python_requires'

Followed by many screens full of errors. Is that just a warning or is
that the issue? I've installed many other packages without a problem
on this same system. What is the issue here?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: scipy

2017-12-11 Thread Larry Martell
On Sat, Dec 9, 2017 at 11:43 AM, Thomas Jollans  wrote:
>
> On 08/12/17 23:57, Larry Martell wrote:
> > Trying to install scipy on ubuntu-trusty-64 running Python 2.7.6.
>
> I STRONGLY recommend moving to Python 3 if you can. The scientific
> python ecosystem has had good support for Python 3 for years now. Many
> scientific packages, including numpy (the king of scientific
> Pythonland), have decided to drop official Python 2 support fairly soon;
> numpy will not release any new versions for Python 2 after 2018.

It's not in my control. This is part of a django app that is deployed
it many sites all over the world, and my customer wants to make as few
changes as possible.

> > It's failing with:
> >
> > $ sudo pip install scipy
> > Downloading/unpacking scipy
> >   Downloading scipy-1.0.0.tar.gz (15.2MB): 15.2MB downloaded
> >   Running setup.py (path:/tmp/pip_build_root/scipy/setup.py) egg_info
> > for package scipy
> > /usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown
> > distribution option: 'python_requires'
> >
> > Followed by many screens full of errors. Is that just a warning or is
> > that the issue? I've installed many other packages without a problem
> > on this same system. What is the issue here?
> >
>
> I'm just guessing here, but do you have the latest versions of
> distutils, setuptools and pip? It's likely that scipy requires newer
> versions of these than your distribution provides. You may have to
> upgrade them.

I resolved this by installing a newer version of pip.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python Learning

2017-12-17 Thread Larry Martell
On Sun, Dec 17, 2017 at 4:18 PM, Chris Angelico  wrote:
> On Mon, Dec 18, 2017 at 6:51 AM, Bill  wrote:
>> The point is that it takes a certain amount of what is referred to as
>> "mathematical maturity" (not mathematical knowledge) to digest a book
>> concerning computer programming.
>
> Emphasis on *a book*.
>
>> In my years of teaching experience,
>> students who came to college without the equivalent of "college algebra"
>> were under-prepared for what was expected of them. This is not just an
>> opinion, it's a fact.
>
> So, your experience is that the style of learning you offer is
> unsuitable to anyone who doesn't have some background in algebra.
> That's fine. For your course, you set the prereqs. But that's not the
> only way for someone to get into coding. You do NOT have to go to
> college before you start creating software. That is also not an
> opinion; it's a fact backed by a number of proven instances (myself
> included).

I started coding when I was 16, in 1975. I wrote a downhill skiing
game in basic, which I had taught to myself. I went to collage when I
was 17, and I had taught myself FORTRAN and I tested out of the class.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python Learning

2017-12-18 Thread Larry Martell
On Mon, Dec 18, 2017 at 9:09 AM, Rhodri James  wrote:
> On 18/12/17 13:28, Marko Rauhamaa wrote:
>>
>> However, I have been doing quite a bit of hiring, quite successfully, I
>> might add. I am not prejudiced one way or another. Your résumé doesn't
>> count. Your education doesn't count. What you can do for the team
>> counts, and that is measured during the interview process.
>
>
> While I agree with most of what you say, I disagree with you here.  Your CV
> (résumé) does count, just not necessarily in the way most people expect.
>
> I haven't often been involved in hiring, but the few times I have we had
> more applicants than it was feasible to interview.  We used CVs as the only
> thing we had to filter with, looking for *interesting* people. Exactly what
> "interesting" meant was somewhat arbitrary; we put one person through to
> interview because she was a cellist, and that would have given us a complete
> string quartet (she didn't get the job, sadly).

Yes, I once chose to interview someone because he had on his resume
that he was an award winning duck decoy carver. He also did not get
the job.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python Learning

2017-12-18 Thread Larry Martell
On Mon, Dec 18, 2017 at 11:33 AM, Marko Rauhamaa  wrote:
> However, one great way to stand out is a portfolio of GitHub projects.
> Several people have gotten an offer largely based on those (after they
> aced the technical interviews). For example, we just hired someone who
> had written a game in sed. That doesn't make him an "interesting
> person," nor do we look for game or sed developers. But that silly
> exercise deeply resonated with our team. We expect to have great synergy
> with him.

I have been excluded from even getting an interview because I did not
have a portfolio of GitHub projects. I think that is a bad filter. I
work 60-70 hours a week for pay, and I have a family and personal
interests.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python Learning

2017-12-18 Thread Larry Martell
On Mon, Dec 18, 2017 at 12:05 PM, Chris Angelico  wrote:
> On Tue, Dec 19, 2017 at 3:45 AM, Larry Martell  
> wrote:
>> On Mon, Dec 18, 2017 at 11:33 AM, Marko Rauhamaa  wrote:
>>> However, one great way to stand out is a portfolio of GitHub projects.
>>> Several people have gotten an offer largely based on those (after they
>>> aced the technical interviews). For example, we just hired someone who
>>> had written a game in sed. That doesn't make him an "interesting
>>> person," nor do we look for game or sed developers. But that silly
>>> exercise deeply resonated with our team. We expect to have great synergy
>>> with him.
>>
>> I have been excluded from even getting an interview because I did not
>> have a portfolio of GitHub projects. I think that is a bad filter. I
>> work 60-70 hours a week for pay, and I have a family and personal
>> interests.
>
> Maybe not GitHub, but something else. Do you have, anywhere on the
> internet, a list of demo-worthy projects? Again drawing from the
> students I work with, they're encouraged to build an actual portfolio
> web site. Granted, they *are* full stack web developers, so this may
> not be applicable to everyone, but still, it's independent of GitHub.

Nothing I can put on the internet because the work I have done is
either an embedded system or proprietary and used in house for a
company, or part of a commercial project. I do have things I can show
from my machine using my development environment, and I have offered
that up, but for those who want to see something on GitHub it does not
get that far.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python Learning

2017-12-18 Thread Larry Martell
On Mon, Dec 18, 2017 at 4:05 PM, Rob Gaddi
 wrote:
> On 12/18/2017 08:45 AM, Larry Martell wrote:
>>
>> On Mon, Dec 18, 2017 at 11:33 AM, Marko Rauhamaa  wrote:
>>>
>>> However, one great way to stand out is a portfolio of GitHub projects.
>>> Several people have gotten an offer largely based on those (after they
>>> aced the technical interviews). For example, we just hired someone who
>>> had written a game in sed. That doesn't make him an "interesting
>>> person," nor do we look for game or sed developers. But that silly
>>> exercise deeply resonated with our team. We expect to have great synergy
>>> with him.
>>
>>
>> I have been excluded from even getting an interview because I did not
>> have a portfolio of GitHub projects. I think that is a bad filter. I
>> work 60-70 hours a week for pay, and I have a family and personal
>> interests.
>>
>
> When I'm hiring I don't necessarily need a candidate to have an extensive
> open-source portfolio, but I need to see some kind of portfolio, just as a
> bar of "This is what I consider my good work to be."  The idea that someone
> is going to have years of experience, but not a single page of code that
> they can let me look over always strikes me as odd.

I have lots of code and projects to show, but only on my computer. I
once got a django/python job because I had a PHP app I did to show.
But if they had not interviewed me because I had nothing on a public
site they never would have seen it.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python Learning

2017-12-18 Thread Larry Martell
On Mon, Dec 18, 2017 at 4:52 PM, Gene Heskett  wrote:
> On Monday 18 December 2017 16:05:10 Rob Gaddi wrote:
>
>> On 12/18/2017 08:45 AM, Larry Martell wrote:
>> > On Mon, Dec 18, 2017 at 11:33 AM, Marko Rauhamaa 
> wrote:
>> >> However, one great way to stand out is a portfolio of GitHub
>> >> projects. Several people have gotten an offer largely based on
>> >> those (after they aced the technical interviews). For example, we
>> >> just hired someone who had written a game in sed. That doesn't make
>> >> him an "interesting person," nor do we look for game or sed
>> >> developers. But that silly exercise deeply resonated with our team.
>> >> We expect to have great synergy with him.
>> >
>> > I have been excluded from even getting an interview because I did
>> > not have a portfolio of GitHub projects. I think that is a bad
>> > filter. I work 60-70 hours a week for pay, and I have a family and
>> > personal interests.
>>
>> When I'm hiring I don't necessarily need a candidate to have an
>> extensive open-source portfolio, but I need to see some kind of
>> portfolio, just as a bar of "This is what I consider my good work to
>> be."  The idea that someone is going to have years of experience, but
>> not a single page of code that they can let me look over always
>> strikes me as odd.
>
> I've known Larry for years via another list. He has worked on a lot of
> stuff in the financial arena, wrapped in non-disclosure clauses that
> prevent him from even saying what color he dots the i's with, so he gets
> work as much by word of mouth as other more conventional paths.

True story.

> To not hire him because he doesn't have a big portfolio could be a
> mistake, Rob. Its up to you.

Thank you my friend.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python Learning

2017-12-21 Thread Larry Martell
On Mon, Dec 18, 2017 at 3:22 PM, Marko Rauhamaa  wrote:
>
> Larry Martell :
>
> > On Mon, Dec 18, 2017 at 11:33 AM, Marko Rauhamaa  wrote:
> >> However, one great way to stand out is a portfolio of GitHub
> >> projects. Several people have gotten an offer largely based on those
> >> (after they aced the technical interviews). For example, we just
> >> hired someone who had written a game in sed. That doesn't make him an
> >> "interesting person," nor do we look for game or sed developers. But
> >> that silly exercise deeply resonated with our team. We expect to have
> >> great synergy with him.
> >
> > I have been excluded from even getting an interview because I did not
> > have a portfolio of GitHub projects. I think that is a bad filter. I
> > work 60-70 hours a week for pay, and I have a family and personal
> > interests.
>
> Personal programming projects are not a requirement. They are just a
> very effective advertising tool.
>
> As for 60—70 hours a week... sounds horrible. My sympathies.

Nah - I get paid by the hour and I love what I do.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: has sourceforge exposed the dirty little secret ?

2018-01-05 Thread Larry Martell
On Fri, Jan 5, 2018 at 11:27 AM, Kim of K.  wrote:
>
> "Background
>
> We feel that the world still produces way too much software that is
> frankly substandard. The reasons for this are pretty simple: software
> producers do not pay enough attention [...]"
>
>
> quote from http://texttest.sourceforge.net/index.php?page=about
>
>
> In other words: most sites like SF and github offer tons of crap.
> download and break is the overwhelming theme here.
>
> why is no one complaining ?

You want to complain? Look at these shoes. I've only had them three
weeks and the heels are worn right through.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Simple graphic library for beginners

2018-01-10 Thread Larry Martell
On Wed, Jan 10, 2018 at 7:42 AM Jan Erik Moström 
wrote:

> I'm looking for a really easy to use graphic library. The target users
> are teachers who have never programmed before and is taking a first (and
> possible last) programming course.
>
> I would like to have the ability to draw lines, circles, etc. Nothing
> fancy, as little window management as possible (possible buttons),
> perhaps simple events like button presses or clicks on canvas - think:
> making simple diagrams or simple figures. Cross-platform
>
>
> Yes, I know about tkinter.
>
> Yes, I know about various block languages like Scratch but they are not
> relevant in this case.
>
> Any suggestions?
>

I really like plotly.

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


documentation on read.encode

2018-01-16 Thread Larry Martell
Looking for 2.7 docs on read.encode - googling did not turn up anything.

Specifically, looking for the supported options for base64, and how to
specify them, e.g. Base64.NO_WRAP
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: documentation on read.encode

2018-01-16 Thread Larry Martell
On Tue, Jan 16, 2018 at 12:00 PM, Larry Martell  wrote:
> Looking for 2.7 docs on read.encode - googling did not turn up anything.
>
> Specifically, looking for the supported options for base64, and how to
> specify them, e.g. Base64.NO_WRAP

So I just realized that encode() is not a method of read() it's a
string method. But I still have the same question - can I pass in any
flags?

My issue is that I am base64 encoding PNG images on linux and it's
putting a LF at the end of each line. If I do the same on Windows it's
putting CR/LF. I want the files to be encoded with no platform
dependences. Googling I found mention of Base64.NO_WRAP and I want to
pass that into encode() - can I do that?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: documentation on read.encode

2018-01-16 Thread Larry Martell
On Tue, Jan 16, 2018 at 2:35 PM, Gene Heskett  wrote:
> On Tuesday 16 January 2018 14:19:38 Larry Martell wrote:
>
>> On Tue, Jan 16, 2018 at 12:00 PM, Larry Martell
>  wrote:
>> > Looking for 2.7 docs on read.encode - googling did not turn up
>> > anything.
>> >
>> > Specifically, looking for the supported options for base64, and how
>> > to specify them, e.g. Base64.NO_WRAP
>>
>> So I just realized that encode() is not a method of read() it's a
>> string method. But I still have the same question - can I pass in any
>> flags?
>>
>> My issue is that I am base64 encoding PNG images on linux and it's
>> putting a LF at the end of each line. If I do the same on Windows it's
>> putting CR/LF. I want the files to be encoded with no platform
>> dependences. Googling I found mention of Base64.NO_WRAP and I want to
>> pass that into encode() - can I do that?
>
> Di you not have the manpages installed?
>
> In my copy of the manpage:
> base64 [OPTION]... [FILE]
> where option is:
>  -w, --wrap=COLS
>   wrap encoded lines after COLS character (default 76).  Use
> 0 to disable line wrapping.
>
> Seems pretty simple.

But how do I use that in read().encode('base64')?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: documentation on read.encode

2018-01-16 Thread Larry Martell
On Tue, Jan 16, 2018 at 3:17 PM, Ned Batchelder  wrote:
> On 1/16/18 2:19 PM, Larry Martell wrote:
>>
>> On Tue, Jan 16, 2018 at 12:00 PM, Larry Martell 
>> wrote:
>>>
>>> Looking for 2.7 docs on read.encode - googling did not turn up anything.
>>>
>>> Specifically, looking for the supported options for base64, and how to
>>> specify them, e.g. Base64.NO_WRAP
>>
>> So I just realized that encode() is not a method of read() it's a
>> string method. But I still have the same question - can I pass in any
>> flags?
>>
>> My issue is that I am base64 encoding PNG images on linux and it's
>> putting a LF at the end of each line. If I do the same on Windows it's
>> putting CR/LF. I want the files to be encoded with no platform
>> dependences. Googling I found mention of Base64.NO_WRAP and I want to
>> pass that into encode() - can I do that?
>
>
> Base64.NO_WRAP seems to be a Java thing.

Yeah I saw it mentioned in a SO post that was java related. Wondering
if there is some way to do the same in python.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: documentation on read.encode

2018-01-17 Thread Larry Martell
On Tue, Jan 16, 2018 at 3:58 PM, MRAB  wrote:
> On 2018-01-16 19:52, Larry Martell wrote:
>>
>> On Tue, Jan 16, 2018 at 2:35 PM, Gene Heskett 
>> wrote:
>>>
>>> On Tuesday 16 January 2018 14:19:38 Larry Martell wrote:
>>>
>>>> On Tue, Jan 16, 2018 at 12:00 PM, Larry Martell
>>>
>>>  wrote:
>>>>
>>>> > Looking for 2.7 docs on read.encode - googling did not turn up
>>>> > anything.
>>>> >
>>>> > Specifically, looking for the supported options for base64, and how
>>>> > to specify them, e.g. Base64.NO_WRAP
>>>>
>>>> So I just realized that encode() is not a method of read() it's a
>>>> string method. But I still have the same question - can I pass in any
>>>> flags?
>>>>
>>>> My issue is that I am base64 encoding PNG images on linux and it's
>>>> putting a LF at the end of each line. If I do the same on Windows it's
>>>> putting CR/LF. I want the files to be encoded with no platform
>>>> dependences. Googling I found mention of Base64.NO_WRAP and I want to
>>>> pass that into encode() - can I do that?
>>>
>>>
>>> Di you not have the manpages installed?
>>>
>>> In my copy of the manpage:
>>> base64 [OPTION]... [FILE]
>>> where option is:
>>>  -w, --wrap=COLS
>>>   wrap encoded lines after COLS character (default 76).  Use
>>> 0 to disable line wrapping.
>>>
>>> Seems pretty simple.
>>
>>
>> But how do I use that in read().encode('base64')?
>>
> Use the base64 module instead, which is also how you would do it in Python
> 3.
>
> If you're getting CR/LF on Windows, that's because you're opening the file
> in text mode. In both Python 2 and Python 3 the base64 string will be a
> bytestring, which you'd write out to a file opened in binary mode.
>
> That's an extra bit of future-proofing! :-)

Thanks. That's what it ended up being. The code that was receiving the
PNG was not reading and writing the file as binary. Strangely that
worked on Linux but not on Windows.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: documentation on read.encode

2018-01-18 Thread Larry Martell
On Thu, Jan 18, 2018 at 12:47 AM, Steven D'Aprano
 wrote:
> On Wed, 17 Jan 2018 16:54:37 -0500, Larry Martell wrote:
>
>> The code that was receiving the
>> PNG was not reading and writing the file as binary. Strangely that
>> worked on Linux but not on Windows.
>
> Nothing strange about it -- on Unix and Linux systems (with the possible
> exception of Mac OS?) in Python 2 there's no difference between text and
> binary mode for ASCII-only files. In Python 2, strings are byte strings,
> not Unicode, and reading from files returns such sequences of bytes.
>
> On Windows, reading from files in text mode treats \r\n as the end of
> line, and converts[1] such \r\n pairs to \n; it also treats ^Z byte as
> the end of file[2], or at least it used to back in the 2.5 or so days. I
> haven't tested it in more recent versions.
>
>
> [1] Technically this is a build-time option, but as far as I know it is
> not just the default but pretty much universal.
>
> [2] https://blogs.msdn.microsoft.com/oldnewthing/20040316-00/?p=40233/

Thanks for the clarification. I have been programming since 1975 and
thankfully have had very little exposure to Windows.
-- 
https://mail.python.org/mailman/listinfo/python-list


[RELEASED] Python 3.4.8rc1 and Python 3.5.5rc1 are now available

2018-01-23 Thread Larry Hastings


On behalf of the Python development community, I'm pleased to announce 
the availability of Python 3.4.8rc1 and Python 3.5.5rc1.


Both Python 3.4 and 3.5 are in "security fixes only" mode. Both versions 
only accept security fixes, not conventional bug fixes, and both 
releases are source-only.



You can find Python 3.4.8rc1 here:

   https://www.python.org/downloads/release/python-348rc1/


And you can find Python 3.5.5rc1 here:

   https://www.python.org/downloads/release/python-355rc1/



Happy Pythoning,


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


error from Popen only when run from cron

2018-01-27 Thread Larry Martell
I have a script that does this:

subprocess.Popen(['service', 'some_service', 'status'],
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)

When I run it from the command line it works fine. When I run it from
cron I get:

subprocess.Popen(['service', 'some_service', 'status'],
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
  File "/usr/lib64/python2.7/subprocess.py", line 711, in __init__
errread, errwrite)
  File "/usr/lib64/python2.7/subprocess.py", line 1327, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory

Anyone have any clue as to what file it's complaining about? Or how I
can debug this further?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: error from Popen only when run from cron

2018-01-27 Thread Larry Martell
On Sat, Jan 27, 2018 at 11:09 AM, Chris Angelico  wrote:
> On Sun, Jan 28, 2018 at 2:58 AM, Larry Martell  
> wrote:
>> I have a script that does this:
>>
>> subprocess.Popen(['service', 'some_service', 'status'],
>> stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
>>
>> When I run it from the command line it works fine. When I run it from
>> cron I get:
>>
>> subprocess.Popen(['service', 'some_service', 'status'],
>> stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
>>   File "/usr/lib64/python2.7/subprocess.py", line 711, in __init__
>> errread, errwrite)
>>   File "/usr/lib64/python2.7/subprocess.py", line 1327, in _execute_child
>> raise child_exception
>> OSError: [Errno 2] No such file or directory
>>
>> Anyone have any clue as to what file it's complaining about? Or how I
>> can debug this further?
>
> Looks like you're trying to invoke a process without a full path? It
> could be because cron jobs execute in a restricted environment. Two
> things to try:
>
> 1) Dump out os.environ to a file somewhere (maybe in /tmp if you don't
> have write permission). See if $PATH is set to some really short
> value, or at least to something different from what you see when you
> run it outside of cron.
>
> 2) Replace the word "service" with whatever you get from running
> "which service" on your system. On mine, it's "/usr/sbin/service". See
> what that does.
>
> Might not solve your problem, but it's worth a try.

Thanks! Using the full path fixed the issue.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Where has the practice of sending screen shots as source code come from?

2018-01-28 Thread Larry Martell
On Sun, Jan 28, 2018 at 10:04 AM, Steven D'Aprano
 wrote:
> I'm seeing this annoying practice more and more often. Even for trivial
> pieces of text, a few lines, people post screenshots instead of copying
> the code.
>
> Where has this meme come from? It seems to be one which inconveniences
> *everyone* involved:
>
> - for the sender, instead of a simple copy and paste, they have to take a
> screen shot, possibly trim the image to remove any bits of the screen
> they don't want to show, attach it to their email or upload it to an
> image hosting site;
>
> - for the receiver, you are reliant on a forum which doesn't strip
> attachments, or displays externally hosted images; the visually impaired
> are excluded from using a screen reader; and nobody can copy or edit the
> given text.
>
> It is as if people are deliberately inconveniencing themselves in order
> to inconvenience the people they are asking to help them.
>
> With the exception of one *exceedingly* overrated advantage, namely the
> ability to annotate the image with coloured lines and circles and
> squiggles or other graphics (which most people don't bother to do), this
> seems to me to be 100% counter-productive for everyone involved. Why has
> it spread and why do people keep doing it?
>
> I don't want to be the old man yelling "Get Of My Lawn!" to the cool
> kids, but is this just another sign of the downward spiral of programming
> talent? Convince me that there is *some* justification for this practice.
> Even a tiny one.
>
> (The day a programmer posts a WAV file of themselves reading their code
> out aloud, is the day I turn my modem off and leave the internet forever.)

I work remotely and have for over 20 years. At first I communicated
with my colleagues via phone and email. Then it was skype for a while
but then it went back to email. Then IRC had a moment, then it was
slack for a while, then back to email. Now everyone seems to be
switching to google hangouts, both chat and video. Recently I have
seen that some people are sending screen shots of their code and/or
error messages instead of copy/pasting.  It's mostly with the younger
ones, and I do not care for it at all, but I did not want to be the
old fogy, so I did not say anything.
-- 
https://mail.python.org/mailman/listinfo/python-list


[RELEASED] Python 3.4.8 and Python 3.5.5 are now available

2018-02-04 Thread Larry Hastings


On behalf of the Python development community, I'm happy to announce the 
availability of Python 3.4.8 and Python 3.5.5.


Both Python 3.4 and 3.5 are in "security fixes only" mode.  Both 
versions only accept security fixes, not conventional bug fixes, and 
both releases are source-only.



You can find Python 3.4.8 here:

   https://www.python.org/downloads/release/python-348/


And you can find Python 3.5.5 here:

   https://www.python.org/downloads/release/python-355/



Happy Pythoning,


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


Re: This newsgroup (comp.lang.python) may soon be blocked by Google Gro

2018-02-08 Thread Larry Martell
On Thu, Feb 8, 2018 at 12:36 PM, Gilmeh Serda
 wrote:
> On Sat, 03 Feb 2018 04:33:36 +1200, breamoreboy wrote:
>
>>> When trying to access comp.lang.idl-pvwave, a message is now displayed,
>> stating that the group owner needs to remove the spam, and can then
>> apply to Google in order to have access reinstated.
>
> Just as I have always suspected: Google are run by idiots!

Very, very rich idiots.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [RELEASED] Python 3.4.8 and Python 3.5.5 are now available

2018-02-10 Thread Larry Hastings


Actually, it was updated on the server, but somehow the old version was 
sticking around in the CDN cache.  I "purged" it and it's fine now.  
Weird that it would linger this long!


Cheers,


//arry/

On 02/10/2018 03:20 AM, Serhiy Storchaka wrote:

05.02.18 02:35, Larry Hastings пише:
On behalf of the Python development community, I'm happy to announce 
the availability of Python 3.4.8 and Python 3.5.5.


Both Python 3.4 and 3.5 are in "security fixes only" mode.  Both 
versions only accept security fixes, not conventional bug fixes, and 
both releases are source-only.



You can find Python 3.4.8 here:

    https://www.python.org/downloads/release/python-348/


And you can find Python 3.5.5 here:

    https://www.python.org/downloads/release/python-355/


Online documentation for 3.5 is not updated yet.


https://docs.python.org/3.5/whatsnew/changelog.html#python-3-5-5



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


Re: [RELEASED] Python 3.4.8 and Python 3.5.5 are now available

2018-02-10 Thread Larry Hastings


Actually, it was updated on the server, but somehow the old version was 
sticking around in the CDN cache.  I "purged" it and it's fine now.  
Weird that it would linger this long!


Cheers,


//arry/

On 02/10/2018 03:20 AM, Serhiy Storchaka wrote:

05.02.18 02:35, Larry Hastings пише:
On behalf of the Python development community, I'm happy to announce 
the availability of Python 3.4.8 and Python 3.5.5.


Both Python 3.4 and 3.5 are in "security fixes only" mode.  Both 
versions only accept security fixes, not conventional bug fixes, and 
both releases are source-only.



You can find Python 3.4.8 here:

    https://www.python.org/downloads/release/python-348/


And you can find Python 3.5.5 here:

    https://www.python.org/downloads/release/python-355/


Online documentation for 3.5 is not updated yet.


https://docs.python.org/3.5/whatsnew/changelog.html#python-3-5-5



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


atws

2018-02-21 Thread Larry Martell
I want to use the atws package
(https://atws.readthedocs.io/readme.html). I am using python 2.7.6 on
ubuntu-trusty-64 3.13.0-87-generic. I get this error when importing
the package:

>>> import atws
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/local/lib/python2.7/dist-packages/atws/__init__.py", line
4, in 
from .wrapper import connect
  File "/usr/local/lib/python2.7/dist-packages/atws/wrapper.py", line
32, in 
from . import connection
  File "/usr/local/lib/python2.7/dist-packages/atws/connection.py",
line 19, in 
from requests.exceptions import ConnectTimeout, Timeout,
ReadTimeout, SSLError
ImportError: cannot import name ConnectTimeout

I would not be surprised if no one here has used this package, but has
anyone seen this error in other packages or their own work?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: atws

2018-02-22 Thread Larry Martell
On Thu, Feb 22, 2018 at 2:00 AM, Chris Angelico  wrote:
> On Thu, Feb 22, 2018 at 5:27 PM, Larry Martell  
> wrote:
>> I want to use the atws package
>> (https://atws.readthedocs.io/readme.html). I am using python 2.7.6 on
>> ubuntu-trusty-64 3.13.0-87-generic. I get this error when importing
>> the package:
>>
>>>>> import atws
>> Traceback (most recent call last):
>>   File "", line 1, in 
>>   File "/usr/local/lib/python2.7/dist-packages/atws/__init__.py", line
>> 4, in 
>> from .wrapper import connect
>>   File "/usr/local/lib/python2.7/dist-packages/atws/wrapper.py", line
>> 32, in 
>> from . import connection
>>   File "/usr/local/lib/python2.7/dist-packages/atws/connection.py",
>> line 19, in 
>> from requests.exceptions import ConnectTimeout, Timeout,
>> ReadTimeout, SSLError
>> ImportError: cannot import name ConnectTimeout
>>
>> I would not be surprised if no one here has used this package, but has
>> anyone seen this error in other packages or their own work?
>
> You're running that on a fairly old version of Python (2.7.6 - the
> latest in the 2.x branch is 2.7.14). It's entirely possible that the
> app doesn't support the versions of Python and/or the 'requests'
> library that you have installed.
>
> First thing to try: can you use the app under Python 3?

This is a mature django app and I cannot switch to Python 3.

> For reference, here's the version of requests that I have (which does
> have that exception available):
>
>>>> import requests
>>>> requests.__version__
> '2.18.4'
>
> What's yours?

I had 2.2.1. I updated requests to 2.18.4 and now when I import atws I get:

No handlers could be found for logger "atws.connection"
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: atws

2018-02-22 Thread Larry Martell
On Thu, Feb 22, 2018 at 10:25 AM, Mark Lawrence  wrote:
> On 22/02/18 15:06, Larry Martell wrote:
>>
>> On Thu, Feb 22, 2018 at 2:00 AM, Chris Angelico  wrote:
>>>
>>> On Thu, Feb 22, 2018 at 5:27 PM, Larry Martell 
>>> wrote:
>>>>
>>>> I want to use the atws package
>>>> (https://atws.readthedocs.io/readme.html). I am using python 2.7.6 on
>>>> ubuntu-trusty-64 3.13.0-87-generic. I get this error when importing
>>>> the package:
>>>>
>>>>>>> import atws
>>>>
>>>> Traceback (most recent call last):
>>>>File "", line 1, in 
>>>>File "/usr/local/lib/python2.7/dist-packages/atws/__init__.py", line
>>>> 4, in 
>>>>  from .wrapper import connect
>>>>File "/usr/local/lib/python2.7/dist-packages/atws/wrapper.py", line
>>>> 32, in 
>>>>  from . import connection
>>>>File "/usr/local/lib/python2.7/dist-packages/atws/connection.py",
>>>> line 19, in 
>>>>  from requests.exceptions import ConnectTimeout, Timeout,
>>>> ReadTimeout, SSLError
>>>> ImportError: cannot import name ConnectTimeout
>>>>
>>>> I would not be surprised if no one here has used this package, but has
>>>> anyone seen this error in other packages or their own work?
>>>
>>>
>>> You're running that on a fairly old version of Python (2.7.6 - the
>>> latest in the 2.x branch is 2.7.14). It's entirely possible that the
>>> app doesn't support the versions of Python and/or the 'requests'
>>> library that you have installed.
>>>
>>> First thing to try: can you use the app under Python 3?
>>
>>
>> This is a mature django app and I cannot switch to Python 3.
>>
>>> For reference, here's the version of requests that I have (which does
>>> have that exception available):
>>>
>>>>>> import requests
>>>>>> requests.__version__
>>>
>>> '2.18.4'
>>>
>>> What's yours?
>>
>>
>> I had 2.2.1. I updated requests to 2.18.4 and now when I import atws I
>> get:
>>
>> No handlers could be found for logger "atws.connection"
>>
>
> I get exactly the same thing, but do the import interactively and then
> help(atws) shows help so I'm guessing that it's just a poor informational
> message, so I suggest that you just try running your code and see what
> happens.

Thanks - it seems to work despite that message.

> p.s. enjoying the curling at the Winter Olympics?

For sure - huge upset over Canada! I stayed up until 3am watching the
women's hockey game last night and I had to be up at 6 this morning,
so I'm dragging now.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: atws

2018-02-23 Thread Larry Martell
On Fri, Feb 23, 2018 at 2:01 AM, dieter  wrote:
> Larry Martell  writes:
>> ...
>> I had 2.2.1. I updated requests to 2.18.4 and now when I import atws I get:
>>
>> No handlers could be found for logger "atws.connection"
>
> This is a warning (only), telling you that the "atws" package wants
> to log a message but there is not corresponding logging handler
> defined -- likely because you did not configure Python's logging
> infrastructure (--> "logging" package in Python's standard documentation).

Yes, but this message comes from the import, which happens before any
of my code runs.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: atws

2018-02-23 Thread Larry Martell
On Fri, Feb 23, 2018 at 8:34 AM, Chris Angelico  wrote:
> On Sat, Feb 24, 2018 at 12:08 AM, Larry Martell  
> wrote:
>> On Fri, Feb 23, 2018 at 2:01 AM, dieter  wrote:
>>> Larry Martell  writes:
>>>> ...
>>>> I had 2.2.1. I updated requests to 2.18.4 and now when I import atws I get:
>>>>
>>>> No handlers could be found for logger "atws.connection"
>>>
>>> This is a warning (only), telling you that the "atws" package wants
>>> to log a message but there is not corresponding logging handler
>>> defined -- likely because you did not configure Python's logging
>>> infrastructure (--> "logging" package in Python's standard documentation).
>>
>> Yes, but this message comes from the import, which happens before any
>> of my code runs.
>
> It's perfectly legal to put other code before an import:
>
> import logging
> logging.basicConfig(...)
> import atws
>
> But this is just a warning, so it's not that big a deal either way.

Yes, I know it's legal, but I've always thought it was bad form.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: help me ?

2018-02-27 Thread Larry Martell
On Tue, Feb 27, 2018 at 12:56 PM, Ian Kelly  wrote:
> On Tue, Feb 27, 2018 at 10:16 AM, Igor Korot  wrote:
>> Congratulations!
>> You have an "A" for solving the problem and "F" for helping the guy cheat.
>> You should be expelled from the course.
>
> In my experience, this is what happens pretty much every time.
> Somebody posts a homework question asking for the answer, a few people
> say something to the effect of, "This looks like homework. What have
> you tried so far?" Then some other bozo comes along who just likes
> solving easy problems and hands up the answer on a silver platter.
>
> Cheaters are gonna cheat. In the unlikely event they don't get the
> answer here, they'll probably just manage to convince somebody to do
> the work for them somewhere else. Honestly, I don't know if it's even
> worth the bother to engage.

When I was in college back in the 70's they made people in majors like
printing or chemistry, for example, take 1 programming course. They
were always clueless and I often wrote programs for them - my typical
fee was a case of beer.
-- 
https://mail.python.org/mailman/listinfo/python-list


psutil

2018-02-27 Thread Larry Martell
Trying to install psutil (with pip install psutil) on Red Hat EL 7.
It's failing with:

Python.h: No such file or directory

Typically that means the python devel libs are not installed, but they are:

[root@liszt ~]# yum install python-devel
Package python-devel-2.7.5-58.el7.x86_64 already installed and latest version
Nothing to do

Anyone have any idea what to try next?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: psutil

2018-02-27 Thread Larry Martell
On Tue, Feb 27, 2018 at 7:37 PM, Chris Angelico  wrote:
> On Wed, Feb 28, 2018 at 11:29 AM, Larry Martell  
> wrote:
>> Trying to install psutil (with pip install psutil) on Red Hat EL 7.
>> It's failing with:
>>
>> Python.h: No such file or directory
>>
>> Typically that means the python devel libs are not installed, but they are:
>>
>> [root@liszt ~]# yum install python-devel
>> Package python-devel-2.7.5-58.el7.x86_64 already installed and latest version
>> Nothing to do
>>
>> Anyone have any idea what to try next?
>
> Are you trying to install that into Python 3 or Python 2? Might need
> to grab python3-devel.

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


Re: psutil

2018-02-27 Thread Larry Martell
On Tue, Feb 27, 2018 at 7:36 PM, José María Mateos  wrote:
> On Tue, Feb 27, 2018 at 07:29:50PM -0500, Larry Martell wrote:
>> Trying to install psutil (with pip install psutil) on Red Hat EL 7.
>> It's failing with:
>>
>> Python.h: No such file or directory
>
> Two questions come to my mind:
>
> - Does it work if you try to install some other package?

Yes, I have installed other packages (e.g. numpy)

> - Is `pip` by any change trying to install a Python 3 package, but you
>   only have the libraries for Python 2 installed?

No, here is the gcc command line that failed:

gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong
--param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic
-D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong
--param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic
-D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPSUTIL_POSIX=1
-DPSUTIL_VERSION=543 -DPSUTIL_LINUX=1
-I/opt/rh/python27/root/usr/include/python2.7 -c
psutil/_psutil_common.c -o
build/temp.linux-x86_64-2.7/psutil/_psutil_common.o
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: psutil

2018-02-28 Thread Larry Martell
On Tue, Feb 27, 2018 at 8:30 PM, Matt Wheeler  wrote:
>
>
> On Wed, 28 Feb 2018, 00:49 Larry Martell,  wrote:
>>
>> On Tue, Feb 27, 2018 at 7:36 PM, José María Mateos 
>> wrote:
>> > On Tue, Feb 27, 2018 at 07:29:50PM -0500, Larry Martell wrote:
>> >> Trying to install psutil (with pip install psutil) on Red Hat EL 7.
>> >> It's failing with:
>> >>
>> >> Python.h: No such file or directory
>> >
>> > Two questions come to my mind:
>> >
>> > - Does it work if you try to install some other package?
>>
>> Yes, I have installed other packages (e.g. numpy)
>
>
> Did that install definitely involve a build from source?
>
>> > - Is `pip` by any change trying to install a Python 3 package, but you
>> >   only have the libraries for Python 2 installed?
>>
>> No, here is the gcc command line that failed:
>>
>> gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall
>> -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong
>> --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic
>> -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall
>> -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong
>> --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic
>> -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPSUTIL_POSIX=1
>> -DPSUTIL_VERSION=543 -DPSUTIL_LINUX=1
>> -I/opt/rh/python27/root/usr/include/python2.7 -c
>> psutil/_psutil_common.c -o
>> build/temp.linux-x86_64-2.7/psutil/_psutil_common.o
>
>
> Based on the include path you have here this looks like you have a non
> standard python package for EL7 (in addition to the system one, or you'd be
> having a worse day), which is probably the root of your problem.
>
> Are you using python packages from scl perhaps?
> If so you probably need to install python27-python-devel (found at
> http://mirror.centos.org/centos/7/sclo/x86_64/rh/python27/)

Thanks to all who replied. The machine got rebooted (for an unrelated
issue) and when it came back up the install worked fine.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why no list as dict key?

2022-04-20 Thread Larry Martell
On Wed, Apr 20, 2022 at 2:23 PM Abdur-Rahmaan Janhangeer
 wrote:
>
> Greetings list,
>
> Using Python3.9, i cannot assign a list [1, 2] as key
> to a dictionary. Why is that so? Thanks in advanced!

Dict keys cannot be mutable. Use a tuple instead.
-- 
https://mail.python.org/mailman/listinfo/python-list


terminate called after throwing an instance of 'boost::python::error_already_set

2022-05-27 Thread Larry Martell
I have a script that has literally been running for 10 years.
Suddenly, for some runs it crashes with the error:

terminate called after throwing an instance of 'boost::python::error_already_set

No stack trace. Anyone have any thoughts on what could cause this
and/or how I can track it down?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: terminate called after throwing an instance of 'boost::python::error_already_set

2022-05-27 Thread Larry Martell
On Fri, May 27, 2022 at 5:51 PM dn  wrote:

> On 28/05/2022 08.14, Larry Martell wrote:
> > I have a script that has literally been running for 10 years.
> > Suddenly, for some runs it crashes with the error:
> >
> > terminate called after throwing an instance of
> 'boost::python::error_already_set
> >
> > No stack trace. Anyone have any thoughts on what could cause this
> > and/or how I can track it down?
>
> 1 a change to Python interpreter being used
>
> 2 a change to the boost library being used
>
> 3 a change to lower levels in 'the s/w stack' or h/w
>
> 4 a change to the data being passed-across


Definitely not 1. 4 is always the case - every run is with different data.
2 and 3 I don’t know. What is boost and how does Python use it? None of my
code is importing it. How can get a stack trace when it crashes with just
that message?

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


Re: Function to Print a nicely formatted Dictionary or List?

2022-06-09 Thread Larry Martell
On Thu, Jun 9, 2022 at 11:44 AM Dave  wrote:
>
> Hi,
>
> Before I write my own I wondering if anyone knows of a function that will 
> print a nicely formatted dictionary?
>
> By nicely formatted I mean not all on one line!

>>> import json
>>> d = {'John': 'Cleese', 'Eric': "Idle", 'Micheal': 'Palin'}
>>> print(json.dumps(d, indent=4))
{
"John": "Cleese",
"Eric": "Idle",
"Micheal": "Palin"
}
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: flattening lists

2022-10-11 Thread Larry Martell
On Tue, Oct 11, 2022 at 12:48 PM SquidBits _  wrote:
>
> Does anyone else think there should be a flatten () function, which just 
> turns a multi-dimensional list into a one-dimensional list in the order it's 
> in. e.g.
>
> [[1,2,3],[4,5,6,7],[8,9]] becomes [1,2,3,4,5,6,7,8,9].
>
> I have had to flatten lists quite a few times and it's quite tedious to type 
> out. It feels like this should be something built in to python, anyone else 
> think this way?

x = [[1,2,3],[4,5,6,7],[8,9]]
[i for j in x for i in j]
[1, 2, 3, 4, 5, 6, 7, 8, 9]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Rob Cliffe should stop sending me rude email messages.

2023-02-26 Thread Larry Martell
On Sun, Feb 26, 2023 at 3:49 PM Hen Hanna  wrote:

>
> Rob Cliffe should stop sending me rude email messages.


You should stop spamming this lists with with meaningless posts.
-- 
https://mail.python.org/mailman/listinfo/python-list


  1   2   3   4   5   6   7   8   9   10   >