Re: [Tutor] While learning Py: To IDE or not to IDE?

2012-05-21 Thread Alan Gauld

On 21/05/12 01:41, Steven D'Aprano wrote:


That is insanity! There is only One True EDitor, ed! It is right there
in the name, it's an EDitor! ed is the true unix editor:

http://www.gnu.org/fun/jokes/ed.msg.html


Having once had no alternative to ed and a 3500 line C program to write, 
I don't get the joke! (but I did get very tight C!) :-(


$ cat > hello.py
print 'hello world'
^D
$ ed -p'->' hello.py
20
->1,$p
print 'hello world'
->i
for n in range(3):
.
->1,$p
for n in range(3):
print 'hello world'
->2s/print/   print/
->1,$p
for n in range(3):
   print 'hello world'
->wq
42
$

Note I made ed more "user friendly" by including a prompt (->)...

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

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


Re: [Tutor] While learning Py: To IDE or not to IDE?

2012-05-21 Thread Alan Gauld

On 21/05/12 06:57, Modulok wrote:


Learning to use a command line at first feels really clunky and primitive, but
eventually it eclipses most GUI's and IDE's in terms of speed and the tools


An old colleague of mine used to say: "A GUI makes easy things trivial 
and hard things impossible" :-)


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

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


Re: [Tutor] While learning Py: To IDE or not to IDE?

2012-05-21 Thread Steven D'Aprano
On Sun, May 20, 2012 at 11:57:14PM -0600, Modulok wrote:

> Learning to use a command line at first feels really clunky and primitive, but
> eventually it eclipses most GUI's and IDE's in terms of speed and the tools
> available. You can also ooze right into system administration without much
> effort.

Perhaps the hardest part about using the command line is 
*discoverability*. There is nothing even close to the equivalent of 
clicking on a menu to see what commands are available. If you have a bad 
memory for commands you use only once every six months, like I do, 
you'll forever be googling for "how do I do X on Linux?" type questions. 
"Oh yeah, that's right, it's such-and-such a command."

But if you can get past that, and I understand that commandlines are not 
for everyone, they are *much* more powerful and efficient than graphical 
applications, for many (although not all!) tasks.



-- 
Steven

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


[Tutor] Is this possible and should it be done?

2012-05-21 Thread wolfrage8...@gmail.com
All, I have had a curious idea for awhile, and was wondering the best
way to implement it in Python and if it is even possible. The concept
is this, a file that is actually a folder that contains multiple files
(Like an Archive format). The actual files are really un-important.
What I want is for the folder to be represented as a single file by
any normal file browser, but to be able to access the files with-in
via Python. I will actually use the word archive to represent my
mystical folder as a file concept for the rest of this message. Some
additional things I would like to be possible: is for multiple copies
of the program to write to the same archive, but different files
with-in at the same time (Reading & Writing to the archive should not
lock the archive as long as they are different files); and for just
the desired files with-in the archive to be loaded to memory with out
having to hold the entire archive in memory.
Use case for these additional capabilities. I was reading about how
some advanced word processing programs (MS Word) actually save
multiple working copies of the file with-in a single file
representation and then just prior to combining the working copies it
locks the original file and saves the working changes. That is what I
would like to do. I want the single file because it is easy for a user
to grasp that they need to copy a single file or that they are working
on a single file, but it is not so easy for them to grasp the multiple
file concepts.

MS Word uses Binary streams as shown here:
http://download.microsoft.com/download/5/0/1/501ED102-E53F-4CE0-AA6B-B0F93629DDC6/WindowsCompoundBinaryFileFormatSpecification.pdf
Is this easy to do with python? Does it prevent file locking if you
use streams? Is this worth the trouble, or should I just use a
directory and forget this magical idea?
A piece of reference for my archive thoughts, ISO/IEC 26300:2006 chapter 17.2
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Is this possible and should it be done?

2012-05-21 Thread Joel Goldstick
On Mon, May 21, 2012 at 6:38 AM, wolfrage8...@gmail.com
 wrote:
> All, I have had a curious idea for awhile, and was wondering the best
> way to implement it in Python and if it is even possible. The concept
> is this, a file that is actually a folder that contains multiple files
> (Like an Archive format). The actual files are really un-important.
> What I want is for the folder to be represented as a single file by
> any normal file browser, but to be able to access the files with-in
> via Python. I will actually use the word archive to represent my
> mystical folder as a file concept for the rest of this message. Some
> additional things I would like to be possible: is for multiple copies
> of the program to write to the same archive, but different files
> with-in at the same time (Reading & Writing to the archive should not
> lock the archive as long as they are different files); and for just
> the desired files with-in the archive to be loaded to memory with out
> having to hold the entire archive in memory.
> Use case for these additional capabilities. I was reading about how
> some advanced word processing programs (MS Word) actually save
> multiple working copies of the file with-in a single file
> representation and then just prior to combining the working copies it
> locks the original file and saves the working changes. That is what I
> would like to do. I want the single file because it is easy for a user
> to grasp that they need to copy a single file or that they are working
> on a single file, but it is not so easy for them to grasp the multiple
> file concepts.
>
> MS Word uses Binary streams as shown here:
> http://download.microsoft.com/download/5/0/1/501ED102-E53F-4CE0-AA6B-B0F93629DDC6/WindowsCompoundBinaryFileFormatSpecification.pdf
> Is this easy to do with python? Does it prevent file locking if you
> use streams? Is this worth the trouble, or should I just use a
> directory and forget this magical idea?
> A piece of reference for my archive thoughts, ISO/IEC 26300:2006 chapter 17.2
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor

I'm not sure if this is exactly what you are looking for, but python
handles tar files (various compression formats) with this module:
http://docs.python.org/library/tarfile.html.

What is your motivation for this idea?

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


Re: [Tutor] Is this possible and should it be done?

2012-05-21 Thread Steven D'Aprano

wolfrage8...@gmail.com wrote:

All, I have had a curious idea for awhile, and was wondering the best
way to implement it in Python and if it is even possible. The concept
is this, a file that is actually a folder that contains multiple files
(Like an Archive format). The actual files are really un-important.


What you are describing is exactly like any one of many different file 
formats, such as zip files, tar files, and others.




What I want is for the folder to be represented as a single file by
any normal file browser, but to be able to access the files with-in
via Python. I will actually use the word archive to represent my
mystical folder as a file concept for the rest of this message. 


Actual folders ("directories") are special, since they are handled by the file 
system. But you can create any file format you like, it is just data. For 
example, a GIF file can contain multiple frames (animated GIFs); Libre Office 
and Open Office files contain multiple pieces of data; zip files can contain 
multiple compressed files of any type; AVI files can contain multiple audio 
streams; cd/dvd image files can contain multiple file system; etc.


There's nothing special about file browsers: if they don't understand a file 
format, they can't do anything special with files of that format. But if they 
do understand the file format, then they can. *Any* program that understands 
the file format can do anything it likes with the data.



Some
additional things I would like to be possible: is for multiple copies
of the program to write to the same archive, but different files
with-in at the same time (Reading & Writing to the archive should not
lock the archive as long as they are different files); and for just
the desired files with-in the archive to be loaded to memory with out
having to hold the entire archive in memory.


*shrug*

Sure, whatever you like. You just have to program it.

[...]

MS Word uses Binary streams as shown here:
http://download.microsoft.com/download/5/0/1/501ED102-E53F-4CE0-AA6B-B0F93629DDC6/WindowsCompoundBinaryFileFormatSpecification.pdf
Is this easy to do with python? Does it prevent file locking if you


File locking is not a property of the programming language, but of the file 
system and operating system.




use streams? Is this worth the trouble, or should I just use a
directory and forget this magical idea?


Seems like a lot of work for very little benefit, but if you want it, you can 
build it.


Personally, I think that instead of re-inventing the wheel, use existing 
tools. Python comes with the pre-built tools to use tar, zip, gzip, xml, json, 
 pickle file formats. You should investigate the powers and limitations of 
those file formats before inventing your own.


I'm sorry that I can't be more specific, but your question is awfully generic. 
It's a bit like somebody saying "Can I build a remote-controlled car out of 
electronics and metal?" Of course you can. But to actually do so, you need to 
have detailed plans rather than vague questions -- you need to know 
electronics and mechanics.


But good luck!


--
Steven

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


Re: [Tutor] While learning Py: To IDE or not to IDE?

2012-05-21 Thread Joel Goldstick
On Mon, May 21, 2012 at 5:06 AM, Steven D'Aprano  wrote:
> On Sun, May 20, 2012 at 11:57:14PM -0600, Modulok wrote:
>
>> Learning to use a command line at first feels really clunky and primitive, 
>> but
>> eventually it eclipses most GUI's and IDE's in terms of speed and the tools
>> available. You can also ooze right into system administration without much
>> effort.
>
> Perhaps the hardest part about using the command line is
> *discoverability*. There is nothing even close to the equivalent of
> clicking on a menu to see what commands are available. If you have a bad
> memory for commands you use only once every six months, like I do,
> you'll forever be googling for "how do I do X on Linux?" type questions.
> "Oh yeah, that's right, it's such-and-such a command."
>
> But if you can get past that, and I understand that commandlines are not
> for everyone, they are *much* more powerful and efficient than graphical
> applications, for many (although not all!) tasks.
>
>
>
> --
> Steven
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor

There seem to be two different mindsets about ide vs plain editor.  I
used to be an MS guy and I used MS IDE.  Its nice in that you get
dropdowns for things you might kind of know, but can't remember.  They
save keystrokes.  And if that world is good for you, then go that way.

Since moving away from MS to Linux, I have had to switch my thinking.
Of course in python there is good documentation available with
help(whatever) in the interactive shell.  Its great!  I like the
spareness of an editor, switching from vim (which I know just the tip
of the iceberg) and gedit.  It makes it easy to work on different
machines, ssh to a server and edit stuff there.

You are planning to learn a whole lot of new stuff, which may be
doable for you, but I couldn't do that.  You will find plenty to
challenge your mind with python, an editor, and a tutorial or two (or
Alan's book!).  Read-code-discover-repeat.  You can pick up tools
along the way when it seems they would make something more productive.

but... others like IDEs


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


Re: [Tutor] Is this possible and should it be done?

2012-05-21 Thread Steven D'Aprano

Joel Goldstick wrote:


I'm not sure if this is exactly what you are looking for, but python
handles tar files (various compression formats) with this module:
http://docs.python.org/library/tarfile.html.


Technically, tar is not a compression format. It just combines multiple files 
into a single tar file, with no compression.


Of course, you can compress the tar file afterwards, with zip, gzip, bzip2, 
rar, or any other compression format you like. Especially common ones are 
.tar.gz and .tar.bz2.




What is your motivation for this idea?


With respect Joel, the OP did give a use-case for his idea, did you not notice 
it?



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


Re: [Tutor] Is this possible and should it be done?

2012-05-21 Thread Joel Goldstick
On Mon, May 21, 2012 at 7:38 AM, Steven D'Aprano  wrote:
> Joel Goldstick wrote:
>
>> I'm not sure if this is exactly what you are looking for, but python
>> handles tar files (various compression formats) with this module:
>> http://docs.python.org/library/tarfile.html.
>
>
> Technically, tar is not a compression format. It just combines multiple
> files into a single tar file, with no compression.
>
> Of course, you can compress the tar file afterwards, with zip, gzip, bzip2,
> rar, or any other compression format you like. Especially common ones are
> .tar.gz and .tar.bz2.
>
>
>
>> What is your motivation for this idea?
>
>
> With respect Joel, the OP did give a use-case for his idea, did you not
> notice it?

Maybe I said that wrong.  I was just wondering why someone would want
to rebuild something that is already available with python module.
Sometimes people like to build things to see how they work.  Sometimes
they build because they aren't aware of a previously built solution.

And thanks about pointing out that tar doesn't do the compressing, but
can be combined with compression software.
>
>
>
> --
> Steven
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor



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


Re: [Tutor] Is this possible and should it be done?

2012-05-21 Thread Dave Angel
On 05/21/2012 06:38 AM, wolfrage8...@gmail.com wrote:
> All, I have had a curious idea for awhile, and was wondering the best
> way to implement it in Python and if it is even possible. The concept
> is this, a file that is actually a folder that contains multiple files
> (Like an Archive format). The actual files are really un-important.
> What I want is for the folder to be represented as a single file by
> any normal file browser, but to be able to access the files with-in
> via Python. I will actually use the word archive to represent my
> mystical folder as a file concept for the rest of this message. Some
> additional things I would like to be possible: is for multiple copies
> of the program to write to the same archive, but different files
> with-in at the same time (Reading & Writing to the archive should not
> lock the archive as long as they are different files); and for just
> the desired files with-in the archive to be loaded to memory with out
> having to hold the entire archive in memory.
> Use case for these additional capabilities. I was reading about how
> some advanced word processing programs (MS Word) actually save
> multiple working copies of the file with-in a single file
> representation and then just prior to combining the working copies it
> locks the original file and saves the working changes. That is what I
> would like to do. I want the single file because it is easy for a user
> to grasp that they need to copy a single file or that they are working
> on a single file, but it is not so easy for them to grasp the multiple
> file concepts.
>
> MS Word uses Binary streams as shown here:
> http://download.microsoft.com/download/5/0/1/501ED102-E53F-4CE0-AA6B-B0F93629DDC6/WindowsCompoundBinaryFileFormatSpecification.pdf
> Is this easy to do with python? Does it prevent file locking if you
> use streams? Is this worth the trouble, or should I just use a
> directory and forget this magical idea?
> A piece of reference for my archive thoughts, ISO/IEC 26300:2006 chapter 17.2
>

When I first read your description, I assumed you were talking about the
streams supported by NTFS, where it's possible to store multiple
independent, named, streams of data within a single file.  That
particular feature isn't portable to other operating systems, nor even
to non-NTFS systems.  And the user could get tripped up by copying what
he thought was the whole file, but in fact was only the unnamed stream.

However, thanks for the link.  That specification describes building an
actual filesystem inside the file, which is a lot of work.  It does not
mention anything about stream locking, and my experience with MSWORD
(which has been several years ago, now) indicates that the entire
archive is locked whenever one instance of MSWORD is working on it.

I think if you're trying to do something as flexible as MSWORD
apparently does (or even worse - adding locking to it) you're asking for
subtle bugs and race conditions.  If the data you were storing is
structured such that you can simplify the MS approach, then it may be
worthwhile.  For example, if each stream is always 4k.



-- 

DaveA

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


Re: [Tutor] While learning Py: To IDE or not to IDE?

2012-05-21 Thread bob gailer
When I started learning Python I was pleased to discover Python For 
Windows. I probably would have given up if this tool were not available.


Perhaps this is because I had spent many years working with other IDEs 
in other languages/applications. (VBA, FoxPro, Advanced Revelation  to 
name some).


I have no concern with there being features I might not use. I am 
delighted with the ones I do use.


There are numerous IDES for Python that run on Linux systems (most are 
free).


You too may find such IDEs a better choice.

--
Bob Gailer
919-636-4239

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


[Tutor] Fwd: Is this possible and should it be done?

2012-05-21 Thread wolfrage8...@gmail.com
-- Forwarded message --
From: wolfrage8...@gmail.com 
Date: Mon, May 21, 2012 at 2:16 PM
Subject: Re: [Tutor] Is this possible and should it be done?
To: Steven D'Aprano 


Thank you for the information. Sorry if I implied I wanted to
re-invent the wheel but actually this feedback is exactly what I was
looking for. I wanted to know existing methods to do just such
operations. Also good point about the file browsers the only
limitation to them is how much they understand the format.
So since tar looks like an excellent option for what I want to do, I
have another question before I begin my research. Do you already know
if any of these formats offer file locking with in them, ;et me say
that better. Can I open a, as example, tar file and lock a file with
in it, with out locking the entire tar archive? Just asking if you
already know if this is possible? Thank you again for the information!


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


[Tutor] Is this possible and should it be done?

2012-05-21 Thread wolfrage8...@gmail.com
Forwarded because I did not reply to the list properly. Hopefully I
did not forward wrong.
-- Forwarded message --
From: wolfrage8...@gmail.com 
Date: Mon, May 21, 2012 at 2:18 PM
Subject: Re: [Tutor] Is this possible and should it be done?
To: Joel Goldstick 


Thank you for your help Joel. In this case I don't want to know about
the details just want an easy implementation and tar looks like the
right solution. I also think that the compression being seperated from
the format is likely best and will probably not use the compression as
it would hinder my overall goal. OK going to read up on TAR now!
Thanks again.


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


Re: [Tutor] Is this possible and should it be done?

2012-05-21 Thread wolfrage8...@gmail.com
On Mon, May 21, 2012 at 4:06 PM, William R. Wing (Bill Wing)
 wrote:
> On May 21, 2012, at 6:38 AM, wolfrage8...@gmail.com wrote:
>
>> All, I have had a curious idea for awhile, and was wondering the best
>> way to implement it in Python and if it is even possible. The concept
>> is this, a file that is actually a folder that contains multiple files
>> (Like an Archive format). The actual files are really un-important.
>> What I want is for the folder to be represented as a single file by
>> any normal file browser, but to be able to access the files with-in
>> via Python. I will actually use the word archive to represent my
>> mystical folder as a file concept for the rest of this message. Some
>> additional things I would like to be possible: is for multiple copies
>> of the program to write to the same archive, but different files
>> with-in at the same time (Reading & Writing to the archive should not
>> lock the archive as long as they are different files); and for just
>> the desired files with-in the archive to be loaded to memory with out
>> having to hold the entire archive in memory.
>> Use case for these additional capabilities. I was reading about how
>> some advanced word processing programs (MS Word) actually save
>> multiple working copies of the file with-in a single file
>> representation and then just prior to combining the working copies it
>> locks the original file and saves the working changes. That is what I
>> would like to do. I want the single file because it is easy for a user
>> to grasp that they need to copy a single file or that they are working
>> on a single file, but it is not so easy for them to grasp the multiple
>> file concepts.
>
> As others have noted, this smells a lot like a .tar or similar archive.
>
> I'd suggest that it also smells like a scaled down and locally served 
> Concurrent Versioning System.  CVS does exactly what you want in terms of 
> preserving only differences between edited versions of a file and it only 
> locks the particular file that has been checked out; also allows you to back 
> up to any previous version of a file.  There are CVS-Python bindings (as well 
> as SVN-Python, SVN being a newer more modern version of CVS).  Google will 
> turn up lots of references to both.
>
> -Bill

Hey that sounds really interesting I did not know that SVN or CVS was
even an option, but can they work with an archive, I will have to
experiment, but that would take care of the multiple working copies
and final merges latter. Thanks for the idea!
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Coding Challenges

2012-05-21 Thread Malcolm Newsome
Hey all,

Being new to programming, I've found that my learning is accelerated when
I've been asked to write scripts and deliver them in a specified time
frame...Then, have those scripts critiqued.

My question: Would the moderators of this list be interested in creating a
monthly "challenge" of sorts? Then, those who participated could receive
suggestions on how their code could have been written differently.

If not, and you know of something else like this that exists, would you
kindly share those resources?

Thanks!

Malcolm Newsome


Sent from my Windows Phone
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Coding Challenges

2012-05-21 Thread wolfrage8...@gmail.com
On Mon, May 21, 2012 at 4:47 PM, Malcolm Newsome
 wrote:
> Hey all,
>
> Being new to programming, I've found that my learning is accelerated when
> I've been asked to write scripts and deliver them in a specified time
> frame...Then, have those scripts critiqued.
>
> My question: Would the moderators of this list be interested in creating a
> monthly "challenge" of sorts? Then, those who participated could receive
> suggestions on how their code could have been written differently.
>
> If not, and you know of something else like this that exists, would you
> kindly share those resources?
>
> Thanks!
>
> Malcolm Newsome
>
>
> Sent from my Windows Phone
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>

If they agree I am all for it, if not I would still like to know what
kind of plan that you come up with; as it will only make me better.
--
Jordan Farrell
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Coding Challenges

2012-05-21 Thread Martin A. Brown

Hello,

 : Being new to programming, I've found that my learning is 
 : accelerated when I've been asked to write scripts and deliver 
 : them in a specified time frame...Then, have those scripts 
 : critiqued.
 :
 : My question: Would the moderators of this list be interested in 
 : creating a monthly "challenge" of sorts? Then, those who 
 : participated could receive suggestions on how their code could 
 : have been written differently.
 : 
 : If not, and you know of something else like this that exists, 
 : would you kindly share those resources?

I'm answering a question slightly tangential to what you asked, in 
the time-honored tradition of asking a completely different 
question...

Are you familiar with Project Euler?

  http://projecteuler.net/
  http://projecteuler.net/problems

I don't know whether critique is involved in the Project Euler, 
though.  I would agree, having a concrete task to approach is a good 
way to learn.

Enjoy,

-Martin

-- 
Martin A. Brown
http://linux-ip.net/
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] [OT] Re: While learning Py: To IDE or not to IDE?

2012-05-21 Thread Brian van den Broek
On 21 May 2012 03:39, "Steven D'Aprano"  wrote:
>
> boB Stepp wrote:



>> now on learning an IDE if it will save me time overall. IF it would be
>> beneficial now to learn an IDE, then it begs the question
>
>
> No it doesn't. It RAISES the question -- begging the question means to
*assume the answer in the question*, and it is a logical fallacy.
>
> "Notepad is the best editor, because no other editor is as good as
Notepad" is begging the question.

Steven,

I am a philospher of logic and mathematics. Everytime I encounter 'begs the
question' used in the way which you here resist, a little piece inside me
dies. Thanks for fighting the good fight!

However, as I hear this on the BBC and CBC Radio, and read it in
periodicals I think ought be edited by those who know better, I confess I
feel the worthy battle is lost.

As W.V.O. Quine said:

  We cannot stem the tide of linguistic
  change, but we can drag our feet.

Best,

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


[Tutor] Datetime Integers

2012-05-21 Thread Jeremy Traurig
Hello,

Is there a module available for python to convert datetime into an
array of integers. For example, I have date where the first column is
a datetime string (i.e. '2010-10-10 01:10:00') and I would like to
convert that into an array with 5 columns corresponding to the integer
values of Year,Month,Day,Hour,Minute. There is a function in Matlab
that performs called datevec() that performs this operation. I find it
much easier to index datetime or perform calculations on other data
when date and time are integers. For example, i generally need to
calculate averages, std, etc based on specific months, years, days,
and hours. Those calculations are extremely simple when I can index an
array of datetime integers. If there is no module to convert datetime
to an array of integers, does anyone have an example of how i might
index datetime using python datetime or numpy datetime64? In each
case, I would need an array of datetime the same dimension as my data
array.

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


Re: [Tutor] Coding Challenges

2012-05-21 Thread Chris Fuller
On Monday 21 May 2012, Martin A. Brown wrote:
> Hello,
> 
>  : Being new to programming, I've found that my learning is
>  : accelerated when I've been asked to write scripts and deliver
>  : them in a specified time frame...Then, have those scripts
>  : critiqued.
>  : 
>  : My question: Would the moderators of this list be interested in
>  : creating a monthly "challenge" of sorts? Then, those who
>  : participated could receive suggestions on how their code could
>  : have been written differently.
>  : 
>  : If not, and you know of something else like this that exists,
>  : would you kindly share those resources?
> 
> I'm answering a question slightly tangential to what you asked, in
> the time-honored tradition of asking a completely different
> question...
> 
> Are you familiar with Project Euler?
> 
>   http://projecteuler.net/
>   http://projecteuler.net/problems
> 
> I don't know whether critique is involved in the Project Euler,
> though.  I would agree, having a concrete task to approach is a good
> way to learn.
> 
> Enjoy,
> 
> -Martin

Project Euler is *very* math heavy (it is named after a famous mathematician, 
after all).  Some of the problems are accessible to the general programmer, 
but expect to see a lot of stuff you might not have much familiarity with, if 
you aren't a math nerd.

Another choice is The Python Challenge http://www.pythonchallenge.com/.  It 
emphasizes a puzzle/riddle aspect, often the actual programming is pretty 
straightforward once you figure out what is needed.  On the other hand, I 
haven't used it enough to progress all that far, so I really don't know it 
that well.

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


Re: [Tutor] Datetime Integers

2012-05-21 Thread Vince Spicer
This should do what you want.

import time
timestring = '2010-10-10 01:10:00'
time_format = '%Y-%m-%d %H:%M:%S'
timestruct = time.strptime(timestring, time_format)
print [x for x in timestruct]


For complex date parsing I would recommend checking out the dateutil.parser
http://labix.org/python-dateutil



On Mon, May 21, 2012 at 9:47 AM, Jeremy Traurig wrote:

> Hello,
>
> Is there a module available for python to convert datetime into an
> array of integers. For example, I have date where the first column is
> a datetime string (i.e. '2010-10-10 01:10:00') and I would like to
> convert that into an array with 5 columns corresponding to the integer
> values of Year,Month,Day,Hour,Minute. There is a function in Matlab
> that performs called datevec() that performs this operation. I find it
> much easier to index datetime or perform calculations on other data
> when date and time are integers. For example, i generally need to
> calculate averages, std, etc based on specific months, years, days,
> and hours. Those calculations are extremely simple when I can index an
> array of datetime integers. If there is no module to convert datetime
> to an array of integers, does anyone have an example of how i might
> index datetime using python datetime or numpy datetime64? In each
> case, I would need an array of datetime the same dimension as my data
> array.
>
> thanks -- jeremy
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>



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


Re: [Tutor] Is this possible and should it be done?

2012-05-21 Thread Emile van Sebille

On 5/21/2012 3:38 AM wolfrage8...@gmail.com said...

All, I have had a curious idea for awhile, and was wondering the best
way to implement it in Python and if it is even possible. The concept
is this, a file that is actually a folder that contains multiple files
(Like an Archive format). The actual files are really un-important.
What I want is for the folder to be represented as a single file by
any normal file browser,


pyfuse allows you to create and represent whatever you want using python 
as a file system to the OS.  Probably worth a look...


Emile

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


Re: [Tutor] Datetime Integers

2012-05-21 Thread Joel Goldstick
On Mon, May 21, 2012 at 11:47 AM, Jeremy Traurig
 wrote:
> Hello,
>
> Is there a module available for python to convert datetime into an
> array of integers. For example, I have date where the first column is
> a datetime string (i.e. '2010-10-10 01:10:00') and I would like to
> convert that into an array with 5 columns corresponding to the integer
> values of Year,Month,Day,Hour,Minute. There is a function in Matlab
> that performs called datevec() that performs this operation. I find it
> much easier to index datetime or perform calculations on other data
> when date and time are integers. For example, i generally need to
> calculate averages, std, etc based on specific months, years, days,
> and hours. Those calculations are extremely simple when I can index an
> array of datetime integers. If there is no module to convert datetime
> to an array of integers, does anyone have an example of how i might
> index datetime using python datetime or numpy datetime64? In each
> case, I would need an array of datetime the same dimension as my data
> array.
>
> thanks -- jeremy
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor

Yes, its called datetime

>>> import datetime

>>> datetime.datetime.strptime('2010-10-10 01:10:00', "%Y-%m-%d %H:%M:%S")
datetime.datetime(2010, 10, 10, 1, 10)

>>> print datetime.datetime.strptime('2010-10-10 01:10:00', "%Y-%m-%d %H:%M:%S")
2010-10-10 01:10:00
>>>

I think there are Constants that can be used in place of the
formatting characters, but I couldn't find them in a quick search


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


Re: [Tutor] Datetime Integers

2012-05-21 Thread Walter Prins
Hi Jeremy,

On 21 May 2012 16:47, Jeremy Traurig  wrote:

> Is there a module available for python to convert datetime into an
>
I presume you mean, "convert a datetime *string* into an array of integers"?

array of integers. For example, I have date where the first column is
> a datetime string (i.e. '2010-10-10 01:10:00') and I would like to
> convert that into an array with 5 columns corresponding to the integer
> values of Year,Month,Day,Hour,Minute. There is a function in Matlab
>
Yes, Python datetime objects support that directly.  If d is a Python
datetime, then d.year gives you the year, d.month gives you the month
etc.   See here:  http://docs.python.org/library/datetime.html  Also see
8.1.7 regarding converting to and from datetime strings.

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


Re: [Tutor] While learning Py: To IDE or not to IDE?

2012-05-21 Thread Brian van den Broek
On 21 May 2012 01:19, "boB Stepp"  wrote:
>
> On Sun, May 20, 2012 at 4:44 PM, Brian van den Broek
>  wrote:



> > With you polyglot agenda, I would say you would be much better off to
learn
> > a powerful multipurpose editor well than to try to find the best of
breed of
> > each class of special purpose tool.
> >
> > There are three basic choice: emacs, vi or vim, and everything else.
There
> > is widespread, though not uniform, consensus that The One True Editor
is one
> > of emacs and vi. After that, the rest is flamewars.
> >
> > I am an emacist, myself. But some of my best friends are vimists.
>
> I gather, then, that you feel my time would be well-spent now to learn
> a good editor/IDE now, rather than continue with IDLE?



> But since you brought it up, I'll ask a somewhat more general
> question: Why do you prefer an editor instead of a graphical IDE? I
> have limited experience with Emacs as I finally installed it on my PC
> at work to avoid having Windows-style end-of-line characters messing
> up my scripts which were to run in an UNIX environment. I can see
> potential there, but as my future projects get larger and more
> involved will it be able to do everything I would want it to do? Would
> I find myself wanting a full-fledged IDE? I don't have enough
> technical knowledge to answer these questions right now. Your
> thoughts?

Hi boB,

If IDLE is working well for you, there's a good reason to stick with it.

I meant to address whether you ought build a stable of purpose-specific
IDEs or learn one editor to rule them all.

The advantage of emacs, as I see it, is that it provides general purpose
tools of high power for text-wrangling and the (non-trivial) time you have
to invest to learn to exploit that power yields fruit whenever you are
editing text. Emacs key bindings turn on all over the place, too; bash
shell supports a bunch, for instance.

It might be that editor plus language would be frustrating to try to learn
all at once, though.

Best,

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


Re: [Tutor] While learning Py: To IDE or not to IDE?

2012-05-21 Thread delegbede
In my humble opinion, I think what is important is to get familiar with python 
for now. The free version of Komodo is what I have been using and its been 
cool. 

When you're comfortable with the language and you want to start writing some 
apps and all of that, you would be matured and independent enough to make a 
choice as to which editor to go with. 

Trust me, when you bury your head into writing amazing codes, the choice of 
editor would come almost naturally. 

All the best. 
Sent from my BlackBerry wireless device from MTN

-Original Message-
From: Brian van den Broek 
Sender: tutor-bounces+delegbede=dudupay@python.org
Date: Mon, 21 May 2012 18:17:01 
To: boB Stepp
Cc: 
Subject: Re: [Tutor] While learning Py: To IDE or not to IDE?

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

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


Re: [Tutor] Fwd: Is this possible and should it be done?

2012-05-21 Thread Alan Gauld

On 21/05/12 15:23, wolfrage8...@gmail.com wrote:


if any of these formats offer file locking with in them, ;et me say
that better. Can I open a, as example, tar file and lock a file with
in it, with out locking the entire tar archive?


No and you probably shouldn't.

If two users are accessing the same file at once and one of them is 
modifying it (writing) while the other is trying to read it bad things 
are very likely to happen. Remember that these virtual files inside the 
tar file(say) are really just blocks of data within a single file.


If you want to try modifying blocks inside a single store you will be 
better with a database. But that's not usually a single file (Access, 
SQLite etc excepted). Actually SQLite might do what you want by locking 
at the table row level, I haven't checked. You would need a single table 
of BLOB records where each BLOB represented a virtual file...


Version control tools like CVS and SVN don't quite fit your needs either 
since they use multiple files not a single file. Although they do 
usually store all the historic versions of each file in one. So if it is 
really only historic data you need CVS, SVN, RCS etc may work.


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

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


Re: [Tutor] Coding Challenges

2012-05-21 Thread Bod Soutar
Pop onto http://ubuntuforums.org and find the programming talk sub-forum.
One of the stickies there is an index of beginner programming challenges.
It's a rolling process where the winner of the previous challenge posts a
new one and then picks a winning entry who goes on to post the next
challenge.

Bodsda

On May 21, 2012 3:50 PM, "Malcolm Newsome" 
wrote:
>
> Hey all,
>
> Being new to programming, I've found that my learning is accelerated when
I've been asked to write scripts and deliver them in a specified time
frame...Then, have those scripts critiqued.
>
> My question: Would the moderators of this list be interested in creating
a monthly "challenge" of sorts? Then, those who participated could receive
suggestions on how their code could have been written differently.
>
> If not, and you know of something else like this that exists, would you
kindly share those resources?
>
> Thanks!
>
> Malcolm Newsome
>
>
> Sent from my Windows Phone
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Datetime Integer Array

2012-05-21 Thread Jeremy Traurig
Hello,

I am reading a data file with a string time stamp as the first column,
example below:

'03/10/2010 02:00:00'
'03/10/2010 02:10:00'
'03/10/2010 02:20:00'
'03/10/2010 02:30:00'
etc to n number of rows.

I'm using the numpy function genfromtxt to read this data:

import numpy as np
datetime_IN = np.genfromtxt('SIL633_original.txt', delimiter='\t',
skip_header=141, dtype='|S19',
usecols=0)

Now I have a variable called datetime_IN which is an array of datetime
strings to the nth row. I'd like to convert this strings to a numpy
array of integers where each column represents a value of time.
For example, using the same values above, i want an array of integers
to look like this:

3,10,2010,2,0,0
3,10,2010,2,10,0
3,10,2010,2,20,0
3,10,2010,2,30,0
etc to n number of rows.

I have already tried creating a numpy array of integers using this code:

import time
time_format = %m/%d/%Y %H:%M:%S
for x in range(len(datetime_IN)):
junk = time.strptime(datetime[x],time_format)
junk2 = [y for y in junk]

The above code works in general but it doesn't create an array with
the same number of rows as datetime_IN, and I understand it doesn't
because the previous data in junk2 is lost. I'd like to build the
junk2 array but I'm not sure how. In other languages, I'm able to
iterate over an array to build it, so in each iteration of a loop a
new row is created for the arrray I'm building. I'm not quite sure how
to do that in python.

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


Re: [Tutor] Fwd: Is this possible and should it be done?

2012-05-21 Thread Jordan


On 05/21/2012 07:24 PM, Alan Gauld wrote:
> On 21/05/12 15:23, wolfrage8...@gmail.com wrote:
>
>> if any of these formats offer file locking with in them, ;et me say
>> that better. Can I open a, as example, tar file and lock a file with
>> in it, with out locking the entire tar archive?
>
> No and you probably shouldn't.
>
> If two users are accessing the same file at once and one of them is
> modifying it (writing) while the other is trying to read it bad things
> are very likely to happen. Remember that these virtual files inside
> the tar file(say) are really just blocks of data within a single file.
>
> If you want to try modifying blocks inside a single store you will be
> better with a database. But that's not usually a single file (Access,
> SQLite etc excepted). Actually SQLite might do what you want by
> locking at the table row level, I haven't checked. You would need a
> single table of BLOB records where each BLOB represented a virtual
> file...
>
Very interesting idea, I have actually used a SQLite file in this way
before, not sure why I did not think of that possibility. SQLite's BLOB
could be the perfect already created solution. Thank you all for your
inputs.
> Version control tools like CVS and SVN don't quite fit your needs
> either since they use multiple files not a single file. Although they
> do usually store all the historic versions of each file in one. So if
> it is really only historic data you need CVS, SVN, RCS etc may work.
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] While learning Py: To IDE or not to IDE?

2012-05-21 Thread Walter Prins
Hi,

On 21 May 2012 15:17, bob gailer  wrote:

> There are numerous IDES for Python that run on Linux systems (most are
> free).
>

I'd like to add that if/when you do decide to pick up an IDE, I suggest you
try Eclipse.  For one it will allow you to use it for other languages also
(Java, C++, et al).  Have a look at the following video demonstrating some
of the PyDev features in the following video (also a little demonstration
how to develop TDD "red, green, refactor" style) :
http://pydev.org/video_pydev_20.html  Unit testing (PyUnit & friends),
Source code style and problem checking (Pylint), code test coverage
(Coverage.py) are all usable from and integrated reasonably well, making
life just that little bit easier.

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


Re: [Tutor] Datetime Integer Array

2012-05-21 Thread Emile van Sebille

On 5/21/2012 1:04 PM Jeremy Traurig said...

Hello,

I am reading a data file with a string time stamp as the first column,
example below:

'03/10/2010 02:00:00'
'03/10/2010 02:10:00'
'03/10/2010 02:20:00'
'03/10/2010 02:30:00'
etc to n number of rows.

I'm using the numpy function genfromtxt to read this data:

import numpy as np
datetime_IN = np.genfromtxt('SIL633_original.txt', delimiter='\t',
skip_header=141, dtype='|S19',
usecols=0)

Now I have a variable called datetime_IN which is an array of datetime
strings to the nth row. I'd like to convert this strings to a numpy
array of integers where each column represents a value of time.
For example, using the same values above, i want an array of integers
to look like this:

3,10,2010,2,0,0
3,10,2010,2,10,0
3,10,2010,2,20,0
3,10,2010,2,30,0
etc to n number of rows.



Using only builtin python functions you can do this as follows:

>>> source = ['03/10/2010 02:00:00',
... '03/10/2010 02:10:00',
... '03/10/2010 02:20:00',
... '03/10/2010 02:30:00']
>>>
>>> for ts in source:
... print ts, [ int(ii) for ii in 
ts.replace("/","").replace(":","").split() ]

...
03/10/2010 02:00:00 [3, 10, 2010, 2, 0, 0]
03/10/2010 02:10:00 [3, 10, 2010, 2, 10, 0]
03/10/2010 02:20:00 [3, 10, 2010, 2, 20, 0]
03/10/2010 02:30:00 [3, 10, 2010, 2, 30, 0]

HTH,

Emile

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


[Tutor] Optimally configuring Emacs for W7-64bit and Python

2012-05-21 Thread boB Stepp
Many thanks for all of the helpful input to my original questions. The
deciding factors came down to the fact that GNU Emacs, vintage year
2001, is available on the Sun Blade at work, I already own the book
"Learning GNU Emacs" and it would be nice to have my fingers trained
the same way for both work and home study.

What is the best way for me to get my W7-64bit laptop configured for
Python programming? My consultations with the Google oracle have
yielded inconclusive results this evening, though I confess I am quite
tired, so I may be missing the obvious.

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