Re: seeking deeper (language theory) reason behind Python design choice

2018-05-15 Thread Steven D'Aprano
On Mon, 14 May 2018 21:24:01 -0400, Dennis Lee Bieber wrote: > The problem with adding the feature is that it will start to be > used by > newbies who lack the discipline to use it reliably: ensuring that > comparisons are coded with constants (which for Python really means > literals) on t

Extract data from multiple text files

2018-05-15 Thread mahesh d
import glob,os import errno path = 'C:/Users/A-7993\Desktop/task11/sample emails/' files = glob.glob(path) '''for name in files: print(str(name)) if name.endswith(".txt"): print(name)''' for file in os.listdir(path): print(file) if file.endswith(".txt"):

Read data from .msg all files

2018-05-15 Thread mahesh d
import glob import win32com.client files = glob.glob('C:/Users/A-7993/Desktop/task11/sample emails/*.msg') for file in files: print(file) with open(file) as f: msg=f.read() print(msg) outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI"

Uploading on PyPI fail

2018-05-15 Thread Vincent Vande Vyvre
Hi, Trying to upgrade a package on PyPI, I get this error: $ python3 setup.py register sdist upload ... Submitting dist/py3exiv2-0.3.0.tar.gz to https://pypi.python.org/pypi Upload failed (308): Redirect to Primary Domain error: Upload failed (308): Redirect to Primary Domain I know the site ha

Re: Uploading on PyPI fail (solved)

2018-05-15 Thread Vincent Vande Vyvre
Le 15/05/18 à 12:05, Vincent Vande Vyvre a écrit : Hi, Trying to upgrade a package on PyPI, I get this error: $ python3 setup.py register sdist upload ... Submitting dist/py3exiv2-0.3.0.tar.gz to https://pypi.python.org/pypi Upload failed (308): Redirect to Primary Domain error: Upload failed (

Re: Extract data from multiple text files

2018-05-15 Thread Rhodri James
On 15/05/18 13:12, mahesh d wrote: import glob,os import errno path = 'C:/Users/A-7993\Desktop/task11/sample emails/' files = glob.glob(path) for file in os.listdir(path): print(file) if file.endswith(".txt"): print(os.path.join(path, file)) print(file) try:

Re: Pandas cat.categories.isin list, is this a bug?

2018-05-15 Thread Matt Ruffalo
On 2018-05-15 06:23, Zoran Ljubišić wrote: > Matt, > > thanks for the info about pydata mailing group. I didn't know it exists. > Because comp.lang.python is not appropriate group for this question, I > will continue our conversation on gmail. > > I have put len(df.CRM_assetID.cat >

Re: Read data from .msg all files

2018-05-15 Thread Grant Edwards
On 2018-05-15, mahesh d wrote: > import glob _Please_ stop creating new threads for this question. I think this is the fifth thread you've started for what appears to be a single question. -- Grant Edwards grant.b.edwardsYow! Like I always say

Re: object types, mutable or not?

2018-05-15 Thread Mike McClain
On Sun, May 13, 2018 at 07:10:11PM -0400, Richard Damon wrote: > On 5/13/18 4:02 PM, Mike McClain wrote: > > I'm new to Python and OOP. > > Python en 2.7.14 Documentation The Python Language Reference > > 3. Data model > > 3.1. Objects, values and types > > An object's type is also unchangeable.

What's the rationale for b"..." in this example?

2018-05-15 Thread Skip Montanaro
Consider this: >>> bytes("abc", encoding="utf-8") b'abc' Looks reasonable. Then consider this: >>> str(bytes("abc", encoding="utf-8")) "b'abc'" Why is the b'...' bit still there? I suppose it's because I didn't tell it explicitly how to decode the bytes object, as when I do, I get the expected

Re: object types, mutable or not?

2018-05-15 Thread Rhodri James
On 15/05/18 15:29, Mike McClain wrote: On Sun, May 13, 2018 at 07:10:11PM -0400, Richard Damon wrote: On 5/13/18 4:02 PM, Mike McClain wrote: I'm new to Python and OOP. Python en 2.7.14 Documentation The Python Language Reference 3. Data model 3.1. Objects, values and types An object's type i

Re: What's the rationale for b"..." in this example?

2018-05-15 Thread Ethan Furman
On 05/15/2018 08:14 AM, Skip Montanaro wrote: Consider this: bytes("abc", encoding="utf-8") b'abc' Looks reasonable. Then consider this: str(bytes("abc", encoding="utf-8")) "b'abc'" Why is the b'...' bit still there? Because you are printing a bytes object, not a str. I suppose it's b

Simplest way to clobber/replace one populated directory with another?

2018-05-15 Thread Travis Griggs
I have a directory structure that might look something like: Data Current A B C Previous A X In as simple/quick a step as possible, I want to rename Current as Previous including the contents and wiping out the or

Re: seeking deeper (language theory) reason behind Python design choice

2018-05-15 Thread Python
On Tue, May 15, 2018 at 12:52:42AM +, Steven D'Aprano wrote: > But you miss the point that even if = versus == errors are picked up by > code reviews or tests, they are still software bugs. Your *process* > (testing and reviews) picked up the bug before they went into production, > but *the

Re: Extract data from multiple text files

2018-05-15 Thread MRAB
On 2018-05-15 13:12, mahesh d wrote: import glob,os import errno path = 'C:/Users/A-7993\Desktop/task11/sample emails/' files = glob.glob(path) '''for name in files: print(str(name)) if name.endswith(".txt"): print(name)''' for file in os.listdir(path): print(f

Re: object types, mutable or not?

2018-05-15 Thread Ben Finney
Mike McClain writes: > Many thanks to those teachers who responded. Thank you for asking the question in a way that allows the discussion :-) > I think I got it. > The variable is not the object just as the name is not the thing. Yes. The term “variable” is so overloaded, for people new to Pyt

Re: What's the rationale for b"..." in this example?

2018-05-15 Thread Ben Finney
Skip Montanaro writes: > Consider this: > > >>> bytes("abc", encoding="utf-8") > b'abc' > > Looks reasonable. Then consider this: > > >>> str(bytes("abc", encoding="utf-8")) > "b'abc'" > > Why is the b'...' bit still there? Because the bytes object is asked for a text representation of itself, a

Re: What's the rationale for b"..." in this example?

2018-05-15 Thread Serhiy Storchaka
15.05.18 18:14, Skip Montanaro пише: Consider this: bytes("abc", encoding="utf-8") b'abc' Looks reasonable. Then consider this: str(bytes("abc", encoding="utf-8")) "b'abc'" Why is the b'...' bit still there? I suppose it's because I didn't tell it explicitly how to decode the bytes object

Re: What's the rationale for b"..." in this example?

2018-05-15 Thread Chris Angelico
On Wed, May 16, 2018 at 1:14 AM, Skip Montanaro wrote: > Consider this: > bytes("abc", encoding="utf-8") > b'abc' > > Looks reasonable. Then consider this: > str(bytes("abc", encoding="utf-8")) > "b'abc'" > > Why is the b'...' bit still there? I suppose it's because I didn't tell it > ex

syntax oddities

2018-05-15 Thread Tobiah
Why is it len(object) instead of object.len? Why is it getattr(object, item) rather then object.getattr(item)? etc... Thanks -- https://mail.python.org/mailman/listinfo/python-list

Re: Extract data

2018-05-15 Thread Albert-Jan Roskam
On May 15, 2018 08:54, Steven D'Aprano wrote: On Tue, 15 May 2018 11:53:47 +0530, mahesh d wrote: > Hii. > > I have folder.in that folder some files .txt and some files .msg files. > . > My requirement is reading those file contents . Extract data in that > files . Reading .msg can be done

Re: syntax oddities

2018-05-15 Thread Serhiy Storchaka
15.05.18 22:10, Tobiah пише: Why is it len(object) instead of object.len? Because the first form looked better to Guido van Rossum. Why is it getattr(object, item) rather then object.getattr(item)? How do you get the 'getattr' attribute then? -- https://mail.python.org/mailman/listinfo/pyt

Re: seeking deeper (language theory) reason behind Python design choice

2018-05-15 Thread Peter J. Holzer
On 2018-05-15 00:52:42 +, Steven D'Aprano wrote: > Now remember that in 1991 when Guido made the decision to ban = as an > expression, those concepts didn't even exist. There were no Python > linters, and no reason to imagine that there ever would be. Guido didn't > know that Python would be

Re: syntax oddities

2018-05-15 Thread Ian Kelly
On Tue, May 15, 2018 at 1:10 PM, Tobiah wrote: > Why is it len(object) instead of object.len? > > Why is it getattr(object, item) rather then object.getattr(item)? http://effbot.org/pyfaq/why-does-python-use-methods-for-some-functionality-e-g-list-index-but-functions-for-other-e-g-len-list.htm --

Re: What's the rationale for b"..." in this example?

2018-05-15 Thread Skip Montanaro
> Personally, I never use the str(..., encoding="...") notation; I prefer to use the > .decode() method of the bytes object. Thanks. And thanks for the other responses. I obviously didn't have my thinking cap on this morning. (It was too late in the morning to plead lack of coffee.) Skip -- http

Re: Extract data from multiple text files

2018-05-15 Thread Albert-Jan Roskam
On May 15, 2018 14:12, mahesh d wrote: import glob,os import errno path = 'C:/Users/A-7993\Desktop/task11/sample emails/' files = glob.glob(path) '''for name in files: print(str(name)) if name.endswith(".txt"): print(name)''' for file in os.listdir(path): print(f

Re: What's the rationale for b"..." in this example?

2018-05-15 Thread Chris Angelico
On Wed, May 16, 2018 at 9:02 AM, Skip Montanaro wrote: >> Personally, I never use the str(..., encoding="...") notation; I prefer > to use the >> .decode() method of the bytes object. > > Thanks. And thanks for the other responses. I obviously didn't have my > thinking cap on this morning. (It was

Re: object types, mutable or not?

2018-05-15 Thread Steven D'Aprano
On Tue, 15 May 2018 07:29:39 -0700, Mike McClain wrote: > I had gotten the impression that everything in OOP is an object but > you're all saying that variables are not objects. Perhaps it is better to say every VALUE in Python is an object. Keywords aren't values. Operators aren't values. Comme

Re: syntax oddities

2018-05-15 Thread Steven D'Aprano
On Tue, 15 May 2018 12:10:07 -0700, Tobiah wrote: > Why is it len(object) instead of object.len? Because we're not serfs in the Kingdom of Nouns: https://steve-yegge.blogspot.com/2006/03/execution-in-kingdom-of-nouns.html -- Steve -- https://mail.python.org/mailman/listinfo/python-list

Re: seeking deeper (language theory) reason behind Python design choice

2018-05-15 Thread Steven D'Aprano
On Tue, 15 May 2018 22:21:15 +0200, Peter J. Holzer wrote: > On 2018-05-15 00:52:42 +, Steven D'Aprano wrote: [...] >> By 1991 there had already been *decades* of experience with C > > About one and a half decades. That would still be plural decades. C's first release was 1972, so more like

Re: seeking deeper (language theory) reason behind Python design choice

2018-05-15 Thread bartc
On 15/05/2018 21:21, Peter J. Holzer wrote: I have been programming in C since the mid-80's and in Perl since the mid-90's (both languages allow assignment expressions). I accumulated my fair share of bugs in that time, but AFAIR I made this particular error very rarely (I cannot confidently cla

Re: seeking deeper (language theory) reason behind Python design choice

2018-05-15 Thread bartc
On 16/05/2018 01:04, Steven D'Aprano wrote: I'm not a C coder, but I think that specific example would be immune to the bug we are discussing, since (I think) you can't chain assignments in C. Am I right? Assignments can be chained in C (with right-to-left precedence) as can augmented assignm

stock quotes off the web, py style

2018-05-15 Thread Mike McClain
Initially I got my quotes from a broker daily to plug into a spreadsheet, Then I found Yahoo and wrote a perl script to grab them. When Yahoo quit supplying quotes I found AlphaVantage.co and rewrote the perl script. AlphaVantage.co has been down since last week and I found iextrading.com h

Re: object types, mutable or not?

2018-05-15 Thread Ben Finney
Steven D'Aprano writes: > On Tue, 15 May 2018 07:29:39 -0700, Mike McClain wrote: > > > I had gotten the impression that everything in OOP is an object but > > you're all saying that variables are not objects. > > Perhaps it is better to say every VALUE in Python is an object. IMO that is better

Re: Extract data from multiple text files

2018-05-15 Thread Cameron Simpson
On 15May2018 18:18, MRAB wrote: On 2018-05-15 13:12, mahesh d wrote: import glob,os [...] files = glob.glob(path) You've got a list of filenames here - they would work, _if_ you had passed in a glob pattern, instead of just the directory path. Try this again, joining "*.msg" or "*.txt" to

Re: object types, mutable or not?

2018-05-15 Thread Steven D'Aprano
On Wed, 16 May 2018 11:30:26 +1000, Ben Finney wrote: > Steven D'Aprano writes: > >> On Tue, 15 May 2018 07:29:39 -0700, Mike McClain wrote: >> >> > I had gotten the impression that everything in OOP is an object but >> > you're all saying that variables are not objects. >> >> Perhaps it is bett

Re: object types, mutable or not?

2018-05-15 Thread Chris Angelico
On Wed, May 16, 2018 at 4:39 PM, Steven D'Aprano wrote: > > But I digress... we ought to distinguish between the value of a list, > which of course may change through the list's lifetime, and the fact that > no matter what value it has, it is still a value. > > I'm not the same person I was 40 yea