Re: Python modules

2014-11-09 Thread Ben Finney
Steve Hayes writes: > So if I want to run it on another computer, where do I look for the > compiled executable program to copy? You generally don't do that (the compiled files tend to be specific to various aspects of the target platform). This is a way that i's important to remember that most

Re: Python modules

2014-11-09 Thread Steve Hayes
On Mon, 10 Nov 2014 16:12:07 +1100, Ben Finney wrote: >Steve Hayes writes: > >> I have a book on Python that advocates dividing programs into modules, >> and importing them when needed. > >Which book is this? (This is not essential to your question, but it >might help to gauge your broader learn

Re: Python modules

2014-11-09 Thread Ben Finney
Steve Hayes writes: > I have a book on Python that advocates dividing programs into modules, > and importing them when needed. Which book is this? (This is not essential to your question, but it might help to gauge your broader learning environment.) > I can understand doing that in a compiled

Re: Python modules

2014-11-09 Thread Deepfriedice
On 10/11/14 14:55, Steve Hayes wrote: I have a book on Python that advocates dividing programs into modules, and importing them when needed. I have a question about this. I can understand doing that in a compiled language, where different modules can be imported from all sorts of places when th

Python modules

2014-11-09 Thread Steve Hayes
I have a book on Python that advocates dividing programs into modules, and importing them when needed. I have a question about this. I can understand doing that in a compiled language, where different modules can be imported from all sorts of places when the program is compiled. But I understa

Re: Python script that does batch find and replace in txt files

2014-11-09 Thread Syed Khalid
Albert, Code is not removing empty lines containing blank characters and not removing leading and trailing spaces present in each line. import glob, codecs, re, os regex = re.compile(r"Age: |Sex: |House No: ") # etc etc for txt in glob.glob("D:/Python/source/*.txt"): with codecs.o

__missing__ for the top-level Python script

2014-11-09 Thread Chris Angelico
Let's have some fun nutting out possible implementations for a bad idea :) If you want a dictionary that prepopulates itself on demand, you implement __missing__. Is there a way to implement the same thing for the __main__ module? Since it isn't imported (as such), I don't think "switch out what's

Re: Python script that does batch find and replace in txt files

2014-11-09 Thread Albert-Jan Roskam
On Sun, Nov 9, 2014 10:51 PM CET Syed Khalid wrote: >Albert, > >Thanks a million for script, > >It worked fine after I closed the bracket. > > >import glob, codecs, re, os > >regex = re.compile(r"Age: |Sex: |House No: ") # etc etc > >for txt in glob.glob("D:/Python/s

Re: Python script that does batch find and replace in txt files

2014-11-09 Thread Syed Khalid
Albert, Thanks a million for script, It worked fine after I closed the bracket. import glob, codecs, re, os regex = re.compile(r"Age: |Sex: |House No: ") # etc etc for txt in glob.glob("D:/Python/source/*.txt"): with codecs.open(txt, encoding="utf-8") as f: oldlines = f.readlines

Re: Python script that does batch find and replace in txt files

2014-11-09 Thread MRAB
On 2014-11-09 21:20, Syed Khalid wrote: Code after adding path of .txt files : import glob, codecs, re, os regex = re.compile(r"Age: |Sex: |House No: ") # etc etc for txt in glob.glob("D:/Python/source/*.txt"): with codecs.open(txt, encoding="utf-8") as f: oldlines = f.readlines

Re: Python script that does batch find and replace in txt files

2014-11-09 Thread Syed Khalid
Code after adding path of .txt files : import glob, codecs, re, os regex = re.compile(r"Age: |Sex: |House No: ") # etc etc for txt in glob.glob("D:/Python/source/*.txt"): with codecs.open(txt, encoding="utf-8") as f: oldlines = f.readlines() for i, line in enumerate(oldlines):

Re: Python script that does batch find and replace in txt files

2014-11-09 Thread Syed Khalid
My Script, I have added import glob, codecs, re, os regex = re.compile(r"Age: |Sex: |House No: ") # etc etc Script I executed in EditRocket : for txt in glob.glob("/D:/Python/source/*.txt"): with codecs.open(txt, encoding="utf-8") as f: oldlines = f.readlines() for i, line

Re: Python script that does batch find and replace in txt files

2014-11-09 Thread Syed Khalid
Hi Albert, Thank you for script. I am getting the below error : File "EamClean.log", line 12 with codecs.open(txt + "_out.txt", "wb", encoding="utf-8") as w: ^ SyntaxError: invalid syntax Kindly do the needful. On Mon, Nov 10, 2014 at 1:53 AM, Albert-Jan Roskam wrote: > > > > >

Re: Python script that does batch find and replace in txt files

2014-11-09 Thread Albert-Jan Roskam
- Original Message - > From: Syed Khalid > To: python-list@python.org > Cc: > Sent: Sunday, November 9, 2014 8:58 PM > Subject: Python script that does batch find and replace in txt files > > Python script that does batch find and replace in txt files Need a python > script > that

Re: Python script that does batch find and replace in txt files

2014-11-09 Thread Mark Lawrence
On 09/11/2014 19:58, Syed Khalid wrote: Python script that does batch find and replace in txt files Need a python script that opens all .txt files in a folder find replace/delete text and save files. I have text files and I need to perform below steps for each file. Step 1: Put cursor at star

Re: [Python-Dev] Dinamically set __call__ method

2014-11-09 Thread Ethan Furman
On 11/09/2014 03:38 AM, Gregory Ewing wrote: Ethan Furman wrote: And the thing going on is the normal python behavior (in __getattribute__, I believe) of examining the returned attribute to see if it is a descriptor, and if so invoking it. Only if you look it up through the instance, though.

Python script that does batch find and replace in txt files

2014-11-09 Thread Syed Khalid
Python script that does batch find and replace in txt files Need a python script that opens all .txt files in a folder find replace/delete text and save files. I have text files and I need to perform below steps for each file. Step 1: Put cursor at start of file and Search for "Contact's Name:

Re: What is rstrip() in python?

2014-11-09 Thread Joel Goldstick
On Sun, Nov 9, 2014 at 12:46 PM, Terry Reedy wrote: > On 11/9/2014 6:11 AM, satishmlm...@gmail.com wrote: >> >> What is rstrip() in python? google on 'rstrip python' gets this at first link: https://docs.python.org/2/library/stdtypes.html#str.rstrip google is your friend. > > > The manuals have

Re: What is rstrip() in python?

2014-11-09 Thread Terry Reedy
On 11/9/2014 6:11 AM, satishmlm...@gmail.com wrote: What is rstrip() in python? The manuals have a rather complete index. If 'rstrip' is missing from the index, let us know so we can fix it. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list

Re: functools documentation - help with funny words

2014-11-09 Thread Ian Kelly
On Sun, Nov 9, 2014 at 2:06 AM, Veek M wrote: > https://docs.python.org/3.4/library/functools.html > > 1. "A key function is a callable that accepts one argument and returns > another value indicating the position in the desired collation sequence." > > x = ['x','z','q']; sort(key=str.upper) This

Re: dictionary issue for formatted print

2014-11-09 Thread Peter Otten
Yusuf Can Bayrak wrote: > when dictionary has one value for each key it's okey. I'm just type '% > greek_letters' and it's working. > > But how can i assign dict's values to formatted print, if it has more > values than one. > >> >>1. # -*- coding: utf-8 -*- >>2. greek_letters = { >>

Re: What is rstrip() in python?

2014-11-09 Thread Mark Lawrence
On 09/11/2014 11:11, satishmlm...@gmail.com wrote: What is rstrip() in python? It's a function or method call. What does it do in the following piece of code? I'm not actually sure. Would you be kind enough to look it up in the documentation for me and let me know, thanks? import sql

Re: What is description attribute in python?

2014-11-09 Thread Mark Lawrence
On 09/11/2014 11:05, satishmlm...@gmail.com wrote: curs is coming from the following piece of code import sqlite3 conn = sqlite3.connect('dbase1') curs = conn.cursor() Today's exercise is to find the documentation and read it before posting another question. Better still is to use the inter

Re:dictionary issue for formatted print

2014-11-09 Thread Dave Angel
Yusuf Can Bayrak Wrote in message: > when dictionary has one value for each key it's okey. I'm just type '% > greek_letters' and it's working. > > But how can i assign dict's values to formatted print, if it has more values > than one. # -*- coding: utf-8 -*-greek_letters = {

Re: [Python-Dev] Dinamically set __call__ method

2014-11-09 Thread Steven D'Aprano
Gregory Ewing wrote: > Ethan Furman wrote: >> And the thing going on is the normal python behavior (in >> __getattribute__, I believe) of examining the returned attribute to see >> if it is a descriptor, and if so invoking it. > > Only if you look it up through the instance, though. > Normally, i

Re: What is rstrip() in python?

2014-11-09 Thread Steven D'Aprano
satishmlm...@gmail.com wrote: > What is rstrip() in python? Have you read the Fine Manual? Did you try googling first? https://duckduckgo.com/html/?q=python+rstrip > What does it do in the following piece of code? It removes trailing whitespace. > import sqlite3 > conn = sqlite3.connect('d

Re: Syncing audio and video for casual recording

2014-11-09 Thread Steven D'Aprano
Tobiah wrote: > I decided I'd like to publish some youtube videos of me playing > an instrument. The audio being the important bit, I'd like to use > my existing mics, which I've been sending through a USB audio interface > to my computer. > > I don't have any camera yet, other than a prosumer

Re: What is description attribute in python?

2014-11-09 Thread Tim Chase
On 2014-11-09 02:42, satishmlm...@gmail.com wrote: > What does description attribute in the following code mean? > > curs.execute('select * from people') > colnames = [desc[0] for desc in curs.description] http://legacy.python.org/dev/peps/pep-0249/#cursor-attributes -tkc -- https://mail.py

Engaging, powerful - video inspriration/learning - Your best selections

2014-11-09 Thread flebber
Not fans of videos hey(well python videos anyway) bugger. Sayth. -- https://mail.python.org/mailman/listinfo/python-list

Re: [Python-Dev] Dinamically set __call__ method

2014-11-09 Thread Gregory Ewing
Ethan Furman wrote: And the thing going on is the normal python behavior (in __getattribute__, I believe) of examining the returned attribute to see if it is a descriptor, and if so invoking it. Only if you look it up through the instance, though. Normally, if you look up an attribute on a cla

Re: What is rstrip() in python?

2014-11-09 Thread Chris Angelico
On Sun, Nov 9, 2014 at 10:11 PM, wrote: > What is rstrip() in python? > > What does it do in the following piece of code? > > import sqlite3 > conn = sqlite3.connect('dbase1') > curs = conn.cursor() > > file = open('data.txt') > rows = [line.rstrip().split(',') for line in file] Do you know what

What is rstrip() in python?

2014-11-09 Thread satishmlmlml
What is rstrip() in python? What does it do in the following piece of code? import sqlite3 conn = sqlite3.connect('dbase1') curs = conn.cursor() file = open('data.txt') rows = [line.rstrip().split(',') for line in file] -- https://mail.python.org/mailman/listinfo/python-list

Re: What is description attribute in python?

2014-11-09 Thread Deepfriedice
On 09/11/14 20:59, Steven D'Aprano wrote: It's an attribute called "description". You would need to read the documentation for curs to know what it does. What is curs? Where does it come from? It looks like a cursor from an SQL DB library. For example, sqlite3 in the standard library provides

Re: What is description attribute in python?

2014-11-09 Thread satishmlmlml
curs is coming from the following piece of code import sqlite3 conn = sqlite3.connect('dbase1') curs = conn.cursor() -- https://mail.python.org/mailman/listinfo/python-list

Re: What does zip mean?

2014-11-09 Thread milos zorica
sorry my bad On Sun, Nov 9, 2014 at 7:58 AM, Steven D'Aprano < steve+comp.lang.pyt...@pearwood.info> wrote: > satishmlm...@gmail.com wrote: > > > What does zip return in the following piece of code? > > Have you read the Fine Manual? > > In Python 2, zip returns a list: > > zip(['a', 'b', 'c'], [

Re: What does zip mean?

2014-11-09 Thread Steven D'Aprano
satishmlm...@gmail.com wrote: > What does zip return in the following piece of code? Have you read the Fine Manual? In Python 2, zip returns a list: zip(['a', 'b', 'c'], [1, 2, 3]) => [('a', 1), ('b', 2), ('c', 3)] https://docs.python.org/2/library/functions.html#zip In Python 3, zip does t

Re: What is description attribute in python?

2014-11-09 Thread Steven D'Aprano
satishmlm...@gmail.com wrote: > What does description attribute in the following code mean? > > curs.execute('select * from people') > colnames = [desc[0] for desc in curs.description] It's an attribute called "description". You would need to read the documentation for curs to know what it does.

What does zip mean?

2014-11-09 Thread satishmlmlml
What does zip return in the following piece of code? curs.execute('select * from people') colnames = [desc[0] for desc in curs.description] rowdicts = [] for row in curs.fetchall(): rowdicts.append(dict(zip(colnames, row))) -- https://mail.python.org/mailman/listinfo/python-list

What is description attribute in python?

2014-11-09 Thread satishmlmlml
What does description attribute in the following code mean? curs.execute('select * from people') colnames = [desc[0] for desc in curs.description] -- https://mail.python.org/mailman/listinfo/python-list

dictionary issue for formatted print

2014-11-09 Thread Yusuf Can Bayrak
when dictionary has one value for each key it's okey. I'm just type '% greek_letters' and it's working. But how can i assign dict's values to formatted print, if it has more values than one. > >1. # -*- coding: utf-8 -*- >2. greek_letters = { >3. 'omega': ['ω','Ω']

functools documentation - help with funny words

2014-11-09 Thread Veek M
https://docs.python.org/3.4/library/functools.html 1. "A key function is a callable that accepts one argument and returns another value indicating the position in the desired collation sequence." x = ['x','z','q']; sort(key=str.upper) My understanding is that, x, y, .. are passed to the key fun

Re: How do i reduce this to a single function - the code is largely similar, just a direction of search toggle.

2014-11-09 Thread Veek M
Ned Batchelder wrote: > On 11/7/14 9:52 AM, Veek M wrote: > and you want to end up on the "def" token, not the "def" in yep, bumped into this :) thanks! -- https://mail.python.org/mailman/listinfo/python-list