Re: Convert the decimal numbers expressed in a `numpy.ndarray` into a matrix representing elements in fractional form

2022-05-23 Thread Cousin Stanley



> hongy... wrote 
>
> This method doesn't work, as shown below:
>
? b 
>
>  [0.0, -1.0, 0.0, 0.25]
>  [1.0, 0.0, 0.0, 0.25]
>  [0.0, 0.0, 1.0, 0.25]
>  [0.0, 0.0, 0.0, 1.0]
>
> a 
>
> 0  0  0  1
>

# ---

Using 

  debian 11.3 bullseye
  python 3.9
  numpy  1,21,5

  Code as I posted in my reply dated 2022-05-18


$ python3 np_array_to_fractions_2.py

  b 

 [0.0, -1.0, 0.0, 0.25]
 [1.0, 0.0, 0.0, 0.25]
 [0.0, 0.0, 1.0, 0.25]
 [0.0, 0.0, 0.0, 1.0]

  a 

0 -1 0 1/4
1 0 0 1/4
0 0 1 1/4
0 0 0 1


--
Stanley C. Kitching
Human Being
Phoenix, Arizona
--
https://mail.python.org/mailman/listinfo/python-list


Re: Convert the decimal numbers expressed in a `numpy.ndarray` into a matrix representing elements in fractional form

2022-05-18 Thread Cousin Stanley

#!/usr/bin/env python3

'''
NewsGroup  comp.lang.python

Subject .. Convert the decimal numbers
   expressed in a numpy.ndarray
   into a matrix representing elements
   in fractiona

Date . 2022-05-16

Post_By .. hongy...

Edit_By .. Stanley C. Kitching
'''

import numpy as np

from fractions import Fraction

b = [
  [ 0.0 , -1.0 , 0.0 , 0.25 ] ,
  [ 1.0 ,  0.0 , 0.0 , 0.25 ] ,
  [ 0.0 ,  0.0 , 1.0 , 0.25 ] ,
  [ 0.0 ,  0.0 , 0.0 , 1.0  ] ]

a = [ ]

print( '\n  b  \n' )

for row in b :
arow = []
print( '' , row )

for dec_x in row :
frac_x = Fraction( dec_x )
arow.append( frac_x )

a.append( arow )


# using f-string format

print( '\n  a  \n' )

for row in a :

for item in row :

print( f'{item} ' , end = '' )

print()

# --

--
Stanley C. Kitching
Human Being
Phoenix, Arizona
--
https://mail.python.org/mailman/listinfo/python-list


Re: Suggestion for Linux Distro (from PSA: Linux vulnerability)

2022-03-11 Thread Cousin Stanley
Cousin Stanley wrote:

>> apt-cache search lxqt | grep ^lxqt


Chris Angelico wrote:

> Much faster:
> 
> apt-cache pkgnames lxqt
> 
> apt-cache search will look for "lxqt" in descriptions too, 
> hence the need to filter those out 
> 
>   apt-cache pkgnames is used by tab completion)
> 

  Thanks 

I didn't know about using  pkgnames  with apt-cache.

-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: Suggestion for Linux Distro (from PSA: Linux vulnerability)

2022-03-10 Thread Cousin Stanley
Marco Sulla wrote:

>>
>> Maybe Debian itself?
> 
> I tried Debian on a VM, but I found it too much basical. A little
> example: it does not have the shortcut ctrl+alt+t to open a terminal
> that Ubuntu has. I'm quite sure it's simple to add, but I'm starting
> to be old and lazy...
> 

  I use the current stable release of Debian 11.2 Bullseye
  with the lxqt desktop environment  

[Ctrl]-[Alt]-[T] will open a new qterminal window.


  The following will display a list of lxqt packages
  that are in the repository and available to install 

apt-cache search lxqt | grep ^lxqt

  
-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: Python LSTM forecast future values for time series

2022-02-12 Thread Cousin Stanley
Jorge Conforte wrote:

> 
> I'm starting run the LSTM to forecast future values for time serie data.
> 
> please can someone give me some information 
> on how i can predict future values 
​​> for my time series using LSTM. Thanks, Conrado

  I cannot personlly help but a google search
  using the following phrase seems promising  

lstm predict future values


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: What to write or search on github to get the code for what is written below:

2022-01-28 Thread Cousin Stanley
Dennis Lee Bieber wrote:

> Ignoring the code spam I presume 
>  

  I'm an sqlite user myself and was glad to see 
  the code you posted and have a couple of tiny example
  book/author sql3 databases but nothing resembling 
  an actual library check in/out program  

  I've never used PySimpleGUI 
  but it does look interesting  

https://pysimplegui.readthedocs.io/en/latest/

https://pypi.org/search/?q=pysimplegui

  After you complete your BookDepository DataBase development
  perhaps you would consider making it publically available 
  for others to learn from 


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: What to write or search on github to get the code for what is written below:

2022-01-28 Thread Cousin Stanley
Dennis Lee Bieber wrote:

> 
> How would you do this assignment on paper ?
> 

  Your patience and willingness to help and guide someone else
  with such a complete and understanable post is hihgly commendable.

  Thanks  
  
-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: Where is the problem?

2021-02-27 Thread Cousin Stanley
RD wrote:

> In article , cousinstan...@gmail.com says...
>  
> [snip]
> 
>>   I have a couple of postscript saving examples
>>   that include the following geometry parameters
>>   which produce  .ps  files that render the same
>>   as the canvas drawings when viewed in ghostsript.
> 
>> retval = canvas.postscript(
>>file   = "image/ps/xyzzy.ps ,
>>height = 400 ,
>>width  = 400 ,
>>pagewidth  = 400 ,
>>pageheight = 400 ,
>>colormode = "color" )
>  
> [snip]
> 
> Wow! It worked! Thankyouthankyouthankyou.
> 
> RD

  You're welcome  
  You're Welcome  
  You're Welcome 
  

-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: Where is the problem?

2021-02-26 Thread Cousin Stanley
RD wrote:

> Python 3.4.3 on WinXP.
> 
> I create a Tk canvas and draw on it with create_text(),
> create_line(), and create_polygon with fill and stipple.
> 
> So far, so good, looks fine on the screen.
> 
> So I go to send it to a postsctript file:
> 
> bmap.postscript(file="tmp.ps", colormode='color')
> 
> It generates a file, no errors reported.
> 
> So I open up the file in a PS viewer (2, actually),
> and the saved file looks like someone left a
> watercolor out in the rain.
> 
> Artifacts everywhere, the lines are blurred, and the
> text is unreadable.
> 
> Googling was unhelpful; did I miss something?
> 
> TIA

  I have a couple of postscript saving examples
  that include the following geometry parameters
  which produce  .ps  files that render the same
  as the canvas drawings when viewed in ghostsript.
   
retval = canvas.postscript( 
   file   = "image/ps/xyzzy.ps , 
   height = 400 , 
   width  = 400 ,
   pagewidth  = 400 , 
   pageheight = 400 ,  
   colormode = "color" )

  Perhaps adding the geomerty parameters
  might help.


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: issue with seaborn

2021-02-20 Thread Cousin Stanley
Dino wrote:

> trying to do some dayaviz with Italian Covid Open Data (
> https://github.com/italia/covid19-opendata-vaccini/ )
> 
> here's how I pull my data:
> 
> import sys
> import urllib.request
> import pandas as pd
> import ssl
> ssl._create_default_https_context = ssl._create_unverified_context
> 
> URL =
> "https://github.com/italia/covid19-opendata-vaccini/blob/master/dati/somministrazioni-vaccini-latest.csv?raw=true;
> 
> with urllib.request.urlopen(URL) as url:
> df = pd.read_csv(url)
> 
> 
> One of my diagrams came out screwed up today, and I am having a hard
> time understanding what went wrong:
> 
> https://imgur.com/a/XTd4akn
> 
> Any ideas?
> 

  I first downloaded a local copy of the  .csv  file
  using  

wget URL  

  Then the python code below following the plot parameters
  shown in your  imgur.com  image which was executed
  in a jupyter notebook 

# it_covid.py ---

import pandas as pd
import seabornas sns
import numpy  as np
import matplotlib.pyplot as plt

df = pd.read_csv( 'data/somministrazioni-vaccini-latest.csv' )

plt.figure( figsize = ( 20 , 10 ) )

plt.xticks( rotation = 70 )

sns.lineplot( 
x= "data_somministrazione" , 
y= "prima_dose" , 
data = df , 
hue  = "nome_area" , 
ci   = None )


plt.show()

# ---

  The resulting plot doesn't seem to be cluttered
  as the one that you posted  

http://csphx.net/image/it_covid.png


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: Seeking guidance to start a career in python programming

2020-11-05 Thread Cousin Stanley
ankur gupta wrote:

> Good Morning to All,

> My name is Ankur Gupta and I wish to seek guidance from you. 
> 
> I belong to a non-computer science background 
> but have always been attracted to this field. 
> 
> I had computer science in class 12th ( Where I learned C++ 
> and Python ) but I did Mechanical Engineering instead in college. 
> 
> I wish to pursue a career in Python programming 
> and therefore undertook 2 online certification courses 
> in python but besides this, my progress is almost stalled.
> 
> Request you all to please guide how I can move forward 
> with my current learning of the language and also steps 
> that I can take to pursue a career in this field.

  Mechanical Engineers are needed 
  in an almost endlessly wide array
  of applications ...

from  nano-bots in bio-engineering
  to space-bots sampling soil samples on asteroids

  You might consider applying the Python knowledge
  that you have acquired to endeavors in the field
  that you are most familar with.


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: How do I get datetime to stop showing seconds?

2020-10-16 Thread Cousin Stanley
Steve wrote:

> d2 =  datetime.datetime.now() #Time Right now
> 
> Show this: 2020-10-16 02:53
> and not this: 2020-10-16 02:53:48.585865
> 
> 
> ==
> Footnote:
> If you double major in psychology and reverse psychology, to they cancel
> each other out?
> 
> --

py> 
py> import datetime as dt
py> 
py> d = dt.datetime.now().strftime( '%Y-%m-%d  %H:%M' )
py> 
py> print( '\n  ' , d )

   2020-10-16  07:22


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: How do I place a preset into the text box?

2020-08-28 Thread Cousin Stanley
Steve wrote:

> The following program compiles but does not quite do what I would like it to
> do. Line 19 is the preset information but I do not seem to be able to get it
> into the form by code.  My purpose is to let the user make changes without
> having to re-enter the entire code.
> 

You might consider moving the entry  get()  function
into the  Submit()  call back 

def Submit() :

label.configure( text = 'The new code is : ' + NewCode.get() )

x = ( NewCode.get() )

print( "\n  The new code entered is :  " + x )



The following  insert  function will show the OldCode
in the  entry  box 
 
OldCode = ( "1234-abcd" )

# 

CodeEntered = ttk.Entry( window , width = 15 , textvariable = NewCode )

CodeEntered.grid( column = 2 , row = 3 , pady = 10 )

CodeEntered.insert( 0 , OldCode )


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: Button press event - event handling and picking: IndexError: list index out of range

2020-06-09 Thread Cousin Stanley
Caledonian26 wrote:


> However, I keep getting the error: 
> 
>   IndexError: list index out of range. 
> 
>  Could anyone give me a helping hand 
>  as to where I am going wrong?
> 

  I appended a single arbitrary value for limits  
  since the  limits  list had not been previously
  initialized  
  
  

  colourofbars = [ ]

  for key , value in dict_means.items() :

  limits.append( 3000 )

  if limits[ 0 ] > ( key + ( value ) ) :
  

  This fix gets past the  index out of range  error
  and produces a plot which might let you proceed
  to the next problem you might encounter 


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: Floating point issue

2020-04-17 Thread Cousin Stanley
Aakash Jana wrote:

> I am calculating couple of ratios and according to the problem 
> there must be a 6 decimal precision. 
> 
> But when I print the result I only get one 0.
>
> E.g:- 2 / 5 = 0.40 but I am only getting 0.4

You might try using a  ' '.format  string 

ratios = { 
 '1/8'  :  1/8 , 
 '1/5'  :  1/5 ,  
 '1/4'  :  1/4 , 
 '1/3'  :  1/3 , 
 '2/5'  :  2/5 , 
 '5/9'  :  5/9 , 
 '2/3'  :  2/3 , 
 '4/5'  :  4/5 , 
 '7/8'  :  7/8 , 
 '9/5'  :  9/5 , 
 '22/7' :  22/7 }

print()
 
for fraction , ratio in ratios.items() : 

print( '  {:4s}  {:.6f} '.format( fraction , ratio ) )









-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: How to get filesystem in python.

2020-01-17 Thread Cousin Stanley
Antoon Pardon wrote:

> I would like to get the information given by the df command on linux/unix.
> I found the os.statvfs call, but it misses one thing: The filesystem.
> 
> Does anyone know how to get that information.
> 

import os

pipe_in = os.popen( 'df -h -T -x tmpfs -x devtmpfs' )

list_source = pipe_in.readlines()

for this_item in list_source[ 1 : ] :

this_list = this_item.strip().split()

file_sys  = this_list[ 0 ]
file_type = this_list[ 1 ]
size  = this_list[ 2 ]
used  = this_list[ 3 ]
avail = this_list[ 4 ]
used_pc   = this_list[ 5 ]
mounted   = this_list[ 6 ]


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: upgrading python on raspbian

2019-10-16 Thread Cousin Stanley
Gene Heskett wrote:

> Continueing this thread, I now have a missing function by name, "units",
> that is preventing LinuxCNC from running.
> 
> Where in the python 3 world do I find that function?,
> 

  Under debian buster there is a python 2 package
  called  python-quantities  that apparently
  deals with units via numpy dependencies.

  $ apt-cache show python-quantities
  Package: python-quantities
  Version: 0.12.1-1
  Priority: optional
  Section: python
  Maintainer: Debian Science Maintainers 
  
  Installed-Size: 358 kB
  Depends: python (<< 2.8), python (>= 2.7), python:any (>= 2.6.6-7~),
   python-numpy
  Suggests: python-unittest2
  
  Description-en: Library for computation of physical quantities 
  with units, based on numpy  Quantities is designed to handle 
  arithmetic and conversions of physical quantities, which have 
  a magnitude, dimensionality specified by various units, 
  and possibly an uncertainty.  Quantities builds on 
  the popular numpy library and is designed to work with 
  numpy ufuncs, many of which are already supported.
  

  Also 

  $ apt-files list python-quantities
  
  Shows a  units  sub-directory under /usr/lib/python2.7/dist-packages
  with several individual modules such as force, length, mass, pressue,
  temperature, etc.

  Seems to be also available throug the python package index 

https://pypi.org/project/quantities/

$ pip install quantities


  I have  no  personal expeience with this package.



-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: question about making an App for Android

2019-10-15 Thread Cousin Stanley
Cousin Stanley wrote:

> There is also a useful python package
> called  sunset  which I fouund a reference to
> on stackoverflow 

  Maybe I'll wake up some time today :-)

  The python package is called suntime
  not sunset  

  # pip3 show suntime


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: question about making an App for Android

2019-10-15 Thread Cousin Stanley
Cousin Stanley wrote:
  
> 
> d_sse = sse_sunset - sse_sunrise  # seconds of daylight
> 

  I think it might be required to convert
  utc time to local time for the difference
  in sunrise and sunset times to make sense 
  in local time 
 

-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: question about making an App for Android

2019-10-15 Thread Cousin Stanley
Chris Angelico wrote:

> Or maybe it's really simple, because there's an HTTP API 
>that > gives you the information. 
>
> There's an API for everything these days. 
> 
> A quick web search showed up this:
> 
>   https://sunrise-sunset.org/api
> 

  There is also a useful python package
  called  sunset  which I fouund a reference to
  on stackoverflow 


https://stackoverflow.com/questions/38986527/sunrise-and-sunset-time-in-python/38986561

  # pip3 install sunset

  # pip 3 show sunset
  os pip3 show suntime
  Name: suntime
  Version: 1.2.5
  Summary: Simple sunset and sunrise time calculation python library
  Home-page: https://github.com/SatAgro/suntime
  Author: Krzysztof Stopa
  Author-email: None
  License: LGPLv3
  Location: /usr/local/lib/python3.7/dist-packages
  Requires: python-dateutil
  Required-by: 

  If latidude and longitude are known
  sunrise and sunset times are available  

$ cat daylight_phoenix.py

#!/usr/bin/env python3

'''
NewsGroup  comp.lang.python 
Subject .. question about maiking an App for Android
Date . 2019-10-10
Post_By .. pyotr filipivich

Code_By .. Stanley C. Kitching
Code_Date  2019-10-10 
'''

import time
import datetime as dt

from suntime import Sun , SunTimeException

# Phoenix, Arizona

latitude  = 33.4484 # ° N

longitude = 112.0740# ° W

sun = Sun( latitude , longitude )

# Get today's sunrise and sunset in UTC

sunrise = sun.get_sunrise_time()

sunset  = sun.get_sunset_time()

sse_sunrise = sunrise.timestamp()  # sunrise seconds since epoch

sse_sunset  = sunset.timestamp()   # sunset  seconds since epoch

d_sse   = sse_sunset - sse_sunrise  # seconds of daylight

print( '\n  Today in Phoenix ' )

print( '\n sunrise : ' , sunrise , '  ' , sse_sunrise )
print( '\n sunset  : ' , sunset  , '  ' , sse_sunset  )
print( '\ndaylight :  {} seconds '.format( d_sse ) )

# -

 
-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: Enumerate - int object not subscriptable

2019-08-20 Thread Cousin Stanley
Sayth Renshaw wrote:

> I want to do basic math with a list.
> 
> a = [1, 2, 3, 4, 5, 6, 7, 8]
> 
> for idx, num in enumerate(a):
> print(idx, num)
> 
> This works, but say I want to print the item value 
> at the next index as well as the current.
> 
> for idx, num in enumerate(a):
>
> print(num[idx + 1], num)
> 


#!/usr/bin/env python3

# sum each adjacent pair of elements in a list

ls = list( range( 10 , 1 , -1 ) ) 

print('\n  ' , ls , '\n' )

for enum , n in enumerate( range( len( ls ) - 1 ) ) :

i_left , i_rite = ls[ n : n + 2 ]

i_tot = i_left  +  i_rite

print( '  {:2d} :  {:2d}  +  {:2d} = {:4d} '.format( enum , i_left , i_rite 
, i_tot ) )


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: Make sure the window title is visible in tkinter

2019-06-30 Thread Cousin Stanley
Cousin Stanley wrote  

>>  You might try setting a given window geometry
>>  to accomodate the long title  
>>
>>  win_w = 400 
>>  win_h = 300
>>
>>  ofs_h = 40
>>  ofs_v = 30
>>
>>  window.geometry( "%dx%d+%d+%d" % ( win_w , win_h , ofs_h , ofs_v ) )
>>
>>  
>>  Maybe add a bit of extra space for users 
>>  with different default font sizes 
>>
>>  Not a general solution 
>>  but perhaps workable 

moi wrote  

> No, huge mistake.

  It isn't clear to me how specifying a particular geometry
  for one's own self-coded tkinter gui prgrams with windows
  that are resize-able would be a mistake 

> Take for example the Windows installer.
>
> The window is so small, you can not even read the path 
> where Python will be installed.
>
> Bonus: the windows is not resizable and part of items 
> are not even visible.
>
> It would be to bad to not mimic this behavior.
>
> Just tested it 2 min ago on my Windows 7.1 with py3.7.3.

  I didn't suggest modifying 3rd party programs,
  but the suggestion I offered was meant to be applied
  to one's own code 

  I have used a given geometry for dozens of my own
  tkinter gui programs such that a modest window size
  which assures that all widgets are viewable 
  when first presented to the user 


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: Make sure the window title is visible in tkinter

2019-06-26 Thread Cousin Stanley
Cecil Westerhof wrote:

> I need to write a desktop program. I choose to use tkinter. 
> 
> How can I make sure the window title is visible? For example 
> when I have the following code :

> from tkinter  import Button, filedialog, Label, messagebox, Tk
> 
> 
> window = Tk()
> window.title('A long window title')
> Button (window, text = 'Short text').pack()
> window.mainloop()
> 
> I see only a part of the 'A', but I would like to see 
> the complete :
>
>   'A long window title'
> 

  You might try setting a given window geometry
  to accomodate the long title  

  win_w = 400 
  win_h = 300

  ofs_h = 40
  ofs_v = 30

  window.geometry( "%dx%d+%d+%d" % ( win_w , win_h , ofs_h , ofs_v ) )

  
  Maybe add a bit of extra space for users 
  with different default font sizes 

  Not a general solution 
  but perhaps workable 


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: polar coordinates?

2018-12-10 Thread Cousin Stanley
Brian Christiansen wrote:

> 
> I guess my question is if python can do this natively 
> or if there is a package somewhere ( polar.py ? ) that can do this
> 

  You might consider  matplotlib  for polar coordinate plotting ...

https://matplotlib.org/examples/pylab_examples/polar_demo.html


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: Program to keep track of success percentage

2018-12-10 Thread Cousin Stanley
Musatov wrote:

> I am thinking about a program where the only user input is win/loss. 
> 
> The program let's you know if you have won 
> more than 31% of the time or not. 
> 
> Any suggestions about how to approach authoring
> such a program? Thanks.

  The following results are from a python  toss_up  program
  using the python random.choice module where  win  or  lose  
  was chosen randomly for each try for various numbers of tries 

  For random choice of  win  or  lose 
  distribution seems to be very even 
  for each result  

 # tries   win %   lose %

10 50.0050.00
   100 52.0048.00
  1000 48.4051.60
 1 49.7550.25
10 50.1749.83
   100 50.0050.00


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: [Tutor] SyntaxError: can't assign to literal while using ""blkid -o export %s | grep 'TYPE' | cut -d"=" -f3" % (fs)" using subprocess module in Python

2018-11-09 Thread Cousin Stanley
srinivasan wrote:

> Even after changing as per the below
> "blkid -o export %s | grep 'TYPE' | cut -d'=' -f3"
> or:
> 'blkid -o export %s | grep "TYPE" | cut -d"=" -f3'
> or:
> "blkid -o export %s | grep \"TYPE\" | cut -d\"=\" -f3"
> 
> Still my output is:
> */dev/mmcblk1p1: LABEL="efi" UUID="1084-AA42" TYPE="vfat"*
> 
> My expected output should be only:
> *vfat*
> 
> Could you guys please do the needful?

 
  I tried a simiar command line from a rock64 sbc shell
  and found that  -f2  instead of  -f3  returned only  vfat 
   

-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: How to move the scrollbar to inside the text widget

2018-06-03 Thread Cousin Stanley
moidee...@gmail.com wrote:

> I am a Newbie
> 
> I have this code
> 
> from tkinter import *
> 
> root = Tk()
> root.geometry("1200x1000+30+30")
> # width x height + x_offset + y_offset:
> T = Text(root, height=10, width=100)
> T.place(x=20, y=30)
> for i in range(40):
>T.insert(END, "This is line %d\n" % i)
> 
> # create a vertical scrollbar to the right of the listbox
> yscroll = Scrollbar(command=T.yview, orient=VERTICAL)
> T.configure(yscrollcommand=yscroll.set)
> yscroll.pack(side="right", fill="y", expand=False)
> 
> root.mainloop()
> 
> 
> The srollbar is on the window frame, is there a way I can move it to inside 
> and right edge of
> text area?
> 
> Thanks


You might try the tkinter  ScrolledText  widget 


from tkinter import *

from tkinter import scrolledtext as ST


root = Tk()

root.geometry( "1200x1000+30+30" )  # width x height + x_offset + y_offset


T = ST.ScrolledText( root, height=40, width=100, font=( 'Fixed' , 14 ) )


T.place( x = 20 , y = 30 )

for i in range( 101 ) :

   T.insert( END , "  This is line %03d\n" % i )


.
include the rest of your orignal code 
.


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: Problem: Need galileo running on debian wheezy

2018-03-02 Thread Cousin Stanley
Gene Heskett wrote:

> 
> And the rock64 doesn't have wifi hardware 
> that I know of.
>  

  I did manage to get wifi working on my rock64
  using a usb wifi dongle ordered from their store  

  It was a bit fiddly to set up, somewhat shaky 
  connection-wise, and slower than I was comfortable with
  so I went with an ethernet connection which is quick 
  and stable  


> So, is galileo shown for armhf's ?

  The galileo package information 
  doesn't explicitly mention arm 

  However, I've had no problem 
  with any other python package
  on the rock64 here  

  dpkg-print-architecture indicates that it is arm64 
  and I pull the debian stretch packages and updates from 

o http://mirrors.kernel.org/debian/ stretch main non-free contrib
  
o http://mirrors.kernel.org/debian/ stretch-updates main contrib non-free

o http://ppa.launchpad.net/ayufan/rock64-ppa/ubuntu xenial main


> The reason for posting here is that galileo 
> is supposedly written in python, 
> but don't know if 2 or 3.

  The stretch package  depends  information for galileo
  indicates it is for python3  

  $ apt-cache show galileo

Depends: python3-requests (>= 2), python3-usb (>= 1.0.0~b2), python3:any 
(>= 3.4~)



-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: Problem: Need galileo running on debian wheezy

2018-03-01 Thread Cousin Stanley
Gene Heskett wrote:

> I know its supposed to be in the debian stretch repo's.
> 
> I've been told to get a fitbit, but they don't support linux 
> of any flavor, and that leaves galileo as the possible solution?
> 
> So how should I proceed since the only stretch machine I have ATM 
> is an arm64, aka a rock64.

  The galileo package is available under debian stretch
  on my rock64  

# apt-cache policy galileo

galileo:
Installed: (none)
Candidate: 0.5.1-4
Version table:
   0.5.1-4 500
500 http://approx:/debian stretch/main arm64 Packages


   Package details 

# apt-cache show galileo


  However, I have no clue as to its usage or effectiveness 



-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: enum

2017-10-31 Thread Cousin Stanley
ast wrote:

> https://docs.python.org/3.5/library/enum.html#planet
> 
> Documentation says that the value of the enum
> members will be passed to this method.
> 
> But in that case __init__ waits for two arguments, mass
> and radius, while enum member's value is a tuple.
> 
> It seems that there is a tuple unpacking, but it is
> not documented, that's not clear
>  
  
  
I added the following code to your example
to unpack  planet.value  into mass and radius 
after first importing Enum 

from enum import Enum
 

def test_01() :

print( '\n  planet   mass   radius  gravity \n' )

for planet in Planet : 

mass , radius = planet.value

print( '  {:8s}  {:9.4E}  {:9.4E}  {:9.4E} '.format( planet.name , mass 
, radius , 
  planet.surface_gravity ) )


if __name__ == '__main__' :

test_01()


A working copy  

http://csphx.net/python/planets_enum.txt


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: Get min and max dates

2016-12-08 Thread Cousin Stanley
DFS wrote:

> 
> Not wanting to use any date parsing libraries,
> 

  If you happen reconsider date parsing libraries 
  the  strptime  function  from the  datetime  module
  might be useful 

#!/usr/bin/env python3

from datetime import datetime

dates = [ '10-Mar-1998' ,
  '20-Aug-1997' ,
  '06-Sep-2009' ,
  '23-Jan-2010' ,
  '12-Feb-2010' ,
  '05-Nov-2010' ,
  '03-Sep-2009' ,
  '07-Nov-2014' ,
  '08-Mar-2013' ]

dict_dates = { }

print( )

for this_date in dates :

dt = datetime.strptime( this_date , '%d-%b-%Y' )

sd = dt.strftime( '%Y-%m-%d' )

print( '  {0}  {1}'.format( this_date , sd ) )

dict_dates[ sd ] = this_date


min_date = min( dict_dates.keys() )

max_date = max( dict_dates.keys() )

print( '\n  {0}  {1}  min'.format( dict_dates[ min_date ] , min_date ) )

print( '\n  {0}  {1}  max'.format( dict_dates[ max_date ] , max_date ) )








































-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: Python Dice Game/Need help with my script/looping!

2016-11-03 Thread Cousin Stanley
Constantin Sorin wrote:

> Hello,I recently started to make a dice game in python.
> 
> Everything was nice and beautiful,until now.
> 
> My problem is that when I try to play and I win or lost 
> or it's equal next time it will continue only with that.
>  

  Following is a link to a version of your code
  rewritten to run using python3  

http://csphx.net/fire_dice.py.txt

  The only significant differences 
  between python2 and python3
  in your code are  

python2 . python3

 print ... print( )

 raw_input( ) ... input( )


Bob Gailer wrote: 

> 
> The proper way to handle this 
> is to put the entire body of game() 
> in a while loop.
>   
> Since the values of e and f are not changed in the loop 
> he will continue to get the same thing.
>  

  These changes are the key
  to making the program loop
  as desired  

  All other changes are mostly cosmetic  

 
  * Note *

I  am  partial to white space 
both  horizontal  and  vertical ... :-)
  

-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: Stupid question, just need a quick and dirty fix

2016-07-22 Thread Cousin Stanley
Jordan Bayless wrote:

> 
> desired = Id < 10 or Id > 133 or Id in good_ids
> 
> When I try to validate whether I passed that check, 
> I'm told there's a Name error and it's not defined 
>  

  On the outside chance that failing to define Id 
  produces the Name error, I defined Id in a for loop
  as a test for your copy/pasted code 


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

good_ids = {
2, 3, 4, 5, 6, 7, 8, 9, 12, 15, 24, 25, 26, 27, 28, 31, 34, 35, 36, 37,
38, 39, 40, 45, 50, 51, 53, 55, 56, 57, 59, 62, 65, 68, 71, 76, 78, 80,
82, 83, 87, 88, 89, 91, 93, 94, 96, 97, 101, 103, 105, 106, 107, 109,
110, 112, 113, 115, 122, 124, 125, 126, 130, 131, 132, 134, 135, 136,
137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 
151
}

test_ids = [ 1 , 10 , 128 , 42 , 137 , 444 ]

print( )

for Id in test_ids : 

desired = Id < 10  or  Id > 133  or  Id in good_ids

print( '  Id :  %4d  desired :  %s ' % ( Id , desired ) )


$ ./id_test.py

  Id : 1  desired :  True 
  Id :10  desired :  False 
  Id :   128  desired :  False 
  Id :42  desired :  False 
  Id :   137  desired :  True 
  Id :   444  desired :  True 



-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: Assignment Versus Equality

2016-06-26 Thread Cousin Stanley
Dennis Lee Bieber wrote:

> 
> but I'm sure we'd have a revolt 
> if Python comparison operators looked like:
> 
> a .eq. b
> a .ne. b
> a .gt. b .or. c .lt. d
> a .le. b .and. c .ge. d
> 

  As someone who learned fortran in the mid 1960s
  and pounded a  lot  of fortran  code in the 1970s,
  the code above seems very readable 


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: Guys, can you please share me some sites where we can practice python programs for beginners and Intermediate.

2016-06-23 Thread Cousin Stanley
DFS wrote:

> On 6/23/2016 11:11 AM, Cousin Stanley wrote:
>> DFS wrote:
>>
>>> Here's a fun one: scraping data off a website,
>>> and storing it in a SQLite database file.
>>> 
>>
>>   After testing your example code here I found
>>   that the length of the  categories  list
>>   was 1 less than the  terms  list after applying
>>   dropwords in the  terms  list comprehension 
>>
>>   The subsequent len comparison then failed
>>   and no data was inserted into the data base 
>>
>>   As a fix I added an extra category 
>>
>> category.append( 'didly' )
>>
>>   Subsequently, data was inserted
>>   with a single extra category
>>   for the  last  term in terms 
> 
> 
> Strange!  After dropwords, the list lengths match 
> for me (both are 152).
> 

  Found 153 for terms and 152 for categories,
  so I appended 1 to categories ...

> So in your table, is 'didly' now the category for the last term

> 'Rendering'?  Mine is 'Technical', as it is on the source webpage.

  Last 5 printed from the final loop 
  just before the db insert  


Passphrase , Technical
Passcode , Technical
Touchpad , Hardware
Rendering , Technical
Terms of Use , didly

> 
> I usually put list length tests in place, 
> not sure what happened here.

  Possibly a copy/paste difference
  on my end 
 

-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: Guys, can you please share me some sites where we can practice python programs for beginners and Intermediate.

2016-06-23 Thread Cousin Stanley
DFS wrote:

> Here's a fun one: scraping data off a website, 
> and storing it in a SQLite database file.
> 

  After testing your example code here I found 
  that the length of the  categories  list
  was 1 less than the  terms  list after applying
  dropwords in the  terms  list comprehension  

  The subsequent len comparison then failed
  and no data was inserted into the data base  

  As a fix I added an extra category 

category.append( 'didly' )
  
  Subsequently, data was inserted
  with a single extra category 
  for the  last  term in terms  
  

  Thanks for posting the example code 


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: [OT'ish] Is there a list as good as this for Javascript

2016-03-25 Thread Cousin Stanley


> Occasionally I have to make forays into Javascript, 
> can anyone recommend a place similar to this list 
> where Javascript questions can be asked ?


  Several years back I found 
  the newsgroup comp.lang.javascript
  to be helpful 

  However, I haven't used that group
  for some time now so don't know
  the current nature of the group 


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pygtk2 and colors

2015-07-07 Thread Cousin Stanley

 With python 2.7.5, pygtk 2.24, gtk 2.24:
 The following snippet successfully sets the line_width 
 but not the foreground color, and I can't figure-out why. 
 
 The color human-name and the result returned 
 by gtk.gdk.color_parse are correct. Clues? Thanks.
 
 self.gc.set_line_attributes(myclass.board_line_width, gtk.gdk.LINE_SOLID,

 gtk.gdk.CAP_ROUND, gtk.gdk.JOIN_BEVEL)

 fg = gtk.gdk.color_parse(myclass.board_foreground)

 self.gc.set_foreground(fg)


  You might try  

self.set_rgb_fg_color( fg ) 


  Example from ... 

http://www.linuxplanet.com/linuxplanet/tutorials/6750/2/

 

-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Classic OOP in Python

2015-06-18 Thread Cousin Stanley

 
 python -m doctest application.py
 
 And from there, I would build up extra doc tests
 

An extra doc test  

  that fails 


#!/usr/bin/env python


NewsGroup  comp.lang.python 
Subject .. Classic OOP in Python
Date . 2015-06-17
Post_By .. Steven D'Aprano
Edit_By .. Stanley C. Kitching


def bracket( s ) :

Return string s bracketed in parentheses.

 bracket( Hello )
'(Hello)'

 bracket( Yo Mama is a Perl Monkey )
'(Yo Mama is a Java Monkey')



return (%s) % s


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python Worst Practices

2015-02-28 Thread Cousin Stanley

 From :  Tim Chase

 A quick google-and-tally for languages 
 and their corresponding number of keywords:
 

  re-sorted  

 21 :  Lua 
 31 :  Python2.x 
 33 :  Python3.x 
 33 :  C 
 37 :  Pike 
 40 :  Perl 
 40 :  Ruby 
 50 :  Java 
 54 :  Pascal 
 67 :  PHP 
 77 :  C# 
 86 :  C++ 


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pyqtgraph window position

2015-02-13 Thread Cousin Stanley

 I can control the size of my pyqtgraph window below with 'resize'.

 But how can I control the position on the screen?
 

  Also, try  

  w.setGeometry( x_pos , y_pos , width , height )


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pyqtgraph window position

2015-02-13 Thread Cousin Stanley

 I can control the size of my pyqtgraph window below
 with 'resize'.

 But how can I control the position on the screen ?
 
 import pyqtgraph as pg
 
 w = pg.GraphicsWindow()
 w.resize(250,400)
 
 for i in range(4):
 w.addPlot(0, i)
 
 def onClick(event):
 but=event.button()
 print(but: ,but)
 
 w.scene().sigMouseClicked.connect(onClick)

  try  

  pos_x = 300
  pos_y = 400

  w.move( pos_x , pos_y )


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Cairo module

2015-02-04 Thread Cousin Stanley


 You might consider using python-imaging
 to display the image after writing it
 from cairo 
 
 import image

  import statement should be  

  import Image

  note uppercase I 


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Cairo module

2015-02-04 Thread Cousin Stanley

 
 Could matplotlib be used to show the image?

  You might consider using python-imaging
  to display the image after writing it 
  from cairo  

  import image
  
  surface.write_to_png ( x_surface.png ) 

  img = Image.open( x_surface.png )

  img.show( command = 'display' )


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Beginner question - class definition error

2015-01-28 Thread Cousin Stanley

 from kivy.app import App
 from kivy.uix.label import Label
 
 class MyApp(App):
   def build(self):
 return Label(text='Hello World')
 
   if __name__ == '__main__':
 MyApp().run()

 

 I get this error when I run it:
 

 Traceback (most recent call last):
   File MinimalApplication.py, line 7, in module
 class MyApp(App):
   File MinimalApplication.py, line 12, in MyApp
 MyApp().run()
 NameError: name 'MyApp' is not defined

 How can I fix this please?
 
  Try removing beginning indentation 
  from 

if __name__ == '__main__': 
  
if __name__ == '__main__':


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Glade/Python - positioning main window at startup

2014-12-30 Thread Cousin Stanley

 
 Problem: Can anyone help me find settings (either in Glade or elsewhere) 
 which will start the application window with the application window center 
 aligned with the desktop center ?

  You might try the following entry
  in your  .glade  file  

 property name=window_positioncenter/property

-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pack circles into a partial annulus

2014-11-20 Thread Cousin Stanley

 I need to pack circles into a partial annulus ie part of a larger circle
 bounded by two radii and angles of  say 18  90. 

  You might take a look at Descartes Circle Theorem  

http://en.wikipedia.org/wiki/Descartes'_theorem

  Blub from google search 

In geometry, Descartes' theorem states that 
for every four kissing, or mutually tangent, circles, 
the radii of the circles satisfy a certain quadratic equation. 

By solving this equation, one can construct a fourth circle 
tangent to three given, mutually tangent circles.

  There is a screen saver in Debian Linux
  named Apollonian that uses this algorihm
  packing smaller circles into a larger circle 

  The C source code for this screen saver 
  is available under Debian 


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Dictionaries with variable default.

2014-11-04 Thread Cousin Stanley

 So How should I call this:
 
 class ...dict(dict):
 def __init__(self, fun):
 self.fun = fun
 
 def __missing__(self, key):
 return self.fun(key)

  I don't know how you should,
  but I tried the following 
  which seems to work  

class KeyPlusOne( dict ) :
def __missing__( self , key ) : 
return ( 2 * key ) + 1 

kp1 = KeyPlusOne()

d   = { }

for n in range( 11 ) :  
d[ n ] = kp1[ n ]

print '\n   key :  value \n'

for key , value in d.iteritems() : 
print '%2d :  %2d' % ( key , value )


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [ANN] dbf v0.96 is released

2014-10-28 Thread Cousin Stanley

 
 dbf
 ===
 
 dbf (also known as python dbase) is a module 
 for reading/writing dBase III, FP, VFP, 
 and Clipper .dbf database files.
 

  Available via PyPI at ?

https://pypi.python.org/pypi/dbf/0.96.001


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Top down Python

2014-02-12 Thread Cousin Stanley

 
 3) Create terminal window with size 64x20 
 (which, IMO, is tiny)
  

  Maybe  

64 characters x 20 lines

-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: need to print seconds from the epoch including the millisecond

2013-12-30 Thread Cousin Stanley

 On 30/12/2013 12:16, matt.doolittl...@gmail.com wrote:
 

 thanks a bunch.  the %.6f  was the cure.  
 can you please point me to the doc for formatting time?  
 Thanks!


 Would you please read and action this 
 https://wiki.python.org/moin/GoogleGroupsPython 
 to prevent us seeing the double line spacing above, thanks.

  You might consider either turning off an option
  in your news client for including message in reply
  and/or snipping all but a few lines for context
  to prevent us from seeing the double line spacing
  all over again  :-)
 

-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: need to print seconds from the epoch including the millisecond

2013-12-30 Thread Cousin Stanley

 You might consider either turning off an option
 in your news client for including message in reply
 and/or snipping all but a few lines for context
 to prevent us from seeing the double line spacing
 all over again  :-)
 
 Great idea, but one slight snag is 
 the poster then doesn't see how many newlines 
 they've managed to insert using their superb tool.

  A few lines to illustrate along with your
  standard reference  might  be enough   

https://wiki.python.org/moin/GoogleGroupsPython

 I am on Ubuntu 12.10.   I am still working with the 2 decimal places.
 

 
 Sometime ago i had this issue and I forget how i solved it. maybe i used
 

 
 datetime? thanks!
 

-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Experiences/guidance on teaching Python as a first programming language

2013-12-17 Thread Cousin Stanley



Rick Johnson rantingrickjohn...@gmail.com wrote:

 Dovetails are nothing more than sadistic nostalgia --
 they give old men a chubby and young men a nightmare.



There is nothing more satisfying than cutting a set of dovetails by hand
and having them glide together like silk, the first time you test-fit
them, with no daylight visible anywhere.


  This dove-tailer understands Rapid Application Development 

 http://woodwork.ars-informatica.ca/tool.php?art=dovetail_video
 Frank Klausz's three-minute dovetails using a bow saw

--
Stanley C. Kitching
Human Being
Phoenix, Arizona 



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

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


Re: [newbie] struggling wth tkinter

2013-12-08 Thread Cousin Stanley

 
 This is what I get:

 Traceback (most recent call last):
 File ./feet2meters.py, line 2, in module
 from tkinter import *
 File /home/jean/tkinter.py, line 2, in module
 import Tkinter as tk
 ImportError: No module named Tkinter
 

  From your original post I only changed the she-bang line
  from python to python3 

#!/usr/bin/env python3

  and the import lines remained 
  as you originally posted 
  which are appropriate for python3  

from tkinter import *
from tkinter import ttk

  The traceback above shows an import statement
  that is different from the one you originally posted 
  which would be ok in python2 but not python3  

import Tkinter as tk


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [newbie] struggling wth tkinter

2013-12-07 Thread Cousin Stanley

  
 The only thing I see when running it is a little popup 
 with Click mouse here to quit which works as expected 
 but always shows the following error-message. 

  This seems to be left over from an earlier post
  where you were binding a mouse event to a tk label

  Did you create a  new  file ?


 However the main window which should let you enter the
 numbers is not shown.
 
 This is the quit error message:
 Traceback (most recent call last):
 File ./feet2meters.py, line 3, in module
 from tkinter import ttk
 ImportError: cannot import name ttk
 
 This is the code:
  

  If I copy/paste your code as posted
  into a new file named ftom.py
  and change the she-bang line
  as follows 

#!/usr/bin/env python3

  Then from the command line 

python3 ftom.py

  Your code runs as expected
  using python 3.2.3 


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python 3.3 repr

2013-11-15 Thread Cousin Stanley

 
 We don't say len({42: None}) to discover 
 that the dict requires 136 bytes, 
 why would you use len(heåvy) 
 to learn that it uses 23 bytes ?
 

#!/usr/bin/env python
# -*- coding: utf-8 -*-


illustrate the difference in length of python objects
and the size of their system storage


import sys

s = heåvy

d = { 42 :  None }

print
print '   s :  %s' % s
print 'len( s ) :  %d' % len( s )
print '  sys.getsizeof( s ) :  %s ' % sys.getsizeof( s )
print
print
print '   d : ' , d
print 'len( d ) :  %d' % len( d )
print '  sys.getsizeof( d ) :  %d ' % sys.getsizeof( d )


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: The meaning of doubt, was Re: Python Basic Doubt

2013-08-10 Thread Cousin Stanley
Peter Otten wrote:

 
 doubt
  

  Oh bother, said Pooh, what's in a word ?

http://en.wikipedia.org/wiki/Curry

https://pypi.python.org/pypi/curry/

http://en.wikipedia.org/wiki/Currying


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: [tkinter] trouble running imported modules in main program

2013-08-07 Thread Cousin Stanley
Terry Reedy wrote:

 Code comments : 
 
   double and triple spacing code 
   make it painful to read, 

Not for everyone  :-)

I prefer  mostly  double-spaced code
in any language  
 
   especially in a 10 line box.

Agree, but the 10 line box 
would not be used for routine
code editing and viewing 
and could be made larger 
to accomodate viewing code
posted online 


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: Can someone suggest better resources for learning sqlite3? I wanted to use the Python library but I don't know sql.

2013-08-03 Thread Cousin Stanley
Aseem Bansal wrote:

 
 Can someone suggest me better resources 
 for learning sql/sqlite3 ?

  http://docs.python.org/3/library/sqlite3.html

  http://wiki.python.org/moin/DbApiCheatSheet

  http://www.w3schools.com/sql/default.asp

  http://www.sqlcourse.com/index.html

  http://sqlite.org/docs.html

  http://zetcode.com/db/sqlite/  
 


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: Looking for a name for a deployment framework...

2013-06-24 Thread Cousin Stanley
jonathan.slend...@gmail.com wrote:

 Any suggestions for a good name, 
 for a framework that does 
 automatic server deployments ?

  asdf :  automatic server deployment framework


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: python-noob - which container is appropriate for later exporting into mySql + matplotlib ?

2013-04-14 Thread Cousin Stanley
Steven D'Aprano wrote:

 On Fri, 12 Apr 2013 23:26:05 +, Cousin Stanley wrote:

   The firefox browser keeps different sqlite database files for various
   uses 

 Yes, and I *really* wish they wouldn't. 

 It's my number 1 cause of major problems with Firefox.

  Problems with software of any flavor,
  especially software that is used regularly
  and upon which we are somewhat dependent,
  are always a source of frustration  

  My own personal use of firefox over the years
  has been limited as I have not used it
  for my primary browser and have not experienced
  any problems with its bookmarks  

  I use opera as my primary browser
  and would very much like to convert
  the plain-vanilla bookmark.adr file
  that opera uses into an sqlite data base
  for diversity in bookmark searches 
  that would be independent of reglular
  browser usage  

$ grep FOLDER ~/.opera/bookmarks.adr | wc -l
631

$ grep URL ~/.opera/bookmarks.adr | wc -l
14944


 http://kb.mozillazine.org/Bookmarks_history_and_toolbar_buttons_not_working_-_Firefox

  Although there have been many reports entailing corruption 
  of the places.sqlite file, it isn't apparent to me 
  from the link above that sqlite itself is the culprit  

  Could the complexity/bugginess of the firefox code
  possibly be the cause instead ?

If Firefox works normally when you first open it 
 after starting up the computer but multiple symptoms arise 
 after you close and later reopen Firefox, it's likely 
 that a Firefox process from a previous session 
 did not close properly and the Places database 
 ( places.sqlite file ) is locked.


  If you check the headers of any of my posts here
  you will find that I post with a python-based news client
  named XPN that also uses sqlite for persistent storage,
  one sqlite database for each different newsgroup  

  I've used xpn daily for many years and have never experienced 
  a corrupted sqlite database file 

firefox + sqlite  buggy ? ... :-(

 python + sqlite  ok, hooray  :-)


 Using a database for such lightweight data as bookmarks is, in my 
 opinion, gross overkill and adds to the complexity of Firefox. 

 More complexity leads to more bugs, e.g.:

   https://bugzilla.mozilla.org/show_bug.cgi?id=465684#c11

   https://bugzilla.mozilla.org/show_bug.cgi?id=431558

  These pages show problems that are 4 and 5 years old
  from 2008  2009 and are marked as Status: RESOLVED FIXED 
  at the top of the page  

  Are you still having firefox bookmark problems today ?


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: python-noob - which container is appropriate for later exporting into mySql + matplotlib ?

2013-04-12 Thread Cousin Stanley
someone wrote:

 As you can see, on my system I 
 had to use:

   print row[0] , row[1]

 instead of:

   print row[ 'xtime' ] , row[ 'col4' ]

 I'm not sure exactly why

  The magic there is setting up the row_factory 
  after the database connection  

dbc = DBM.connect( 'some.sql3' )

dbc.row_factory = DBM.Row

 I don't really know what's the difference 
 between sqlite3 and mysql...
 
  MySQL is used through a client/server system
  where the db server is always running 
  and client processes submit requests to it
  in the form of sql statements  

  SQLite is used as a stand-alone single process 
  with no external server involved 
  
  Both speak sql but there are some differences
  mostly in data base connection strings 
  and data type declarations 

  Basic sql selection is  

select these fields 
from   these files
where  these conditions are met 

  And that part of sql doesn't vary much
  among different data base managers 


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: python-noob - which container is appropriate for later exporting into mySql + matplotlib ?

2013-04-12 Thread Cousin Stanley
someone wrote:

 
 So SQLite is very good for practicing
 

  Yes it is but it is also very good 
  for much more than just practice  

  Check the wikipedia info  

http://en.wikipedia.org/wiki/Sqlite

It is arguably the most widely deployed database engine, 
 as it is used today by several widespread browsers, 
 operating systems, and embedded systems, among others

  The firefox browser keeps different sqlite database files 
  for various uses  

  If you use firefox check its default directory 
  and you will see several files with .sqlite  
  file type extensions 

  Under debian debian linux  

~/.mozilla/firefox/*.default

  Many programmers, including pythonistas,
  use sqlite for a convenient and persistent 
  data store where data can be stashed now 
  and used later in many different ways 
  through the diversity of sql selections 


 Thanks again  

  You're welcome 

 I just love this python language

  Me too  :-)


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: python-noob - which container is appropriate for later exporting into mySql + matplotlib ?

2013-04-11 Thread Cousin Stanley
someone wrote:

 
 I want to put this table into an appropriate container 
 such that afterwards I want to:

 1) Put the data into a mySql-table
 

  You might consider using sqlite3 as a database manager
  since it is  batteries included  with python 

  The stand-alone sqlite interpreter can first be used
  to create an empty database named some.sql3 
  and create a table named  xdata  in that data base  

sqlite3 some.sql3 '.read xdata_create.sql'

  where the file  xdata_create.sql  contains 

create table xdata
(
 xdate  integer , 
 xtime  integer , 
 col1   real , 
 col2   integer , 
 col3   integer , 
 col4   real , 
 col5   integer , 
 col6   integer 
) ;


# ---

  The csv data file can then be inserted into the xdata table
  in the  some.sql3  database via python  

import sqlite3 as DBM

fs = open( 'some.csv' ) 

ls = [ ]

dbc = DBN.connect( 'some.sql3' )

cur = dbc.cursor()

sql = 'insert into xdata values( ? , ? , ? , ? , ? , ? , ? , ? )'

for row in fs : 

dt, col1, col2, col3, col4,col5, col6 = row.strip().split(',' )

xdate , xtime = dt.split( 'T' )

xtuple = ( xdate, xtime, col1, col2, col3, col4, col5, col6 )

cur.execute( sql , xtuple )

fs.close()

dbc.commit()

dbc.close()


# 

# python data selection example
# for column 4 between 8 and 9


import sqlite3 as DBM

fs = open( 'some.csv' ) 

ls = [ ]

dbc = DBM.connect( 'some.sql3' )

dbc.row_factory = DBM.Row

cur = dbc.cursor()

list_sql = [ 
  'select xtime , col4' , 
  'from   xdata' , 
  'where  xtime = 8  and  xtime = 9 ; ' ]

str_sql = '\n'.join( list_sql )

cur.execute( str_sql )

for row in cur : 

print row[ 'xtime' ] , row[ 'col4' ]

fs.close()

dbc.close()


# 

  You can be creative with the data selections
  and pass them off to be plotted as needed 

  If mysql is used instead of sqlite3
  you should only have to monkey with 
  the data type declarations in xdata_create.sql
  and the  dbc.connect  strings in the python code 


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: python-noob - which container is appropriate for later exporting into mySql + matplotlib ?

2013-04-11 Thread Cousin Stanley
Cousin Stanley wrote:

   The stand-alone sqlite interpreter can first be used
   to create an empty database named some.sql3 
   and create a table named  xdata  in that data base  

 sqlite3 some.sql3 '.read xdata_create.sql'

  This step can also be done in python
  without using the stand-alone sqlite interpreter 


# -

import sqlite3 as DBM

dbc = DBM.connect( 'some.sql3' )

cur = dbc.cursor()

list_sql = [ 
  'create table if not exists xdata ' , 
  '( ' , 
  '  xdate  integer , ' , 
  '  xtime  integer , ' , 
  '  col1   real, ' , 
  '  col2   integer , ' , 
  '  col3   integer , ' , 
  '  col4   real, ' , 
  '  col5   integer , ' , 
  '  col6   integer   ' , 
  ') ; ' ]

str_sql = '\n'.join( list_sql ) 

cur.execute( str_sql )

dbc.commit()

dbc.close()


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: python-noob - which container is appropriate for later exporting into mySql + matplotlib ?

2013-04-10 Thread Cousin Stanley
someone wrote:

 
 I want to put this table into an appropriate container 
 such that afterwards I want to:

 1) Put the data into a mySql-table
 2) Be able to easily plot column 1 vs. either of the other columns 
 using matplotlib etc...
 

  Consider editing your data file 
  into a csv file named someone.csv 

20130315T071500,39000.,10,26,48000.,1,40
20130315T071501,39000.,10,26,48000.,2,42
20130315T071501,39000.,10,26,47520.,15,69
20130315T071501,39000.,10,26,47160.,1,70
20130315T071501,39000.,10,26,47000.,1,72
20130315T071501,39000.,10,26,47000.,2,81
20130315T071501,39000.,10,26,47000.,6,85
20130315T071501,39000.,10,26,46520.,10,95
20130315T071501,43000.,10,36,46520.,10,95
20130315T071501,43200.,4,43,46520.,10,104
20130315T071501,44040.,1,45,46520.,10,108
20130315T071501,44080.,3,48,46520.,10,109
20130315T071501,44080.,3,48,46520.,11,113
20130315T071501,44080.,3,48,46400.,2,131
20130315T071501,45080.,1,51,46400.,2,145
20130315T071501,45080.,1,51,46200.,1,147
20130315T071501,45080.,1,60,46120.,1,182
20130315T071501,45520.,1,65,46120.,1,225
20130315T071501,45520.,1,73,46120.,2,247
20130315T08,45760.,1,133,46120.,2,378
20130315T080241,45760.,2,199,46120.,2,453
20130315T080945,45760.,3,217,46120.,2,456
20130315T081103,45760.,3,217,46080.,1,457
20130315T081105,45760.,3,218,46080.,2,458
20130315T081106,45760.,4,222,46080.,2,458
20130315T081107,45800.,1,229,46080.,2,458
20130315T082754,45800.,8,266,46080.,2,514

# ---
#
# The csv data can be loaded using the csv module
#
# named tuples might be used
# for convenience to access
# individual columns


#!/usr/bin/env python

import csv

from collections import namedtuple as NT

file_source = open( 'someone.ssv' )

# --- individual column names ---

nt = NT( 'csv_data' , 'date time col1 col2 col3 col4 col5 col6' )

list_tuples = [ ]

for this_row in csv.reader( file_source ) : 

# unpack the current row 

zed , one , two , tre , fur , fiv , six = this_row  

# split the date and time

d , t = zed.split( 'T' )

# convert individual columns in row to a named tuple

this_tuple = nt( d , 
 t , 
 float( one ) , 
 int( two ) , 
 int( tre ) , 
 float( fur ) , 
 int( fiv ) , 
 int( six ) )

# save the current named tuple into a list

list_tuples.append( this_tuple )

# update_data_base( this_tuple )  
#  or 
# update_data_base( choose individual columns )


# individual elements of the named tuples
# can be accessed by name 
# 
# this might be convenient for settup up
# data for plots of diffeent columns


print

for row in list_tuples : 

print '  ' , row.date , row.time , row.col1 , row.col3 , row.col4

file_source.close()


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: can anyone help me in developing a simple webpage in jinja2

2013-04-07 Thread Cousin Stanley
Satabdi Mukherjee wrote:

 i am a rookie in python and i am trying 
 to develop a simple webpage using jinja2. 

 can anyone please help me how to do that  

  You might try using your jinja template
  with named tuples 

# ---

from jinja2 import Template

from collections import namedtuple as NT

nt = NT( 'Navigation' , 'href  caption' )

n1 = nt( 'http://python.org' , 'python' )
n2 = nt( 'http://cython.org' , 'cython' )
n3 = nt( 'http://jython.org' , 'jython' )
n4 = nt( 'http://pypy.org/'  , 'pypy' )

nav = ( n1 , n2 , n3 , n4 )

tmpl = Template( '''\
!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01//EN
html lang=en
head
titleMy Webpage/title
/head
body
ul id=navigation
{% for url , caption  in navigation %}
lia href={{ url }}{{ caption }}/a/li
{% endfor %}
/ul

h1My Webpage/h1
{{ a_variable }}
/body
/html
''' )
 
print tmpl.render(
variable   = 'Navigation' ,  navigation = nav )


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: Performance of int/long in Python 3

2013-03-26 Thread Cousin Stanley
Chris Angelico wrote:

 Interesting, so your 3.x sum() is optimizing something somewhere.
 Strange. Are we both running the same Python ? 
 
 I got those from apt-get
 

  I also installed python here under Debian Wheezy
  via apt-get and our versions look to be the same 

  -sk-

2.7.3 (default, Jan  2 2013, 16:53:07)   [GCC 4.7.2]

3.2.3 (default, Feb 20 2013, 17:02:41)   [GCC 4.7.2]  

CPU :  Intel(R) Celeron(R) D CPU 3.33GHz


  -ca-

2.7.3 (default, Jan  2 2013, 13:56:14)   [GCC 4.7.2]

3.2.3 (default, Feb 20 2013, 14:44:27)   [GCC 4.7.2]

CPU :  ???


  Could differences in underlying CPU architecture  
  lead to our differing python integer results ?
  


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: Performance of int/long in Python 3

2013-03-26 Thread Cousin Stanley

Chris Angelico wrote:

 Once again, Py3 is slower on small integers than Py2. 

  Chris Angelico  
  Ubuntu Karmic. 
  Pentium(R) Dual-Core  CPU E6500  @ 2.93GHz.

  python  inline  range_sum  forloop  forloop_offset

  2.6.4   2.7050  2.6492  6.5877  16.5168 

  3.1.1   4.4453  4.3731 12.4834  13.5001

  You do seem to have a slight py3 improvement
  under ubuntu for the  forloop_offset  case 


 So where's the difference with your system ? 

  CPU 


 This is really weird ! 

  Yep ...


 I assume you can repeat the tests 
 and get the same result every time ?

  Yes 

  First lines of numbers below are from yesterday
  while second lines are from today 

  Stanley C. Kitching
  Debian Wheezy
  Intel(R) Celeron(R) D CPU 3.33GH  Single Core

  python  inline  range_sum  forloop  forloop_offset

  2.7.3   3.1359  3.0725 9.0778   15.6475
  2.7.3   3.0382  3.1452 9.8799   16.8579

  3.2.3   2.8226  2.807413.47624  13.6430 
  3.2.3   2.8331  2.822813.54151  13.8716


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: Performance of int/long in Python 3

2013-03-25 Thread Cousin Stanley

Chris Angelico wrote:

 The Python 3 merge of int and long has effectively penalized
 small-number arithmetic by removing an optimization.
 
 The cost is clear. 
 

  The cost isn't quite as clear 
  under Debian Wheezy here 

  Stanley C. Kitching
  Debian Wheezy

  python  inline  range_sum  forloop  forloop_offset

  2.7.3   3.1359  3.0725 9.0778   15.6475

  3.2.3   2.8226  2.807413.47624  13.6430 


# -

  Chris Angelico
  Debian Wheezy

  python  inline  range_sum  forloop  forloop_offset

  2.7.3   1.9276  1.9341 5.1463   5.1346

  3.2.3   2.8841  2.6586 7.6602   8.1182


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: Import Json web data source to xls or csv

2013-02-19 Thread Cousin Stanley
io wrote:

 
 How do i manage to read the data source 
 from http://bitcoincharts.com/t/markets.json
 
 I just need currency, symbol, bid, ask, volume
 

  Following is a simple way load the json data
  and write the desired fields to a  .csv  file


import json
import urllib

url= http://bitcoincharts.com/t/markets.json;

response   = urllib.urlopen( url ) ;

data   = json.loads( response.read() )

list_dicts = [ dict( this ) for this in data ]

f  = open( 'markets.csv' , 'w' ) 

for this_dict in list_dicts :

currency  = str( this_dict[ 'currency'] )
symbol= str( this_dict[ 'symbol' ] )
bid   = str( this_dict[ 'bid' ] )
ask   = str( this_dict[ 'ask' ] )
volume= str( this_dict[ 'volume' ] )

this_list = [ currency , symbol , bid , ask , volume ]

this_str  = ','.join( this_list )

f.write( this_str + '\n' )

f.close()
  

-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: Fast forward-backward (write-read)

2012-10-23 Thread Cousin Stanley
Virgil Stokes wrote:

 Not sure about tac --- could you provide more details on this 
 and/or a simple example of how it could be used for fast reversed 
 reading of a data file ?

  tac is available as a command under linux  

  $ whatis tac
  tac (1) - concatenate and print files in reverse

  $ whereis tac
  tac: /usr/bin/tac /usr/bin/X11/tac /usr/share/man/man1/tac.1.gz

  $ man tac

  SYNOPSIS
tac [OPTION]... [FILE]...

  DESCRIPTION

Write each FILE to standard output, last line first.  

With no FILE, or when FILE is -, read standard input.


  I only know that the  tac  command exists
  but have never used it myself 


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: Eclipse and the Python plugin

2012-08-03 Thread Cousin Stanley
lipska the kat wrote:

 
 I can now create, debug and test a simple IRC server 
 written in Java and an IRC Bot that I am attempting 
 to build in Python 
 

  For a bit of inspiration python-irc-bot-wise
  you might look at supybot  

  It's currently available in debian wheezy
  so probably also available in ubuntu 

# apt-cache show supybot

  A few years back I ran it 24/7 for several months
  on a very low spec debian box and was impressed
  with its performance, configurability, and 
  plugin usage  

  However, I haven't looked at or used
  recent versions 
  

-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: [newbie] problem with data (different behaviour between batch and interactive use)

2012-06-27 Thread Cousin Stanley
Jean Dupont wrote:

 I have some data which is presented 
 in the following format to me :

 +3.874693E-01,+9.999889E-03,+9.91E+37,+1.876595E+04,+3.994000E+04

 I'm only interested in the first two fields i.e.

 +3.874693E-01,+9.999889E-03
  

  The following program will read lines
  of comma-separated data from a text file 
  and add each line as a row in a list of lists  

  The first two items in each row
  could be accessed by their indexes  

# --

#!/usr/bin/env python

fsource = open( 'edata.txt' )

ltarget = [ ]

for this_line in fsource : 

this_list = this_line.strip().split( ',' )

that_list = [ float( x ) for x in this_list ]

ltarget.append( that_list ) 


for this_row in ltarget : 

print '  %e' % this_row[ 0 ] 
print '  %e' % this_row[ 1 ]
print

fsource.close()


# -
# 
# edata.txt

+3.874693E01,+9.999889E03,+9.91E+37,+1.876595E+04,+3.994000E+04
1e01,2e02,3e03,4e04,5e05
5e-05,4e-04,3e-03,2e-02,1e-01


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: python for android anyone?

2012-05-28 Thread Cousin Stanley

rusi wrote:

 
 Any specific tips will of course be welcome 
 but also the general idea
 -- is android really python friendly (yet)?

  You might take a look at Kivy  

http://kivy.org/

  It is built with Cython ( C extensions for Python ) 
   and, in order to create apps, Python knowledge 
   is required.

  The platforms currently supported are Linux, Windows, 
  Mac OS X and Android.

  The gallery is impressive  

http://kivy.org/#gallery

  
  I have very limited experience with Kivy
  using Debian Linux as the development platform
  and installing a couple of simple demo apps 
  on an ArchOS tablet running Android ICS 

  Back at the first of this month I had problems
  trying to build android packages using 
  the newest versions of the android sdk / ndk packages 
  on Debian  

  Advice at the time was to drop back a version and try again 
  or wait for kivy versioning to catch up a bit  
 

-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: Questions about compiled Python (beginner)

2012-01-29 Thread Cousin Stanley


  This short article provides some basic information
  about  .pyc  and  .pyo  files 

  http://www.network-theory.co.uk/docs/pytut/CompiledPythonfiles.html


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: What I do and do not know about installing Python on Win 7 with regard to IDLE.

2011-11-21 Thread Cousin Stanley
W. eWatson wrote:

 My criterion for success is that it puts IDLE as a choice for editor
 on the menu produced with a right-click on a py file. 
 
 So far no response on this has solved the problem.
 

  As an alternative you might consider adding a short-cut to IDLE 
  to the  Send To  directory if that option is still available
  under windows 7  

  That would seem  almost  as handy 
  only moving the mouse one more time
  to roll out the  Send To  target menu  
  before the final click to launch 


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: learning another programing language

2011-07-24 Thread Cousin Stanley

Benjamin Gregg wrote:

 
 I want to know is there any good tutorials or tips 
 for learning C++/java after using python?

  You might find the following site
  to be useful java information 

http://mindprod.com/jgloss/jgloss.html


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: python xauth

2011-07-11 Thread Cousin Stanley

kracekumar ramaraju wrote:

 I am looking to use xauth in python ?

 It is for my command line process,
 I would like to have few examples 
 and resources.

A simple example 

 import subprocess as SP
 
 proc = [ 'xauth' , 'list' , ':0' ]
 
 pipe = SP.Popen( proc , stdout = SP.PIPE )
 
 data = pipe.stdout.readline()
 
 print '\n' , data

em1dsq/unix:0  MIT-MAGIC-COOKIE-1  10a533afab15a57c8704a16d1dc5bb12


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: web browsing short cut

2011-07-07 Thread Cousin Stanley

Chris Angelico wrote:

 frameset rows=50%,50%
   frameset cols=50%,50%
 frame src=http://blah/blah;
 frame src=http://another/blah;
   /frameset
   frameset cols=50%,50%
 frame src=http://third/blah;
 frame src=http://final/blah;
   /frameset
 /frameset

 That should divide your screen four ways 
 ( if I haven't botched my HTML
   - ages since I've used frames ).

  html !botched  :-)

  An example of your frameset code 

http://csphx.net/fourpy.htm


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: Automatic placement of a text box? ie empty legend [matplotlib]

2011-06-29 Thread Cousin Stanley

Christopher Barrington-Leigh wrote:

 I'd like to have the Sample A box place itself 
 in the optimal empty space, so as not to overlay 
 any graphing elements (if possible):
 

  A simple alternative might be to place the label
  just outside of the plot region either at the top 
  or the bottom of the plot instead of finding 
  an open area in which to place the label 

def extremes( x1 , y1 , x2 , y2 ) :

min_x1 = min( x1 )
min_y1 = min( y1 )

max_x1 = max( x1 )
max_y1 = max( y1 )

min_x2 = min( x2 )
min_y2 = min( y2 )

max_x2 = max( x2 )
max_y2 = max( y2 )

min_x  = min( min_x1 , min_x2 )
min_y  = min( min_y1 , min_y2 )

max_x  = max( max_x1 , max_x2 )
max_y  = max( max_y1 , max_y2 )

aminx  = min_x
aminy  = min_y - 1.4

amaxx  = max_x
amaxy  = max_y + 1.4

return aminx , aminy , amaxx , amaxy


# bump up the plot size a bit

fig = plt.figure( 1 , figsize = ( 6 , 6 ) )



aminx , aminy , amaxx , amaxy = extremes( x1 , y1 , x2 , y2 )



# label at top center 

ax.text( 0 , amaxy , Sample A , ha = center , va = center , 
 size = 16 , bbox = bbox_props )


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: NEED HELP-process words in a text file

2011-06-26 Thread Cousin Stanley

Steven D'Aprano wrote:

 If ONE word in uppercase is read in a SLIGHTLY louder voice, 
 then naturally it doesn't take much imagination TO READ 
 EVEN QUITE SHORT PASSAGES OF UNINTERRUPTED UPPERCASE WORDS 
 AS SHOUTING LOUDLY -- 

  And it doesn't take much of a reality check
  through my own personal faculties to realize 
  that my newsreader is not currently piped
  into a text-to-speech process and is not
  emitting any sound  :-)

  Even then, there most likely wouldn't be 
  any extra emphasis on words written 
  in all capital letters unless the tts process
  was specifically altered to do so  

 regardless of the poor design of programming languages 
 in the 60s and 70s.

  I don't think programming languages of that era
  were poorly designed and especially not just because
  they happened to be coded in text with all caps  


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: NEED HELP-process words in a text file

2011-06-24 Thread Cousin Stanley

Chris Rebert wrote:

 Netiquette comment: Please avoid SHOUTING 
 

  The brilliant beam of light that first thought  
  capitilized words amounted to shouting
  never programmed cobol, fortran, or pl/1
  in the 1960s or 1970s  :-) 

  How or why this behavior was cultivated
  and continues to spread is mind boggling 
  to me  :-)


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: NEED HELP-process words in a text file

2011-06-24 Thread Cousin Stanley

John Gordon wrote:

 In iu2ns9$kkq$1...@dont-email.me Cousin Stanley cousinstan...@gmail.com 
 writes:

   How or why this behavior was cultivated
   and continues to spread is mind boggling 

 The behavior of writing in all caps, 
 or the behavior of equating such writing with shouting ?

  The latter  

equating writing in all caps with shouting 

  It wobbles the mind.
 

-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: pyGTK identify a button

2011-05-25 Thread Cousin Stanley
Tracubik wrote:

 Hi all,
 i'm trying to write a simple windows with two button in GTK, 
 i need a  way to identify wich button is pressed.
 

#!/usr/bin/env python

import gtk

def console_display( button , args ) :

a0 , a1 , a2 = args

print '%s  %s %s ' % ( a0 , a1 , a2 )


window = gtk.Window()

window.set_title( gtk.buttons.01 )
  
window.set_size_request( 300 , -1 )

window.set_position( gtk.WIN_POS_CENTER )

window.connect( destroy , gtk.main_quit )


# Create VBox and add in Window

vbox = gtk.VBox()

window.add( vbox )


# Create buttons

dict_buttons = {
12   :  [ 'OneTwo' , 'Buckle ' , 'My Shoe' ] ,
34   :  [ 'TreFor' , 'Shut   ' , 'The Door' ] ,
56   :  [ 'FivSix' , 'Pick   ' , 'Up Sticks' ] ,
78   :  [ 'SvnAte' , 'Lay' , 'Them Straight' ] ,
910  :  [ 'NinTen' , 'Big' , 'Fat Hen' ] }

list_keys = dict_buttons.keys()

list_keys.sort()

for this_button in list_keys :

this_name = dict_buttons[ this_button ][ 0 ]

b = gtk.Button( this_name )

b.set_name( this_name )

b.connect( clicked , console_display , dict_buttons[ this_button ] )

vbox.pack_start( b )


window.show_all()

gtk.main()


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Only 7 Years

2011-03-29 Thread Cousin Stanley

  On May 8, 2004 I posted a note[1] here in comp.lang.python
  with a subject line of  Lost : Plot_Demo  looking for
  a small 2d plot program that I had seen, misplaced,
  and which I thought came along as a demo with a PYTHON 
  installation 

  This morning after rooting about in an old JYTHON demo dir
  I found the program in  Demo/awt/Graph.py  along with
  a comment that I had edited the file about 7 months
  before posting here looking for it ! 

  It's a very nice demo with a single text box
  to enter simple functions to be parsed and plotted 

  At least it's good to know that I'm only forgetful
  and not totally daft  :-)

  [1]
  http://groups.google.com/group/comp.lang.python  
/browse_thread/thread/54d4b716bfbdcb9c/f3e48b33fcf4e1d3

-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: First time using an API...

2011-02-17 Thread Cousin Stanley

Matty Sarro wrote:

 
 I am in charge of deploying a platform to allow people 
 across my company to access a variety of crunched metrics 
 using splunk.
 

  For the convenience of others
  that may not be familar with splunk 

http://en.wikipedia.org/wiki/Splunk

http://www.splunk.com/


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: Suggested editor for wxPython on Ubuntu

2011-02-17 Thread Cousin Stanley

usenet.digi...@spamgourmet.com wrote:

 Ok, I've decided that Boa Constructor is too buggy to be useful 
 under Ubuntu, so what would the team recommend for developing 
 Python projects with wxPython? Preferably with some GUI design capability?

  perhaps  python-wxglade

GUI designer written in Python with wxPython

wxGlade is a GUI designer written in Python with the popular 
GUI toolkit wxPython, that helps you create wxWidgets/wxPython 
user interfaces. At the moment it can generate Python, C++ and 
XRC (wxWidgets' XML resources) code.


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: Problem with giant font sizes in tkinter

2011-02-10 Thread Cousin Stanley
Steven D'Aprano wrote:

 I have a tkinter application under Python 2.6 which is shows text 
 in a giant font, about twenty(?) times larger than expected.

 The fonts are set using:

 titlefont = '-Adobe-Helvetica-Bold-R-Normal-*-180-*'
 buttonfont = '-Adobe-Helvetica-Bold-R-Normal-*-140-*'
 labelfont = '-Adobe-Helvetica-Bold-R-Normal-*-140-*'
 

  Although I've been a linux user for several years,
  that type of font spec hurts my head  :-)

  Will the more simplistic type of tuple spec 
  not work in your tkinter application ?

  canv.create_text(
 81 , 27 ,
 text = ' NTSC Standard ' ,
 fill = 'white' ,
 font = ( 'Helvetica' , 12 , 'bold' ) )


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: IDLE: A cornicopia of mediocrity and obfuscation.

2011-02-01 Thread Cousin Stanley
rantingrick wrote:

 Terry (or anyone) can you give some link to info on hg 
 so i can study up on this topic ?

  http://mercurial.selenic.com/


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: SQLite is quite SQL compliant

2010-10-02 Thread Cousin Stanley
Ravi wrote:

 The documentation of the sqlite module 
 at http://docs.python.org/library/sqlite3.html
 says:

 ...
  allows accessing the database 
  using a nonstandard variant of the SQL...

 But if you see SQLite website they clearly say 
 at  http://sqlite.org/omitted.html  that only 
 very few of the SQL is not implemented. 

 I think docs should clarify on that. 

 Many users might be scared of using SQLite 
 just because of this.

  SQLite is very widely used 
  in many different contexts  

  You might check the related wikipedia article
  and scroll down to the  Adoption  section
  for a brief list of some well-known users 

  http://en.wikipedia.org/wiki/Sqlite


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: problem in Gasp !

2010-09-30 Thread Cousin Stanley
n.a.s wrote:

 I want to ask about graphics using Gasp .Attached is exercise 10 
 (houses at night) http://openbookproject.net/thinkCSpy/ch04.html#exercises 

 if  i call the draw_house function once it will work properly ,but more than 
 one call,windows and doors disappear from some houses .

 Any one can advice?

  A working version that runs using Python2.6 
  under Debian 6 Squeeze can be found at 
 
http://csphx.net/python/house.tar.bz

  A screenshot of the result is included 
  in that archive  

http://csphx.net/image/houses_10.png 


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: palindrome iteration

2010-09-13 Thread Cousin Stanley

 To deal with real palindromes such as, Madam, I'm Adam, 
 you should probably strip all spaces and punctuation:

 # untested
 pat = re.compile(r'[a-z]')
 def is_palindrome(s):
 letters = pat.findall(s.lower())
 return letters == reversed(letters)

  Using python 2.5 the above solution always returned False
  for me until the  reversed( letters )  iterator was explicitly
  coerced into a list  

return letters == list( reversed( letters ) ) 
 

-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: python styles: why Use spaces around arithmetic operators?

2010-07-30 Thread Cousin Stanley

 Parentheses are punctuation. Why not leave spaces around the commas as well, 
 to be consistent?

 myTuple = ( 1 , 2 , 3 , 4 , 5 )

  Personally, I do use this particular style with commas
  as I find it more readable to my old and tired eyes 

  Mandate  m o r e  whitespace  :-)


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: Getting pyparsing to backtrack

2010-07-07 Thread Cousin Stanley

 I'm working on street address parsing again, 
 and I'm trying to deal with some of the harder cases.
  

  For yet another test case
  my actual address includes 

  ... East South Mountain Avenue


  Sometimes written as 

  ... E. South Mtn Ave


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: Another nntplib Question

2010-06-09 Thread Cousin Stanley

 
 I've run into another snag with nntplib 
 

  Anthony 

  For inspiration you might take a look at 
  a nice news client written in python 

XPN (X Python Newsreader) is a graphical newsreader 
written in Python with the GTK+ toolkit. 

http://xpn.altervista.org/index-en.html


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: PIL show() not working for 2nd pic

2010-01-09 Thread Cousin Stanley

 I am using PIL for image processing in ubuntu 9.04. When i give two
 im.show() commands for two different images, the second image is not
 displayed (eye of gnome is the display program). It says no such file
 or directory. Any ideas?

  Suresh  

I also had problems with  show()  when using eye of gnome
as the image viewer with your code but no problems using 
the  display  viewer from the imagemagick package 

  im.show( command = 'eog' )#problems
  im.show( command = 'display' )# no problems

# --

#!/usr/bin/python

'''
NewsGroup  comp.lang.python
Subject .. PIL show() not working for 2nd pic
Date . 2010-01-07
Post_By .. suresh.amritapuri
Edit_By .. Stanley C. Kitching
'''

import math
import Image

list_source = [
'image/beach.tif' ,
'image/colors.tif' ]

list_target = [ ]

def neg( x ) :
return 255 - 1 - x

def logtr( x ) :
y = math.log( 1 + x , 10 )
print y
return y * 100

for this_image in list_source :
im_source  = Image.open( this_image )
im_neg = im_source.point( neg )
im_logtr   = im_source.point( logtr )

list_target.append( im_source )
list_target.append( im_neg )
list_target.append( im_logtr )

for this_image in list_target :
this_image.show( command = 'display' )

# --

-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: Dynamic text color

2010-01-03 Thread Cousin Stanley

 John Posner wrote  
 
 I've posted a complete solution 
   
   http://cl1p.net/jjp_dynamic_text_color/.

  John  

Thanks for posting your solution to Dave McCormick's query
about colorizing text  

I was not familiar with the re.finditer method
for searching strings or with using tags in 
Tkinter Text widgets to change text attributes  

Instead of binding the Text widget to KeyRelease events
to call the colorizer on each key-stroke, I used a button
callback   

   http://cl1p.net/cs_static_text_color

This provides a static one-shot colorization after all
of the text is entered and should save a few cpu cycles 
although it's not as nifty as the dynamic process  

I used a dictionary instead of a list for position data
and also added a  { term : color }  dictionary so that 
words other than color names can be hi-lighted 


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: How do I correctly download Wikipedia pages?

2009-11-26 Thread Cousin Stanley

 I'm trying to scrape a Wikipedia page from Python.
 

  On occasion I use a program under Debian Linux
  called  wikipedia2text  that is very handy 
  for downloading wikipedia pages as plain text files  

Description: displays Wikipedia articles on the command line
 
This script fetches Wikipedia articles (currently supports 
around 30 Wikipedia languages) and displays them as plain text 
in a pager or just sends the text to standard out. Alternatively 
it opens the Wikipedia article in a (possibly GUI) web browser 
or just shows the URL of the appropriate Wikipedia article.

  Example directed through the lynx browser  

wp2t -b lynx gorilla  gorilla.txt


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


Re: sys.stdout is not flushed

2009-11-23 Thread Cousin Stanley

 
 You misunderstand what flush means. It is not about 
 clearing the screen, or the line.

 Try printing

    stdout.write('\r--%d')

 Diez


 But there is still a problem. When you use control character '\r', 
 you actually move to the head of the current buffer line and 
 overwrite it.

 So if I use this way:
 for i in range(100, 0,-1)

 The tail of the buffer is not overwrote.
 

  The following version works ok for me
  using python2.5 under debian linux 

import sys
import time

print

for n in range( 11 ) :
sys.stdout.write( '\rWorking  %d ' % n )
sys.stdout.flush()
time.sleep( 1 )

else :
print \n
print That's all, folks !
print Adios ... 


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


  1   2   >