Re: How an editor can help with block nesting (was Re: How coding in Python is bad for you)

2017-01-25 Thread Ben Iannitelli
On Wed, Jan 25, 2017 at 6:31 AM, Ben Bacarisse 
 wrote:

In Python the editor could, for example, highlight the block you are
typing in, so as soon as you leave the body of the 'if' it would stop
being marked and the containing code would be highlighted.  Just moving
the cursor up and down would show you what block everything is in.  I
don't know if any editors help like this -- that's part of my reason to
ask.
@Ben B.: Have you had a look at Notepad++? When it detects that you're editing 
a Python file, a ruler on the left-hand margin of the editing window employs a 
system of boxes and lines to show which blocks of code belong to which 
conditional clause, with those pertaining to the current block in red.

Below are attempts to sketch it out without the benefit of screenshots or color.
First attempt:
[box with a dash inside of it ]if __name__ == "__main__":
[U+2514]main()

Second attempt (imagine that your cursor is somewhere in the same line as the 
"print" statement) :
[box with a dash inside of it, in gray ]def main():
[box with a dash inside of it, in gray ]with 
open("some_spreadsheet.csv",newline='') as sheet:
[U+2502, in gray]data = csv.DictReader(sheet)
[box with a dash inside of it, in RED ]for n,row in enumerate(data):
[U+2514, in RED]print(n,row)

I didn't do it justice, but that's honestly the best I can do. If you can find 
the time to install it and then play with it, you can actually see for yourself 
whether that feature is loyal to the idea you described.


HTH


-Ben I.
-- 
https://mail.python.org/mailman/listinfo/python-list


RE: My code won't work if I double click the saved file

2015-08-01 Thread Ben Iannitelli
> > On 29Jul2015 00:20, john  wrote:
> >> I have windows 8 running on my computer and I think I downloaded
> >> python 2 and 3 simultaneously or I think my computer has built in
> >> python 2 and I downloaded python 3.

John,

Sorry to back-track this conversation, but would you mind telling us some more 
about how you installed Python on your computer in the first place? 

For example, I run Windows 8.1 on my computer, and at the time that I installed 
Python I used the installer provided on the official Python site. When the 
wizard was done, I had a file called 'Python33' at the top level of C: (I 
haven't gotten around to Python 3.4 yet), so I know that I installed version 
3.3 at root level.

Everyone else: sorry if I messed up with this post somehow, it's my first time 
writing back to anyone on the newsletter.

-Ben I.
  -- 
https://mail.python.org/mailman/listinfo/python-list


Re: i got error while writing data to file

2017-03-13 Thread Ben Iannitelli
Hi Madhu,

I don't know much about web scraping but I can explain why your output is so 
much smaller than your input: you keep writing over your output file. The way I 
see it you have two options:

1. Where you wrote "mode='wt'", change "wt" to "at". The replacement "at" 
appends your output text, as opposed to "wt", which writes over your output 
text as if the file hadn't already existed.

2. Leave the file modes alone,  but move the "with" statement further up the 
"for" block. If you use this option, your code should look more like below (if 
email didn't garble the formatting):

with open('E:/amadown2py-master/reviews1.csv', 'r',encoding='UTF8') as csvfile:
mycsv = csv.reader(csvfile)
for row in mycsv:
data = row[0]
#print (data)
with open('E:/amadown2py-master/Sam7_pos_rev.txt',mode='wt') as 
myfile:#Moved this!
try:
score = ast.literal_eval(row[1])
if score > 3:
cnt=0;
#print (score)
print (data)
positivedata.append((data))
myfile.writelines('\n'.join(positivedata))
#myfile.close()#You shouldn't need this, bc you're using 
"with"

Of the two options, I would think that option 1 is easier.

HTH,

Ben I.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: i got error while writing data to file

2017-03-13 Thread Ben Iannitelli
Hello again,

It seems I was a little too quick to hit "send". Option #2 of the two possible 
solutions I offered is not right. Here's what it should be (unless the 
formatting gets garbled):

with open('E:/amadown2py-master/reviews1.csv', 'r',encoding='UTF8') as csvfile:
with open('E:/amadown2py-master/Sam7_pos_rev.txt',mode='wt') as 
myfile:#Moved this!
mycsv = csv.reader(csvfile)
for row in mycsv:
data = row[0]
#print (data)
try:
score = ast.literal_eval(row[1])
if score > 3:
cnt=0;
#print (score)
print (data)
positivedata.append((data))
myfile.writelines('\n'.join(positivedata))
#myfile.close()#You shouldn't need this, bc you're using 
"with"

ttfn,

Ben I.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Default .py program and Edit with IDLE problem

2017-08-18 Thread Ben Iannitelli
Hi Kevi,


Just to clarify your situation:


  1.  Which operating system?
  2.  You still have all of the .py files that you yourself wrote?


Sincerely,


-Ben I.

--
https://mail.python.org/mailman/listinfo/python-list
Python-list Info Page
mail.python.org
This mailing list is a general discussion list for the Python programming 
language. Please note that for those who prefer, this list is mirrored to the 
Usenet ...



-- 
https://mail.python.org/mailman/listinfo/python-list