[Tutor] Tutor Digest, Vol 112, Issue 135

David Yomtobian david at yomtobian.com
Thu Jun 27 18:49:57 CEST 2013


Remove

Sent from my iPhone

On Jun 27, 2013, at 11:56 AM, tutor-request at python.org wrote:

> Send Tutor mailing list submissions to
>    tutor at 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-request at python.org
> 
> You can reach the person managing the list at
>    tutor-owner at 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: Need help appending data to a logfile (Matt D)
>   2. Re: Need help printing a pickled data (Matt D)
>   3. Re: Need help appending data to a logfile (Matt D)
>   4. Re: Windows Linux Popen (Matthew Ngaha)
>   5. Re: Windows Linux Popen (Matthew Ngaha)
>   6. Re: Windows Linux Popen (Peter Otten)
>   7. Re: Need help appending data to a logfile (Dave Angel)
> 
> 
> ----------------------------------------------------------------------
> 
> Message: 1
> Date: Thu, 27 Jun 2013 10:36:36 -0400
> From: Matt D <md123 at nycap.rr.com>
> To: Dave Angel <davea at davea.name>
> Cc: "tutor at python.org" <tutor at python.org>
> Subject: Re: [Tutor] Need help appending data to a logfile
> Message-ID: <51CC4DF4.3020205 at nycap.rr.com>
> Content-Type: text/plain; charset=UTF-8
> 
> 
>> 
>> You asked about a "save-as" feature.  Why isn't that as simple as
>> copying the current contents of the saved csv file?  Or do you not know
>> how you would go about copying?
> 
> Hi.  So I have the logger working, meaning the correct data is being
> written to the 'internal' file 'logfile.txt' which is opened like this:
> 
>   self.logfile = open('logfile.txt', 'a')
> 
> And I have the button that starts the file dialog like this:
> 
> #open file dialog -----------------------------
>    def openFile(self, evt):
>        with wx.FileDialog(self, "Choose a file", os.getcwd(), "",
>                            "*.*", wx.OPEN) as dlg:
>            if dlg.ShowModal() == wx.ID_OK:
>                path = dlg.GetPath()
>                mypath = os.path.basename(path)
>                                with open(mypath, "a") as f:
> 
> 
> Is there a simple way to copy what is in the 'internal' logfile.txt to
> the file that the user chooses from the button?
> Thanks!
> 
> 
> ------------------------------
> 
> Message: 2
> Date: Thu, 27 Jun 2013 10:52:19 -0400
> From: Matt D <md123 at nycap.rr.com>
> To: tutor at python.org
> Subject: Re: [Tutor] Need help printing a pickled data
> Message-ID: <51CC51A3.1050606 at nycap.rr.com>
> Content-Type: text/plain; charset=ISO-8859-1
> 
> im really sorry guys.  i must have had some copy and paste mistake.  I
> didnt want put all that stuff here.
> 
> 
> 
> ------------------------------
> 
> Message: 3
> Date: Thu, 27 Jun 2013 10:55:50 -0400
> From: Matt D <md123 at nycap.rr.com>
> To: tutor at python.org
> Subject: Re: [Tutor] Need help appending data to a logfile
> Message-ID: <51CC5276.2080807 at nycap.rr.com>
> Content-Type: text/plain; charset=ISO-8859-1
> 
> On 06/27/2013 10:36 AM, Matt D wrote:
>> 
>>> 
>>> You asked about a "save-as" feature.  Why isn't that as simple as
>>> copying the current contents of the saved csv file?  Or do you not know
>>> how you would go about copying?
>> 
>> Hi.  So I have the logger working, meaning the correct data is being
>> written to the 'internal' file 'logfile.txt' which is opened like this:
>> 
>>   self.logfile = open('logfile.txt', 'a')
>> 
>> And I have the button that starts the file dialog like this:
>> 
>> #open file dialog -----------------------------
>>    def openFile(self, evt):
>>        with wx.FileDialog(self, "Choose a file", os.getcwd(), "",
>>                            "*.*", wx.OPEN) as dlg:
>>            if dlg.ShowModal() == wx.ID_OK:
>>                path = dlg.GetPath()
>>                mypath = os.path.basename(path)
>>                                with open(mypath, "a") as f:
>> 
>> 
>> Is there a simple way to copy what is in the 'internal' logfile.txt to
>> the file that the user chooses from the button?
>> Thanks!
>> _______________________________________________
>> Tutor maillist  -  Tutor at python.org
>> To unsubscribe or change subscription options:
>> http://mail.python.org/mailman/listinfo/tutor
> I forgot to mention i have the 'with open(mypath, "a") as f: commented
> out because it was making an indentation error that i could not fix.
> 
> 
> 
> ------------------------------
> 
> Message: 4
> Date: Thu, 27 Jun 2013 16:32:10 +0100
> From: Matthew Ngaha <chigga101 at gmail.com>
> To: eryksun <eryksun at gmail.com>
> Cc: "tutor at python.org" <tutor at python.org>
> Subject: Re: [Tutor] Windows Linux Popen
> Message-ID:
>    <CACzNyA2DQoRc4YbaaLRjP-ATegy_QZut30cQEYzn7uhWV62_Uw at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
> 
> On Thu, Jun 27, 2013 at 1:41 PM, eryksun <eryksun at gmail.com> wrote:
> 
>> The error is telling you that Windows can't find "python3". The exe is
>> named python.exe on Windows, not python3.exe, and it will have to be
>> on your system PATH to be invoked like that. If you want to run the
>> script with the current interpreter, you can use sys.executable. For
>> example:
>> 
>>>>> subprocess.Popen(
>>    ...   [sys.executable, '-c', r'print("spam")']).wait()
>>    spam
>>    0
> 
> i really don't know what to say. no one on irc could resolve my issue
> and in 1 go you spot where i went wrong. The small change of making
> 'python3', 'python' has fixed the issue. Thanks you very much:)
> 
> 
> ------------------------------
> 
> Message: 5
> Date: Thu, 27 Jun 2013 16:39:00 +0100
> From: Matthew Ngaha <chigga101 at gmail.com>
> To: Peter Otten <__peter__ at web.de>
> Cc: "tutor at python.org" <tutor at python.org>
> Subject: Re: [Tutor] Windows Linux Popen
> Message-ID:
>    <CACzNyA0r__1F7afdOP19c1MsaSHWXBwRwoT0t3BWg9JiJqiSsw at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
> 
> On Thu, Jun 27, 2013 at 1:37 PM, Peter Otten <__peter__ at web.de> wrote:
> 
>> Your working directory may differ from the directory containing
>> echo_server.py. Try specifying the full path, e. g.
>> 
>> SCRIPT = 'c:\\path\to\\echo_server.py' # replace with your actual path
>> p = subprocess.Popen(
>>    ['python3', SCRIPT])
> oh for some reason i didnt see this message. Thanks i will try this out also
> 
> 
> ------------------------------
> 
> Message: 6
> Date: Thu, 27 Jun 2013 17:55:42 +0200
> From: Peter Otten <__peter__ at web.de>
> To: tutor at python.org
> Subject: Re: [Tutor] Windows Linux Popen
> Message-ID: <kqhn9h$l6t$1 at ger.gmane.org>
> Content-Type: text/plain; charset="ISO-8859-1"
> 
> Matthew Ngaha wrote:
> 
>> On Thu, Jun 27, 2013 at 1:37 PM, Peter Otten <__peter__ at web.de> wrote:
>> 
>>> Your working directory may differ from the directory containing
>>> echo_server.py. Try specifying the full path, e. g.
>>> 
>>> SCRIPT = 'c:\\path\to\\echo_server.py' # replace with your actual path
>>> p = subprocess.Popen(
>>>    ['python3', SCRIPT])
>> oh for some reason i didnt see this message. Thanks i will try this out
>> also
> 
> I'm sorry, I was wrong. I figured "echo_server.py" wasn't found when it was 
> actually "python3".
> 
> 
> 
> ------------------------------
> 
> Message: 7
> Date: Thu, 27 Jun 2013 11:55:46 -0400
> From: Dave Angel <davea at davea.name>
> To: tutor at python.org
> Subject: Re: [Tutor] Need help appending data to a logfile
> Message-ID: <51CC6082.4060102 at davea.name>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
> 
> On 06/27/2013 10:55 AM, Matt D wrote:
>> On 06/27/2013 10:36 AM, Matt D wrote:
>>> 
>>>> 
>>>> You asked about a "save-as" feature.  Why isn't that as simple as
>>>> copying the current contents of the saved csv file?  Or do you not know
>>>> how you would go about copying?
>>> 
>>> Hi.  So I have the logger working, meaning the correct data is being
>>> written to the 'internal' file 'logfile.txt' which is opened like this:
>>> 
>>>    self.logfile = open('logfile.txt', 'a')
>>> 
>>> And I have the button that starts the file dialog like this:
>>> 
>>>  #open file dialog -----------------------------
>>>    def openFile(self, evt):
>>>        with wx.FileDialog(self, "Choose a file", os.getcwd(), "",
>>>                            "*.*", wx.OPEN) as dlg:
>>>            if dlg.ShowModal() == wx.ID_OK:
>>>                path = dlg.GetPath()
>>>                mypath = os.path.basename(path)
>>>                                 with open(mypath, "a") as f:
>>> 
>>> 
>>> Is there a simple way to copy what is in the 'internal' logfile.txt to
>>> the file that the user chooses from the button?
>>> Thanks!
> 
> shutil.copy(src, dst)
> 
> See:  http://docs.python.org/2/library/shutil.html#shutil.copy
> 
>   <SNIP>
>> I forgot to mention i have the 'with open(mypath, "a") as f: commented
>> out because it was making an indentation error that i could not fix.
> 
> It was indented, and should not have been.  The extra indentation 
> FOLLOWS the with statement, it's not correct to indent the line itself.
> 
> Line it up with mypath=
> 
> Isn't the rule for indentation simple enough?  If a line ends with a 
> colon, you indent the next line.  And keep indenting till the scope of 
> that colon ends.  I don't know of any exceptions, but if there are any, 
> they're rare.  Anyway, when the compiler complains, there aren't many 
> choices on how to change the line, so experimentation should teach you 
> pretty quickly.
> 
> Maybe you're getting confused about indentation because your editor 
> doesn't handle tabs correctly.  If you mix tabs and spaces, you'll drive 
> yourself crazy, at least with 2.x   Python 3 tells you about it with a 
> new error.  The easy answer (and my strong preference) is to never use 
> tabs in Python sources.  Expand all your existing tabs (to 4 column 
> intervals), and tell your editor to always expand the tab key when entering.
> 
> I suggest you fix this problem first, and understand the fix, before 
> going off and using shutil.copy().
> 
> 
> -- 
> DaveA
> 
> 
> ------------------------------
> 
> Subject: Digest Footer
> 
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
> 
> 
> ------------------------------
> 
> End of Tutor Digest, Vol 112, Issue 135
> ***************************************


More information about the Tutor mailing list