[Tutor] Automatic updates for a program?
So I have a program I want to release, but it's still in early stages without some of its planned functionality. I want to distribute automatic updates. I'm working under the assumption that the easiest way to do this is to just replace the old files with the new ones. My questions is this: How do I replace a script that is running, with a new version? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Tkinter progress bar not responding when moved
I am trying to use a progress bar for my application and used the following code by Michael Lange ( http://tkinter.unpythonic.net/wiki/ProgressMeter?action=PackagePages). However, the progress bar stops responding when I move it. I haven't modified class declaration and _demo but created my own modified function []: class Meter(Tkinter.Frame): def __init__(self, master, width=300, height=20, bg='white', fillcolor='orchid1',\ value=0.0, text=None, font=None, textcolor='black', *args, **kw): Tkinter.Frame.__init__(self, master, bg=bg, width=width, height=height, *args, **kw) self._value = value self._canv = Tkinter.Canvas(self, bg=self['bg'], width=self['width'], height=self['height'],\ highlightthickness=0, relief='flat', bd=0) self._canv.pack(fill='both', expand=1) self._rect = self._canv.create_rectangle(0, 0, 0, self._canv.winfo_reqheight(), fill=fillcolor,\ width=0) self._text = self._canv.create_text(self._canv.winfo_reqwidth()/2, self._canv.winfo_reqheight()/2,\ text='', fill=textcolor) if font: self._canv.itemconfigure(self._text, font=font) self.set(value, text) self.bind('', self._update_coords) def _update_coords(self, event): '''Updates the position of the text and rectangle inside the canvas when the size of the widget gets changed.''' # looks like we have to call update_idletasks() twice to make sure # to get the results we expect self._canv.update_idletasks() self._canv.coords(self._text, self._canv.winfo_width()/2, self._canv.winfo_height()/2) self._canv.coords(self._rect, 0, 0, self._canv.winfo_width()*self._value, self._canv.winfo_height()) self._canv.update_idletasks() def get(self): return self._value, self._canv.itemcget(self._text, 'text') def set(self, value=0.0, text=None): #make the value failsafe: if value < 0.0: value = 0.0 elif value > 1.0: value = 1.0 self._value = value if text == None: #if no text is specified use the default percentage string: text = str(int(round(100 * value))) + ' %' self._canv.coords(self._rect, 0, 0, self._canv.winfo_width()*value, self._canv.winfo_height()) self._canv.itemconfigure(self._text, text=text) self._canv.update_idletasks() def _demo(meter, value): meter.set(value) if value < 1.0: value = value + 0.005 meter.after(50, lambda: _demo(meter, value)) else: meter.set(value, 'TM completed - Please close this window') # this is where progress bar is loaded and where I have added my own stuff def test(): if __name__ == '__main__': root2 = Tkinter.Tk(className=' Text Mining Progress') m = Meter(root2, relief='ridge', bd=3) m.pack(fill='x') i=0.0 for fileid in reader.fileids(): m.set(i, 'Processing will take a few minutes...') i=i+1.000/len(reader.fileids()) # here I increment the colored bar in each iteration m.after(1000, lambda: _demo(m, i)) print str(fileid)[:-4],document_features(reader.raw(fileid))# I call some other processes here root2.withdraw() Thanks Tax ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] What is the trick ???!
On 05/12/11 21:24, Karim wrote: Hello See below, I was surprised about finding hidden function in module sys: karim@Requiem4Dream: python2.7 Python 2.7.1rc1 (r271rc1:86455, Nov 16 2010, 21:53:40) [GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> sys.getdefaultencoding() 'ascii' >>> sys.setdefaultencoding() Traceback (most recent call last): File "", line 1, in AttributeError: 'module' object has no attribute 'setdefaultencoding' >>> karim@Requiem4Dream:~/build/OpenProcessManager/test$ python2.7 Python 2.7.1rc1 (r271rc1:86455, Nov 16 2010, 21:53:40) [GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> sys.getdefaultencoding() 'ascii' >>> sys.setdefaultencoding('utf-8') Traceback (most recent call last): File "", line 1, in AttributeError: 'module' object has no attribute 'setdefaultencoding' >>> reload(sys) >>> sys.setdefaultencoding('utf-8') >>> sys.getdefaultencoding() 'utf-8' >>> :-\ ??? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor Ok I found the trick at http://docs.python.org/library/sys.html#sys.setdefaultencoding. The function is removed dynamically at startup when reload I get the nominal one (the original). Sorry for the disturb. Cheers Karim ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] What is the trick ???!
Hello See below, I was surprised about finding hidden function in module sys: karim@Requiem4Dream: python2.7 Python 2.7.1rc1 (r271rc1:86455, Nov 16 2010, 21:53:40) [GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> sys.getdefaultencoding() 'ascii' >>> sys.setdefaultencoding() Traceback (most recent call last): File "", line 1, in AttributeError: 'module' object has no attribute 'setdefaultencoding' >>> karim@Requiem4Dream:~/build/OpenProcessManager/test$ python2.7 Python 2.7.1rc1 (r271rc1:86455, Nov 16 2010, 21:53:40) [GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> sys.getdefaultencoding() 'ascii' >>> sys.setdefaultencoding('utf-8') Traceback (most recent call last): File "", line 1, in AttributeError: 'module' object has no attribute 'setdefaultencoding' >>> reload(sys) >>> sys.setdefaultencoding('utf-8') >>> sys.getdefaultencoding() 'utf-8' >>> :-\ ??? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] cpython
"tee chwee liong" wrote thanks for your advice. let me check it out. If you mean cython I wouldn't bother. Since you are "just starting" in Python reading about cython is more likely to confuse you than help. Cython is great once you really know python (and at least a little C) but I doubt if it will help you get to grips with the basics. -- Alan Gauld 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] ImportError: Module use of python25.dll conflicts with this version of Python.
"Susana Iraiis Delgado Rodriguez" wrote from _mapnik import * ImportError: Module use of python25.dll conflicts with this version of Python. I'm using Python 2.6 You will need to find a Python 2.6 version of the DLL or revert your Python version to 2.5. This is always a risk when using third party modules. Ther may not be an updated version to match your Python. If there isn't a 2.6 version you might try asking the maintainer to create a new version, it may well just involve a rebuild for them. But if the maintainer has lost interst, ior its a more complex issue you might be out of luck and have to revert to 2.5. HTH, -- Alan Gauld 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] Just Joined!
"Alex Smith" wrote SwapcaseAndCenter('hello', 10) I don't understand how from your example you get an output ...I get the below error: NameError: name 'SwapcaseAndCenter' is not defined Wayne was showing how it should work. As Python says the function is not defined yet. Defining the function so that is does do what Wayne showed is your homework! :-) -- Alan Gauld 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] create an xls file using data from a txt file
Maybe we're splitting hairs over semantics then. I thought there was confusion about what the CLI shell was doing with file separators as opposed to just handing the arguments as-is to the applications (which is true... the CLI doesn't really process them much, it's up to the application. Where in the application, though, this is dealt with is not where I think we disagree. In my original response, I clarified that, although as a short parenthetical note: On 12-May-11 02:25, Peter Otten wrote: Steve Willoughby wrote: Actually, yes, that's exactly what Python (or actually the underlying file handling libraries it's built with) is doing on Windows. There is the "underlying file handling libraries" would be the API calls. But that's not the CLI shell's doing. Although maybe that's what you meant all along. There are enough difference between the way the Windows CLI shell and Unix-derived command shells function in the handling of files and option handling that there's often confusion there which I thought was what was happening here too, that the OP was saying the CLI was somehow doing the translation. -- Steve Willoughby / st...@alchemy.com "A ship in harbor is safe, but that is not what ships are built for." PGP Fingerprint 4615 3CCE 0F29 AE6C 8FF4 CA01 73FE 997A 765D 696C ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] ImportError: Module use of python25.dll conflicts with this version of Python.
Hello list! I just started working with a dll fro geospatial data, it uses Python to analyze data, this package is OSGeo4W; when I run the script and got the next error: >>> import mapnik Traceback (most recent call last): File "", line 1, in File "C:\OSGeo4W\apps\Python25\lib\site-packages\mapnik\__init__.py", line 42, in from _mapnik import * ImportError: Module use of python25.dll conflicts with this version of Python. I'm using Python 2.6 ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] cpython
CPython refers to the main implementation, which is written in C. There are a bunch of different implementations, such as IronPython for .NET or Jython for the Java Virtual Machine. There's also Cython (subtle spelling difference), which you can use to combine C and Python code. It isn't quite an implementation in the same sense, but it's close. Most folk use CPython, and it's what we discuss on this list, unless otherwise specified. http://www.python.org/getit/ http://cython.org/ Cheers On Thursday 12 May 2011, tee chwee liong wrote: > hi all, > > i just started python but i'm hearing there is cpython. what is it > different from python? is there any tutorials i can refer. > > thanks > tcl ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] create an xls file using data from a txt file
>Respectfully, I think you aren't clear on how command line execution >works. Hopefully I can help a little (yes, there are enough cases where >it'll bite you that it's good to know this). True >If Windows natively supported it, then you could do this: >C:\> DIR /users/fred/desktop >C:\> DEL /temp/myfile >Or try running your Python program like >C:\> /python27/python.exe scriptname.py >That doesn't work either, because Windows is NOT in any way at all >interpreting the / characters. > C:\> /python27/python.exe scriptname.py Oh, really? Works for me. C:\>/Python31/python.exe /temp/test.py File "/temp/test.py", line 1 print 'Hello World' ^ SyntaxError: invalid syntax True that does not work for dir and del because both use '/' as the argument passing prefix, but that does not mean that Windows cannot handle it. Ramit Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology 712 Main Street | Houston, TX 77002 work phone: 713 - 216 - 5423 -Original Message- From: Steve Willoughby [mailto:st...@alchemy.com] Sent: Wednesday, May 11, 2011 6:24 PM To: Prasad, Ramit; tutor@python.org Subject: Re: [Tutor] create an xls file using data from a txt file On 11-May-11 15:54, Prasad, Ramit wrote: >> Core windows commands don't generally accept it, including native >> Windows applications (although sometimes they're lenient in what they >> accept). It'll work for command-line Python script usage because it's >> *python* that allows them, not *windows*. > > They work in *Windows* command prompt natively. > Some apps do not work well that is true, but the reason that theywork like > this with Python is NOT because Python allows it but because Windows does. I highly doubt Python checks for "/" and converts it to "\\" (or does any complicated checking of file strings). YMMV for apps, but I have never had a problem with '/' on the command prompt. It is an important caveat to note that this behavior is not Guaranteed. Actually, yes, that's exactly what Python (or actually the underlying file handling libraries it's built with) is doing on Windows. There is a decades-long tradition of C compilers (et al) doing this conversion for the sake of all the ported Unix C programs that people wanted to run on Windows (or, at the time, MSDOS). If Windows natively supported it, then you could do this: C:\> DIR /users/fred/desktop C:\> DEL /temp/myfile Or try running your Python program like C:\> /python27/python.exe scriptname.py That doesn't work either, because Windows is NOT in any way at all interpreting the / characters. So why does this work: C:\> myscript.py /temp/myfile /users/fred/desktop or even C:\> \python27\python.exe myscript.py /temp/myfile That works because Windows hands ALL of the argument strings, as-is, with NO interpretation, to the application to deal with. In this case, the application is Python, and Python is going to the extra work to interpret the / characters as \ characters when you try to use them in open() calls and the like. -- Steve Willoughby / st...@alchemy.com "A ship in harbor is safe, but that is not what ships are built for." PGP Fingerprint 4615 3CCE 0F29 AE6C 8FF4 CA01 73FE 997A 765D 696C This communication is for informational purposes only. It is not intended as an offer or solicitation for the purchase or sale of any financial instrument or as an official confirmation of any transaction. All market prices, data and other information are not warranted as to completeness or accuracy and are subject to change without notice. Any comments or statements made herein do not necessarily reflect those of JPMorgan Chase & Co., its subsidiaries and affiliates. This transmission may contain information that is privileged, confidential, legally privileged, and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. Although this transmission and any attachments are believed to be free of any virus or other defect that might affect any computer system into which it is received and opened, it is the responsibility of the recipient to ensure that it is virus free and no responsibility is accepted by JPMorgan Chase & Co., its subsidiaries and affiliates, as applicable, for any loss or damage arising in any way from its use. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you. Please refer to http://www.jpmorgan.com/pages/disclosures for disclosures relating to European legal entities. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] cpython
thanks for your advice. let me check it out. Date: Thu, 12 May 2011 15:18:40 +0200 Subject: Re: [Tutor] cpython From: izzaddin.ruhules...@gmail.com To: tc...@hotmail.com CC: tutor@python.org Hi, CPython is the C implementation of Python. You can read the tutorial in the Python docs. It is a rather advanced topic, however. If you nevertheless want to delve into it, it might be a good idea to check out www.cython.org first. 2011/5/12 tee chwee liong hi all, i just started python but i'm hearing there is cpython. what is it different from python? is there any tutorials i can refer. thanks tcl ___ 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] cpython
Hi, CPython is the C implementation of Python. You can read the tutorial in the Python docs. It is a rather advanced topic, however. If you nevertheless want to delve into it, it might be a good idea to check out www.cython.org first. 2011/5/12 tee chwee liong > hi all, > > i just started python but i'm hearing there is cpython. what is it > different from python? is there any tutorials i can refer. > > thanks > tcl > > ___ > 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] cpython
On 12/05/2011 14:10, tee chwee liong wrote: hi all, i just started python but i'm hearing there is cpython. what is it different from python? is there any tutorials i can refer. CPython is just the most common version of Python, so-called because it's written in C: the one you download from python.org. It's normally only called "Cpython" to distinguish it if needed from other implementations, such as Jython (Java-based), IronPython (.NET-based), PyPy (Python-based) and others. TJG ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] cpython
hi all, i just started python but i'm hearing there is cpython. what is it different from python? is there any tutorials i can refer. thanks tcl ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Just Joined!
Thank you both for the quick replies! So I understand now dir is just used to assist in finding relevant strings. wapcaseAndCenter('hello', 10) I don't understand how from your example you get an output from : SwapcaseAndCenter('hello', 10) I get the below error: Traceback (most recent call last): File "", line 1, in SwapcaseAndCenter('hello', 10) NameError: name 'SwapcaseAndCenter' is not defined So i started thinking the string used is "swapcase" and "center" although I still get an error with that input: >>> swapcase.center('hello',10) Traceback (most recent call last): File "", line 1, in swapcase.center('hello',10) TypeError: an integer is required From: Wayne Werner To: Alex Smith Cc: "tutor@python.org" Sent: Thursday, 12 May 2011, 5:05 Subject: Re: [Tutor] Just Joined! On Thu, May 12, 2011 at 6:34 AM, Alex Smith wrote: Hi All, I just joined this list and am really new to python. Hi! Welcome to the Python tutor list, and Python! I have an assignment to create a function with (a_string, width) which returns the a_string with all the lower case characters changed to upper case characters and vice versa and centered; was wondering if someone could point me in the right direction. I am not just asking for the answer but just need a few tips to get started. That's good, because that's our policy here ;) So far I do know I should use the dir(str) I think you might be a little confused as to what dir actually does, or maybe what your assignment is really asking! and do not quite understand what the "width" option is used for Since you said the text is supposed to be centered, I suspect it means the final width of the string... >>> help(dir) > Return an alphabetized list of names comprising (some of) the attributes > of the given object, and of attributes reachable from it: So dir gives you the attributes of an object. In this case since you're playing with a string you want to take a look at string objects. What happens when you run dir(str)? What happens when you run dir('this is a string')? > >def SwapcaseAndCenter(dir,??) The best way to understand what an assignment is asking is usually to have an example - and if you don't have an example, make one up! So I suspect your teacher might want something like this: (I'm replacing spaces with 'x' so you can see them. It's a good thing to do while you're testing) >>> SwapcaseAndCenter('a', 3) 'xAx' >>> SwapcaseAndCenter('hello', 10) 'xxHELLOxxx' >>> SwapcaseAndCenter('WeIrD', 12) 'xxxwEiRd' I suspect if you look carefully at the output of the `dir` commands that I mentioned above, you will find some help. HTH, Wayne___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Just Joined!
On Thu, May 12, 2011 at 6:34 AM, Alex Smith wrote: > Hi All, > > I just joined this list and am really new to python. > Hi! Welcome to the Python tutor list, and Python! > I have an assignment to create a function with (a_string, width) which > returns the a_string with all the lower case characters changed to upper > case characters and vice versa and centered; was wondering if someone could > point me in the right direction. I am not just asking for the answer but > just need a few tips to get started. > That's good, because that's our policy here ;) > So far I do know I should use the dir(str) > I think you might be a little confused as to what dir actually does, or maybe what your assignment is really asking! > and do not quite understand what the "width" option is used for > Since you said the text is supposed to be centered, I suspect it means the final width of the string... > >>> help(dir) > > Return an alphabetized list of names comprising (some of) the attributes > of the given object, and of attributes reachable from it: > So dir gives you the attributes of an object. In this case since you're playing with a string you want to take a look at string objects. What happens when you run dir(str)? What happens when you run dir('this is a string')? > > def SwapcaseAndCenter(dir,??) > The best way to understand what an assignment is asking is usually to have an example - and if you don't have an example, make one up! So I suspect your teacher might want something like this: (I'm replacing spaces with 'x' so you can see them. It's a good thing to do while you're testing) >>> SwapcaseAndCenter('a', 3) 'xAx' >>> SwapcaseAndCenter('hello', 10) 'xxHELLOxxx' >>> SwapcaseAndCenter('WeIrD', 12) 'xxxwEiRd' I suspect if you look carefully at the output of the `dir` commands that I mentioned above, you will find some help. HTH, Wayne ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Just Joined!
On 12 May 2011 12:34, Alex Smith wrote: > Hi All, > > I just joined this list and am really new to python. I have an assignment > to create a function with (a_string, width) which returns the a_string with > all the lower case characters changed to upper case characters and vice > versa and centered; was wondering if someone could point me in the right > direction. I am not just asking for the answer but just need a few tips to > get started. So far I do know I should use the dir(str) > and do not quite understand what the "width" option is used for > > I think you're missing the point about the suggestion to use dir() -- as per the help you yourself retrieved, dir returns "an alphabetized list of names comprising (some of) the attributes of the given object, and of attributes reachable from it..." The suggestion to do dir(str) was intended as a way to learn about how string objects work in Python, not that it should be used directly in the source code of your solution. For example, "dir(str)" lists an interesting attribute (in this case a method) called "swapcase"... now investigating this by doing "help(str.swapcase)" you get: >>> help(str.swapcase) Help on method_descriptor: swapcase(...) S.swapcase() -> string Return a copy of the string S with uppercase characters converted to lowercase and vice versa. Sounds relevant to your goals. ;) As for the "width" question, think about the requirement to "center" the string. Centered with reference to what? How are you going to center something if you don't know how wide the thing you're centering on, is? Walter ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Just Joined!
Hi All, I just joined this list and am really new to python. I have an assignment to create a function with (a_string, width) which returns the a_string with all the lower case characters changed to upper case characters and vice versa and centered; was wondering if someone could point me in the right direction. I am not just asking for the answer but just need a few tips to get started. So far I do know I should use the dir(str) and do not quite understand what the "width" option is used for >>> help(dir) Help on built-in function dir in module __builtin__: dir(...) dir([object]) -> list of strings Return an alphabetized list of names comprising (some of) the attributes of the given object, and of attributes reachable from it: No argument: the names in the current scope. Module object: the module attributes. Type or class object: its attributes, and recursively the attributes of its bases. Otherwise: its attributes, its class's attributes, and recursively the attributes of its class's base classes. def SwapcaseAndCenter(dir,??) Thanks for any advice! ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] create an xls file using data from a txt file
To confirm: Python does *nothing* to convert automatically from one form of path separator to another. Windows from very early on, has accepted /-slashes as path separators to API calls. Where they don't work is: at the command shell itself presumably since slashes are commonly used to introduce options; and, sometimes, the Windows Shell API although I can't lay my hands on an example at the moment. If you were to write something in C to call CreateFile and pass a path such as "c:/temp/temp.txt" it would work without a problem because the Windows API accepts those kinds of paths. TJG ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] create an xls file using data from a txt file
Steve Willoughby wrote: > On 11-May-11 15:54, Prasad, Ramit wrote: >>> Core windows commands don't generally accept it, including native >>> Windows applications (although sometimes they're lenient in what they >>> accept). It'll work for command-line Python script usage because it's >>> *python* that allows them, not *windows*. >> >> They work in *Windows* command prompt natively. > > Respectfully, I think you aren't clear on how command line execution > works. Hopefully I can help a little (yes, there are enough cases where > it'll bite you that it's good to know this). > >> Some apps do not work well that is true, but the reason that theywork >> like this with Python is NOT because Python allows it but because > Windows does. I highly doubt Python checks for "/" and converts it to > "\\" (or does any complicated checking of file strings). YMMV for apps, > but I have never had a problem with '/' on the command prompt. It is an > important caveat to note that this behavior is not Guaranteed. > > Actually, yes, that's exactly what Python (or actually the underlying > file handling libraries it's built with) is doing on Windows. There is > a decades-long tradition of C compilers (et al) doing this conversion > for the sake of all the ported Unix C programs that people wanted to run > on Windows (or, at the time, MSDOS). > > If Windows natively supported it, then you could do this: > > C:\> DIR /users/fred/desktop > C:\> DEL /temp/myfile > > Or try running your Python program like > > C:\> /python27/python.exe scriptname.py > > That doesn't work either, because Windows is NOT in any way at all > interpreting the / characters. > > So why does this work: > > C:\> myscript.py /temp/myfile /users/fred/desktop > > or even > > C:\> \python27\python.exe myscript.py /temp/myfile > > That works because Windows hands ALL of the argument strings, as-is, > with NO interpretation, to the application to deal with. In this case, > the application is Python, and Python is going to the extra work to > interpret the / characters as \ characters when you try to use them in > open() calls and the like. > The following suggests otherwise: """ Note File I/O functions in the Windows API convert "/" to "\" as part of converting the name to an NT-style name, except when using the "\\?\" prefix as detailed in the following sections. """ (Found at http://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx ) ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor