Single line if statement with a continue

2022-12-14 Thread Aaron P
I occasionally run across something like:

for idx, thing in enumerate(things):
if idx == 103: 
continue
do_something_with(thing)

It seems more succinct and cleaner to use:

if idx == 103: continue.

Of course this would be considered an anti-pattern, and Flake8 will complain.

Any opinions, or feedback on the matter.
-- 
https://mail.python.org/mailman/listinfo/python-list


Problem Installing Pipenv

2021-12-17 Thread Stephen P. Molnar
I have Python 3.9 installed in Windows 10 on my Laptop and have installed
pipenv v-2021.11.5. When I invoke the python shell command, it fails with
thee following errors:

 

 

C:\Users\SPM\Apps\Spyder-5.2.1>pipenv shell

Traceback (most recent call last):

  File "C:\Python39\lib\runpy.py", line 197, in _run_module_as_main

return _run_code(code, main_globals, None,

  File "C:\Python39\lib\runpy.py", line 87, in _run_code

exec(code, run_globals)

  File "C:\Python39\Scripts\pipenv.exe\__main__.py", line 7, in 

  File "C:\Python39\lib\site-packages\pipenv\vendor\click\core.py", line
1137, in __call__

return self.main(*args, **kwargs)

  File "C:\Python39\lib\site-packages\pipenv\vendor\click\core.py", line
1062, in main

rv = self.invoke(ctx)

  File "C:\Python39\lib\site-packages\pipenv\vendor\click\core.py", line
1668, in invoke

return _process_result(sub_ctx.command.invoke(sub_ctx))

  File "C:\Python39\lib\site-packages\pipenv\vendor\click\core.py", line
1404, in invoke

return ctx.invoke(self.callback, **ctx.params)

  File "C:\Python39\lib\site-packages\pipenv\vendor\click\core.py", line
763, in invoke

return __callback(*args, **kwargs)

  File "C:\Python39\lib\site-packages\pipenv\vendor\click\decorators.py",
line 84, in new_func

return ctx.invoke(f, obj, *args, **kwargs)

  File "C:\Python39\lib\site-packages\pipenv\vendor\click\core.py", line
763, in invoke

return __callback(*args, **kwargs)

 File "C:\Python39\lib\site-packages\pipenv\cli\command.py", line 419, in
shell

do_shell(

  File "C:\Python39\lib\site-packages\pipenv\core.py", line 2309, in
do_shell

shell = choose_shell()

TypeError: choose_shell() missing 1 required positional argument: 'project'

 

Stephen P. Molnar, Ph.D.

(614)312-7528

Skype: smolnar1

 

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


Re: Covariance matrix syntax

2020-10-13 Thread Bruno P. Kinoshita via Python-list
 I think the np.cov is from the numpy module (imported/aliased as np?).
If so, the numpy repository should have what you are looking for:

https://github.com/numpy/numpy/blob/156cd054e007b05d4ac4829e10a369d19dd2b0b1/numpy/lib/function_base.py#L2276

Hope that helps
Bruno

On Tuesday, 13 October 2020, 5:38:55 pm NZDT, Meghna Karkera 
 wrote:  
 
 May I know the steps or procedure behind covariance matrix syntax,
np.cov(covar_matrix) in python
-- 
https://mail.python.org/mailman/listinfo/python-list
  
-- 
https://mail.python.org/mailman/listinfo/python-list


python 3.7.2

2019-01-27 Thread Sarah P
Hi,

I’m having problems installing and using python as it defaults into  [ 
...users/ user/appdata/local/programs/] etc  etc, its about 9 locations in all  
but there is no route to ‘app data’, the trail is lost at this point. Its such 
an obscure location and I cannot find it anywhere on windows, even though it is 
working okay, I’m worried I will lose files.

I cannot transfer files saved on python 3.4 to the new python3.7.2 as I cannot 
find the new version on my computer. In the installer it defaults to this 
location and there is no option to install it anywhere else (greyed out box). 
It says I need write permissions to change the location but no more information 
about how to do this.

Also, I thought it would be an add on, not a whole new download. What happens 
if I delete python 3.4 after I have downloaded 3.7.2? will I lose all my 
existing code samples?
I’m a student programmer and I can’t understand the highly technical, expert 
level documentation that might rectify the problem and there is only a small 
amount of information anyway.
I just want to download Python to C drive on windows, it should be really 
easy...

Hope you can help

Sarah Padden

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


help me in python plssss!!!!

2018-09-14 Thread Noel P. CUA
 Calculate the true, relative and approximate errors, and  Relate the absolute 
relative approximate error to the number of significant digits.

epsilon = 1

while epsilon + 1 > 1:
epsilon = epsilon / 2.0

epsilon = 2 * epsilon

help me!

-- 

*This email and any files transmitted with it are confidential and 
intended solely for the use of the individual or entity to whom they are 
addressed. If you have received this email in error please notify the 
system manager . This message contains 
confidential information and is intended only for the individual named. *If 
you are not the named addressee you should not disseminate, distribute or 
copy this e-mail*. Please notify the sender immediately by e-mail if you 
have received this e-mail by mistake and delete this e-mail from your 
system. If you are not the intended recipient you are notified that 
disclosing, copying, distributing or taking any action in reliance on the 
contents of this information is strictly prohibited.*
-- 
https://mail.python.org/mailman/listinfo/python-list


how to convert this psuedo code to python

2018-09-14 Thread Noel P. CUA
 compose your own octave script to calculate the machine
epsilon. Analyze the code.

epsilon = 1
DO
IF (epsilon+1<=1) EXIT
epsilon = epsilon/2
END DO
epsilon = 2 x epsilon

-- 

*This email and any files transmitted with it are confidential and 
intended solely for the use of the individual or entity to whom they are 
addressed. If you have received this email in error please notify the 
system manager . This message contains 
confidential information and is intended only for the individual named. *If 
you are not the named addressee you should not disseminate, distribute or 
copy this e-mail*. Please notify the sender immediately by e-mail if you 
have received this e-mail by mistake and delete this e-mail from your 
system. If you are not the intended recipient you are notified that 
disclosing, copying, distributing or taking any action in reliance on the 
contents of this information is strictly prohibited.*
-- 
https://mail.python.org/mailman/listinfo/python-list


in multiprocessing pool map how to stop one process from executing ahead

2018-03-20 Thread Subramanian P V
I am excecting custom commands like shell  on multiple linux hosts.  and if in 
one host one of the commands fail. I want that process not to proceed. If the 
remote command throws an error i am logging it .. but the process goes to next 
command . but if i terminate the command, the process will terminate all other 
processes on other linux machines as well.
-- 
https://mail.python.org/mailman/listinfo/python-list


what is the best qr package

2018-03-07 Thread Subramanian P V
what is the best qr package 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Combining every pair of list items and creating a new list.

2017-07-18 Thread Rahul K P
You can use a simple logic and list comprehension.

so it will be like this

lst = [1, 2, 3, 4, 5, 6, 7, 8]
print [lst[i:i+2] for i in range(0,len(lst),2)]

Here 2 is the pairing number, You can set is as your need.



On Tue, Jul 18, 2017 at 1:40 AM,  wrote:

> Hi,
>
> I'm having difficulty thinking about how to do this as a Python beginner.
>
> But I have a list that is represented as:
>
> [1,2,3,4,5,6,7,8]
>
> and I would like the following results:
>
> [1,2] [3,4] [5,6] [7,8]
>
> Any ideas?
>
> Thanks
> --
> https://mail.python.org/mailman/listinfo/python-list
>



-- 
Regards
*Rahul K P*

Python Developer
Mumbai
+919895980223
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Instagram: 40% Py3 to 99% Py3 in 10 months

2017-06-16 Thread Rauklei P . S . Guimarães
Very Nice.

Em sex, 16 de jun de 2017 às 13:30, Terry Reedy  escreveu:

> https://thenewstack.io/instagram-makes-smooth-move-python-3/
> --
> Terry Jan Reedy
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


How to fix PyV8 linux setup error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

2016-09-12 Thread p . infante413
Hello, I am currently installing Pyv8 and other requirements for me to run a 
honeypot. I downloaded pyv8 from source and using v8 (version 5.5) - built it 
with depot_tools. I already exported the V8_HOME path. But I still have this 
error whenever I run 'python setup.py build' of pyv8. Also, I am using Python 
2.7. Here is the output I get:

running build
running build_py
running build_ext
building '_PyV8' extension
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-
prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g 
-fstack-protector-strong -Wformat -Werror=format-security -fPIC 
-DBOOST_PYTHON_STATIC_LIB -DV8_NATIVE_REGEXP -DENABLE_DISASSEMBLER 
-DENABLE_LOGGING_AND_PROFILING -DENABLE_DEBUGGER_SUPPORT -DV8_TARGET_ARCH_X64 
-I/home/patricia/Thesis/v8/include -I/home/patricia/Thesis/v8 
-I/home/patricia/Thesis/v8/src -I/usr/include/python2.7 -c src/Exception.cpp -o 
build/temp.linux-x86_64-2.7/src/Exception.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC 
but not for C++
In file included from /usr/include/c++/5/unordered_set:35:0,
 from /home/patricia/Thesis/v8/src/heap/spaces.h:10,
 from /home/patricia/Thesis/v8/src/heap/mark-compact.h:12,
 from /home/patricia/Thesis/v8/src/heap/incremental-marking.h:12,
 from /home/patricia/Thesis/v8/src/heap/incremental-marking-inl.h:8,
 from /home/patricia/Thesis/v8/src/heap/heap-inl.h:13,
 from /home/patricia/Thesis/v8/src/objects-inl.h:24,
 from /home/patricia/Thesis/v8/src/arguments.h:9,
 from /home/patricia/Thesis/v8/src/debug/debug.h:9,
 from /usr/include/c++/5/bits/stl_iterator_base_funcs.h:65,
 from /usr/include/c++/5/bits/stl_algobase.h:66,
 from /usr/include/c++/5/bits/char_traits.h:39,
 from /usr/include/c++/5/string:40,
 from /usr/include/c++/5/stdexcept:39,
 from src/Exception.h:4,
 from src/Exception.cpp:1:
/usr/include/c++/5/bits/c++0x_warning.h:32:2: error: #error This file requires 
compiler and library support for the ISO C++ 2011 standard. This support must 
be enabled with the -std=c++11 or -std=gnu++11 compiler options.
#error This file requires compiler and library support \
 ^
src/Exception.cpp:18:25: fatal error: src/natives.h: No such file or directory
#include "src/natives.h"
 ^

compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1


Well, before that, it repeatedly asks for exporting V8 to V8_HOME and building 
it. I do it repeatedly just to move on from it, and now, I get this. Also, I 
already searched in Ubuntu Packages Content Search (http://tiny.cc/snyrey) 
about /usr/include/c++/5/bits/stl_iterator_base_funcs.h, .../stl_algobase.h, 
.../char_traits.h, etc. That all led me to installing libstdc++-5-dev via 
apt-get install libstdc++-5-dev

But still. I am getting the error. Any help will be appreciated. :)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python Access logging of another program ran in subprocess

2016-06-26 Thread p . infante413
On Monday, June 27, 2016 at 1:36:24 AM UTC+8, MRAB wrote:
> >
> The output you're seeing might be going to stderr, not stdout.

Wow, huhuhu. Thank you. I did not know that. Thanks man! 
-- 
https://mail.python.org/mailman/listinfo/python-list


Python Access logging of another program ran in subprocess

2016-06-26 Thread p . infante413
Hello, I'm currently running another Python program (prog2.py) in my program 
via subprocess. 

input_args = ['python', '/path/to/prog2.py'] + self.chosen_args
file = open("logfile.txt",'w')
self.process = Popen((input_args), stdout=file)

However, the logs that prog2.py contains still show at the terminal since logs 
are not covered in the stdout module and printed in the terminal, also, the 
logfile.txt is empty. Is there a way I can access those logs while in prog1.py? 
I can't modify prog2.py since it is not mine. I'm stuck here for days now, any 
tips or help will do.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help

2016-03-04 Thread Tom P

On 02/29/2016 01:53 PM, tomwilliamson...@gmail.com wrote:

Thanks. If a word appears more than once how would I bring back both locations?



for i, str in enumerate(l): . . . .
--
https://mail.python.org/mailman/listinfo/python-list


Re: problem with dateutil

2016-02-14 Thread Tom P

On 02/13/2016 09:45 PM, Gary Herron wrote:

On 02/13/2016 12:27 PM, Tom P wrote:

On 02/13/2016 07:13 PM, Gary Herron wrote:

On 02/13/2016 09:58 AM, Tom P wrote:

I am writing a program that has to deal with various date/time formats
and convert these into timestamps. It looks as if
dateutil.parser.parse should be able to handle about any format, but
what I get is:

datetimestr = '2012-10-22 11:22:33'
print(dateutil.parser.parse(datetimestr))
result: datetime.datetime(2012, 10, 22, 11, 22, 33)

However:
datetimestr = '2012:10:22 11:22:33'
print(dateutil.parser.parse(datetimestr))
result: datetime.datetime(2016, 2, 13, 11, 22, 33)

In other words, it's getting the date wrong when colons are used to
separate :MM:DD. Is there a way to include this as a valid format?



Yes, there is a way to specify your own format.  Search the datetime
documentation for
 datetime.strptime(date_string, format)

Gary Herron



Thanks.  I started out with datetime.strptime but AFAICS that means I
have to go through try/except for every conceivable format. Are you
saying that I can't use dateutil.parser?


Well now...  If by "every conceivable format" you are including formats
that the author of dateutil.parser did not conceive of, then of course
you cannot use dateutil.parser.   But you have the code for
dateutil.parser -- perhaps you could modify it to accept whatever odd
formats you care about.

Gary Herron



I had a look at the code for dateutil.parser. Have you looked at it?

Meanwhile I'm living with
try:
dt = datetime.datetime.strptime(datetimestr, '%Y:%m:%d %H:%M:%S')
except ValueError:
dt = dateutil.parser.parse(datetimestr)
unixtime = time.mktime(dt.timetuple())

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


Re: problem with dateutil

2016-02-14 Thread Tom P

On 02/13/2016 10:01 PM, Mark Lawrence wrote:

On 13/02/2016 17:58, Tom P wrote:

I am writing a program that has to deal with various date/time formats
and convert these into timestamps. It looks as if dateutil.parser.parse
should be able to handle about any format, but what I get is:

datetimestr = '2012-10-22 11:22:33'
print(dateutil.parser.parse(datetimestr))
result: datetime.datetime(2012, 10, 22, 11, 22, 33)

However:
datetimestr = '2012:10:22 11:22:33'
print(dateutil.parser.parse(datetimestr))
result: datetime.datetime(2016, 2, 13, 11, 22, 33)

In other words, it's getting the date wrong when colons are used to
separate :MM:DD. Is there a way to include this as a valid format?



 From
http://labix.org/python-dateutil#head-a23e8ae0a661d77b89dfb3476f85b26f0b30349c



parserinfo
 This parameter allows one to change how the string is parsed, by
using a different parserinfo class instance. Using it you may, for
example, intenationalize the parser strings, or make it ignore
additional words.


HTH.



Thanks, let me look at that.

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


Re: problem with dateutil

2016-02-13 Thread Tom P

On 02/13/2016 07:13 PM, Gary Herron wrote:

On 02/13/2016 09:58 AM, Tom P wrote:

I am writing a program that has to deal with various date/time formats
and convert these into timestamps. It looks as if
dateutil.parser.parse should be able to handle about any format, but
what I get is:

datetimestr = '2012-10-22 11:22:33'
print(dateutil.parser.parse(datetimestr))
result: datetime.datetime(2012, 10, 22, 11, 22, 33)

However:
datetimestr = '2012:10:22 11:22:33'
print(dateutil.parser.parse(datetimestr))
result: datetime.datetime(2016, 2, 13, 11, 22, 33)

In other words, it's getting the date wrong when colons are used to
separate :MM:DD. Is there a way to include this as a valid format?



Yes, there is a way to specify your own format.  Search the datetime
documentation for
 datetime.strptime(date_string, format)

Gary Herron



Thanks.  I started out with datetime.strptime but AFAICS that means I 
have to go through try/except for every conceivable format. Are you 
saying that I can't use dateutil.parser?

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


problem with dateutil

2016-02-13 Thread Tom P
I am writing a program that has to deal with various date/time formats 
and convert these into timestamps. It looks as if dateutil.parser.parse 
should be able to handle about any format, but what I get is:


datetimestr = '2012-10-22 11:22:33'
print(dateutil.parser.parse(datetimestr))
result: datetime.datetime(2012, 10, 22, 11, 22, 33)

However:
datetimestr = '2012:10:22 11:22:33'
print(dateutil.parser.parse(datetimestr))
result: datetime.datetime(2016, 2, 13, 11, 22, 33)

In other words, it's getting the date wrong when colons are used to 
separate :MM:DD. Is there a way to include this as a valid format?


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


Re: Nearest neighbours of points

2015-10-31 Thread Tom P

On 10/24/2015 10:05 PM, Poul Riis wrote:

I have N points in 3D, organized in a list. I want to to point out the numbers 
of the two that have the smallest distance.
With scipy.spatial.distance.pdist I can make a list of all the distances, and I 
can point out the number of the minimum value of that list (see simple example 
below - the line with pts.append... should be indented three times). But I 
guess there is a standard (numpy?) routine which points out the numbers of the 
corresponding two points but I cannot find it. Can someone help?

Poul Riis




import numpy as np
import scipy
from scipy.spatial.distance import pdist


pts=[]
for i in range(-1,2):
 for j in range(-1,2):
 for k in range(-1,2): 
pts.append((i+np.random.random()/10,j+np.random.random()/10,k+np.random.random()/10))
for i in range(0,len(pts)):
 print(pts[i])
distances=scipy.spatial.distance.pdist(pts)
n=np.argmin(distances)
for i in range(0,len(distances)):
 print(i,distances[i])
print('The minimum distance is: ',min(distances),' which has number ',n)



I won't claim to have the definitive answer but - is this a clustering 
problem? Did you look at any machine learning packages?


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


Re: problem with netCDF4 OpenDAP

2015-08-14 Thread Tom P

On 08/14/2015 03:15 PM, Jason Swails wrote:



On Aug 14, 2015, at 3:18 AM, Tom P  wrote:

Thanks for the reply but that is not what the documentation says.

http://unidata.github.io/netcdf4-python/#section8
"Remote OPeNDAP-hosted datasets can be accessed for reading over http if a URL 
is provided to the netCDF4.Dataset constructor instead of a filename. However, this 
requires that the netCDF library be built with OPenDAP support, via the --enable-dap 
configure option (added in version 4.0.1).”


​Huh, so it does.  Your error message says "file not found", though, which 
suggested to me that it's trying to interpret the NetCDF file as a local file instead of 
a URL.  Indeed, when I run that example, the traceback is more complete (the traceback 
you printed had omitted some information):


netCDF4.Dataset('http://www1.ncdc.noaa.gov/pub/data/cmb/ersst/v3b/netcdf/ersst.201507.nc')

syntax error, unexpected WORD_WORD, expecting SCAN_ATTR or SCAN_DATASET or 
SCAN_ERROR
context: 404 Not 
FoundNot FoundThe requested URL /pub/data/cmb/ersst/v3b/netcdf/ersst.201507.nc.dds was not found 
on this server.
Traceback (most recent call last):
   File "", line 1, in 
   File "netCDF4/_netCDF4.pyx", line 1547, in netCDF4._netCDF4.Dataset.__init__ 
(netCDF4/_netCDF4.c:9551)
RuntimeError: NetCDF: file not found

So it’s clear that netCDF4 is at least *trying* to go online to look for the file, 
but it simply can’t find it.  Since the docs say it’s linking to libcurl, I tried 
using curl to download the file (curl -# 
http://www1.ncdc.noaa.gov/pub/data/cmb/ersst/v3b/netcdf/ersst.201507.nc > 
test.nc) and it worked fine.  What’s more, it *seems* like the file 
(/pub/.../ersst.201507.nc.dds) was decorated with the ‘.dds’ suffix for some 
reason (not sure if the server redirected the request there or not).  But this 
looks like a netCDF4 issue.  Perhaps you can go to their project page on Github 
and file an issue there -- they will be more likely to have your answer than 
people here.

HTH,
Jason


Hi,
  yes the file does appear to be there, I can download it and I can 
open and read the URL using urllib. Since there are a whole bunch of 
files in the directory, I really need MFDataset, but according to the 
documentation that doesn't work with URLs. Maybe the solution really is 
to D/L them all into a temporary folder and use MFDataset.






and for the Anaconda package -
http://docs.continuum.io/anaconda/changelog
"2013-05-08: 1.5.0:
Highlights:
  updates to all important packages: python, numpy, scipy, ipython, matplotlib, 
pandas, cython
  added netCDF4 (with OpenDAP support) on Linux and MacOSX"

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


--
Jason M. Swails
BioMaPS,
Rutgers University
Postdoctoral Researcher



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


Re: problem with netCDF4 OpenDAP

2015-08-14 Thread Tom P

On 08/13/2015 05:55 PM, Jason Swails wrote:



On Thu, Aug 13, 2015 at 6:32 AM, Tom P mailto:werot...@freent.dd>> wrote:

I'm having a problem trying to access OpenDAP files using netCDF4.
The netCDF4 is installed from the Anaconda package. According to
their changelog, openDAP is supposed to be supported.

netCDF4.__version__
Out[7]:
'1.1.8'

Here's some code:

url =
'http://www1.ncdc.noaa.gov/pub/data/cmb/ersst/v3b/netcdf/ersst.201507.nc'
nc = netCDF4.Dataset(url)

I get the error -
netCDF4/_netCDF4.pyx in netCDF4._netCDF4.Dataset.__init__
(netCDF4/_netCDF4.c:9551)()

RuntimeError: NetCDF: file not found


However if I download the same file, it works -
url = '/home/tom/Downloads/ersst.201507.nc <http://ersst.201507.nc>'
nc = netCDF4.Dataset(url)
print nc
  . . . .

Is it something I'm doing wrong?


​Yes.  URLs are not files and cannot be opened like normal files.
  netCDF4 *requires* a local file as far as I can tell.

All the best,
Jason

--
Jason M. Swails
BioMaPS,
Rutgers University
Postdoctoral Researcher


Thanks for the reply but that is not what the documentation says.

http://unidata.github.io/netcdf4-python/#section8
"Remote OPeNDAP-hosted datasets can be accessed for reading over http if 
a URL is provided to the netCDF4.Dataset constructor instead of a 
filename. However, this requires that the netCDF library be built with 
OPenDAP support, via the --enable-dap configure option (added in version 
4.0.1)."


and for the Anaconda package -
http://docs.continuum.io/anaconda/changelog
"2013-05-08: 1.5.0:
Highlights:
  updates to all important packages: python, numpy, scipy, ipython, 
matplotlib, pandas, cython

  added netCDF4 (with OpenDAP support) on Linux and MacOSX"

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


problem with netCDF4 OpenDAP

2015-08-13 Thread Tom P

I'm having a problem trying to access OpenDAP files using netCDF4.
The netCDF4 is installed from the Anaconda package. According to their 
changelog, openDAP is supposed to be supported.


netCDF4.__version__
Out[7]:
'1.1.8'

Here's some code:

url = 
'http://www1.ncdc.noaa.gov/pub/data/cmb/ersst/v3b/netcdf/ersst.201507.nc'

nc = netCDF4.Dataset(url)

I get the error -
netCDF4/_netCDF4.pyx in netCDF4._netCDF4.Dataset.__init__ 
(netCDF4/_netCDF4.c:9551)()


RuntimeError: NetCDF: file not found


However if I download the same file, it works -
url = '/home/tom/Downloads/ersst.201507.nc'
nc = netCDF4.Dataset(url)
print nc
 . . . .

Is it something I'm doing wrong?
--
https://mail.python.org/mailman/listinfo/python-list


Re: Gmail eats Python

2015-07-26 Thread Sebastian P . Luque
On Sat, 25 Jul 2015 18:34:30 +0200,
Laura Creighton  wrote:

> Gmail eats Python.  We just saw this mail back from Sebastian Luque
> which says in part:

 try: all_your_code_which_is_happy_with_non_scalars except
 WhateverErrorPythonGivesYouWhenYouTryThisWithScalars:
 whatever_you_want_to_do_when_this_happens

> Ow!  Gmail is understanding the >>> I stuck in as 'this is from the
> python console as a quoting marker and thinks it can reflow that.

> I think that splunqe must already have gmail set for plain text or
> else even worse mangling must show up.

> How do you teach gmail not to reflow what it thinks of as 'other
> people's quoted text'?

Apologies for all the concern the formatting of the quoted message in my
reply has generated.  I actually cannot see the multiple ">" you quote
here on my original follow-up message.  I can tell you I'm using Emacs
Gnus, and when viewing my un-processed message, that snippet looks like
this:

>> try: all_your_code_which_is_happy_with_non_scalars except
>> WhateverErrorPythonGivesYouWhenYouTryThisWithScalars:
>> whatever_you_want_to_do_when_this_happens

Sure, the reflowing is probably a feature I've set up to wrap long
lines.  I know it annoys some people (mildly myself, as I haven't found
a fix), but when reading coding fora, I never really take quoted code
snippets seriously and always check the original post for these...

-- 
Seb

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


Re: scalar vs array and program control

2015-07-25 Thread Sebastian P . Luque
On Sat, 25 Jul 2015 14:44:43 +0200,
Laura Creighton  wrote:

> And because I was rushed and posted without revision I left out
> something important.

>> So this is, quite likely, the pattern that you are looking for:

>> try: all_your_code_which_is_happy_with_non_scalars except
>> WhateverErrorPythonGivesYouWhenYouTryThisWithScalars:
>> whatever_you_want_to_do_when_this_happens

>> This is the usual way to do things.

> I forgot to tell you that you are supposed to stick the try/except
> around the smallest chunk of code that you expect to get the
> exception.

> So you write this as

> code_you_expect_always_to_work more_code_you_expect_always_to_work

> try: these_four_lines_of_code_that_will_be_unhappy_if_its_a_scalar
> except ValueError: # whatever kind of error the real error is
> whatever_you_want_to_do_when_that_happens

> The reason is that if you get any Value Errors in the part of the code
> you always expect to work, then you don't want your program to run
> happily along running the code for 'its a scalar'.  You don't want to
> hide real errors here.

> The other thing I forgot to mention is that sometimes you don't want
> to do anything but ignore any errors of this sort.

> Thats written like this:

> code_you_expect_always_to_work more_code_you_expect_always_to_work

> try: these_four_lines_of_code_that_will_be_unhappy_if_its_a_scalar
> except ValueError: pass # just ignore it

Thanks so much for all the pointers, and especially how `try` is used in
practice.  Avoiding the tangle of checks for kind of input is precisely
what my intuition was telling me.


-- 
Seb

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


Re: Noob in Python. Problem with fairly simple test case

2015-07-21 Thread Jason P.
El miércoles, 15 de julio de 2015, 14:12:08 (UTC+2), Chris Angelico  escribió:
> On Wed, Jul 15, 2015 at 9:44 PM, Jason P.  wrote:
> > I can't understand very well what's happening. It seems that the main 
> > thread gets blocked listening to the web server. My intent was to spawn 
> > another process for the server independent of the test. Obviously I'm doing 
> > something wrong. I've made several guesses commenting pieces of code 
> > (tearDown method for example) but I didn't manage to solve the problem(s).
> >
> 
> When you find yourself making guesses to try to figure out what's
> going on, here are two general tips:
> 
> 1) Cut out as many pieces as you can. Test one small thing at a time.
> 2) If In Doubt, Print It Out! Stick print() calls into the code at key
> places, displaying the values of parameters or the results of
> intermediate calculations - or just saying "Hi, I'm still here and I'm
> running!".
> 
> For #1, I would recommend first just trying to get the web service
> going. Can you connect (using an external program) on port 8000 and
> receive a text/plain HTTP response saying "Hello World!"? Never mind
> about the test for the moment.
> 
> And for #2, judicious placement of console output will help you figure
> out things you're not sure about. For instance, you're suspecting that
> the main thread is getting blocked handling the web server. Easy way
> to check:
> 
> def setUp(self):
> # Start the forecast server
> self.server = ForecastServer()
> self.server.start(webservice.app)
> 
> Just before you construct the server, print something out. After
> you've constructed it but before you call start(), print something
> out. And after starting it, print something out. Then run the program.
> If you see the first line and no other, then it's blocking during the
> construction. Other deductions I'm sure you can figure out.
> 
> One small point: Probe even things that you think are trivial. In the
> above example, I cannot see any reason why constructing
> ForecastServer() could possibly block, because its init does nothing
> but set a flag. But you can get surprised by things sometimes - maybe
> the problem is actually that you're not running the code you think you
> are, but there's some other ForecastServer kicking in, and it's
> synchronous rather than subprocess-based.
> 
> End-to-end testing is all very well, but when something goes wrong,
> the key is to break the program down into smaller parts. Otherwise,
> all you have is "it doesn't work", which is one of the most useless
> error reports ever. If someone comes to python-list saying "it doesn't
> work", we'll be asking him/her to give a lot more details; if your
> aunt asks you for help printing out a document because "it doesn't
> work", you'll probably have to go over and watch her attempt it; and
> it's the same with your test cases - you make them tell you more
> details.
> 
> Hope that helps! The techniques I'm offering are completely
> problem-independent, and even language-independent. IIDPIO debugging
> works in anything that gives you a console, which is pretty much
> everything - maybe it won't be print() but logging.debug(), but the
> same technique works.
> 
> ChrisA


Thanks for your comments Chris.

I've come back to the problem today after a few days on trip. Fortunately 
someone in other mailing list pointed me that the join method was hanging the 
main thread. Without this inconvenience I can focus on the exercise's main goal.

Despite the impression that surely I gave, I'm quite familiar with programming 
and general bug hunting rules. The problem is that I'm inexperienced with 
Python and the subtle details of multiple threads ;)

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


Noob in Python. Problem with fairly simple test case

2015-07-15 Thread Jason P.

Hi all!

I'm working in a little Python exercise with testing since the beginning. So 
far I'm with my first end to end test (not even finished yet) trying to:

1) Launch a development web server linked to a demo app that just returns 
'Hello World!'

2) Make a GET request successfully

I can't understand very well what's happening. It seems that the main thread 
gets blocked listening to the web server. My intent was to spawn another 
process for the server independent of the test. Obviously I'm doing something 
wrong. I've made several guesses commenting pieces of code (tearDown method for 
example) but I didn't manage to solve the problem(s).

I'm running the test through PyCharm. Python version = 3.4.3



Here it's the code:


test_forecast_end_to_end.py
===

import unittest
from tests.end_to_end.forecastserver import ForecastServer
import src.forecast.webservice as webservice
import requests


class TestForecastEndToEnd(unittest.TestCase):

def setUp(self):
# Start the forecast server
self.server = ForecastServer()
self.server.start(webservice.app)

def tearDown(self):
# Stop the forecast server
self.server.stop()

def test_webservice_receives_a_request(self):
response = requests.get('http://localhost:8000')
print(response.text)


if __name__ == '__main__':
unittest.main()



forecastserver.py
=

from wsgiref.simple_server import make_server
import multiprocessing


class ForecastServer:

def __init__(self):
self._httpd_process = None

def start(self, webservice):
if not self._httpd_process:
httpd = make_server('localhost', 8000, webservice)
self._httpd_process = multiprocessing.Process(
target=httpd.serve_forever)
self._httpd_process.start()

def stop(self):
if self._httpd_process:
self._httpd_process.join()
self._httpd_process.terminate()

del self._httpd_process



webservice.py
=

def app(environ, start_response):
status = '200 OK'
headers = [('Content-type', 'text/plain')]
start_response(status, headers)

return ['Hello World!']
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Classic OOP in Python

2015-06-18 Thread Jason P.
El miércoles, 17 de junio de 2015, 22:39:31 (UTC+2), Marko Rauhamaa  escribió:
> Ned Batchelder :
> 
> > TDD is about writing tests as a way to design the best system, and
> > putting testing at the center of your development workflow. It works
> > great with Python even without interfaces.
> 
> I wonder how great it really is. Testing is important, that's for sure,
> but to make it a dogmatic starting point of development is not that
> convincing.
> 
> The way it was explained to me was that in TDD you actually don't write
> code to any requirements or design: you simply do the least to pass the
> tests. Thus, say you need to write a program that inputs a string and
> outputs the same string surrounded by parentheses (the requirement), the
> starting point might be this test case:
> 
>- run the program
>- give it the word "hello" as input
>- check that the program prints out "(hello)"
> 
> The right TDD thing would be to satisfy the test with this program:
> 
>input()
>print("(hello)")
> 
> That *ought* to be the first version of the program until further test
> cases are added that invalidate it.
> 
> 
> Another interesting ism I have read about is the idea that the starting
> point of any software project should be the user manual. The developers
> should then go and build the product that fits the manual.
> 
> 
> Marko

The refactor phase is key in TDD (red-green-refactor). Again, GOOS is an 
advisable source of knowledge in this matter.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Classic OOP in Python

2015-06-18 Thread Jason P.
El miércoles, 17 de junio de 2015, 21:44:51 (UTC+2), Ned Batchelder  escribió:
> On Wednesday, June 17, 2015 at 3:21:32 PM UTC-4, Jason P. wrote:
> > Hello Python community.
> > 
> > I come from a classic background in what refers to OOP. Mostly Java and PHP 
> > (> 5.3). I'm used to abstract classes, interfaces, access modifiers and so 
> > on.
> > 
> > Don't get me wrong. I know that despite the differences Python is fully 
> > object oriented. My point is, do you know any book or resource that 
> > explains in deep the pythonic way of doing OOP?
> > 
> > For example, I'm gonna try to develop a modest application from ground up 
> > using TDD. If it had been done in Java for instance, I would made extensive 
> > use of interfaces to define the boundaries of my system. How would I do 
> > something like that in Python?
> > 
> > 
> > Many thanks!
> 
> What other languages do with interfaces, Python does with duck-typing. You
> can build something like interfaces in Python, but many people don't bother.
> 
> I don't know if your project will be web-based, but here is an entire book
> about developing Python web sites with a TDD approach:
> 
> http://www.obeythetestinggoat.com/
> 
> (Don't mind the unusual domain name, it's a bit of an inside joke...)
> 
> TDD and interfaces are separate concepts, and I'm not sure they even
> intersect.  TDD is about writing tests as a way to design the best system,
> and putting testing at the center of your development workflow.  It works
> great with Python even without interfaces.
> 
> --Ned.

I forgot to mention that the book you recommend seems to be a good starting 
point ;)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Classic OOP in Python

2015-06-18 Thread Jason P.
El miércoles, 17 de junio de 2015, 21:44:51 (UTC+2), Ned Batchelder  escribió:
> On Wednesday, June 17, 2015 at 3:21:32 PM UTC-4, Jason P. wrote:
> > Hello Python community.
> > 
> > I come from a classic background in what refers to OOP. Mostly Java and PHP 
> > (> 5.3). I'm used to abstract classes, interfaces, access modifiers and so 
> > on.
> > 
> > Don't get me wrong. I know that despite the differences Python is fully 
> > object oriented. My point is, do you know any book or resource that 
> > explains in deep the pythonic way of doing OOP?
> > 
> > For example, I'm gonna try to develop a modest application from ground up 
> > using TDD. If it had been done in Java for instance, I would made extensive 
> > use of interfaces to define the boundaries of my system. How would I do 
> > something like that in Python?
> > 
> > 
> > Many thanks!
> 
> What other languages do with interfaces, Python does with duck-typing. You
> can build something like interfaces in Python, but many people don't bother.
> 
> I don't know if your project will be web-based, but here is an entire book
> about developing Python web sites with a TDD approach:
> 
> http://www.obeythetestinggoat.com/
> 
> (Don't mind the unusual domain name, it's a bit of an inside joke...)
> 
> TDD and interfaces are separate concepts, and I'm not sure they even
> intersect.  TDD is about writing tests as a way to design the best system,
> and putting testing at the center of your development workflow.  It works
> great with Python even without interfaces.
> 
> --Ned.

I'm aware of duck typing. The point in using interfaces is to be explicit about 
the boundaries of a system.

Quite a red "Growing Object-Oriented Software, Guided by Tests", by the way. In 
fact interfaces are key components in the style of building software they 
propose, in good company with TDD.

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


Classic OOP in Python

2015-06-17 Thread Jason P.
Hello Python community.

I come from a classic background in what refers to OOP. Mostly Java and PHP (> 
5.3). I'm used to abstract classes, interfaces, access modifiers and so on.

Don't get me wrong. I know that despite the differences Python is fully object 
oriented. My point is, do you know any book or resource that explains in deep 
the pythonic way of doing OOP?

For example, I'm gonna try to develop a modest application from ground up using 
TDD. If it had been done in Java for instance, I would made extensive use of 
interfaces to define the boundaries of my system. How would I do something like 
that in Python?


Many thanks!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: want to learn python

2015-04-24 Thread Tom P

On 04/21/2015 12:57 PM, pm05...@gmail.com wrote:

Hello everyone,

I am willing to learn Python from scratch.Please he me to learn.Although I hv 
knowledge of c and object oriented programming.



Apart from the various tutorials you might want to look at the on-line 
courses offered by Coursera and EDX.


https://www.coursera.org/course/pythonlearn
https://www.edx.org/course/introduction-computer-science-mitx-6-00-1x-0

Check out the websites for more advanced courses.
--
https://mail.python.org/mailman/listinfo/python-list


tarfile vs zipfile

2015-03-02 Thread Seth P
Is there a reason tarfile and zipfile don't use the same method/member names, 
where it makes sense?  Consider the following six methods/members, which I 
would expect to be the same (with the possible exception of mtime vs date_time, 
which are of different types).  It almost seems like someone went out of their 
way to make it difficult to use them interchangeably.

tarfile  zipfile

  TarFile  ZipFile
getmember(name)  getinfo(name)
getmembers() infolist()
getnames()   namelist()

  TarInfo  ZipInfo
name filename
mtimedate_time
size file_size
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python code in presentations

2014-09-30 Thread Tom P

On 30.09.2014 13:50, Jean-Michel Pichavant wrote:

Hello list,

I'm currently writing a presentation to help my co-workers ramp up on new 
features of our tool (written in python (2.7)).

I have some difficulties presenting code in an efficient way (with some basic syntax 
highlights). I need to be catchy about the code I'm presenting otherwise the presentation 
will fail and I would be better saying to my co-workers "RTFM", cause there is 
a manual.

So I really need to make them realize the code I'm presenting will benefit them 
(they're not software engineers, python is just a tool, their expertise and 
focus is aimed at something else, don't blame them :) )

Right now the method I'm using is write the code in notepad++, use a plugin 
(NppExport) to copy paste code into powerpoint.
After using it a little bit, I'm really not satisfied with this method, it's 
expensive and all this copy paste stuff is driving me crazy. Not to mention 
that the syntax highlight from notepads renders like crap in powerpoint.

I wonder if some people in this list who have successfully presented python 
code have some tips about doing the proper way. Ned's presentations for pycons 
are to me one example of successful code presentation:
   - the layout is simple
   - the code and code output are clearly identified
   - a line of code can be highlighted while presenting

http://nedbatchelder.com/text/iter.html

I have access to powerpoint, or any tool under linux (I don't have access to 
Mac's stuff).

Right now I'm so not satisfied by my current method that I'm about to make the 
presentation showing the code from the file directly, alt-tabing between the 
slides and the code. At least it's cheap.

JM





-- IMPORTANT NOTICE:

The contents of this email and any attachments are confidential and may also be 
privileged. If you are not the intended recipient, please notify the sender 
immediately and do not disclose the contents to any other person, use it for 
any purpose, or store or copy the information in any medium. Thank you.



I can't answer your question, but thanks for the great presentation on 
iterables!


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


Reporting and data stats help

2014-07-31 Thread James P
I'm building a report builder for my Django app and could use a little advice.

My reports are fairly simple where I accumulate scores of data (easy enough) 
but then I want to alter the report totals by varying dimensions (date ranges / 
split dates/weeks/months / owners / other metadata etc.). Since I am working 
with Django Querysets, I have some options as to how I can query the data into 
one query set with joins where I can traverse the joins for my accumulating 
data. Or I can take multiple querysets and join them in my app manually which 
simplifies the queries somewhat (this optimization might come later when I load 
test the app). 

My data might look something like this:

Parent (with useful dimensional metadata) -> Child (with useful dimensional 
metadata) ->Child of child (accumulating data source, i.e. Counts to aggregate)

I see some stuff about Pandas, also Anaconda. I took a brief look at both and 
they definitely both sound more hardcore than I need, but then I don't feel 
like rolling my own axis/dimensional modelling logic if I can perhaps build a 
dataset and have the app do it for me. Which package is recommended for babby's 
first stat package that can meet my requirements? Ideally one that uses less 
resources as I plan to scale this app up quite a bit in production.

Also for whichever package recommended, where would I find some good basic 
tutorials on how to build my dataset and alter it for reporting purposes? I 
plan to build charts on the client-side front-end with HTML5/js/css.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: TextBlob on Windows

2014-07-04 Thread selvaperumal . p
On Saturday, 24 May 2014 04:45:14 UTC+5:30, subhaba...@gmail.com  wrote:
> Dear Group,
> 
> 
> 
> It seems there is a nice language processing library named TextBlob, like 
> NLTK. 
> 
> But I am being unable to install it on my Windows(MS-Windows 7 machine. I am 
> using Python 2.7
> 
> 
> 
> If anyone of the esteemed members may kindly suggest me the solution.
> 
> 
> 
> I tried the note in following URL
> 
> http://stackoverflow.com/questions/20562768/trouble-installing-textblob-for-python
> 
> 
> 
> but did not help much.
> 
> 
> 
> Thanking in Advance,
> 
> Regards,
> 
> Subhabrata Banerjee.

hi mam i too having the same problem.
If you got any solution for the problem please let me know
I am in dire need of the package to be used in python.
please!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Convert numpy array to single number

2014-04-29 Thread Tom P

On 28.04.2014 15:04, mboyd02...@gmail.com wrote:

I have a numpy array consisting of 1s and zeros for representing binary numbers:

e.g.

  >>> binary
  array([ 1.,  0.,  1.,  0.])

I wish the array to be in the form 1010, so it can be manipulated.

I do not want to use built in binary converters as I am trying to build my own.



Do you mean that each element in the array represents a power of two?
So array([ 1.,  0.,  1.,  0.]) represents 2^3 + 2 = 6 decimal?

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


Getting a stable virtual env

2014-02-17 Thread P J
Hi ppl,

I'm trying to figure out the whole virtualenv story.
Right now I'm using it to creating an environment for our upcoming debian
upgrade to squeeze.

I'm doing some tests in our current distrib (python 2.5).
I have come to realize that a lot of packages in the version I'm interested
in are not available anymore on pypi. The pip installer fails a lot.

Squeeze features python 2.7 so I'm pretty sure that everything will work
fine. I've actually tested it. The question is, how do I protect myself
from future package removal ?
Do I absolutely need to run a local pypi server (I've seen some python
package doing this), and mirror all the packages I'm interested in ?

cheers,

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


numpy masked array puzzle

2013-11-17 Thread Tom P

I have two numpy arrays, xx and yy -
(Pdb) xx
array([0.7820524520874, masked, masked, 0.3700476837158,
   0.7252384185791, 0.6002384185791, 0.6908474121094,
   0.7878760223389, 0.6512288818359, 0.1110143051147,
   masked, 0.716205039978, 0.5460381469727,
   0.4358950958252, 0.63868808746337891, 0.02700700354576,
   masked, masked], dtype=object)
(Pdb) yy
array([-0.015120843222826226, -0.0080196081193390761, 0.02241851002495138,
   -0.021720756657755306, -0.0095334465407607427,
   -0.0063953867288363917, -0.013363615476044387,
   0.0080645889792231359, -0.0056745213729654086,
   -0.0071783823973457523, -0.0019400978318164389,
   -0.0038670581150256019, 0.0048961156278229494, -0.01315129469368378,
   -0.007727079344820257, -0.0042560259937610449,
   0.0063857167196111056, 0.0024528141737232877], dtype=object)
(Pdb)
-- which gives a strange error -
 stats.mstats.linregress(x, y)
*** AttributeError: 'int' object has no attribute 'view'
(Pdb)

What is stranger I can't get the mask -
(Pdb) np.ma.getmaskarray(xx)
array([False, False, False, False, False, False, False, False, False,
   False, False, False, False, False, False, False, False, False], 
dtype=bool)

(Pdb)

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


Re: i want to know about python language

2013-11-06 Thread Kewl p
On Thursday, November 7, 2013 8:48:26 AM UTC+5:30, Kewl p wrote:
> h

can i get link of a ide in which python can run,,...??
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: i want to know about python language

2013-11-06 Thread Kewl p
On Thursday, November 7, 2013 8:48:26 AM UTC+5:30, Kewl p wrote:
> h

thanks very much
-- 
https://mail.python.org/mailman/listinfo/python-list


i want to know about python language

2013-11-06 Thread Kewl p
h
-- 
https://mail.python.org/mailman/listinfo/python-list


[solved]Re: Python PDB conditional breakpoint

2013-11-06 Thread Tom P

On 06.11.2013 16:14, Tom P wrote:

ok I figured it. ID is a tuple, not a simple variable.
 The correct test is ID[0]==11005



I can't get conditional breakpoints to work. I have a variable ID and I
want to set a breakpoint which runs until ID==11005.

Here's what happens -



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


Python PDB conditional breakpoint

2013-11-06 Thread Tom P
I can't get conditional breakpoints to work. I have a variable ID and I 
want to set a breakpoint which runs until ID==11005.


Here's what happens -


-> import sys
...
(Pdb) b 53, ID==11005
Breakpoint 1 at /home/tom/Desktop/BEST Tmax/MYSTUFF/sqlanalyze3.py:53
(Pdb) b
Num Type Disp Enb   Where
1   breakpoint   keep yes   at /home/tom/Desktop/BEST 
Tmax/MYSTUFF/sqlanalyze3.py:53

stop only if ID==11005

(Pdb) l
 50 for ID in distinct_IDs:
 51  	cursr.execute("select Date, Temperature from data where 
StationID = ? and Date > 1963", ID)

 52 datarecords = cursr.fetchall() # [(date, temp),..]
 53 B->  ll =  len(datarecords)
 54 if ll > 150:   # and len(results) < 100 :

(Pdb) c
...
std_error too large  -132.433 61.967 10912
std_error too large  -133.36274 62.2165 10925
std_error too large  -137.37 62.82 10946
std_error too large  -138.217 64.45 10990
std_error too large  -138.32 65.35 11005
std_error too large  -138.32 65.35 11005
std_error too large  -138.32 65.35 11005
std_error too large  -138.32 65.35 11005
std_error too large  -134.86625 67.415 11036
std_error too large  -135.0 68.22908 11053
...

 - in other words it doesn't stop even though the value ID == 11005 
shows up. Am I specifying the condition incorrectly?


This is Python 2.7.4, Linux 64 bit.

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


Re: Can I trust downloading Python?

2013-09-10 Thread Tom P

On 10.09.2013 11:45, Oscar Benjamin wrote:

On 10 September 2013 01:06, Steven D'Aprano
 wrote:

On Mon, 09 Sep 2013 12:19:11 +, Fattburger wrote:

But really, we've learned *nothing* from the viruses of the 1990s.
Remember when we used to talk about how crazy it was to download code
from untrusted sites on the Internet and execute it? We're still doing
it, a hundred times a day. Every time you go on the Internet, you
download other people's code and execute it. Javascript, Flash, HTML5,
PDF are all either executable, or they include executable components. Now
they're *supposed* to be sandboxed, but we've gone from "don't execute
untrusted code" to "let's hope my browser doesn't have any bugs that the
untrusted code might exploit".


You could have also mentioned pip/PyPI in that. 'pip install X'
downloads and runs arbitrary code from a largely unmonitored and
uncontrolled code repository. The maintainers of PyPI can only try to
ensure that the original author of X would remain in control of what
happens and could remove a package X if it were discovered to be
malware. However they don't have anything like the resources to
monitor all the code coming in so it's essentially a system based on
trust in the authors where the only requirement to be an author is
that you have an email address. Occasionally I see the suggestion to
do 'sudo pip install X' which literally gives root permissions to
arbitrary code coming straight from the net.


Oscar



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


Re: A Pragmatic Case for Static Typing

2013-09-02 Thread Russ P.
On Monday, September 2, 2013 1:10:34 AM UTC-7, Paul Rubin wrote:
> "Russ P." writes:
> 
> > I just stumbled across this video and found it interesting:
> 
> > http://vimeo.com/72870631
> 
> > My apologies if it has been posted here already.
> 
> 
> 
> The slides for it are here, so I didn't bother watching the 1 hour video:
> 
> 
> 
>   http://gbaz.github.io/slides/hurt-statictyping-07-2013.pdf
> 
> 
> 
> I guess for Python programmers looking to expand their horizons a bit,
> 
> it's worth at least looking at the slides.  But, it may overstate its
> 
> case a little bit.  Haskell's type system is way cool but the language
> 
> introduces other headaches into programming.

I thought the video was amusing, but I am probably easily amused. I noticed 
that he did not list my current main language, Scala, as statically typed. I am 
not sure why, but perhaps because it inherits null from Java. In any case, his 
main point was that static typing reduces time to working code. I have no doubt 
that is true for large-scale programming, but I doubt it is true for 
small-scale programming. The question is where the crossover point is.
-- 
http://mail.python.org/mailman/listinfo/python-list


A Pragmatic Case for Static Typing

2013-09-01 Thread Russ P.
I just stumbled across this video and found it interesting:

http://vimeo.com/72870631

My apologies if it has been posted here already.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bools and explicitness [was Re: PyWart: The problem with "print"]

2013-06-06 Thread Russ P.
On Thursday, June 6, 2013 2:29:02 AM UTC-7, Steven D'Aprano wrote:
> On Thu, 06 Jun 2013 12:29:44 +1000, Chris Angelico wrote:
> 
> 
> 
> > On Thu, Jun 6, 2013 at 11:56 AM, Steven D'Aprano
> 
> >  wrote:
> 
> >> On Wed, 05 Jun 2013 14:59:31 -0700, Russ P. wrote:
> 
> >>> As for Python, my experience with it is that, as your application
> 
> >>> grows, you start getting confused about what the argument types are or
> 
> >>> are supposed to be.
> 
> >>
> 
> >> Whereas people never get confused about the arguments in static typed
> 
> >> languages?
> 
> >>
> 
> >> The only difference is whether the compiler tells you that you've
> 
> >> passed the wrong type, or your unit test tells you that you've passed
> 
> >> the wrong type. What, you don't have unit tests? Then how do you know
> 
> >> that the code does the right thing when passed data of the right type?
> 
> >> Adding an extra couple of unit tests is not that big a burden.
> 
> > 
> 
> > The valid type(s) for an argument can be divided into two categories:
> 
> > Those the compiler can check for, and those the compiler can't check
> 
> > for. Some languages have more in the first category than others, but
> 
> > what compiler can prove that a string is an
> 
> > HTML-special-characters-escaped string? In a very few languages, the
> 
> > compiler can insist that an integer be between 7 and 30, but there'll
> 
> > always be some things you can't demonstrate with a function signature.
> 
> > 
> 
> > That said, though, I do like being able to make at least *some*
> 
> > declaration there. It helps catch certain types of error.
> 
> 
> 
> *shrug*
> 
> 
> 
> I don't terribly miss type declarations. Function argument declarations 
> 
> are a bit simpler in Pascal, compared to Python:
> 
> 
> 
> 
> 
> Function Add(A, B : Integer) : Integer; 
> 
> Begin
> 
>  Add := A + B;
> 
> End;
> 
> 
> 
> 
> 
> versus
> 
> 
> 
> 
> 
> def add(a, b):
> 
> if not (isinstance(a, int) and isinstance(b, int)):
> 
> raise TypeError
> 
> return a + b
> 

Scala also has isInstanceOf[Type] which allows you to do this sort of thing, 
but of course it would be considered terrible style in Scala.

> 
> 
> 
> but not that much simpler. And while Python can trivially support 
> 
> multiple types, Pascal cannot. (Some other static typed languages may.)
> 
> 
> 
> Whatever benefit there is in declaring the type of a function is lost due 
> 
> to the inability to duck-type or program to an interface. There's no type 
> 
> that says "any object with a 'next' method", for example. And having to 
> 
> declare local variables is a PITA with little benefit.
> 
> 
> 
> Give me a language with type inference, and a nice, easy way to keep duck-
> 
> typing, and I'll reconsider. But until then, I don't believe the benefit 
> 
> of static types comes even close to paying for the extra effort.


Scala has type inference. For example, you can write

val x = 1

and the compiler figures out that x is an integer. Scala also has something 
called structural typing, which I think is more or less equivalent to "duck 
typing," although I don't think it is used very often.

Are you ready to try Scala yet? 8-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bools and explicitness [was Re: PyWart: The problem with "print"]

2013-06-05 Thread Russ P.
On Wednesday, June 5, 2013 7:29:44 PM UTC-7, Chris Angelico wrote:
> On Thu, Jun 6, 2013 at 11:56 AM, Steven D'Aprano
> 
>  wrote:
> 
> > On Wed, 05 Jun 2013 14:59:31 -0700, Russ P. wrote:
> 
> >> As for Python, my experience with it is that, as
> 
> >> your application grows, you start getting confused about what the
> 
> >> argument types are or are supposed to be.
> 
> >
> 
> > Whereas people never get confused about the arguments in static typed
> 
> > languages?
> 
> >
> 
> > The only difference is whether the compiler tells you that you've passed
> 
> > the wrong type, or your unit test tells you that you've passed the wrong
> 
> > type. What, you don't have unit tests? Then how do you know that the code
> 
> > does the right thing when passed data of the right type? Adding an extra
> 
> > couple of unit tests is not that big a burden.
> 
> 
> 
> The valid type(s) for an argument can be divided into two categories:
> 
> Those the compiler can check for, and those the compiler can't check
> 
> for. Some languages have more in the first category than others, but
> 
> what compiler can prove that a string is an
> 
> HTML-special-characters-escaped string? In a very few languages, the
> 
> compiler can insist that an integer be between 7 and 30, but there'll
> 
> always be some things you can't demonstrate with a function signature.
> 
> 
> 
> That said, though, I do like being able to make at least *some*
> 
> declaration there. It helps catch certain types of error.

I recall reading a few years ago that Guido was thinking about adding optional 
type annotations. I don't know if that went anywhere or not, but I thought it 
was a good idea. Eventually I got tired of waiting, and I realized that I just 
wanted a statically typed language, so I started using one.

Steven's view on static vs. dynamic typing are interesting, but I think they 
are "out of the mainstream," for whatever that's worth. Does that mean he is 
wrong? I don't know. But I do know that statically typed code just seems to me 
to fit together tighter and more solidly. Maybe it's a liberal/conservative 
thing. Do liberals tend to favor dynamic typing?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bools and explicitness [was Re: PyWart: The problem with "print"]

2013-06-05 Thread Russ P.
On Wednesday, June 5, 2013 4:18:13 PM UTC-7, Michael Torrie wrote:
> On 06/05/2013 12:11 AM, Russ P. wrote:
> 
> > But then, what would you expect of a language that allows you to
> 
> > write
> 
> > 
> 
> > x = 1 
> 
> > x = "Hello"
> 
> > 
> 
> > It's all loosey goosey -- which is fine for many applications but
> 
> > certainly not for critical ones.
> 
> 
> 
> This comment shows me that you don't understand the difference between
> 
> names, objects, and variables.  May sound like a minor quibble, but
> 
> there're actually major differences between binding names to objects
> 
> (which is what python does) and variables (which is what languages like
> 
> C have).  It's very clear Rick does not have an understanding of this
> 
> either.

My comment shows you nothing about what I understand about names, objects, and 
variables. You have chosen to question my understanding apparently because my 
point bothered you but you don't have a good reply. Then you link me with Rick 
for good measure. That's two ad hominems in three sentences.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bools and explicitness [was Re: PyWart: The problem with "print"]

2013-06-05 Thread Russ P.
On Wednesday, June 5, 2013 9:59:07 AM UTC-7, Chris Angelico wrote:
> On Thu, Jun 6, 2013 at 2:15 AM, Russ P. wrote:
> 
> > On Wednesday, June 5, 2013 1:59:01 AM UTC-7, Mark Lawrence wrote:
> 
> >> I want to launch this rocket with an expensive satellite on top.  I know
> 
> >>
> 
> >> it's safe as the code is written in ADA.  Whoops :(
> 
> >
> 
> >
> 
> > So Python would have been a better choice? Yeah, right. If you know 
> > anything about that rocket mishap, you should know that Ada was not the 
> > source of the problem. Ada won't keep airplane wings from breaking either, 
> > by the way. It's not magic.
> 
> 
> 
> Frankly, I don't think the language much matters. It's all down to the
> 
> skill of the programmers and testers. Ada wasn't the source of the
> 
> problem unless Ada has a bug in it... which is going to be true of
> 
> pretty much any language. Maybe Python would be a better choice, maybe
> 
> not; but let me tell you this, if the choice of language means the
> 
> difference between testable in three months and testable code in three
> 
> years, I'm going for the former.
> 
> 
> 
> ChrisA

I'm not an Ada guy, but Ada advocates claim that it reduces development time by 
half in the long run compared to C and C++ due to reduced debugging time and 
simpler maintenance. Then again, I think Java people make a similar claim. As 
for Python, my experience with it is that, as your application grows, you start 
getting confused about what the argument types are or are supposed to be. That 
requires the developer to keep much more of the design in his head, and that 
undesirable. Of course, you can always put the argument types in comments, but 
that won't be verified by the compiler.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bools and explicitness [was Re: PyWart: The problem with "print"]

2013-06-05 Thread Russ P.
On Wednesday, June 5, 2013 1:59:01 AM UTC-7, Mark Lawrence wrote:
> On 05/06/2013 07:11, Russ P. wrote:
> 
> 
> 
> > But then, what would you expect of a language that allows you to write
> 
> >
> 
> > x = 1
> 
> > x = "Hello"
> 
> >
> 
> > It's all loosey goosey -- which is fine for many applications but certainly 
> > not for critical ones.
> 
> >
> 
> 
> 
> I want to launch this rocket with an expensive satellite on top.  I know 
> 
> it's safe as the code is written in ADA.  Whoops :(


So Python would have been a better choice? Yeah, right. If you know anything 
about that rocket mishap, you should know that Ada was not the source of the 
problem. Ada won't keep airplane wings from breaking either, by the way. It's 
not magic.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bools and explicitness [was Re: PyWart: The problem with "print"]

2013-06-05 Thread Russ P.
On Wednesday, June 5, 2013 12:15:57 AM UTC-7, Chris Angelico wrote:
> On Wed, Jun 5, 2013 at 4:11 PM, Russ P. wrote:
> 
> > On Tuesday, June 4, 2013 8:44:11 AM UTC-7, Rick Johnson wrote:
> 
> >
> 
> >> Yes, but the problem is not "my approach", rather the lack
> 
> >>
> 
> >> of proper language design (my apologizes to the "anointed
> 
> >>
> 
> >> one". ;-)
> 
> >
> 
> > If you don't like implicit conversion to Boolean, then maybe you should be 
> > using another language -- and I mean that in a constructive sense. I'm not 
> > particularly fond of it either, but I switched from Python to another 
> > language a while back. The issue is not a lack of "proper language design" 
> > but rather a language design philosophy that values conciseness and 
> > simplicity over explicitness and rigor.
> 
> 
> 
> (Out of curiosity, which language? Feel free to not answer, or to
> 
> answer off-list, as that's probably not constructive to the thread.)

No problem. I'm using Scala. It has a sophisticated type system. The language 
is not perfect, but it seems to suit my needs fairly well.

> 
> 
> I cannot name a single modern programming language that does NOT have
> 
> some kind of implicit boolification. The only such language I know of
> 
> is REXX, which has a single data type for everything, but insists on
> 
> the exact strings "1" and "0" for True and False, anything else is an
> 
> error. Every other language has some definition of "these things are
> 
> true, these are false"; for instance:


Scala (and Java) don't do that. Nor does Ada. That's because Ada is designed 
for no-nonsense critical systems. It is the standard higher-order language for 
flight control systems, for example. 


> > It's all loosey goosey -- which is fine for many applications but certainly 
> > not for critical ones.
> 
> 
> 
> The looseness doesn't preclude critical applications. It's all a
> 
> question of what you're testing. Does your code care that this be a
> 
> list, and not something else? Then test! You have that option. What
> 
> happens if it isn't a list, and something is done that bombs with an
> 
> exception? Maybe that's not a problem.
> 
> 
> 
> Critical applications can often be built in layers. For instance, a
> 
> network server might listen for multiple socket connections, and for
> 
> each connection, process multiple requests. You would want to catch
> 
> exceptions at the two boundaries there; if a request handler crashes,
> 
> the connection should not be dropped, and if a connection handler
> 
> crashes, the server should keep running. With some basic defenses like
> 
> that, your code need no longer concern itself with trivialities - if
> 
> something goes wrong, there'll be an exception in the log. (BTW, this
> 
> is one of the places where a bare or very wide except clause is
> 
> appropriate. Log and move on.)


Well, I don't really want to open the Pandora's box of static vs. dynamic 
typing. Yes, with enough testing, I'm sure you can get something good out of a 
dynamically typed language for small to medium-sized applications, but I have 
my doubts about larger applications. However, I don't claim to be an expert. 
Someone somewhere has probably developed a solid large application in Python. 
But I'll bet a dollar to a dime that it took more work than it would have taken 
in a good statically typed language. Yes, extensive testing can go a long way, 
but extensive testing combined with good static typing can go even further for 
the same level of effort.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bools and explicitness [was Re: PyWart: The problem with "print"]

2013-06-04 Thread Russ P.
On Tuesday, June 4, 2013 8:44:11 AM UTC-7, Rick Johnson wrote:

> Yes, but the problem is not "my approach", rather the lack
> 
> of proper language design (my apologizes to the "anointed
> 
> one". ;-)

If you don't like implicit conversion to Boolean, then maybe you should be 
using another language -- and I mean that in a constructive sense. I'm not 
particularly fond of it either, but I switched from Python to another language 
a while back. The issue is not a lack of "proper language design" but rather a 
language design philosophy that values conciseness and simplicity over 
explicitness and rigor. 

Implicit conversion to Boolean is only one of many language features that are 
questionable for critical production software. Another is the convention of 
interpreting negative indices as counting backward from the end of a list or 
sequence. Yeah, I thought that was elegant... until it bit me. Is it a bad 
idea? Not necessarily. It certainly enhances programmer productivity, and it 
can be done correctly "almost" all the time. But that one time in a hundred or 
a thousand when you accidentally use a negative index can be a bitch.

But then, what would you expect of a language that allows you to write

x = 1
x = "Hello"

It's all loosey goosey -- which is fine for many applications but certainly not 
for critical ones.

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


Google App Engine dev_appserver and pdb?

2013-05-30 Thread Tom P

Is there a way to use pdb to debug Google apps written in Python?
When I start the development system to run the app "test" like this -

'./google_appengine/dev_appserver.py' './test'

 - I'd like to send the program into debug. I couldn't see anything in 
the documentation how to do this. If I do this -

python -mpdb './google_appengine/dev_appserver.py' './test'
 - then dev_appserver.py goes into debug but doesn't know anything 
about "test".


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


HTTPServer again

2013-04-22 Thread Tom P

Hi,
 a few weeks back I posed a question about passing static data to a 
request server, and thanks to some useful suggestions, got it working. I 
see yesterday there is a suggestion to use a framework like Tornado 
rather than base classes. However I can't figure achieve the same effect 
using Tornado (BTW this is all python 2.7). The key point is how to 
access the server class from within do_GET, and from the server class 
instance, to access its get and set methods.


Here are some code fragments that work with HTTPServer:

class MyHandler(BaseHTTPRequestHandler):

def do_GET(self):
ss = self.server
tracks = ss.tracks
. . .
class MyWebServer(object):
def get_params(self):
return self.global_params
def set_params(self, params):
self.global_params = params
def get_tracks(self):
return self.tracks
def __init__(self):
self.global_params = ""
self.tracks = setup_()
myServer = HTTPServer
myServer.tracks = self.get_tracks()
myServer.params = self.get_params()
self.server = myServer(('', 7878), MyHandler)
print 'started httpserver on port 7878...'
. . . .
def main():
aServer = MyWebServer()
aServer.runIt()

if __name__ == '__main__':
main()





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


Re: The SOLUTION HTTPserver: how to access variables of a higher class

2013-04-06 Thread Tom P

On 04/05/2013 01:02 PM, Tom P wrote:

ok, after much experimenting it looks like the solution is as follows:

class MyWebServer(object):
def __init__(self):
  #  self.foo = "foo"  delete these from self
   # self.bar = "bar"
myServer = HTTPServer
myServer.foo = "foo"  #define foo,bar here
myServer.bar = "bar"

self.httpd = myServer(('127.0.0.1', 8000), MyRequestHandler)

Then, in the request handler:
class MyRequestHandler(BaseHTTPRequestHandler):
def do_GET(self):
ss=self.server
print ss.foo


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


Re: HTTPserver: how to access variables of a higher class?

2013-04-06 Thread Tom P

On 04/05/2013 02:27 PM, Dylan Evans wrote:

On 05/04/2013 9:09 PM, "Tom P"  wrote:


First, here's a sample test program:

import sys
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler

class MyRequestHandler(BaseHTTPRequestHandler, object):
 def do_GET(self):
 top_self = super(MyRequestHandler, self) # try to access

MyWebServer instance

 self.send_response(200)
 self.send_header('Content-type','text/html')
 self.end_headers()
 self.wfile.write("thanks for trying, but I'd like to get at

self.foo and self.bar")

 return

class MyWebServer(object):
 def __init__(self):
 self.foo = "foo"  # these are what I want to access from inside

do_GET

 self.bar = "bar"
 self.httpd = HTTPServer(('127.0.0.1', 8000), MyRequestHandler)
 sa = self.httpd.socket.getsockname()
 print "Serving HTTP on", sa[0], "port", sa[1], "..."

 def runIt(self):
 self.httpd.serve_forever()

server = MyWebServer()
server.runIt()



I want to access the foo and bar variables from do_GET, but I can't

figure out how. I suppose this is something to do with new-style vs.
old-style classes, but I lost for a solution.

Consider inheriting HTTPServer in MyWebServer which is passed to the
request handler.


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




I keep getting the same problem - if inherit from any of these classes 
in BaseHTTPServer and try to use super(class, self) to initiate the 
higher class, I get the error "TypeError: must be type, not classobj" - 
in other words, these are old-style classes.

That means that in this call -
self.httpd = MyHTTPServer(('127.0.0.1', 8000), MyRequestHandler)

there doesn't seem to be a way to define a
 class MyHTTPServer(HTTPServer)





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


Re: HTTPserver: how to access variables of a higher class?

2013-04-05 Thread Tom P

On 04/05/2013 01:54 PM, Dave Angel wrote:

On 04/05/2013 07:02 AM, Tom P wrote:

First, here's a sample test program:

import sys
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler

class MyRequestHandler(BaseHTTPRequestHandler, object):
 def do_GET(self):
 top_self = super(MyRequestHandler, self) # try to access
MyWebServer instance
 self.send_response(200)
 self.send_header('Content-type','text/html')
 self.end_headers()
 self.wfile.write("thanks for trying, but I'd like to get at
self.foo and self.bar")
 return

class MyWebServer(object):
 def __init__(self):
 self.foo = "foo"  # these are what I want to access from inside
do_GET
 self.bar = "bar"
 self.httpd = HTTPServer(('127.0.0.1', 8000), MyRequestHandler)
 sa = self.httpd.socket.getsockname()
 print "Serving HTTP on", sa[0], "port", sa[1], "..."

 def runIt(self):
 self.httpd.serve_forever()

server = MyWebServer()
server.runIt()



I want to access the foo and bar variables from do_GET, but I can't
figure out how. I suppose this is something to do with new-style vs.
old-style classes, but I lost for a solution.


It'd have been good to tell us that this was on Python 2.7

Is MyWebServer class intended to have exactly one instance?  If so, you
could save the instance as a class attribute, and trivially access it
from outside the class.

If it might have more than one instance, then we'd need to know more
about the class BaseHTTPServer.HTTPServer,  From a quick glance at the
docs, it looks like you get an attribute called server.  So inside the
do_GET() method, you should be able to access   self.server.foo   and
self.server.bar

See http://docs.python.org/2/library/basehttpserver.html


That doesn't work. Maybe you mean something that I'm missing?
Setting a breakpoint in do_GET:
Pdb) b 7
Breakpoint 1 at /home/tom/Desktop/tidy/Python/webserver/simpleWebserver.py:7
(Pdb) c
Serving HTTP on 127.0.0.1 port 8000 ...
> /home/tom/Desktop/tidy/Python/webserver/simpleWebserver.py(7)do_GET()
-> self.send_response(200)
(Pdb) self
<__main__.MyRequestHandler instance at 0x7ff20dde3bd8>
(Pdb) self.server

(Pdb) dir(self.server)
['RequestHandlerClass', '_BaseServer__is_shut_down', 
'_BaseServer__shutdown_request', '__doc__', '__init__', '__module__', 
'_handle_request_noblock', 'address_family', 'allow_reuse_address', 
'close_request', 'fileno', 'finish_request', 'get_request', 
'handle_error', 'handle_request', 'handle_timeout', 'process_request', 
'request_queue_size', 'serve_forever', 'server_activate', 
'server_address', 'server_bind', 'server_close', 'server_name', 
'server_port', 'shutdown', 'shutdown_request', 'socket', 'socket_type', 
'timeout', 'verify_request']

(Pdb) self.server.foo
*** AttributeError: HTTPServer instance has no attribute 'foo'

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


Re: HTTPserver: how to access variables of a higher class?

2013-04-05 Thread Tom P

On 04/05/2013 01:54 PM, Dave Angel wrote:

On 04/05/2013 07:02 AM, Tom P wrote:

First, here's a sample test program:

import sys
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler

class MyRequestHandler(BaseHTTPRequestHandler, object):
 def do_GET(self):
 top_self = super(MyRequestHandler, self) # try to access
MyWebServer instance
 self.send_response(200)
 self.send_header('Content-type','text/html')
 self.end_headers()
 self.wfile.write("thanks for trying, but I'd like to get at
self.foo and self.bar")
 return

class MyWebServer(object):
 def __init__(self):
 self.foo = "foo"  # these are what I want to access from inside
do_GET
 self.bar = "bar"
 self.httpd = HTTPServer(('127.0.0.1', 8000), MyRequestHandler)
 sa = self.httpd.socket.getsockname()
 print "Serving HTTP on", sa[0], "port", sa[1], "..."

 def runIt(self):
 self.httpd.serve_forever()

server = MyWebServer()
server.runIt()



I want to access the foo and bar variables from do_GET, but I can't
figure out how. I suppose this is something to do with new-style vs.
old-style classes, but I lost for a solution.


It'd have been good to tell us that this was on Python 2.7


Yes, sorry for the omission.


Is MyWebServer class intended to have exactly one instance?

Yes, but I was trying to keep it general.
 If so, you

could save the instance as a class attribute, and trivially access it
from outside the class.

If it might have more than one instance, then we'd need to know more
about the class BaseHTTPServer.HTTPServer,  From a quick glance at the
docs, it looks like you get an attribute called server.  So inside the
do_GET() method, you should be able to access   self.server.foo   and
self.server.bar


ok, let me test that.  Do I assume correctly from what you write that 
the super() is not needed?
 In reality there is just one instance of MyWebServer, but I was 
looking for a general solution.


See http://docs.python.org/2/library/basehttpserver.html



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


Re: HTTPserver: how to access variables of a higher class?

2013-04-05 Thread Tom P

On 04/05/2013 02:27 PM, Dylan Evans wrote:

On 05/04/2013 9:09 PM, "Tom P"  wrote:


First, here's a sample test program:

import sys
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler

class MyRequestHandler(BaseHTTPRequestHandler, object):
 def do_GET(self):
 top_self = super(MyRequestHandler, self) # try to access

MyWebServer instance

 self.send_response(200)
 self.send_header('Content-type','text/html')
 self.end_headers()
 self.wfile.write("thanks for trying, but I'd like to get at

self.foo and self.bar")

 return

class MyWebServer(object):
 def __init__(self):
 self.foo = "foo"  # these are what I want to access from inside

do_GET

 self.bar = "bar"
 self.httpd = HTTPServer(('127.0.0.1', 8000), MyRequestHandler)
 sa = self.httpd.socket.getsockname()
 print "Serving HTTP on", sa[0], "port", sa[1], "..."

 def runIt(self):
 self.httpd.serve_forever()

server = MyWebServer()
server.runIt()



I want to access the foo and bar variables from do_GET, but I can't

figure out how. I suppose this is something to do with new-style vs.
old-style classes, but I lost for a solution.

Consider inheriting HTTPServer in MyWebServer which is passed to the
request handler.



That was the next thing I was going to try, thanks.


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




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


HTTPserver: how to access variables of a higher class?

2013-04-05 Thread Tom P

First, here's a sample test program:

import sys
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler

class MyRequestHandler(BaseHTTPRequestHandler, object):
def do_GET(self):
top_self = super(MyRequestHandler, self) # try to access 
MyWebServer instance

self.send_response(200)
self.send_header('Content-type','text/html')
self.end_headers()
self.wfile.write("thanks for trying, but I'd like to get at 
self.foo and self.bar")

return

class MyWebServer(object):
def __init__(self):
self.foo = "foo"  # these are what I want to access from inside 
do_GET

self.bar = "bar"
self.httpd = HTTPServer(('127.0.0.1', 8000), MyRequestHandler)
sa = self.httpd.socket.getsockname()
print "Serving HTTP on", sa[0], "port", sa[1], "..."

def runIt(self):
self.httpd.serve_forever()

server = MyWebServer()
server.runIt()



I want to access the foo and bar variables from do_GET, but I can't 
figure out how. I suppose this is something to do with new-style vs. 
old-style classes, but I lost for a solution.

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


Re: The usage of -m option of python

2013-03-27 Thread Tom P

On 03/18/2013 10:17 PM, Peng Yu wrote:

Hi,

I don't quite understand how -m option is used. And it is difficult to
search for -m in google. Could anybody provide me with an example on
how to use this option? Thanks!

-m module-name
   Searches sys.path for the named module and runs the
corresponding .py file as a script.



The most practical use I know is to run the debug program..
python -mpdb yourprogramm.py arguments..



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


Re: Controlling number of zeros of exponent in scientific notation

2013-03-06 Thread Russ P.
One possibility is to form the string as usual, split on the "e", format each 
part separately, then rejoin with an "e".

On Tuesday, March 5, 2013 12:09:10 PM UTC-8, fa...@squashclub.org wrote:
> Instead of:
> 
> 
> 
> 1.8e-04
> 
> 
> 
> I need:
> 
> 
> 
> 1.8e-004
> 
> 
> 
> So two zeros before the 4, instead of the default 1.

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


Re: Uniquely identifying each & every html template

2013-01-21 Thread Tom P

On 01/21/2013 01:39 PM, Oscar Benjamin wrote:

On 21 January 2013 12:06, Ferrous Cranus  wrote:

Τη Δευτέρα, 21 Ιανουαρίου 2013 11:31:24 π.μ. UTC+2, ο χρήστης Chris Angelico 
έγραψε:


Seriously, you're asking for something that's beyond the power of
humans or computers. You want to identify that something's the same
file, without tracking the change or having any identifiable tag.

That's a fundamentally impossible task.


No, it is difficult but not impossible.
It just cannot be done by tagging the file by:

1. filename
2. filepath
3. hash (math algorithm producing a string based on the file's contents)

We need another way to identify the file WITHOUT using the above attributes.


This is a very old problem (still unsolved I believe):
http://en.wikipedia.org/wiki/Ship_of_Theseus


Oscar

That wiki article gives a hint to a poosible solution -use a timestamp 
to determine which key is valid when.

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


I'm looking for a Junior level Django job (telecommute)

2013-01-07 Thread P Dev
I'm looking for a Junior level Django job (telecommute)

About me:

- less than year of experience with Python/Django

- Intermediate knowledge of Python/Django
- Experience with Linux
- Experience with Django ORM
- Passion for developing high-quality software and Python language

- I am able to use many aplications, for example (south, mptt, 
django-debug-toolbar etc.)

- English: communicative, still learning

I would like to develop my qualifications

I can be reached anytime via email at dreampr...@gmail.com

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


Python-UK Community on google+

2012-12-07 Thread Martin P. Hellwig
Hi All,

I created the Python-UK Community on google+, so if you are using google+ and 
you are interested in Python and you are interested in the UK, I heartily 
invite you to join.

My intention is to transfer the ownership to the PyCon UK organization, which I 
already have contacted a member of.

You can find it here:
https://plus.google.com/u/0/communities/109155400666012015869

Hope to see you soon :-)

Martin P. Hellwig

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


Re: debugging in eclipse

2012-11-15 Thread Martin P. Hellwig
On Thursday, 15 November 2012 12:29:04 UTC, chip...@gmail.com  wrote:
> Hi all!
> 
> 
> 
> I have a stupid problem, for which I cannot find a solution...
> 
> 
> 
> I have a python module, lets call it debugTest.py.
> 
> 
> 
> and it contains:
> 
> def test():
> 
> a=1
> 
> b=2
> 
> c=a+b
> 
> c
> 
> 
> 
> so as simple as possible.
> 
> 
> 
> Now I would like to debug it in eclipse.. (I have pydev and all)
> 
> so the question is how do I debug the test function? (by debug I mean go into 
> it in the debugging mode and execute step by step, inspect the variables and 
> so on.. you know, like it is so easily done in Matlab for example).
> 
> 
> 
> I place a break point in the function, run the debugger and it stars and is 
> terminated immediately. (of course it does not know where to go..)
> 
> 
> 
> So how can I do this? please help!
> 
> 
> 
> Thank you all in advance!

I assume you have at the end of the debugTest.py file something like this:

if __name__ == '__main__':
   test()
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Article on the future of Python

2012-09-25 Thread Martin P. Hellwig
On Tuesday, 25 September 2012 09:14:27 UTC+1, Mark Lawrence  wrote:
> Hi all,
> 
> I though this might be of interest.
> http://www.ironfroggy.com/software/i-am-worried-about-the-future-of-python
> -- 
> 
> Cheers.
> Mark Lawrence.

I glanced over the article but it seems to me another 'I am afraid this is not 
the silver bullet I wanted it to be' article without actually going into the 
need of a silver bullet or whether the concept of a silver bullet is sound at 
all.

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


Re: simple client data base

2012-09-03 Thread Martin P. Hellwig
On Monday, 3 September 2012 15:12:21 UTC+1, Manatee  wrote:
> Hello all, I am learning to program in python. I have a need to make a
> 
> program that can store, retrieve, add, and delete client data such as
> 
> name, address, social, telephone number and similar information. This
> 
> would be a small client database for my wife who has a home accounting
> 
> business.
> 
> 
> 
> I have been reading about lists, tuples, and dictionary data
> 
> structures in python and I am confused as to which would be more
> 
> appropriate for a simple database.
> 
> 
> 
> I know that python has real database capabilities but I'm not there
> 
> yet and would like to proceed with as simple a structure as possible.
> 
> 
> 
> Can anyone give me some idea's or tell me which structure would be
> 
> best to use?
> 
> 
> 
> Maybe its a combination of structures? I need some help.
> 
> 
> 
> Thanks for your help.

How about the half-way house, sqlite3 which comes with python?

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


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

2012-08-06 Thread Tom P

On 08/06/2012 08:29 PM, Grant Edwards wrote:

On 2012-08-06, Grant Edwards  wrote:

On 2012-08-06, Tom P  wrote:

On 08/06/2012 06:18 PM, Nobody wrote:

On Mon, 06 Aug 2012 17:52:31 +0200, Tom P wrote:


consider a nested loop algorithm -

for i in range(100):
   for j in range(100):
   do_something(i,j)

Now, suppose I don't want to use i = 0 and j = 0 as initial values, but
some other values i = N and j = M, and I want to iterate through all
10,000 values in sequence - is there a neat python-like way to this?


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

Or did you mean something else?


no, I meant something else ..

j runs through range(M, 100) and then range(0,M), and i runs through
range(N,100) and then range(0,N)


In 2.x:

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

Dunno if that still works in 3.x.  I doubt it, since I think in 3.x
range returns an iterator, not?


Indeed it doesn't work in 3.x, but this does:

 from itertools import chain

 for i in chain(range(M,100),range(0,M)):
 for j in chain(range(N,100),range(0,N)):
 do_something(i,j)



 ah, that looks good - I guess it works in 2.x as well?
--
http://mail.python.org/mailman/listinfo/python-list


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

2012-08-06 Thread Tom P

On 08/06/2012 06:03 PM, John Gordon wrote:

In  Tom P  writes:


consider a nested loop algorithm -



for i in range(100):
  for j in range(100):
  do_something(i,j)



Now, suppose I don't want to use i = 0 and j = 0 as initial values, but
some other values i = N and j = M, and I want to iterate through all
10,000 values in sequence - is there a neat python-like way to this? I
realize I can do things like use a variable for k in range(1): and
then derive values for i and j from k, but I'm wondering if there's
something less clunky.


You could define your own generator function that yields values
in whatever order you want:

def my_generator():
 yield 9
 yield 100
 for i in range(200, 250):
 yield i
 yield 5


Thanks, I'll look at that but I think it just moves the clunkiness from 
one place in the code to another.


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


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

2012-08-06 Thread Tom P

On 08/06/2012 06:18 PM, Nobody wrote:

On Mon, 06 Aug 2012 17:52:31 +0200, Tom P wrote:


consider a nested loop algorithm -

for i in range(100):
  for j in range(100):
  do_something(i,j)

Now, suppose I don't want to use i = 0 and j = 0 as initial values, but
some other values i = N and j = M, and I want to iterate through all
10,000 values in sequence - is there a neat python-like way to this?


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

Or did you mean something else?


no, I meant something else ..

  j runs through range(M, 100) and then range(0,M), and i runs through 
range(N,100) and then range(0,N)


.. apologies if I didn't make that clear enough.



Alternatively:

import itertools

for i, j in itertools.product(range(N,N+100),range(M,M+100)):
do_something(i,j)

This can be preferable to deeply-nested loops.

Also: in 2.x, use xrange() in preference to range().



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


looking for a neat solution to a nested loop problem

2012-08-06 Thread Tom P

consider a nested loop algorithm -

for i in range(100):
for j in range(100):
do_something(i,j)

Now, suppose I don't want to use i = 0 and j = 0 as initial values, but 
some other values i = N and j = M, and I want to iterate through all 
10,000 values in sequence - is there a neat python-like way to this? I 
realize I can do things like use a variable for k in range(1): and 
then derive values for i and j from k, but I'm wondering if there's 
something less clunky.

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


Re: Newbie question on python programming

2012-07-21 Thread Tom P

On 07/21/2012 02:30 AM, Ian Kelly wrote:

On Fri, Jul 20, 2012 at 5:38 PM, Chris Williams
 wrote:

Hello

I hope this is the right newsgroup for this post.

I am just starting to learn python programming and it seems very
straightforward so far. It seems, however, geared toward doing the sort of
programming for terminal output.

Is it possible to write the sort of applications you can create in something
like c-sharp or visual c++, or should I be looking at some other programming
language? I am using ubuntu 12.04.


There are plenty of options for GUI programming in Python.  Among the
most popular are Tkinter, wxPython, PyGTK, and PyQT, all of which are
cross-platform and free.  Also, since you specifically mention the
.NET languages, IronPython runs on .NET and so is able to make full
use of the .NET APIs including Windows Forms and WPF.  A more
comprehensive list can be found at:

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



Another platform independent approach is to write the program as a web 
server something like this-

def application(environ, start_response):
start_response("200 OK", [("Content-type", "text/plain")])
return ["Hello World!"]

if __name__ == '__main__':
from wsgiref.simple_server import make_server
server = make_server('localhost', 8080, application)
server.serve_forever()

Run this and then use your browser to connect to localhost:8080
You can then use html features such as forms for input/output.

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


Re: Writing a wrapper - any tips?

2012-07-13 Thread Martin P. Hellwig
On Friday, 13 July 2012 05:03:23 UTC+1, Temia Eszteri  wrote:
> I'm going to be looking into writing a wrapper for the Allegro 5 game
> development libraries, either with ctypes or Cython. They technically
> have a basic 1:1 ctypes wrapper currently, but I wanted to make
> something more pythonic, because it'd be next to impossible to deal
> with the memory management cleanly in the script itself.
> 
> Anything I should keep in mind? Any tips to pass on to a first-time
> module writer, pitfalls to watch out for, etc.?

I would split the wrapping in layers, the lowest layer is a one on one exposure 
of the library with your wrapper, I would rather avoid ctypes for performance 
reasons, however if performance is not a concern ctypes is excellent and 
broadly available.

The next layer is purely there to make the lower layer pythonic, i.e. apply 
namespaces, automatic handling of memory, PEP8 naming convetions, etc. etc.
just what you would expect from a modern pure python module

The next layer, if you want to, contains tools that are often used in that 
concept, think in the line of design patterns.

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


Re: code review

2012-06-30 Thread Martin P. Hellwig
On Saturday, 30 June 2012 21:30:45 UTC+1, Alister  wrote:
> On Sat, 30 Jun 2012 21:38:58 +0200, Thomas Jollans wrote:
> 
> > On 06/30/2012 08:39 PM, Thomas 'PointedEars' Lahn wrote:
> >> Peter Otten wrote:
> >> 
> >>> If you spell it
> >>>
> >>> def is_valid_password(password):
> >>> return mud.minpass <= len(password) <= mud.maxpass
> >>>

> Surely this fits perfectly with the lines 1 & 7 in the zen of python 
> (import this)
> "Beautifull is better than ugly" and "Readability counts"
> 
Agree, however I like to stress the "don't make me unnecessary read with care" 
rule. Meaning if I read that line, I have to read it carefully to make sure I 
understand what is happening, the following would not do that although syntax 
wise equal:

def length_between_min_max(password):
   return(mud.minpass <= len(password) <= mud.maxpass)
   

def is_valid_password(password):
   valid = True

   if not length_between_max_min(password):
  valid = False

   if some_other_test(password):
  valid = False


  return(valid)

This I can read, typically I would not even read what the function 
length_beteen_max_min does as long as there is no bug in it because, it is 
perfectly english clear what the intention is.

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


Re: code review

2012-06-29 Thread Martin P. Hellwig
On Friday, 29 June 2012 20:41:11 UTC+1, Alister  wrote:
> On Fri, 29 Jun 2012 09:03:22 -0600, Littlefield, Tyler wrote:
> 
> > On 6/29/2012 1:31 AM, Steven D'Aprano wrote:
> >> On Thu, 28 Jun 2012 20:58:15 -0700, alex23 wrote:
> >>
> >>> On Jun 29, 12:57 pm, "Littlefield, Tyler"  wrote:
> >>>> I was curious if someone wouldn't mind poking at some code. The
> >>>> project page is at:http://code.google.com/p/pymud Any information is
> >>>> greatly appreciated.
> >>> I couldn't find any actual code at that site, the git repository is
> >>> currently empty.
> > 
> > OOPS, sorry. Apparently I'm not as good with git as I thought.
> > Everything's in the repo now.
> 
> I am no expert but from what have picked up so far
> 
> from x import 
> 
>  is frowned upon in most cases 

from x import * is frowned upon, however, from x import y is fine IMHO.
> 
> also this section in main strikes me as a bit odd and convoluted
> 
> w = world()
> serv = server(client)
> w.server = serv
> serv.world = w
> 
> I think you are cross referencing classes & would be better to 
> investigate inheritance.
> 

Generally speaking, read PEP8 and apply it please, there are tools like pylint 
that can help you with that. It also seems you are doing things quite java 
like, but I guess that is just a thing of getting used to python.

If you are planning to let your code being used like a framework that is 
extended by others, try to avoid more advanced functions just because they seem 
handy, always ask yourself is it clearer?

Try to unit-test your code and try to gain some decent code coverage, that will 
increase maturity of your code rather quickly.

But for the rest it looks like you are good in organizing it all in 
sub-modules, which is a very nice thing to see.

Good luck!

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


Re: Open Source: you're doing it wrong - the Pyjamas hijack

2012-05-09 Thread Martin P. Hellwig

On 09/05/2012 12:02, anth...@xtfx.me wrote:


Hello C Anthony,

I am an pyjs user and introduced the project as one of the fundamental 
parts of a new application that is now core of a company of a reasonable 
size (30+), customers include several companies in the top 10 of largest 
IT infrastructures, I can mail you a list in private if you wish so.


I agree that the project leadership had certainly room for improvement.
I also agree that to move forward there had to be made some choices.

However, as the person introducing this project in a commercial venture, 
I am also the one having the responsibility of it in my setting.


I have been put in a position where I have to come up with answers, like 
why the examples page didn't work, why the project seems fragile and if 
there is any viability at all.


Of course, I still believe in the project, with all it warts and so 
forth. However my position has been made needlessly difficult, because 
the action you took did not leave room for choice.


Let me explain this, if you had forked the project, created a new 
domain, mailing list and, took over the majority of the devs, I would be 
able to make a choice if I go with the new guys or stick with the couple 
of old ones, just like the xorg fork.


If your argument is that this was your intention but was persuaded to do 
other wise, I would say that is a lapse of judgement and not a very good 
restart of the project.


Unfortunately mistakes made in public, even if arguably they are not 
mistakes at all, are not easy forgotten and can end up haunting you.


I hope you will take these comments with you as a lesson learned, I do 
wish you all the best and look forward to the improvements you are going 
to contribute.


--
Martin P. Hellwig (mph)
--
http://mail.python.org/mailman/listinfo/python-list


Re: numpy (matrix solver) - python vs. matlab

2012-05-03 Thread Russ P.
On May 3, 4:59 pm, someone  wrote:
> On 05/04/2012 12:58 AM, Russ P. wrote:
>
> > Yeah, I realized that I should rephrase my previous statement to
> > something like this:
>
> > For any *empirical* engineering or scientific work, I'd say that a
> > condition number of 1e6 is likely to be unacceptable.
>
> Still, I don't understand it. Do you have an example of this kind of
> work, if it's not FEM?
>
> > I'd put finite elements into the category of theoretical and numerical
> > rather than empirical. Still, a condition number of 1e6 would bother
> > me, but maybe that's just me.
>
> Ok, but I just don't understand what's in the "empirical" category, sorry...

I didn't look it up, but as far as I know, empirical just means based
on experiment, which means based on measured data. Unless I am
mistaken , a finite element analysis is not based on measured data.
Yes, the results can be *compared* with measured data and perhaps
calibrated with measured data, but those are not the same thing.

I agree with Steven D's comment above, and I will reiterate that a
condition number of 1e6 would not inspire confidence in me. If I had a
condition number like that, I would look for a better model. But
that's just a gut reaction, not a hard scientific rule.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: numpy (matrix solver) - python vs. matlab

2012-05-03 Thread Russ P.
Yeah, I realized that I should rephrase my previous statement to
something like this:

For any *empirical* engineering or scientific work, I'd say that a
condition number of 1e6 is likely to be unacceptable.

I'd put finite elements into the category of theoretical and numerical
rather than empirical. Still, a condition number of 1e6 would bother
me, but maybe that's just me.

--Russ P.


On May 3, 3:21 pm, someone  wrote:
> On 05/03/2012 07:55 PM, Russ P. wrote:
>
>
>
> > On May 3, 10:30 am, someone  wrote:
> >> On 05/02/2012 11:45 PM, Russ P. wrote:
> >>> For any practical engineering or scientific work, I'd say that a
> >>> condition number of 1e6 is very likely to be completely unacceptable.
>
> >> So how do you explain that the natural frequencies from FEM (with
> >> condition number ~1e6) generally correlates really good with real
> >> measurements (within approx. 5%), at least for the first 3-4 natural
> >> frequencies?
>
> >> I would say that the problem lies with the highest natural frequencies,
> >> they for sure cannot be verified - there's too little energy in them.
> >> But the lowest frequencies (the most important ones) are good, I think -
> >> even for high cond number.
>
> > Did you mention earlier what "FEM" stands for? If so, I missed it. Is
> > it finite-element modeling? Whatever the case, note that I said, "If
>
> Sorry, yes: Finite Element Model.
>
> > you are just doing pure mathematical or numerical work with no real-
> > world measurement error, then a condition number of
> > 1e6 may be fine." I forgot much more than I know about finite-element
> > modeling, but isn't it a purely numerical method of analysis? If that
>
> I'm not sure exactly, what is the definition of a purely numerical
> method of analysis? I would guess that the answer is yes, it's a purely
> numerical method? But I also thing it's a practical engineering or
> scientific work...
>
> > is the case, then my comment above is relevant.
>
> Uh, I just don't understand the difference:
>
> 1) "For any practical engineering or scientific work, I'd say that a
> condition number of 1e6 is very likely to be completely unacceptable."
>
> vs.
>
> 2) "If you are just doing pure mathematical or numerical work with no
> real-world measurement error, then a condition number of, 1e6 may be fine."
>
> I would think that FEM is a practical engineering work and also pure
> numerical work... Or something...
>
> > By the way, I didn't mean to patronize you with my earlier explanation
> > of orthogonal transformations. They are fundamental to understanding
> > the SVD, and I thought it might be interesting to anyone who is not
> > familiar with the concept.
>
> Don't worry, I think it was really good and I don't think anyone
> patronized me, on the contrary, people was/is very helpful. SVD isn't my
> strongest side and maybe I should've thought a bit more about this
> singular matrix and perhaps realized what some people here already
> explained, a bit earlier (maybe before I asked). Anyway, it's been good
> to hear/read what you've (and others) have written.
>
> Yesterday and earlier today I was at work during the day so
> answering/replying took a bit longer than I like, considering the huge
> flow of posts in the matlab group. But now I'm home most of the time,
> for the next 3 days and will check for followup posts quite frequent, I
> think...

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


Re: numpy (matrix solver) - python vs. matlab

2012-05-03 Thread Russ P.
On May 3, 10:30 am, someone  wrote:
> On 05/02/2012 11:45 PM, Russ P. wrote:
>
>
>
> > On May 2, 1:29 pm, someone  wrote:
>
> >>> If your data starts off with only 1 or 2 digits of accuracy, as in your
> >>> example, then the result is meaningless -- the accuracy will be 2-2
> >>> digits, or 0 -- *no* digits in the answer can be trusted to be accurate.
>
> >> I just solved a FEM eigenvalue problem where the condition number of the
> >> mass and stiffness matrices was something like 1e6... Result looked good
> >> to me... So I don't understand what you're saying about 10 = 1 or 2
> >> digits. I think my problem was accurate enough, though I don't know what
> >> error with 1e6 in condition number, I should expect. How did you arrive
> >> at 1 or 2 digits for cond(A)=10, if I may ask ?
>
> > As Steven pointed out earlier, it all depends on the precision you are
> > dealing with. If you are just doing pure mathematical or numerical
> > work with no real-world measurement error, then a condition number of
> > 1e6 may be fine. But you had better be using "double precision" (64-
> > bit) floating point numbers (which are the default in Python, of
> > course). Those have approximately 12 digits of precision, so you are
> > in good shape. Single-precision floats only have 6 or 7 digits of
> > precision, so you'd be in trouble there.
>
> > For any practical engineering or scientific work, I'd say that a
> > condition number of 1e6 is very likely to be completely unacceptable.
>
> So how do you explain that the natural frequencies from FEM (with
> condition number ~1e6) generally correlates really good with real
> measurements (within approx. 5%), at least for the first 3-4 natural
> frequencies?
>
> I would say that the problem lies with the highest natural frequencies,
> they for sure cannot be verified - there's too little energy in them.
> But the lowest frequencies (the most important ones) are good, I think -
> even for high cond number.

Did you mention earlier what "FEM" stands for? If so, I missed it. Is
it finite-element modeling? Whatever the case, note that I said, "If
you are just doing pure mathematical or numerical work with no real-
world measurement error, then a condition number of
1e6 may be fine." I forgot much more than I know about finite-element
modeling, but isn't it a purely numerical method of analysis? If that
is the case, then my comment above is relevant.

By the way, I didn't mean to patronize you with my earlier explanation
of orthogonal transformations. They are fundamental to understanding
the SVD, and I thought it might be interesting to anyone who is not
familiar with the concept.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: numpy (matrix solver) - python vs. matlab

2012-05-02 Thread Russ P.
On May 2, 1:29 pm, someone  wrote:

> > If your data starts off with only 1 or 2 digits of accuracy, as in your
> > example, then the result is meaningless -- the accuracy will be 2-2
> > digits, or 0 -- *no* digits in the answer can be trusted to be accurate.
>
> I just solved a FEM eigenvalue problem where the condition number of the
> mass and stiffness matrices was something like 1e6... Result looked good
> to me... So I don't understand what you're saying about 10 = 1 or 2
> digits. I think my problem was accurate enough, though I don't know what
> error with 1e6 in condition number, I should expect. How did you arrive
> at 1 or 2 digits for cond(A)=10, if I may ask ?

As Steven pointed out earlier, it all depends on the precision you are
dealing with. If you are just doing pure mathematical or numerical
work with no real-world measurement error, then a condition number of
1e6 may be fine. But you had better be using "double precision" (64-
bit) floating point numbers (which are the default in Python, of
course). Those have approximately 12 digits of precision, so you are
in good shape. Single-precision floats only have 6 or 7 digits of
precision, so you'd be in trouble there.

For any practical engineering or scientific work, I'd say that a
condition number of 1e6 is very likely to be completely unacceptable.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: numpy (matrix solver) - python vs. matlab

2012-05-01 Thread Russ P.
On May 1, 11:03 pm, someone  wrote:
> On 05/02/2012 01:38 AM, Russ P. wrote:
>
>
>
>
>
>
>
>
>
> > On May 1, 4:05 pm, Paul Rubin  wrote:
> >> someone  writes:
> >>> Actually I know some... I just didn't think so much about, before
> >>> writing the question this as I should, I know theres also something
> >>> like singular value decomposition that I think can help solve
> >>> otherwise illposed problems,
>
> >> You will probably get better advice if you are able to describe what
> >> problem (ill-posed or otherwise) you are actually trying to solve.  SVD
> >> just separates out the orthogonal and scaling parts of the
> >> transformation induced by a matrix.  Whether that is of any use to you
> >> is unclear since you don't say what you're trying to do.
>
> > I agree with the first sentence, but I take slight issue with the word
> > "just" in the second. The "orthogonal" part of the transformation is
> > non-distorting, but the "scaling" part essentially distorts the space.
> > At least that's how I think about it. The larger the ratio between the
> > largest and smallest singular value, the more distortion there is. SVD
> > may or may not be the best choice for the final algorithm, but it is
> > useful for visualizing the transformation you are applying. It can
> > provide clues about the quality of the selection of independent
> > variables, state variables, or inputs.
>
> Me would like to hear more! :-)
>
> It would really appreciate if anyone could maybe post a simple SVD
> example and tell what the vectors from the SVD represents geometrically
> / visually, because I don't understand it good enough and I'm sure it's
> very important, when it comes to solving matrix systems...

SVD is perhaps the ultimate matrix decomposition and the ultimate tool
for linear analysis. Google it and take a look at the excellent
Wikipedia page on it. I would be wasting my time if I tried to compete
with that.

To really appreciate the SVD, you need some background in linear
algebra. In particular, you need to understand orthogonal
transformations. Think about a standard 3D Cartesian coordinate frame.
A rotation of the coordinate frame is an orthogonal transformation of
coordinates. The original frame and the new frame are both orthogonal.
A vector in one frame is converted to the other frame by multiplying
by an orthogonal matrix. The main feature of an orthogonal matrix is
that its transpose is its inverse (hence the inverse is trivial to
compute).

The SVD can be thought of as factoring any linear transformation into
a rotation, then a scaling, followed by another rotation. The scaling
is represented by the middle matrix of the transformation, which is a
diagonal matrix of the same dimensions as the original matrix. The
singular values can be read off of the diagonal. If any of them are
zero, then the original matrix is singular. If the ratio of the
largest to smallest singular value is large, then the original matrix
is said to be poorly conditioned.

Standard Cartesian coordinate frames are orthogonal. Imagine an x-y
coordinate frame in which the axes are not orthogonal. Such a
coordinate frame is possible, but they are rarely used. If the axes
are parallel, the coordinate frame will be singular and will basically
reduce to one-dimensional. If the x and y axes are nearly parallel,
the coordinate frame could still be used in theory, but it will be
poorly conditioned. You will need large numbers to represent points
fairly close to the origin, and small deviations will translate into
large changes in coordinate values. That can lead to problems due to
numerical roundoff errors and other kinds of errors.

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


Re: numpy (matrix solver) - python vs. matlab

2012-05-01 Thread Russ P.
On May 1, 4:05 pm, Paul Rubin  wrote:
> someone  writes:
> > Actually I know some... I just didn't think so much about, before
> > writing the question this as I should, I know theres also something
> > like singular value decomposition that I think can help solve
> > otherwise illposed problems,
>
> You will probably get better advice if you are able to describe what
> problem (ill-posed or otherwise) you are actually trying to solve.  SVD
> just separates out the orthogonal and scaling parts of the
> transformation induced by a matrix.  Whether that is of any use to you
> is unclear since you don't say what you're trying to do.

I agree with the first sentence, but I take slight issue with the word
"just" in the second. The "orthogonal" part of the transformation is
non-distorting, but the "scaling" part essentially distorts the space.
At least that's how I think about it. The larger the ratio between the
largest and smallest singular value, the more distortion there is. SVD
may or may not be the best choice for the final algorithm, but it is
useful for visualizing the transformation you are applying. It can
provide clues about the quality of the selection of independent
variables, state variables, or inputs.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: numpy (matrix solver) - python vs. matlab

2012-05-01 Thread Russ P.
On May 1, 11:52 am, someone  wrote:
> On 04/30/2012 03:35 AM, Nasser M. Abbasi wrote:
>
> > On 04/29/2012 07:59 PM, someone wrote:
> > I do not use python much myself, but a quick google showed that pyhton
> > scipy has API for linalg, so use, which is from the documentation, the
> > following code example
>
> > X = scipy.linalg.solve(A, B)
>
> > But you still need to check the cond(). If it is too large, not good.
> > How large and all that, depends on the problem itself. But the rule of
> > thumb, the lower the better. Less than 100 can be good in general, but I
> > really can't give you a fixed number to use, as I am not an expert in
> > this subjects, others who know more about it might have better
> > recommendations.
>
> Ok, that's a number...
>
> Anyone wants to participate and do I hear something better than "less
> than 100 can be good in general" ?
>
> If I don't hear anything better, the limit is now 100...
>
> What's the limit in matlab (on the condition number of the matrices), by
> the way, before it comes up with a warning ???

The threshold of acceptability really depends on the problem you are
trying to solve. I haven't solved linear equations for a long time,
but off hand, I would say that a condition number over 10 is
questionable.

A high condition number suggests that the selection of independent
variables for the linear function you are trying to fit is not quite
right. For a poorly conditioned matrix, your modeling function will be
very sensitive to measurement noise and other sources of error, if
applicable. If the condition number is 100, then any input on one
particular axis gets magnified 100 times more than other inputs.
Unless your inputs are very precise, that is probably not what you
want.

Or something like that.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: numpy (matrix solver) - python vs. matlab

2012-05-01 Thread Russ P.
On Apr 29, 5:17 pm, someone  wrote:
> On 04/30/2012 12:39 AM, Kiuhnm wrote:
>
> >> So Matlab at least warns about "Matrix is close to singular or badly
> >> scaled", which python (and I guess most other languages) does not...
>
> > A is not just close to singular: it's singular!
>
> Ok. When do you define it to be singular, btw?
>
> >> Which is the most accurate/best, even for such a bad matrix? Is it
> >> possible to say something about that? Looks like python has a lot more
> >> digits but maybe that's just a random result... I mean Element 1,1 =
> >> 2.81e14 in Python, but something like 3e14 in Matlab and so forth -
> >> there's a small difference in the results...
>
> > Both results are *wrong*: no inverse exists.
>
> What's the best solution of the two wrong ones? Best least-squares
> solution or whatever?
>
> >> With python, I would also kindly ask about how to avoid this problem in
> >> the future, I mean, this maybe means that I have to check the condition
> >> number at all times before doing anything at all ? How to do that?
>
> > If cond(A) is high, you're trying to solve your problem the wrong way.
>
> So you're saying that in another language (python) I should check the
> condition number, before solving anything?
>
> > You should try to avoid matrix inversion altogether if that's the case.
> > For instance you shouldn't invert a matrix just to solve a linear system.
>
> What then?
>
> Cramer's rule?

If you really want to know just about everything there is to know
about a matrix, take a look at its Singular Value Decomposition (SVD).
I've never used numpy, but I assume it can compute an SVD.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python randomly exits with Linux OS error -9 or -15

2012-04-09 Thread Martin P. Hellwig

On 09/04/2012 11:01, Janis wrote:

My experience is that these kind of behaviors are observed when (from 
most to least likeliness):

- Your kernel barfs on a limit, e.g. space/inodes/processes/memory/etc.
- You have a linked library mismatch
- You have bit rot on your system
- You have a faulty linked library
- You have a faulty kernel

The last two are academic for me as I never have seen it in real life, 
but could be possible and the bit rot one only bit me once in the last 
15 years (well I since then use RAID on all but convenience systems).


hth

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


Re: f python?

2012-04-08 Thread Martin P. Hellwig

On 08/04/2012 12:11, Xah Lee wrote:

Hi Xah,

You clearly didn't want help on this subject, as you really now how to 
do it anyway. But having read your posts over the years, I'd like to 
give you an observation on your persona, free of charge! :-)


You are actually a talented writer, some may find your occasional 
profanity offensive but at least it highlights your frustration.
You are undoubtedly and proven a good mathematian and more important 
than that self taught. You have a natural feel for design (otherwise you 
would not clash with others view of programming).

You know a mixture of programming languages.

Whether you like it or not, you are in the perfect position to create a 
new programming language and design a new programming paradigm.
Unhindered from all the legacy crap, that keep people like me behind (I 
actually like BNF for example).


It is likely I am wrong, but if that is your destiny there is no point 
fighting it.


Cheers and good luck,

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


Re: Eclipse, C, and Python

2012-03-20 Thread Martin P. Hellwig

On 20/03/2012 06:00, Richard Medina Calderon wrote:

Hello Forum. I have installed Python comnpiler in Eclipse Classic for Windows.
After a while I have installed the C compiler. However, somehow now when I try 
to run my code in Python it shows me for default Ant

Run -->Ant Build

I switched my workspace but still. Do you know how to solve this?..

Thanks


You might want to install the PyDev plugin and switch to that 
perspective (after configuring it).


Cheers,

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


pyserial for GPS data

2012-03-15 Thread Arun p das
I have a USB GPS dongle using this for getting  position information. I
installed gpsd daemon so that any clients can read data from that. It is
working fine
used xgps, cgps as clients.

*gpsd -n -N -D2 /dev/ttyUSB0 *

import gps, os, time
g = gps.gps(mode=gps.WATCH_NEWSTYLE)
while 1:
os.system('clear')
g.poll()
#if gps.PACKET_SET:
g.stream()
print 'latitude ' , g.fix.latitude
print 'longitude ' , g.fix.longitude
print 'time utc ' , g.utc,' + ', g.fix.time


Used the following program to read gps data but it is not giving accurate
readings as cgps,xgps clients. I tried to read directly from the serial
port using the following program but its giving non printable characters as
output as it should return something like

$GPRMC,199304.973,3248.7780,N,11355.7832,W,1,06,02.2,25722.5,M,,,*00"

*import serial*
*ser = serial.Serial( port='/dev/ttyUSB0', baudrate=4800,timeout=1) *
*while True:*
* line=ser.read()*
* print line,*
*f.close()*
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: are int, float, long, double, side-effects of computer engineering?

2012-03-07 Thread Russ P.
On Mar 6, 7:25 pm, rusi  wrote:
> On Mar 6, 6:11 am, Xah Lee  wrote:
>
> > some additional info i thought is relevant.
>
> > are int, float, long, double, side-effects of computer engineering?
>
> It is a bit naive for computer scientists to club integers and reals
> as mathematicians do given that for real numbers, even equality is
> undecidable!
> Mostly when a system like mathematica talks of real numbers it means
> computable real numbers which is a subset of mathematical real numbers
> (and of course a superset of floats)
>
> Seehttp://en.wikipedia.org/wiki/Computable_number#Can_computable_numbers...

I might add that Mathematica is designed mainly for symbolic
computation, whereas IEEE floating point numbers are intended for
numerical computation. Those are two very different endeavors. I
played with Mathematica a bit several years ago, and I know it can do
numerical computation too. I wonder if it resorts to IEEE floating
point numbers when it does.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: are int, float, long, double, side-effects of computer engineering?

2012-03-06 Thread Russ P.
On Mar 5, 10:34 pm, Xah Lee  wrote:
> On Mar 5, 9:26 pm, Tim Roberts  wrote:
>
> > Xah Lee  wrote:
>
> > >some additional info i thought is relevant.
>
> > >are int, float, long, double, side-effects of computer engineering?
>
> > Of course they are.  Such concepts violate the purity of a computer
> > language's abstraction of the underlying hardware.  We accept that
> > violation because of performance reasons.  There are, as you point out,
> > languages that do maintain the purity of the abstraction, but that purity
> > is ALWAYS at the expense of performance.
>
> > I would also point out pre-emptively that there is nothing inherently wrong
> > with asking us to accept an impure abstraction in exchange for performance.
> > It is a performance choice that we choose to make.
>
> while what you said is true, but the problem is that 99.99% of
> programers do NOT know this. They do not know Mathematica. They've
> never seen a language with such feature. The concept is alien. This is
> what i'd like to point out and spread awareness.

I seriously doubt that. I think most decent programmers are well aware
of the limitations of floating point math. If properly used, double-
precision arithmetic is more than adequate for the vast majority of
practical scientific and engineering problems.

> also, argument about raw speed and fine control vs automatic
> management, rots with time. Happened with auto memory management,
> managed code, compilers, auto type conversion, auto extension of
> array, auto type system, dynamic/scripting languages, etc.

First of all, "dynamic/scripting languages" are still a long, long way
from being "fast enough" for computationally intensive applications.

Secondly, nothing is stopping anyone from writing a library to
implement rational numbers or infinite-precision arithmetic in python
(or just about any other language). They are just not needed for most
applications.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: speaking at PyCon

2012-01-31 Thread Martin P. Hellwig

On 29/01/2012 03:32, Eric Snow wrote:

This is my first year speaking at PyCon, so I solicited
speaking/preparation advice from a bunch of folks, particularly
focusing on the PyCon speaking experience.  I've compiled the results
and put them online:

http://ref.rtfd.org/speakers

This is still rough, and feedback is welcome, as is more advice.  :)
For anyone speaking at the conference (or generally), I hope this will
be helpful.  Thanks!

-eric



Good general presentation tips, I have another suggestion:
If you bring your own laptop, make sure to practice connecting it to the 
projector and have a special presentation account (which you also used 
for your practice and nothing else).


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


Re: Where to put data

2012-01-26 Thread Martin P. Hellwig

On 25/01/2012 17:26, bvdp wrote:



Well once you think about distributing, here is the guide line I use:

- If it is meant as a library that can be 'imported' in python:
> site-packages is the place to be, some linux distros are rather 
creative with them so be careful.


- If it is a 'stand-alone' application that just happens to use the 
python interpreter as a dependency:
> /usr/local/bin for the executable script and /usr/local/lib for the 
program module(s) itself, of course this is platform dependent, consult 
posix first and then distribution/os specific preferences.


- If the additional (binary) data is static in nature:
> /usr/local/share is the right place (or whichever preference the 
distribution/os has)


- If the additional (binary) data is dynamic in nature (like databases) 
and the program is run as a daemon:

> /usr/local/,  /var/ or /opt/

- If the additional (binary) data is dynamic and it is run per user:
> $HOME/.[application name]/ (the famous dot files in your home folder).

All that is unix like of course, Windows tend to put it all in the 
application folder in the Program Files folder, and user specific data 
in the profiles Application Data.


Of course opinions vary so I can only say this is what I usually follow, 
with the wisdom bestowed upon me by unix admins that where much more 
experience then I ever will be and always had a fit when I didn't put it 
in the right directory.


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


Re: The devolution of English language and slothful c.l.p behaviors exposed!

2012-01-24 Thread Martin P. Hellwig

On 24/01/2012 14:51, J wrote:

On Tue, Jan 24, 2012 at 09:05, Martin P. Hellwig
  wrote:

On 24/01/2012 05:57, Rick Johnson wrote:

I would wish that pedantic citizens of the British colony in America stopped
calling whatever misinterpreted waffle they produce, English.


I, sir, as a citizen of that FORMER British colony here on the
continent of North America, am offended by this baseless insult. I
know waffles, sir, I eat waffles and I can guarantee that no American
calls their waffles "English".  We have English Muffins and Belgian
Waffles, but no English Waffles.  Though I am particularly fond of
Blueberry Waffles, myself.

Which reminds me, time for breakfast.


Dear Jeff, I do applaud your impeccable taste and appreciate the 
colourful description of your objections. And I rightfully accept that 
you where forced to misinterpret 'waffle' so you could keep consistency 
in the classification of being pedantic.


Having said that,  I do like to bring to your attention that her 
Majesty, never ratified the 'Declaration of Independence'. :-)


--
mph

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


Re: The devolution of English language and slothful c.l.p behaviors exposed!

2012-01-24 Thread Martin P. Hellwig

On 24/01/2012 05:57, Rick Johnson wrote:

I would wish that pedantic citizens of the British colony in America 
stopped calling whatever misinterpreted waffle they produce, English.


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


Re: [TIP] Anyone still using Python 2.5?

2011-12-21 Thread Gregory P. Smith
On Wed, Dec 21, 2011 at 2:57 AM, Jim Fulton  wrote:

> On Wed, Dec 21, 2011 at 2:15 AM, Chris Withers 
> wrote:
> > Hi All,
> >
> > What's the general consensus on supporting Python 2.5 nowadays?
> >
> > Do people still have to use this in commercial environments or is
> everyone
> > on 2.6+ nowadays?
> >
> > I'm finally getting some continuous integration set up for my packages
> and
> > it's highlighting some 2.5 compatibility issues. I'm wondering whether to
> > fix those (lots of ugly "from __future__ import with_statement"
> everywhere)
> > or just to drop Python 2.5 support.
> >
> > What do people feel?
>
> Google app engine is still Python 2.5, as is Jython.
>

There's work being done to change that on the app engine front:
http://code.google.com/appengine/docs/python/python27/newin27.html

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


Re: icmp and raw sockets in python

2011-12-13 Thread Martin P. Hellwig

On 13/12/2011 16:50, Sagy Drucker wrote:

hello

Hi

i am relatively new to python, so please be considerate...
As I am only responding to one of your questions, perhaps it would be 
best if you don't get any other more helpful replies to split your 
questions up and post them separately.


i'm implementing a server and a client via raw_sockets.
i have the necessary privileges.

now, the server i defined so:
host = socket.gethostbyname(socket.gethostname())
address = (host, 4)
sockSer = socket.socket(socket.AF_INET, socket.SOCK_RAW,
socket.IPPROTO_ICMP)
sockSer.bind(address)
sockSer.ioctl(socket.SIO_RCVALL, socket.RCVALL_ON)
packet, addr = sockSer .recvfrom(4096)   # wait for packet from client

Q1) why can't i simply type: hosts = 'localhost'.
if i do so, it doesn't allow me to write the line:
sockSer.ioctl(socket.SIO_RCVALL, socket.RCVALL_ON).
only when doing gethostbyname(socket.gethostname()) i get
192.168.1.101
and then it works.



Well localhost should resolve to 127.0.0.1/8 which is attached to the 
loopback interface, my gut feeling is that this interface has a 
particular set of restrictions which you are encountering.

Sorry I can't be more helpful.

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


Re: Clever hack or code abomination?

2011-12-01 Thread Martin P. Hellwig

On 01/12/2011 03:15, Roy Smith wrote:

Well, I have seen much worse, so the WTFs/minute(*) count won't be too bad.

However, as  general rule for readability; If you think you have to ask, 
don't bother asking, spend that time rethinking and write a more 
readable solution.



*) http://www.osnews.com/story/19266/WTFs_m

--
mph

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


Re: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7

2011-11-17 Thread Martin P. Hellwig

On 17/11/2011 23:54, W. eWatson wrote:


My mistake above. I was talking about the previous 2.5.2 of install in
Win7. Where I'm at is 2.7.2 now. However, I still find in very odd there
is no Edit with IDLE when I right-click on junk.py. That's the way it
worked on 2.5.2 on my XP and earlier, 2010, on Win7. Downright frustrating.



Well if I was still a windows administrator and you would be one of my 
users, I would first make sure that your profile or windows installation 
is not pooped as it definitively smells like that.


After being reassured that this is not the case I would then search the 
interwebs for something like "extending right click context menu".


Probably hitting something like this:

http://answers.microsoft.com/en-us/windows/forum/windows_7-desktop/how-can-i-customize-right-click-mouse-context-menu/5ea7104f-2213-41b9-9933-83f25da086d1

And after that searching where this 'idle' you speak of is actually 
located, probably finding something like this:


http://stackoverflow.com/questions/118260/how-to-start-idle-python-editor-without-using-the-shortcut-on-windows-vista

Then it rest me to combine them both, after promising myself not to 
install one version of a particular program 'for all users' and then 
'updating' for 'only me' as this can screw up the default settings quite 
badly.


But hey I haven't been a win admin since I switched over to FreeBSD 
years and years ago. I find it immensely reassuring that the problems I 
encounter on my systems are all my fault, well actually that is just the 
same as with windows, just less obvious there.


Luckily I am no longer an administrator either as I couldn't stand it 
anymore when users spill their frustrations, although perfectly 
understandable, unto those who are actually willing to help.


Something to do with attitude or so, speaking if which, I do apologize 
for my own attitude, but given the choice of just ignoring you or lacing 
my post with patronization I though that the latter one was the least 
bad of them two.


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


  1   2   3   4   5   6   7   8   9   10   >