On Thu, Jul 30, 2015 at 11:41:56PM +, ltc.hots...@gmail.com wrote:
> Hi Everyone:
>
>
> Why is open not defined in the following code:NameError: name 'open' is not
> defined
Are you still running your code on the PythonTutor website?
http://pythontutor.com/visualize.html
says in the fine-
>
> So main.py contains:
>
> def get_field(value, start_bit, end_bit):
>
>
> and I see:
>
> >>> import main
> >>> help(get_field)
> Traceback (most recent call last):
>File "", line 1, in
> NameError: name 'get_field' is not defined
>
>
> help(main) works ok but is rather verbose.
Try:
On 7/30/2015 4:41 PM, ltc.hots...@gmail.com wrote:
Hi Everyone:
Why is open not defined in the following code:NameError: name 'open' is not
defined
Because of something you did previously.
We don't have enough information to answer. open exists as a built-in
function in python:
Python 2
On 30/07/2015 23:34, ltc.hots...@gmail.com wrote:
sure
Sent from Surface
From: Mark Lawrence
Sent: Thursday, July 30, 2015 3:25 PM
To: Tutor@python.org
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscri
Hi Everyone:
Why is open not defined in the following code:NameError: name 'open' is not
defined
Code reads as follows:
fname = raw_input("Enter file name: ")
if len(fname) < 1 : fname = "mbox-short.txt"
fh = open(fname)
count = 0
for line in fh:
if not line.startswith('From'): continue
On 30/07/15 23:51, ltc.hots...@gmail.com wrote:
fname = raw_input("Enter file name: ")
if len(fname) < 1 : fname = "mbox-short.txt" # assign fname
fh=open(fname,'r') # Open a new file handle
for line in fh:
print line
if 'From' in line.split()[0] and '@' in line: sender = line.split()[
On 30/07/15 22:17, ltc.hots...@gmail.com wrote:
fname = raw_input("Enter file name: ")
if len(fname) < 1 : fname = "mbox-short.txt" # assign fname
fh=open(fname,'r') # Open a new file handle
for line in fh:
print line
if 'From' in line.split()[0] and '@' in line: sender = line.split()[
Hi Mark,
I’m still confused because line 4 reads: fh=open(fname,'r') # Open a new
file handle, not fn = open(fname)
Therefore, can you write down line by line from error to correction?
Here is the revised code:
fname = raw_input("Enter file name: ")
if len(fname) < 1 : fname = "mbox-shor
sure
Sent from Surface
From: Mark Lawrence
Sent: Thursday, July 30, 2015 3:25 PM
To: Tutor@python.org
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listi
Hi everyone,
Revised code:
fname = raw_input("Enter file name: ")
if len(fname) < 1 : fname = "mbox-short.txt" # assign fname
fh=open(fname,'r') # Open a new file handle
for line in fh:
print line
if 'From' in line.split()[0] and '@' in line: sender = line.split()[1]
fn.seek
On 30/07/2015 20:07, ltc.hots...@gmail.com wrote:
When you post here can you please find a mechanism that gives us more
text than whitespace, thank you.
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
Sent from Surface
From: ltc.hots...@gmail.com
Sent: Thursday, July 30, 2015 11:47 AM
To: Steven D'Aprano
Hi Steve:
New revision code:
count = 0
fn = raw_input("Enter file name: ")
if len(fn) < 1 : fname = "mbox-short.txt"
for line in fn:
if 'From' in line.spl
If I have a script called main.py and document a function in it:
def get_value(x):
"""
Some text ...
:param x: Some value
:returns: Something useful
"""
What is the most basic way of showing those docstrings at the
On Thu, Jul 30, 2015 at 04:28:33PM +, David Aldrich wrote:
> So main.py contains:
>
> def get_field(value, start_bit, end_bit):
>
>
> and I see:
>
> >>> import main
> >>> help(get_field)
> Traceback (most recent call last):
>File "", line 1, in
> NameError: name 'get_field' is n
On Thu, Jul 30, 2015 at 08:24:27AM +, David Aldrich wrote:
> I understand that 'help' works with modules that I have imported. But
> if I've just written a script called main.py (which contains
> get_value()) I don't think I can 'import' that. So how would I see the
> docstrings in main.py?
On Thu, Jul 30, 2015 at 4:24 AM, David Aldrich
wrote:
>>> If I have a script called main.py and document a function in it:
>>>
>>> def get_value(x):
>>> """
>>> Some text ...
>>> :param x: Some value
>>> :returns: Something useful
>>> """
>>>
>>> What is the most basic
>> If I have a script called main.py and document a function in it:
>>
>> def get_value(x):
>> """
>> Some text ...
>> :param x: Some value
>> :returns: Something useful
>> """
>>
>> What is the most basic way of showing those docstrings at the Python
>> prompt?
>
> Tr
Writing to share an update on my previous request.
So, after reviewing my code over, it seems like my last print statement
"print(ResolvedAddresses)" was not properly indented inside the for loop - and
for that reason the output was coming our as empty.
After I aligned that with the rest of the l
Thank you all,\.
Programming is the hardest thing i have ever tried to learn.
So thank you for your help.
Job
On Tue, Jul 28, 2015 at 8:29 PM, Job Hernandez wrote:
> How is it going tutors?
>
> The following problem seems impossible to me:
>
> "*Write a program that asks the user to enter an
On 29/07/15 22:55, ltc.hots...@gmail.com wrote:
#top of code, initialize variable
output_list = ["default"]
#rest of code
print output_list
['default']
Raw Data File:
Note, this is the code not the data...
count = 0
fname = raw_input("Enter file name: ")
if len(fname) < 1 : fname = "mbox-s
20 matches
Mail list logo