[Numpy-discussion] http://mail.scipy.org/pipermail/numpy-discussion/2011-January/054512.html

2011-01-16 Thread Alex Ter-Sarkissov
hi thanks I've sorted ou the issue

Alex
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] NOOB Alert: Looping Through Text Files...

2011-01-16 Thread Jochen Schröder
On 15/01/11 09:52, dstaley wrote:
>
> Warning, I am a python noob.  Not only do I not know python, I really don't
> know anything about programming outside of ArcInfo and the ancient AML
> language.  Regardless, here is my problem
>
> Let's say I have three text files (test1.txt, test2.txt and test3.txt).
> Each text file has 1 line of text in it "This is my text file", to which I
> want to add (append) a new line of text saying "I suck at Python and need
> help", and then save the file with a suffix attached (eg test1_modified.txt,
> test2_modified.txt, test3_modified.txt).
>
> I guess this is the equivalent of making a change in MS Word and using the
> "Save As..." command to maintain the integrity of the original file, and
> save the changes in a new file.  But, I want to also do that in a loop (this
> is a simplified example of something I want to do with hundreds of text
> files).
>
> Now, I understand how to add this line to an existing text file:
>
> text_file = open("test1.txt", "a")
> text_file.write("\nI suck at Python and need help")
> text_file.close()
>
> While this adds a line of text, it saves the change to the original file
> (does not add the _modified.txt suffix to the file name), nor does it allow
> me to loop through all three of the files.
>
> I'm sure this is an easy thing to do, and is online in a million places.
> Unfortunately, I just cannot seem to find the answer.  Here is my thought
> process:
>
> First i would define the list from which I would loop:
>
> textlist = ["test1.txt", "test2.txt", "test3.txt"]
>
> for i in textlist:
>   text_file = open(textlist, "a")
  

This is your problem.  You create the textfile list, and then loop over 
the list. Now the is are your elements of the list, however you are 
passing the list to the open function. That is what the error says, it 
expects a string but found a list. The better way to do this would be:

for filename in textlist:
  text_file = open(filename, "a")
...

>   text_file.write("\nI suck at Python and need help")
>   text_file.close()
>
> But, this doesn't work.  It gives me the error:
>
> coercing to Unicode: need string or buffer, list found
>
> SO, I guess I need to do this from something other than a list?
>
> Even if it did work, it does not suit my needs as it does not create a new
> file and does not allow me to add the _modified.txt suffix, which will allow
> me to keep the original file intact.

There are a number of ways to to do this and what the best way is might 
depend on your text files. If they are very short the easiest way is to 
just read the content of your text files and write the content to a 
different file. something like this:

for fn in textlist:
fp = open(fn, 'r')
fp.close()
s = fp.read()
s += "I suck at Python and need help")
fp_new = open(fn[:-4]+'_modified.txt','w')
fp_new.write(s)
fp_new.close()


Just for the future this is the numpy list, which is for discussing 
issues relating to the numpy python module, the next time you might want 
to post a question like this to one of the python beginners lists. This 
link might get you started:
http://wiki.python.org/moin/BeginnersGuide

Cheers
Jochen
>
>> From a responses to a previous post, this seems as if it may have something
> to do with a python dictionary, but I'm not sure.
>
> I'm probably totally off on how this should even be written, so any advice
> or suggestions would be greatly appreciated.
>
> Thanks in advance for your help!
>
> -DS
>

___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] defmatrix 1.3 versus 1.5

2011-01-16 Thread zb
Hi

I am trying to compile a py2exe app. It works with numpy 1.3 but if I try numpy 
1.5 I get an error when loading the app.exe

Traceback (most recent call last):
  File "artisan.pyw", line 109, in 
  File "numpy\__init__.pyo", line 136, in 
  File "numpy\add_newdocs.pyo", line 9, in 
  File "numpy\lib\__init__.pyo", line 5, in 
  File "numpy\lib\index_tricks.pyo", line 15, in 
ImportError: No module named defmatrix

I've noticed that there is a change in the location of defmatrix from 1.3 to 
the newer 1.5.

1.3 numpy/core/defmatrix

1.5 numpy/matrixlib/defmatrix


How could I make py2exe work? Any tips?

Thanks



  
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Getting a clone copy of the NumPy repository.

2011-01-16 Thread Hector troy
On Sun, Jan 16, 2011 at 8:31 PM, David Cournapeau wrote:

> On Sun, Jan 16, 2011 at 10:09 PM, Hector troy 
> wrote:
> > Hello everyone, I am a newbie on this open source world, and sincerely
> > trying to make contribution to the development of Numpy. I was trying to
> > learn about making patches from
> > http://docs.scipy.org/doc/numpy/dev/gitwash/patching.html  but unable to
> get
> > the clone of Numpy repository.
> >
> > In the terminal error massage shown is -
> >
> > $hector@hector:~$ sudo git clone git://github.com/numpy/numpy.git
> > [sudo] password for hector:
> > Initialized empty Git repository in /home/hector/numpy/.git/
> > github.com[0: 207.97.227.239]: errno=Connection timed out
> > fatal: unable to connect a socket (Connection timed out)
> > $hector@hector:~$
>
> You should try through http: it may be that your network blocks the
> git protocol/port:
>
> git clone http://github.com/numpy/numpy.git
>
> You should also avoid using sudo to clone repositories (although it is
> unlikely to be the cause of your issue).
>
> cheers,
>
> David
> ___
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>

Mr. David,
Thanks a lot, it worked.

Hope you will help me with future quarries.

Thanks again,

-- 
-Regards
Hector

Whenever you think you can or you can't, in either way you are right.
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Getting a clone copy of the NumPy repository.

2011-01-16 Thread David Cournapeau
On Sun, Jan 16, 2011 at 10:09 PM, Hector troy  wrote:
> Hello everyone, I am a newbie on this open source world, and sincerely
> trying to make contribution to the development of Numpy. I was trying to
> learn about making patches from
> http://docs.scipy.org/doc/numpy/dev/gitwash/patching.html  but unable to get
> the clone of Numpy repository.
>
> In the terminal error massage shown is -
>
>     $hector@hector:~$ sudo git clone git://github.com/numpy/numpy.git
>     [sudo] password for hector:
>     Initialized empty Git repository in /home/hector/numpy/.git/
>     github.com[0: 207.97.227.239]: errno=Connection timed out
>     fatal: unable to connect a socket (Connection timed out)
>     $hector@hector:~$

You should try through http: it may be that your network blocks the
git protocol/port:

git clone http://github.com/numpy/numpy.git

You should also avoid using sudo to clone repositories (although it is
unlikely to be the cause of your issue).

cheers,

David
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] Getting a clone copy of the NumPy repository.

2011-01-16 Thread Hector troy
Hello everyone, I am a newbie on this open source world, and sincerely
trying to make contribution to the development of Numpy. I was trying to
learn about making patches from
http://docs.scipy.org/doc/numpy/dev/gitwash/patching.html  but unable to get
the clone of Numpy repository.

In the terminal error massage shown is -

$hector@hector:~$ sudo git clone git://github.com/numpy/numpy.git
[sudo] password for hector:
Initialized empty Git repository in /home/hector/numpy/.git/
github.com[0: 207.97.227.239]: errno=Connection timed out
fatal: unable to connect a socket (Connection timed out)
$hector@hector:~$

My internet is quite good at the moment but unable to understand why am I
getting this error.
Any help regarding this will be extremely helpful and encouraging for me.
Thanking you in anticipation.

-- 
-Regards
Hector

Whenever you think you can or you can't, in either way you are right.
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] float conversion

2011-01-16 Thread Christian K.
Am 16.01.11 09:24, schrieb Alex Ter-Sarkissov:
> hi every1,
>
> I got the following issue: I wrote a function that converts binary
> strings into a decimal value (binary expansion). When I write
>
> type(x)
>
> to find out the type of the value I get NoneType. Therefore I can't

Your function most probably returns None. Show us your code and we will 
able to help.

Regards, Christian

___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] float conversion

2011-01-16 Thread Alex Ter-Sarkissov
hi every1,

I got the following issue: I wrote a function that converts binary strings
into a decimal value (binary expansion). When I write

type(x)

to find out the type of the value I get NoneType. Therefore I can't convert
it into anything else, such as float numbers, since command float(x) returns


TypeError: float() argument must be a string or a number

Any ideas what to do with this (e.g. convert to floating numbers)?

cheers,

Alex
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion