Re: [Tutor] glob and file names

2014-06-05 Thread Gabriele Brambilla
No,
I wanted to say that Peter method works!
Thanks anyway and sorry for the html.

Gabriele

sent from Samsung Mobile
Il giorno 05/giu/2014 23:14, "Dave Angel"  ha scritto:

> Gabriele Brambilla  Wrote in message:
> >
> >
> (missing because you posted in html. Please tell your email program to use
> text)
>
> Simplify your program to where it's small and self contained.  You
>  currently have a string built up from several parts.  Since you
>  think the problem is in the glob call, you should be able to show
>  it in 3 lines or so.
>
>filespec="f gytrr y yyrddty*.txt"
> hh= glob.glo...
>print (repr (hh))
>
> Then specify the python version and OS.
>
> Since I have to guess,  I'd say you had an unprintable in one of
>  those variables.
>
>
>
>
> --
> DaveA
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] glob and file names

2014-06-05 Thread Dave Angel
Gabriele Brambilla  Wrote in message:
>
> 
(missing because you posted in html. Please tell your email program to use text)

Simplify your program to where it's small and self contained.  You
 currently have a string built up from several parts.  Since you
 think the problem is in the glob call, you should be able to show
 it in 3 lines or so.

   filespec="f gytrr y yyrddty*.txt"
hh= glob.glo...
   print (repr (hh))

Then specify the python version and OS.

Since I have to guess,  I'd say you had an unprintable in one of
 those variables.




-- 
DaveA

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Fwd: glob and file names

2014-06-05 Thread Gabriele Brambilla
-- Forwarded message --
From: Gabriele Brambilla 
Date: 2014-06-05 22:15 GMT-04:00
Subject: Re: [Tutor] glob and file names
To: Peter Romfeld 


thanks,

it works.

Gabriele


2014-06-05 22:10 GMT-04:00 Peter Romfeld :

On Friday, June 06, 2014 10:04 AM, Gabriele Brambilla wrote:
> >
> > fiLUMOname = 'Lsum_' + period + '_' + parts[2] + '_' + parts[3] + '_'
> > + parts[4] + '_*.dat'
> >
> > aaa = glob.glob(fiLUMOname)
> > print(aaa)
> > fiLUMO = open(aaa[0], 'r')
>
> i would do:
>
> aaa = glob.glob('Lsum_%s_%s_%s_%s_*.dat' % (period, parts[2], parts[3],
> parts[4]))
>
> cheers
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] glob and file names

2014-06-05 Thread Gabriele Brambilla
Hi,

I'm trying to use glob to read a file of which I don't know the complete
name (but only some parts).


fiLUMOname = 'Lsum_' + period + '_' + parts[2] + '_' + parts[3] + '_' +
parts[4] + '_*.dat'

aaa = glob.glob(fiLUMOname)
print(aaa)
fiLUMO = open(aaa[0], 'r')


where period, and the elements of parts are strings.
but aaa results empty. (and so it cannot open the file)

The file exist and I'm able to recover it if I write by hand inside
glob.glob() the name between " " with the * where I don't know the name.

How can I pass my string to glob.glob inside " "?
Is there a simpler method to obtain the same result?

thanks

Gabriele
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Ctypes and Sockets

2014-06-05 Thread Alan Gauld

On 05/06/14 20:02, Leo Nardo wrote:

Looking for a complete introduction to ctypes that I can understand.


How well do you know C? Without understanding C a complete intro to 
ctypes will be next to impossible.



I would also like someones input on the following code and what it
basically does. Im guessing it creates a connection between two
computers but sends no meaningful data? Is there a way i can
manipulate the following code to make it send strings or integers back
and forth?


Yes. You might find my tutorial on using sockets useful, it contains an 
example of such a program as well as some pictorial explanation of hiw 
it works.


Its in the Python v2 tutor under the heading "Network Programming"

HTH


--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Error message received when running “from scipy import interpolate”

2014-06-05 Thread Alan Gauld

On 05/06/14 23:36, Colin Ross wrote:

I am attempting to run the following in python:

|from  scipyimport  interpolate|


This list is for those learning the core Python language and its 
standard library.


Support for scipy is probably best gained from the scipy forum
The MacPython list may also be able to help with MacOS specific queries.

But there are some Mac/Scipy users here so I'll leave it to them to 
chime in if they can help.



I receive this error message:

|Traceback  (most recent call last):
   File  "",  line1,  in  
   File  
"/Library/Python/2.7/site-packages/scipy-0.11.0.dev_0496569_20111005-py2.7-macosx-10.7-x86_64.egg/scipy/interpolate/__init__.py",
  line156,  in  
 from  ndgriddataimport  *
   File  
"/Library/Python/2.7/site-packages/scipy-0.11.0.dev_0496569_20111005-py2.7-macosx-10.7-x86_64.egg/scipy/interpolate/ndgriddata.py",
  line9,  in  
 from  interpndimport  LinearNDInterpolator,  NDInterpolatorBase,  \
   File  "numpy.pxd",  line172,  in  init 
interpnd(scipy/interpolate/interpnd.c:7696)
ValueError:  numpy.ndarray has the wrong size,  try  recompiling|

I am currently running Mac OS X Lion 10.7.5 and Python 2.7.1. with
MacPorts installed.

I am attempting to run the code on a different computer than it was
created on. After doing some reading my understanding is that this error
may be a result of the ABI not being forward compatible. To try and
solve the issue I updated my MacPorts and then ran ($ sudo port upgrade
outdated) to upgrade the installed ports. However, the same error
continues to appear when I try and run the code.


--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Error message received when running “from scipy import interpolate”

2014-06-05 Thread Colin Ross
I am attempting to run the following in python:

from scipy import interpolate

I receive this error message:

Traceback (most recent call last):
  File "", line 1, in 
  File 
"/Library/Python/2.7/site-packages/scipy-0.11.0.dev_0496569_20111005-py2.7-macosx-10.7-x86_64.egg/scipy/interpolate/__init__.py",
line 156, in 
from ndgriddata import *
  File 
"/Library/Python/2.7/site-packages/scipy-0.11.0.dev_0496569_20111005-py2.7-macosx-10.7-x86_64.egg/scipy/interpolate/ndgriddata.py",
line 9, in 
from interpnd import LinearNDInterpolator, NDInterpolatorBase, \
  File "numpy.pxd", line 172, in init interpnd
(scipy/interpolate/interpnd.c:7696)ValueError: numpy.ndarray has the
wrong size, try recompiling

I am currently running Mac OS X Lion 10.7.5 and Python 2.7.1. with MacPorts
installed.

I am attempting to run the code on a different computer than it was created
on. After doing some reading my understanding is that this error may be a
result of the ABI not being forward compatible. To try and solve the issue
I updated my MacPorts and then ran ($ sudo port upgrade outdated) to
upgrade the installed ports. However, the same error continues to appear
when I try and run the code.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Ctypes and Sockets

2014-06-05 Thread Leo Nardo
Looking for a complete introduction to ctypes that I can understand.
I learn well from David Malans stuff, and the book 'how to think like
a computer scientist for python 3'. Hope that helps with my learning
style.

https://www.youtube.com/results?search_query=david+malan

http://openbookproject.net/thinkcs/python/english3e/index.html



I would also like someones input on the following code and what it
basically does. Im guessing it creates a connection between two
computers but sends no meaningful data? Is there a way i can
manipulate the following code to make it send strings or integers back
and forth?


" A simple
server""

#!/usr/bin/python   # This is server.py file

import socket   # Import socket module

s = socket.socket() # Create a socket object
host = socket.gethostname() # Get local machine name
port = 12345# Reserve a port for your service.
s.bind((host, port))# Bind to the port

s.listen(5) # Now wait for client connection.
while True:
   c, addr = s.accept() # Establish connection with client.
   print 'Got connection from', addr
   c.send('Thank you for connecting')
   c.close()# Close the connection


" A simple
client""



#!/usr/bin/python   # This is client.py file

import socket   # Import socket module

s = socket.socket() # Create a socket object
host = socket.gethostname() # Get local machine name
port = 12345# Reserve a port for your service.

s.connect((host, port))
print s.recv(1024)
s.close # Close the socket when done
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor