Re: [Tutor] How to replace the '\'s in a path with '/'s?

2011-07-31 Thread Steven D'Aprano

Sandip Bhattacharya wrote:


Generally, converting slashes manually should be kept at a minimum. You
should be using library functions as much as possible. The experts here
can correct me here, but this is a roundabout way I would be doing this:


str.replace('\\', '/') is a perfectly fine library function to use to 
convert backslashes.


[...]

# Use raw strings so that backslash doesnt matter
path=r'C:\Users\Dick\Desktop\Documents\Notes\College Notes.rtf'


That's not quite true. Even with raw strings, you can't write:

path = r'C:\Users\Dick\Desktop\Documents\Notes\'

Try it and see what happens.


[...]

I am not happy with the loop to collect the components. But I couldn't
find a single path function which splits a path into all the components
in one go.


Just use str.split.

Be prepared to filter out empty path components if the user enters a 
path with doubled-up backslashes:


C:\Users\Dick\\Desktop

but that's no real difficulty.



--
Steven

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


Re: [Tutor] How to replace the '\'s in a path with '/'s?

2011-07-31 Thread Steven D'Aprano

Richard D. Moores wrote:


File "c:\P32Working\untitled-5.py", line 2
   return path.replace('\', '/')
   ^
SyntaxError: EOL while scanning string literal



Others have already told you how to solve the immediate problem (namely, 
escape the backslash), but I'd like to talk more about general 
problem-solving techniques, in the principle that it is better to teach 
someone how to catch their own fish rather than just to feed them fish 
for a day.


As a programmer (amateur or profession), we *must* learn to read the 
error messages and glean as much information as possible. In this case, 
the error tells you that the line couldn't even be executed, because it 
doesn't compile: you get a SyntaxError.


SyntaxErrors show you where the failure occurs: look at the ^ up-arrow 
under the line of code. It points to the end of the line. Combine that 
with the error message "EOL while scanning string literal" and the cause 
of the error is solved: Python ran out of line before the string was closed.


(You may need to google on "EOL" to learn that it means "End Of Line".)

This of course opens more questions. Python, apparently, thinks that the 
closing bracket ) is inside a string, instead of outside of it. Look at 
the offending line and work backwards, and you should be able to see 
that Python sees the line as:


return path.replace( AAA / BBB

where AAA is the string '\', ' and BBB is the broken string ')


This gives you a clue to try in the interactive interpreter. You should 
*expect* this to raise an exception, but it does not:


>>> s = '\', '
>>> print s
',
>>> print repr(s)
"', "



which should lead you to googling on "python backslash", which in turn 
leads to a mass of information. Just from the google search results 
themselves, I see:


  # first search result
  2. Lexical analysis — Python v2.7.2 documentation
  Python uses the 7-bit ASCII character set for program text. ... A
  backslash does not continue a token except for string literals


  # second search result
  2.4.1 String literals
  21 Feb 2008 – The backslash ( \ ) character is used to escape
  characters ...


  # third result
  Python Gotchas
  3 Jun 2008 – 2 "raw" strings and backslashes (when dealing with
  Windows filenames). ...


The first one looks a bit technical (what on earth is lexical analysis? 
-- look it up if you care) but the second and third look very promising. 
Backslash is used to escape characters, and backslashes in Windows 
filenames are a Gotcha.



And now you know how to catch fish :)




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


Re: [Tutor] How to replace the '\'s in a path with '/'s?

2011-07-31 Thread Richard D. Moores
On Sat, Jul 30, 2011 at 23:32, Sandip Bhattacharya
 wrote:
>
> On Sat, Jul 30, 2011 at 10:28:11PM -0700, Richard D. Moores wrote:
> > File "c:\P32Working\untitled-5.py", line 2
> >    return path.replace('\', '/')
> >                                ^
> > SyntaxError: EOL while scanning string literal
> > Process terminated with an exit code of 1
>
> The first backslash up there is escaping the ending quote. This is  what
> you want:
>    return path.replace('\\', '/')
>
> Generally, converting slashes manually should be kept at a minimum. You
> should be using library functions as much as possible. The experts here
> can correct me here, but this is a roundabout way I would be doing this:
>
>    # I use a linux machine. Using this to work with Windows paths
>    # Use os.path if you are on windows
>    import ntpath
>
>    # Use raw strings so that backslash doesnt matter
>    path=r'C:\Users\Dick\Desktop\Documents\Notes\College Notes.rtf'
>
>    #take out drive first because ntpath.split end sentinel is predictable 
> that way
>    drive,rest = ntpath.splitdrive(path)
>
>    # This will store the path components
>    comps = []
>    comps.append(drive)
>
>    while rest != '\\':
>        parts = ntpath.split(rest)
>        comps.insert(1,parts[1])
>        rest = parts[0]
>
>
>    print '/'.join(comps)
>
> I am not happy with the loop to collect the components. But I couldn't
> find a single path function which splits a path into all the components
> in one go.

Terrific! I now have my function, thanks to Sandip:

def fwd2bk_path_slashes(path):
    import os.path

    # Use raw strings so that backslash doesn't matter
    #path=r'C:\Users\Dick\Desktop\Documents\Notes\College Notes.rtf'

    #take out drive first because os.path.split end sentinel is
predictable that way
    drive, rest = os.path.splitdrive(path)

    # This will store the path components
    comps = []
    comps.append(drive)

    while rest != '\\':
        parts = os.path.split(rest)
        comps.insert(1, parts[1])
        rest = parts[0]

    return ('/'.join(comps))


I've put it in my mycomp.py module, my collection of useful functions.
>>> from mycalc import fwd2bk_path_slashes
>>> path = r'C:\Users\Dick\Desktop\Documents\Notes\College Notes.rtf'
>>> fwd3bk_path_slashes(path)
'C:/Users/Dick/Desktop/Documents/Notes/College Notes.rtf'


BTW I had figured out that I could solve my problem if I either
manually doubled all the backslashes in the path or manually changed
each backslash to a forward slash, but that wouldn't solve my problem
-- I wanted a function that would convert paths such as

'C:\Users\Dick\Desktop\Documents\Notes\College Notes.rtf'
to paths such as
'C:/Users/Dick/Desktop/Documents/Notes/College Notes.rtf'

I can live with having to put the path in single quotes and then
precede this with an  r  .

===Stop reading here; what follows is OT

I'll explain why I wanted the function for those few who might be curious:

I have a bunch of RTF files which are used to collect one sort of
information or another. Comcast Voicemail Notes.rtf, Diary.rtf, Python
Notes.rtf, IPython Notes.rtf, Vista Notes.rtf, Agent Ransack Tips.rtf,
etc.

I also use ActiveWords (http://www.activewords.com/). I've been using
it for years, and now have over 1600 "active words" that do all sorts
of things for me: access websites (with my default browser), call
programs, open folders, execute Python programs, etc. And of course,
open files such as those RTF files. One of those RTFs is
ActiveWords,rtf (which I open using the activeword 'aw'. 'nyt' gets me
to the New York Times; 'at' (for 'add times') executes/calls my Python
script for adding times (such as track times on a CD), 'prec' (for
'precision') enters an often used bit of code,
'decimal.getcontext().prec ='.

Now of course I can remember only the activewords that I frequently
use. To retrieve the others of the 1600+, I have them all listed, one
per line in ActiveWords.rtf, and have a Python script that essentially
greps them for the one I want. Each line has the activeword, a short
description of what it does, and the path if the activeword opens a
folder or a file. For each path, I copy it from Windows Explorer
(using Shift when I right-click on the file or folder, then select
'Copy as path' from the context menu that opens. But if I paste this
into its line in ActiveWords.rtf, my grepping script makes a mess of
it. Therefore my need for a function to first convert those
backslashes to forward slashes.

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


Re: [Tutor] How to replace the '\'s in a path with '/'s?

2011-07-31 Thread Peter Otten
Sandip Bhattacharya wrote:

> On Sat, Jul 30, 2011 at 10:28:11PM -0700, Richard D. Moores wrote:
>> File "c:\P32Working\untitled-5.py", line 2
>>return path.replace('\', '/')
>>^
>> SyntaxError: EOL while scanning string literal
>> Process terminated with an exit code of 1
> 
> The first backslash up there is escaping the ending quote. This is  what
> you want:
> return path.replace('\\', '/')
> 
> Generally, converting slashes manually should be kept at a minimum. You
> should be using library functions as much as possible. The experts here
> can correct me here, but this is a roundabout way I would be doing this:
> 
> # I use a linux machine. Using this to work with Windows paths
> # Use os.path if you are on windows
> import ntpath
> 
> # Use raw strings so that backslash doesnt matter
> path=r'C:\Users\Dick\Desktop\Documents\Notes\College Notes.rtf'
> 
> #take out drive first because ntpath.split end sentinel is predictable
> #that way
> drive,rest = ntpath.splitdrive(path)
> 
> # This will store the path components
> comps = []
> comps.append(drive)
> 
> while rest != '\\':
> parts = ntpath.split(rest)
> comps.insert(1,parts[1])
> rest = parts[0]
> 
> 
> print '/'.join(comps)
> 
> I am not happy with the loop to collect the components. But I couldn't
> find a single path function which splits a path into all the components
> in one go.

What happens if the path looks like 

r"C:relative\path\to\my\file.txt"

or

r"C:/mixed\slashes.txt"?

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


Re: [Tutor] How to replace the '\'s in a path with '/'s?

2011-07-31 Thread Sergey
Maybe something useful could be find in urllib? It can open local files. And
UNIX slashes are equal to Web slashes.
http://docs.python.org/release/3.2.1/library/urllib.request.html#urllib.request.URLopener
--
class urllib.request.URLopener(proxies=None, **x509)

Base class for opening and reading URLs. Unless you need to support opening
objects using schemes other than http:, ftp:, or file:, you probably want to use
FancyURLopener.
--

>On Sat, 30 Jul 2011 22:28:11 -0700 "Richard D. Moores" 
wrote

>I would like to write a function that would take a path 


South Africas premier free email service - www.webmail.co.za 

For super low premiums, click here http://www.dialdirect.co.za/?vdn=15828


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


Re: [Tutor] How to replace the '\'s in a path with '/'s?

2011-07-31 Thread Richard D. Moores
On Sun, Jul 31, 2011 at 03:34, Peter Otten <__pete...@web.de> wrote:
>
> Sandip Bhattacharya wrote:
>
> > On Sat, Jul 30, 2011 at 10:28:11PM -0700, Richard D. Moores wrote:
> >> File "c:\P32Working\untitled-5.py", line 2
> >>    return path.replace('\', '/')
> >>                                ^
> >> SyntaxError: EOL while scanning string literal
> >> Process terminated with an exit code of 1
> >
> > The first backslash up there is escaping the ending quote. This is  what
> > you want:
> >     return path.replace('\\', '/')
> >
> > Generally, converting slashes manually should be kept at a minimum. You
> > should be using library functions as much as possible. The experts here
> > can correct me here, but this is a roundabout way I would be doing this:
> >
> >     # I use a linux machine. Using this to work with Windows paths
> >     # Use os.path if you are on windows
> >     import ntpath
> >
> >     # Use raw strings so that backslash doesnt matter
> >     path=r'C:\Users\Dick\Desktop\Documents\Notes\College Notes.rtf'
> >
> >     #take out drive first because ntpath.split end sentinel is predictable
> >     #that way
> >     drive,rest = ntpath.splitdrive(path)
> >
> >     # This will store the path components
> >     comps = []
> >     comps.append(drive)
> >
> >     while rest != '\\':
> >         parts = ntpath.split(rest)
> >         comps.insert(1,parts[1])
> >         rest = parts[0]
> >
> >
> >     print '/'.join(comps)
> >
> > I am not happy with the loop to collect the components. But I couldn't
> > find a single path function which splits a path into all the components
> > in one go.
>
> What happens if the path looks like
>
> r"C:relative\path\to\my\file.txt"
>
> or
>
> r"C:/mixed\slashes.txt"?
>
> ___
> 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] How to replace the '\'s in a path with '/'s?

2011-07-31 Thread Richard D. Moores
On Sun, Jul 31, 2011 at 03:34, Peter Otten <__pete...@web.de> wrote:
> Sandip Bhattacharya wrote:
>
>> On Sat, Jul 30, 2011 at 10:28:11PM -0700, Richard D. Moores wrote:
>>> File "c:\P32Working\untitled-5.py", line 2
>>>    return path.replace('\', '/')
>>>                                ^
>>> SyntaxError: EOL while scanning string literal
>>> Process terminated with an exit code of 1
>>
>> The first backslash up there is escaping the ending quote. This is  what
>> you want:
>>     return path.replace('\\', '/')
>>
>> Generally, converting slashes manually should be kept at a minimum. You
>> should be using library functions as much as possible. The experts here
>> can correct me here, but this is a roundabout way I would be doing this:
>>
>>     # I use a linux machine. Using this to work with Windows paths
>>     # Use os.path if you are on windows
>>     import ntpath
>>
>>     # Use raw strings so that backslash doesnt matter
>>     path=r'C:\Users\Dick\Desktop\Documents\Notes\College Notes.rtf'
>>
>>     #take out drive first because ntpath.split end sentinel is predictable
>>     #that way
>>     drive,rest = ntpath.splitdrive(path)
>>
>>     # This will store the path components
>>     comps = []
>>     comps.append(drive)
>>
>>     while rest != '\\':
>>         parts = ntpath.split(rest)
>>         comps.insert(1,parts[1])
>>         rest = parts[0]
>>
>>
>>     print '/'.join(comps)
>>
>> I am not happy with the loop to collect the components. But I couldn't
>> find a single path function which splits a path into all the components
>> in one go.
>
> What happens if the path looks like
>
> r"C:relative\path\to\my\file.txt"
>
> or
>
> r"C:/mixed\slashes.txt"?

Not quite sure what the intent of your question is, but all the paths
I want to modify are full, with only back slashes.

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


Re: [Tutor] How to replace the '\'s in a path with '/'s?

2011-07-31 Thread Sergey
Gotcha!
http://pymon.googlecode.com/svn/tags/pymon-0.2/Internet/rsync.py
231-239 strings

## code ##

def convertPath(path):
# Convert windows, mac path to unix version.
separator = os.path.normpath("/")
if separator != "/":
path = re.sub(re.escape(separator), "/", path)

# Help file, folder pattern to express that it should match the all 
file or
folder name.
path = "/" + path
return path

## code ##

>On Sat, 30 Jul 2011 22:28:11 -0700 "Richard D. Moores" 
wrote



South Africas premier free email service - www.webmail.co.za 

Save on insurance with OUTsurance
https://www.outsurance.co.za/insurance-quote/?source=webmailmailer&cr=facp11_468x60&cid=221


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


Re: [Tutor] How to replace the '\'s in a path with '/'s?

2011-07-31 Thread Richard D. Moores
On Sun, Jul 31, 2011 at 08:59, Sergey  wrote:
> Gotcha!
> http://pymon.googlecode.com/svn/tags/pymon-0.2/Internet/rsync.py
> 231-239 strings
>
> ## code ##
>
> def convertPath(path):
>        # Convert windows, mac path to unix version.
>        separator = os.path.normpath("/")
>        if separator != "/":
>                path = re.sub(re.escape(separator), "/", path)
>
>        # Help file, folder pattern to express that it should match the all 
> file or
> folder name.
>        path = "/" + path
>        return path
>
> ## code ##

Nice!

I went with


import os.path
import re

def convertPath(path):
separator = os.path.normpath("/")
if separator != "/":
path = re.sub(re.escape(separator), "/", path)

return path



path=r'C:\Users\Dick\Desktop\Documents\Notes\College Notes.rtf'

print(convertPath(path))

"""
Output
C:/Users/Dick/Desktop/Documents/Notes/College Notes.rtf
"""
Dick
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How to replace the '\'s in a path with '/'s?

2011-07-31 Thread Sergey
Haha. Works!
Happy help you.
Ask gurus about regexps. I know they have an opinion about its speed and
optimization. So they can try to criticise. But the problem is solved. It's
good. 


On Sun, 31 Jul 2011 09:18:33 -0700 "Richard D. Moores" 
wrote

> 
> Nice!
> 
> I went with
> 
> 
> import os.path
> import re
> 
> def convertPath(path):
> separator = os.path.normpath("/")
> if separator != "/":
> path = re.sub(re.escape(separator), "/", path)
> 
> return path
> 
> 
> 
> path=r'C:\Users\Dick\Desktop\Documents\Notes\College Notes.rtf'
> 
> print(convertPath(path))
> 
> """
> Output
> C:/Users/Dick/Desktop/Documents/Notes/College Notes.rtf
> """
> Dick


South Africas premier free email service - www.webmail.co.za 

For super low premiums, click here http://www.dialdirect.co.za/?vdn=15828


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


Re: [Tutor] How to replace the '\'s in a path with '/'s?

2011-07-31 Thread Steven D'Aprano

Sergey wrote:

Gotcha!
http://pymon.googlecode.com/svn/tags/pymon-0.2/Internet/rsync.py
231-239 strings

## code ##

def convertPath(path):
# Convert windows, mac path to unix version.
separator = os.path.normpath("/")
if separator != "/":
path = re.sub(re.escape(separator), "/", path)


The above code is buggy. It doesn't work as expected on a classic Mac. 
Hint: import macpath; print macpath.normpath('/')


Besides, there is no need to use the 20 lb sledgehammer of regular 
expressions to crack the tiny little peanut of replacing a simple 
character with another simple character.


The above function is much more sensibly written as:

def convertPath(path):
separator = os.path.sep
if sep != '/':
path = path.replace(os.path.sep, '/')
return path

Or even more simply:

return path.replace(os.path.sep, '/')

(although that may do a small amount of unnecessary work on Unix systems).




--
Steven

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


Re: [Tutor] How to replace the '\'s in a path with '/'s?

2011-07-31 Thread Sergey
Nice!
That's what I've been expecting.
Thanks.

Your one string command is tiny and complete. And elegant.
Final desicion?
Or it could be something better and more professional?
So we have removed regexps and everything is fine now. Yes?


On Mon, 01 Aug 2011 02:37:09 +1000 Steven D'Aprano  wrote

> Sergey wrote:
> > Gotcha!
> > http://pymon.googlecode.com/svn/tags/pymon-0.2/Internet/rsync.py
> > 231-239 strings
> >
> > ## code ##
> >
> > def convertPath(path):
> > # Convert windows, mac path to unix version.
> > separator = os.path.normpath("/")
> > if separator != "/":
> > path = re.sub(re.escape(separator), "/", path)
> 
> The above code is buggy. It doesn't work as expected on a classic Mac.
> Hint: import macpath; print macpath.normpath('/')
> 
> Besides, there is no need to use the 20 lb sledgehammer of regular
> expressions to crack the tiny little peanut of replacing a simple
> character with another simple character.
> 
> The above function is much more sensibly written as:
> 
> def convertPath(path):
>  separator = os.path.sep
>  if sep != '/':
>  path = path.replace(os.path.sep, '/')
>  return path
> 
> Or even more simply:
> 
>  return path.replace(os.path.sep, '/')
> 
> (although that may do a small amount of unnecessary work on Unix systems).
> 
> 
> 
> 
> --
> Steven
> 
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor




South Africas premier free email service - www.webmail.co.za 

For super low premiums, click here http://www.dialdirect.co.za/?vdn=15828


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


Re: [Tutor] How to replace the '\'s in a path with '/'s?

2011-07-31 Thread Peter Otten
Richard D. Moores wrote:

>> What happens if the path looks like
>>
>> r"C:relative\path\to\my\file.txt"
>>
>> or
>>
>> r"C:/mixed\slashes.txt"?
> 
> Not quite sure what the intent of your question is, but all the paths
> I want to modify are full, with only back slashes.

If you invoke your fwd2bk_path_slashes() with one of those paths it'll stay 
in the while loop forever (until it runs out of memory). 

I'd consider that a bug that you should be aware of.


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


Re: [Tutor] How to replace the '\'s in a path with '/'s?

2011-07-31 Thread Richard D. Moores
On Sun, Jul 31, 2011 at 10:34, Peter Otten <__pete...@web.de> wrote:
>
> Richard D. Moores wrote:
>
> >> What happens if the path looks like
> >>
> >> r"C:relative\path\to\my\file.txt"
> >>
> >> or
> >>
> >> r"C:/mixed\slashes.txt"?
> >
> > Not quite sure what the intent of your question is, but all the paths
> > I want to modify are full, with only back slashes.
>
> If you invoke your fwd2bk_path_slashes() with one of those paths it'll stay
> in the while loop forever (until it runs out of memory).
>
> I'd consider that a bug that you should be aware of.

Yes. Thanks.

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


[Tutor] Mailing list documentation

2011-07-31 Thread Alexander Etter
Hello everyone, is there a page that contains documentation for this mailing 
list? I've seen a few users top post and others advise against it; if there 
isn't a page listing conventions let's create it and if there is what is it's 
URL and how do you suggest users read it?
Alexander
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Mailing list documentation

2011-07-31 Thread Sergey
On Sun, 31 Jul 2011 14:22:41 -0400 Alexander Etter  wrote

> Hello everyone, is there a page that contains documentation for this mailing
> list? I've seen a few users top post and others advise against it; if there
> isn't a page listing conventions let's create it and if there is what is it's
> URL and how do you suggest users read it?
> Alexander
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor

---
tutor-requ...@python.org
Fri, 29 Jul 2011 19:52:43 +0200(2 days, 1 hour ago)

Welcome to the Tutor@python.org mailing list! This list is for folks
who want to ask (and/or answer) questions from folks who wish to learn
how to program with Python.  Feel free to ask even the most basic of
questions -- that's what the list is for!

For best results when asking a question on this list: - Try to write
some code to solve your problem - Show the code you have written -
Describe what the code does and what you want it to do - If the code
generates an error, copy and paste the entire error message, including
the traceback, into your email. - Tell us what OS and Python version
you are using.

- Don't ask us to do your homework. - Don't assume we know what you
are talking about. If you are having trouble with a third-party
library, include a link to the library home page.

When replying to a posting: - Use Reply All to reply to the entire
list - Don't top post - put your reply after the text to which you are
replying

For all posts: - Format your email as plain text, not HTML


To post to this list, send your email to:

  tutor@python.org

General information about the mailing list is at:

  http://mail.python.org/mailman/listinfo/tutor

If you ever want to unsubscribe or change your options (eg, switch to
or from digest mode, change your password, etc.), visit your
subscription page at:

  http://mail.python.org/mailman/options/tutor/***

You can also make such adjustments via email by sending a message to:

  tutor-requ...@python.org

with the word `help' in the subject or body (don't include the
quotes), and you will get back a message with instructions.

You must know your password to change your options (including changing
the password, itself) or to unsubscribe.  It is:

***

Normally, Mailman will remind you of your python.org mailing list
passwords once every month, although you can disable this if you
prefer.  This reminder will also include instructions on how to
unsubscribe or change your account options.  There is also a button on
your options page that will email your current password to you.



South Africas premier free email service - www.webmail.co.za 

For super low premiums, click here http://www.dialdirect.co.za/?vdn=15828


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


[Tutor] How do I learn python for web development

2011-07-31 Thread abdulhakim haliru
Hi guys,

I am really interested in switching from PHP to python but there don't appear 
to be a book for such.

Can anyone advice me please.

Abdulhakim.
Sent from my BlackBerry wireless device from MTN

-Original Message-
From: tutor-requ...@python.org
Sender: tutor-bounces+abdulhakim.haliru=leproghrammeen@python.org
Date: Sun, 31 Jul 2011 07:01:56 
To: 
Reply-To: tutor@python.org
Subject: Tutor Digest, Vol 89, Issue 92

Send Tutor mailing list submissions to
tutor@python.org

To subscribe or unsubscribe via the World Wide Web, visit
http://mail.python.org/mailman/listinfo/tutor
or, via email, send a message with subject or body 'help' to
tutor-requ...@python.org

You can reach the person managing the list at
tutor-ow...@python.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Tutor digest..."


Today's Topics:

   1. Re: How to make tkMessage function to have duration
  (Steven D'Aprano)
   2. Re: How to make tkMessage function to have duration (Emeka)
   3. newbie needs pypy setup tips (Tom Roche)
   4. Re: newbie needs pypy setup tips (eire1...@gmail.com)
   5. Re: Mainloop conflict (Christopher King)
   6. Re: Mainloop conflict (Stefan Behnel)


--

Message: 1
Date: Sat, 30 Jul 2011 21:25:27 +1000
From: Steven D'Aprano 
To: tutor@python.org
Subject: Re: [Tutor] How to make tkMessage function to have duration
Message-ID: <4e33ea27.50...@pearwood.info>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Emeka wrote:
> Hello All,
> 
> Say I have the below(code),  I would want the message to last say 30
> seconds and afterwards disappear. I won't want the user to be the one to
> enable it to disappear.
> 
> Basically, what I want is to be able to show the user some message , and
> after some seconds, the message goes away

I *hate* it when applications do that. Just as I'm trying to read the 
message, take a screen shot, or whatever, the message disappears. I 
think that's one of the worst things you can do in an application.

If the message isn't important enough to require it to stay visible 
until the user explicitly closes it, then it shouldn't go into a dialog 
in the first place.



-- 
Steven


--

Message: 2
Date: Sat, 30 Jul 2011 16:27:21 +0100
From: Emeka 
To: "Steven D'Aprano" 
Cc: tutor@python.org
Subject: Re: [Tutor] How to make tkMessage function to have duration
Message-ID:

Content-Type: text/plain; charset="iso-8859-1"

Steven,,


Thanks!


Emeka

On Sat, Jul 30, 2011 at 12:25 PM, Steven D'Aprano wrote:

> Emeka wrote:
>
>> Hello All,
>>
>> Say I have the below(code),  I would want the message to last say 30
>> seconds and afterwards disappear. I won't want the user to be the one to
>> enable it to disappear.
>>
>> Basically, what I want is to be able to show the user some message , and
>> after some seconds, the message goes away
>>
>
> I *hate* it when applications do that. Just as I'm trying to read the
> message, take a screen shot, or whatever, the message disappears. I think
> that's one of the worst things you can do in an application.
>
> If the message isn't important enough to require it to stay visible until
> the user explicitly closes it, then it shouldn't go into a dialog in the
> first place.
>
>
>
> --
> Steven
> __**_
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/**mailman/listinfo/tutor
>



-- 
*Satajanus  Nig. Ltd


*
-- next part --
An HTML attachment was scrubbed...
URL: 


--

Message: 3
Date: Sat, 30 Jul 2011 17:49:02 -0400
From: Tom Roche 
To: tutor@python.org,
Subject: [Tutor] newbie needs pypy setup tips
Message-ID: <877h6zfnht@pobox.com>
Content-Type: text/plain; charset=us-ascii


I need advice about configuring pypy to run other python code. Why I ask:

I'm running a model implemented in python. Unfortunately a run on "straight" 
python 2.6.x or 2.7.x requires

- 130 min on my ubuntu laptop (on which working would be more convenient)
- 55 min on a better build machine on which I currently have access

However I have read that this model runs 5x faster under pypy, so I wanna get 
me that, but I'm finding the pypy docs pretty inscrutable. Nevertheless, I have 
managed to do

me@it:~$ uname -rv
> 2.6.32-33-generic #70-Ubuntu SMP Thu Jul 7 21:13:52 UTC 2011
me@it:~$ which pypy
> /usr/local/bin/pypy
me@it:~$ ls -al $(which pypy)
> lrwxrwxrwx 1 root root 37 2011-07-30 16:06 /usr/local/bin/pypy -> 
> /opt/pypy-c-jit-1.5.0-alpha0/bin/pypy
me@it:~$ pypy --version
> Python 2.7.1 (b590cf6de419, Apr 30 2011, 02:00:34)
> [PyPy 1.5.0-alpha0 with GCC 4.4.3]

Howeve

Re: [Tutor] How do I learn python for web development

2011-07-31 Thread eire1130
There are several books om django. This is what you are looking for


Sent from my Verizon Wireless BlackBerry

-Original Message-
From: "abdulhakim haliru" 
Sender: tutor-bounces+eire1130=gmail@python.org
Date: Sun, 31 Jul 2011 20:22:30 
To: 
Reply-To: abdulhakim.hal...@leproghrammeen.com
Subject: [Tutor] How do I learn python for web development

Hi guys,

I am really interested in switching from PHP to python but there don't appear 
to be a book for such.

Can anyone advice me please.

Abdulhakim.
Sent from my BlackBerry wireless device from MTN

-Original Message-
From: tutor-requ...@python.org
Sender: tutor-bounces+abdulhakim.haliru=leproghrammeen@python.org
Date: Sun, 31 Jul 2011 07:01:56 
To: 
Reply-To: tutor@python.org
Subject: Tutor Digest, Vol 89, Issue 92

Send Tutor mailing list submissions to
tutor@python.org

To subscribe or unsubscribe via the World Wide Web, visit
http://mail.python.org/mailman/listinfo/tutor
or, via email, send a message with subject or body 'help' to
tutor-requ...@python.org

You can reach the person managing the list at
tutor-ow...@python.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Tutor digest..."


Today's Topics:

   1. Re: How to make tkMessage function to have duration
  (Steven D'Aprano)
   2. Re: How to make tkMessage function to have duration (Emeka)
   3. newbie needs pypy setup tips (Tom Roche)
   4. Re: newbie needs pypy setup tips (eire1...@gmail.com)
   5. Re: Mainloop conflict (Christopher King)
   6. Re: Mainloop conflict (Stefan Behnel)


--

Message: 1
Date: Sat, 30 Jul 2011 21:25:27 +1000
From: Steven D'Aprano 
To: tutor@python.org
Subject: Re: [Tutor] How to make tkMessage function to have duration
Message-ID: <4e33ea27.50...@pearwood.info>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Emeka wrote:
> Hello All,
> 
> Say I have the below(code),  I would want the message to last say 30
> seconds and afterwards disappear. I won't want the user to be the one to
> enable it to disappear.
> 
> Basically, what I want is to be able to show the user some message , and
> after some seconds, the message goes away

I *hate* it when applications do that. Just as I'm trying to read the 
message, take a screen shot, or whatever, the message disappears. I 
think that's one of the worst things you can do in an application.

If the message isn't important enough to require it to stay visible 
until the user explicitly closes it, then it shouldn't go into a dialog 
in the first place.



-- 
Steven


--

Message: 2
Date: Sat, 30 Jul 2011 16:27:21 +0100
From: Emeka 
To: "Steven D'Aprano" 
Cc: tutor@python.org
Subject: Re: [Tutor] How to make tkMessage function to have duration
Message-ID:

Content-Type: text/plain; charset="iso-8859-1"

Steven,,


Thanks!


Emeka

On Sat, Jul 30, 2011 at 12:25 PM, Steven D'Aprano wrote:

> Emeka wrote:
>
>> Hello All,
>>
>> Say I have the below(code),  I would want the message to last say 30
>> seconds and afterwards disappear. I won't want the user to be the one to
>> enable it to disappear.
>>
>> Basically, what I want is to be able to show the user some message , and
>> after some seconds, the message goes away
>>
>
> I *hate* it when applications do that. Just as I'm trying to read the
> message, take a screen shot, or whatever, the message disappears. I think
> that's one of the worst things you can do in an application.
>
> If the message isn't important enough to require it to stay visible until
> the user explicitly closes it, then it shouldn't go into a dialog in the
> first place.
>
>
>
> --
> Steven
> __**_
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/**mailman/listinfo/tutor
>



-- 
*Satajanus  Nig. Ltd


*
-- next part --
An HTML attachment was scrubbed...
URL: 


--

Message: 3
Date: Sat, 30 Jul 2011 17:49:02 -0400
From: Tom Roche 
To: tutor@python.org,
Subject: [Tutor] newbie needs pypy setup tips
Message-ID: <877h6zfnht@pobox.com>
Content-Type: text/plain; charset=us-ascii


I need advice about configuring pypy to run other python code. Why I ask:

I'm running a model implemented in python. Unfortunately a run on "straight" 
python 2.6.x or 2.7.x requires

- 130 min on my ubuntu laptop (on which working would be more convenient)
- 55 min on a better build machine on which I currently have access

However I have read that this model runs 5x faster under pypy, so I wanna get 
me that, but I'm finding the pypy docs pretty inscrutable. Nevertheless, I have 
managed to do

me@it:~$ uname -rv
> 

Re: [Tutor] How do I learn python for web development

2011-07-31 Thread James Thornton
On Sun, Jul 31, 2011 at 3:22 PM, abdulhakim haliru
 wrote:
> Hi guys,
>
> I am really interested in switching from PHP to python but there don't appear 
> to be a book for such.

Hi -

Start off by becoming familiar with Python -- here are some good
online tutorials, in order from introductory to more advanced:

http://www.quora.com/How-can-I-learn-to-program-in-Python/answer/James-Thornton

And then do the Flask Quickstart and Tutorial (http://flask.pocoo.org/docs/).

Flask is an elegantly-designed Python Web microframework so it's great
for beginners because you don't have too spend much time learning it
-- it let's you program in Python rather than writing to the
framework.

Ironically, this also makes Flask an ideal choice for advanced Python
programmers because it gives you flexibility rather than always
wondering "will the framework allow me to easily do...?"

- James

-- 
Bulbflow: A Python framework for graph databases (http://bulbflow.com)
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How do I learn python for web development

2011-07-31 Thread bob gailer

PLEASE DO NOT HIJACK PRIOR MESSAGES.
New thread? Start a new email.
PLEASE DO NOT SEND A BUNCH OF IRREVELANT TEXT.
Just what is relevant.



On 7/31/2011 4:27 PM, eire1...@gmail.com wrote:

There are several books om django. This is what you are looking for


Sent from my Verizon Wireless BlackBerry

-Original Message-
From: "abdulhakim haliru"
Sender: tutor-bounces+eire1130=gmail@python.org
Date: Sun, 31 Jul 2011 20:22:30
To:
Reply-To: abdulhakim.hal...@leproghrammeen.com
Subject: [Tutor] How do I learn python for web development

Hi guys,

I am really interested in switching from PHP to python but there don't appear 
to be a book for such.

Can anyone advice me please.

Abdulhakim.
Sent from my BlackBerry wireless device from MTN

-Original Message-
From: tutor-requ...@python.org
Sender: tutor-bounces+abdulhakim.haliru=leproghrammeen@python.org
Date: Sun, 31 Jul 2011 07:01:56
To:
Reply-To: tutor@python.org
Subject: Tutor Digest, Vol 89, Issue 92

Send Tutor mailing list submissions to
tutor@python.org

To subscribe or unsubscribe via the World Wide Web, visit
http://mail.python.org/mailman/listinfo/tutor
or, via email, send a message with subject or body 'help' to
tutor-requ...@python.org

You can reach the person managing the list at
tutor-ow...@python.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Tutor digest..."


Today's Topics:

1. Re: How to make tkMessage function to have duration
   (Steven D'Aprano)
2. Re: How to make tkMessage function to have duration (Emeka)
3. newbie needs pypy setup tips (Tom Roche)
4. Re: newbie needs pypy setup tips (eire1...@gmail.com)
5. Re: Mainloop conflict (Christopher King)
6. Re: Mainloop conflict (Stefan Behnel)


--

Message: 1
Date: Sat, 30 Jul 2011 21:25:27 +1000
From: Steven D'Aprano
To: tutor@python.org
Subject: Re: [Tutor] How to make tkMessage function to have duration
Message-ID:<4e33ea27.50...@pearwood.info>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Emeka wrote:

Hello All,

Say I have the below(code),  I would want the message to last say 30
seconds and afterwards disappear. I won't want the user to be the one to
enable it to disappear.

Basically, what I want is to be able to show the user some message , and
after some seconds, the message goes away

I *hate* it when applications do that. Just as I'm trying to read the
message, take a screen shot, or whatever, the message disappears. I
think that's one of the worst things you can do in an application.

If the message isn't important enough to require it to stay visible
until the user explicitly closes it, then it shouldn't go into a dialog
in the first place.






--
Bob Gailer
919-636-4239
Chapel Hill NC

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


Re: [Tutor] How do I learn python for web development

2011-07-31 Thread Alan Gauld

abdulhakim haliru wrote:

Hi guys,

I am really interested in switching from PHP to python 

> but there don't appear to be a book for such.




I don;t know of any books expressly for converting from PHP to P{ython 
web development but there is a lot of documentation on Python web 
development, plus several different frameworks to choose from.


I've used TurboGears, and played with Django and Zope.

There are dead tree books on all three, the most popular
seems to be Django.

There are other, simpler frameworks too like Pylons and CherryPy.
Take a look at them, they all do pretty much the same things and
all are easier to use than traditional CGI, although Python
supports that too of course.

HTH,

Alan G.

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


Re: [Tutor] Mailing list documentation

2011-07-31 Thread Christopher King
Wow wow, way is a ser...@might.co.za person doing a tutor response. And why
can I see it if it isn't to me.. I'm sorry Sergey if this
isn't something malicious, it just seems suspicious.

On Sun, Jul 31, 2011 at 3:30 PM, Sergey  wrote:

> On Sun, 31 Jul 2011 14:22:41 -0400 Alexander Etter 
> wrote
>
> > Hello everyone, is there a page that contains documentation for this
> mailing
> > list? I've seen a few users top post and others advise against it; if
> there
> > isn't a page listing conventions let's create it and if there is what is
> it's
> > URL and how do you suggest users read it?
> > Alexander
> > ___
> > Tutor maillist  -  Tutor@python.org
> > To unsubscribe or change subscription options:
> > http://mail.python.org/mailman/listinfo/tutor
>
> ---
> tutor-requ...@python.org
> Fri, 29 Jul 2011 19:52:43 +0200(2 days, 1 hour ago)
>
> Welcome to the Tutor@python.org mailing list! This list is for folks
> who want to ask (and/or answer) questions from folks who wish to learn
> how to program with Python.  Feel free to ask even the most basic of
> questions -- that's what the list is for!
>
> For best results when asking a question on this list: - Try to write
> some code to solve your problem - Show the code you have written -
> Describe what the code does and what you want it to do - If the code
> generates an error, copy and paste the entire error message, including
> the traceback, into your email. - Tell us what OS and Python version
> you are using.
>
> - Don't ask us to do your homework. - Don't assume we know what you
> are talking about. If you are having trouble with a third-party
> library, include a link to the library home page.
>
> When replying to a posting: - Use Reply All to reply to the entire
> list - Don't top post - put your reply after the text to which you are
> replying
>
> For all posts: - Format your email as plain text, not HTML
>
>
> To post to this list, send your email to:
>
>  tutor@python.org
>
> General information about the mailing list is at:
>
>  http://mail.python.org/mailman/listinfo/tutor
>
> If you ever want to unsubscribe or change your options (eg, switch to
> or from digest mode, change your password, etc.), visit your
> subscription page at:
>
>  http://mail.python.org/mailman/options/tutor/***
>
> You can also make such adjustments via email by sending a message to:
>
>  tutor-requ...@python.org
>
> with the word `help' in the subject or body (don't include the
> quotes), and you will get back a message with instructions.
>
> You must know your password to change your options (including changing
> the password, itself) or to unsubscribe.  It is:
>
> ***
>
> Normally, Mailman will remind you of your python.org mailing list
> passwords once every month, although you can disable this if you
> prefer.  This reminder will also include instructions on how to
> unsubscribe or change your account options.  There is also a button on
> your options page that will email your current password to you.
>
>
> 
> South Africas premier free email service - www.webmail.co.za
>
> For super low premiums, click here http://www.dialdirect.co.za/?vdn=15828
>
>
> ___
> 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] Mailing list documentation

2011-07-31 Thread Brett Ritter
On Sun, Jul 31, 2011 at 8:42 PM, Christopher King  wrote:
> Wow wow, way is a ser...@might.co.za person doing a tutor response.

Assuming you mean _why_ (not _way_) , Sergey was simply quoting the
introductory email we all get when we join, as it answered the
original posters question.

There is nothing of concern here.
-- 
Brett Ritter / SwiftOne
swift...@swiftone.org
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Mailing list documentation

2011-07-31 Thread Dave Angel

On 07/31/2011 08:42 PM, Christopher King wrote:

Wow wow, way is a ser...@might.co.za person doing a tutor response. And why
can I see it if it isn't to me.. I'm sorry Sergey if this
isn't something malicious, it just seems suspicious.

(You could try reading it, instead of just getting suspicious.  one of 
the things it requests is "don't top-post".  Put your response after the 
part you're quoting.)


A simple google search finds a similar article dated from 2008, so I 
don't think it's a plot by Sergey.


http://mail.python.org/pipermail/tutor/2008-March/060723.html

As for why it comes to you, presumably that has something to do with you 
subscribing to the list.




--

DaveA

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


Re: [Tutor] How do I learn python for web development

2011-07-31 Thread Christian Witts

On 2011/07/31 10:22 PM, abdulhakim haliru wrote:

Hi guys,

I am really interested in switching from PHP to python but there don't appear 
to be a book for such.

Can anyone advice me please.

Abdulhakim.
Sent from my BlackBerry wireless device from MTN



You can try Python 3 Web Development Beginner's Guide
http://www.packtpub.com/python-3-web-development-beginners-guide/book

It's Python 3.x, CherryPy, jQuery, jQuery UI

--

Christian Witts
Python Developer

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