Re: [Tutor] Which is better in principle: to store (in file) calculated data or to re-calculate it upon restarting program?

2019-07-30 Thread Zachary Ware
On Tue, Jul 30, 2019 at 11:24 AM boB Stepp wrote: > In this trivial example I cannot imagine there is any realistic > difference between the two approaches, but I am trying to generalize > my thoughts for potentially much more expensive calculations, very > large data sets, and what is the likelih

Re: [Tutor] Trouble Downloading To MacOS Mojave 10.14.3 released mid 2014

2019-03-13 Thread Zachary Ware
On Wed, Mar 13, 2019 at 7:06 AM Robert Landers wrote: > Hello Tutor, Hi Robert, and welcome! > I am having trouble finding a python 3.7.2 download for my MacOS Mojave > 10.14.3 released mid 2014. If you go to https://www.python.org/downloads/, the large yellow "Download Python ..." button near

Re: [Tutor] Displaying Status on the Command Line

2018-11-08 Thread Zachary Ware
On Thu, Nov 8, 2018 at 10:10 AM Steven D'Aprano wrote: > Sorry, I don't understand that. Maybe its too early in the morning for > my brain, but given that you've imported the Python 3 print function > from the __future__ why do you need the customer wrapper? > > from __future__ import print_functi

Re: [Tutor] Displaying Status on the Command Line

2018-11-08 Thread Zachary Ware
On Thu, Nov 8, 2018 at 4:12 AM Chip Wachob wrote: > I should have mentioned that I'm working with Python 2, but I think I > can parse my way through these examples. You can use any of the `print` function tricks above in Python 2 with the following boilerplate: from __future__ import print_funct

Re: [Tutor] Displaying Status on the Command Line

2018-11-07 Thread Zachary Ware
On Wed, Nov 7, 2018 at 1:17 PM Alan Gauld via Tutor wrote: > In Python 3 there are parameters to print() > > while someProcess(): >time.sleep(1) >print('.', end='', sep='') # no newline and no spaces You'll also want `flush=True` here to avoid having your dots buffered until end-of-line

Re: [Tutor] SSL Error

2018-07-31 Thread Zachary Ware
On Tue, Jul 31, 2018 at 12:06 PM Alan Gauld via Tutor wrote: > > On 31/07/18 03:52, Saket Mehrotra wrote: > > > error ssl.PROTOCOL_SSLv23: OpenSSL.SSL.SSLv23_METHOD, > > AttributeError: module 'ssl' has no attribute 'PROTOCOL_SSLv23' > > Are you sure you spelled the attribute correctly? > > Have

Re: [Tutor] Dictionary viceversa

2018-07-30 Thread Zachary Ware
On Mon, Jul 30, 2018 at 1:08 PM Alan Gauld via Tutor wrote: > There are lots of options including those suggested elsewhere. > Another involves using get() which makes your function > look like: > > def viceversa(d): > new_d = dict() > for k in d: > for e in d[k]: > new

Re: [Tutor] Dictionary viceversa

2018-07-30 Thread Zachary Ware
On Mon, Jul 30, 2018 at 12:20 PM Valerio Pachera wrote: > I was looking to substiture the cicle for e in new_d like this: > [ new_d[e].append(k) if e in new_d else new_d[e].append(k) for e in d[k] ] > but it can't work because 'new_d[e] = []' is missing. Have a look at `dict.setdefault` and pla

Re: [Tutor] pip stopped working gives error

2018-05-03 Thread Zachary Ware
On Thu, May 3, 2018 at 2:10 PM, Jim wrote: > I have python 3.6 installed in a virtual environment on Mint 18. Today I > wanted to use pip and got this error when I tried to use it. > > (env36) jfb@jims-mint18 ~ $ pip help > Traceback (most recent call last): > File "/home/jfb/EVs/env36/bin/pip"

Re: [Tutor] Sam Kahraman Campus Middle School Advice

2018-04-26 Thread Zachary Ware
Hi Sam, On Thu, Apr 26, 2018 at 3:00 PM, Kahraman, Sam K. wrote: > Hello, > > I am a 8th grade student at Campus Middle School. We have a project on > coding and I need a expert to interview. Currently I'm learning Python and > thought I should ask someone who works their to Interview. To cont

Re: [Tutor] about tree input

2018-04-23 Thread Zachary Ware
On Mon, Apr 23, 2018 at 11:28 AM, 劉權陞 <01patrick...@gmail.com> wrote: > I still have no idea about how to write the code. Can you make a > demonstration? Something like this: def set(tree, path, key, value): for p in path: tree = tree[p] tree[key] = value -- Zach __

Re: [Tutor] about tree input

2018-04-22 Thread Zachary Ware
Basically what you want to do here is give Tree a local name (d), loop through T reassigning d to d[k_from_T], and then d[k] = v after the loop. T can be arbitraily long, and Tree can actually be and contain any indexable type. If this pointer isn't enough to send you in the right direction, I'll

Re: [Tutor] Using the Nimblenet Library in Python 3.6

2018-04-05 Thread Zachary Ware
On Thu, Apr 5, 2018 at 3:39 AM, Alan Gauld via Tutor wrote: > On 05/04/18 04:02, Mark Lawrence wrote: > >> Python 3.6 has more functionality than 2.7 by definition, but your >> comment implies, at least to me, that 2.7 and 3.6 are chalk and cheese. >> Nothing could be further from the truth and ha

Re: [Tutor] question about metaclasses

2018-01-10 Thread Zachary Ware
On Wed, Jan 10, 2018 at 10:08 AM, Albert-Jan Roskam wrote: > Hi, > > > In another thread on this list I was reminded of types.SimpleNamespace. This > is nice, but I wanted to create a bag class with constants that are > read-only. My main question is about example #3 below (example #2 just > il

Re: [Tutor] Python

2017-11-30 Thread Zachary Ware
On Thu, Nov 30, 2017 at 2:20 AM, Jeroen van de Ven wrote: > Hello, > Can you build these 4 programms for me? No, we will not do your homework for you. However, you can show us the code you've written, describe the problem you're having with it (including the full text of all error messages), and

Re: [Tutor] (no subject)

2017-08-16 Thread Zachary Ware
Hi Howard, On Wed, Aug 16, 2017 at 5:36 PM, Howard Lawrence <1019sh...@gmail.com> wrote: > class Address: > def _init_(self,Hs,St,Town,Zip): Your issue is in this line, it should be `__init__` rather than `_init_` (that is, two underscores before and after "init"). Hope this helps, -- Z

Re: [Tutor] How does len() compute length of a string in UTF-8, 16, and 32?

2017-08-07 Thread Zachary Ware
On Mon, Aug 7, 2017 at 9:44 PM, boB Stepp wrote: > py3: s = 'Hello!' > py3: len(s.encode("UTF-8")) > 6 > py3: len(s.encode("UTF-16")) > 14 > py3: len(s.encode("UTF-32")) > 28 > > How is len() getting these values? And I am sure it will turn out not > to be a coincidence that 2 * (6 + 1) = 14 and

Re: [Tutor] if __name__=='main' vs entry points: What to teach new comers?

2017-08-01 Thread Zachary Ware
On Tue, Aug 1, 2017 at 9:54 AM, Thomas Güttler wrote: > I have a friend who is a talented shell script writer. He is a linux guru > since > several years. > > He asked me if "if __name__=='main':" is state of the art if you want > to translate a shell script to python. > > I started to stutter and

Re: [Tutor] centos 7 - new setup.. weird python!

2017-07-19 Thread Zachary Ware
On Wed, Jul 19, 2017 at 3:48 PM, bruce wrote: > Hi. Hi Bruce, > > Testing setting up a new Cnntos7 instance. > > I ran python -v from the cmdline... and instantly got a bunch of the > following! Pretty sure this isn't correct. > > Anyone able to give pointers as to what I've missed. > > thanks

Re: [Tutor] Which DB use with standalone desktop app

2017-07-06 Thread Zachary Ware
On Thu, Jul 6, 2017 at 3:57 AM, Freedom Peacemaker wrote: > Hi Tutors, > I am working on standalone desktop app with tkinter GUI (Python3), and i > dont know which database should i use. I've tried to find solution on my > own but google cant help me. There are some with SQL in name (eg. sqlite3,

Re: [Tutor] Why use main() ?

2017-07-05 Thread Zachary Ware
On Wed, Jul 5, 2017 at 10:37 AM, David Rock wrote: > This is not a question about using if __name__ == '__main__':. I know > what the difference is between running the script or importing it and > using the value of __name__ to determine behavior. > > This is a question about the benefits of usin

Re: [Tutor] Coming from R, what's a good IDE editor? I've tried PyCharm and Spyder

2017-06-03 Thread Zachary Ware
On Fri, Jun 2, 2017 at 12:46 PM, C W wrote: > Dear Python list, > > I am an R user learning Python. What is a good editor? > > 1) Pycharm > PyCharm evaluates the entire script, I just want to change a few lines in > the script. > For example, > > import matplotlib.pyplot as plt > import numpy as n

Re: [Tutor] reading files in Python 3

2017-03-30 Thread Zachary Ware
On Mar 30, 2017 15:07, "Rafael Knuth" wrote: I can read files like this (relative path): with open("Testfile_B.txt") as file_object: contents = file_object.read() print(contents) But how do I read files if I want to specify the location (absolute path): file_path = "C:\Users\Rafael\Tes

Re: [Tutor] How to access an instance variable of a superclass from an instance of the subclass?

2017-02-22 Thread Zachary Ware
On Wed, Feb 22, 2017 at 10:25 PM, boB Stepp wrote: > I am trying to wrap my head around the mechanics of inheritance in > Python 3. I thought that all attributes of a superclass were > accessible to an instance of a subclass. > > Obviously I am horribly misunderstanding something, and being > cur

Re: [Tutor] Test for type(object) == ???

2017-02-10 Thread Zachary Ware
On Fri, Feb 10, 2017 at 7:34 PM, boB Stepp wrote: > So my question is why does "type(5)" result in "", but > the correct Boolean test is "type(5) == int"? I suspect it has > something to do with the built-in attributes of Python objects that I > currently know so very little about. Try `help(rep

Re: [Tutor] Multiple tabs using tkinter

2017-02-07 Thread Zachary Ware
On Tue, Feb 7, 2017 at 12:59 PM, Alan Gauld via Tutor wrote: > On 07/02/17 16:41, Zachary Ware wrote: > >> Full disclosure, I've never actually used Tix beyond making it build >> with the rest of CPython on Windows and making sure it actually worked >> on one of my Li

Re: [Tutor] Multiple tabs using tkinter

2017-02-07 Thread Zachary Ware
On Tue, Feb 7, 2017 at 3:56 AM, Alan Gauld via Tutor wrote: > On 07/02/17 03:31, Zachary Ware wrote: > >> ttk rather than Tix; Tix is unmaintained and soft-deprecated in 3.6+. > > Really? Thats a pity. > Tix was supposed to be the module with the extra widgets > and t

Re: [Tutor] Multiple tabs using tkinter

2017-02-06 Thread Zachary Ware
On Mon, Feb 6, 2017 at 7:31 PM, Alan Gauld via Tutor wrote: > On 06/02/17 16:40, Pooja Bhalode wrote: > >> I was wondering if someone could help me regarding multiple tabs in >> tkinter. > > Look at the tabbed notebook in the Tix module. > It should do what you want. ttk rather than Tix; Tix is u

Re: [Tutor] overriding brackets in lvalue assignment possible?

2016-12-27 Thread Zachary Ware
On Tue, Dec 27, 2016 at 10:48 AM, James Hartley wrote: > I can successfully override __getitem__() for rvalues, but the following > example shows that more is required when used as an lvalue: > > ===8<- > #!/usr/bin/env python > > class Foo(): > def __init__(self, n): > self.d = di

Re: [Tutor] Python 3.x and Sqlite3

2016-10-11 Thread Zachary Ware
Hi Greg, On Tue, Oct 11, 2016 at 3:54 PM, Greg Schmit wrote: > On FreeBSD I built lang/python34 from source and when I run python 3.4 I > cannot import sqlite3. I thought it was being packaged with python 3.4. Am I > incorrect in this assumption? This is more the kind of fare that python-list

Re: [Tutor] pytsk

2016-04-29 Thread Zachary Ware
Hi Peter, On Fri, Apr 29, 2016 at 8:15 AM, Tees, Peter (EthosEnergy) wrote: > Hi folks > > I'm pretty new to Python and programming, I've done the first four modules of > the Python course at Coursera.org to get started > > Now I want to put what I've learned to good use, based on the articles b

Re: [Tutor] asyncio or threading

2016-02-27 Thread Zachary Ware
My apologies for taking so long to reply here again, it's been a busy couple of weeks. On Mon, Feb 15, 2016 at 7:18 PM, Alan Gauld wrote: > On 15/02/16 21:08, Zachary Ware wrote: >> This is not all asyncio can do. Callbacks are only one way of using it, the >> other, more com

Re: [Tutor] asyncio or threading

2016-02-15 Thread Zachary Ware
On Feb 15, 2016 1:25 PM, "Alan Gauld" wrote: > > On 15/02/16 13:09, CMG Thrissur wrote: > > > I just wanted an opinion on the subject, asyncio and threading both seam > > to do the same job, but i feel threading is better because of the > > multiple ways i can control it. > > They do similar jobs

Re: [Tutor] asyncio or threading

2016-02-15 Thread Zachary Ware
On Feb 15, 2016 1:12 PM, "CMG Thrissur" wrote: > > Hello, > > I just wanted an opinion on the subject, asyncio and threading both seam to do the same job, but i feel threading is better because of the multiple ways i can control it. > > Just want get the groups opinion based on there experience in

Re: [Tutor] Missing Standard Libraries on Python 3.5 for Mac

2015-11-03 Thread Zachary Ware
Hi Andrew, On Tue, Nov 3, 2015 at 11:20 AM, Andrew Machen wrote: > Hi, > > I am new to Python, and I am trying to use a Python Standard Library, namely > ‘unicodedata’, however it appears to be missing (others are also missing) > from the built-in libraries that come with Python 3.5 for Mac. >

Re: [Tutor] Messy - Very Messy string manipulation.

2015-10-28 Thread Zachary Ware
On Wed, Oct 28, 2015 at 11:09 AM, Zachary Ware wrote: >return ''.join(c for c in text if c not in vowels Looking again, I see I typo'd here too. There should of course be a ')' at the end. -- Zach ___ Tutor mail

Re: [Tutor] Messy - Very Messy string manipulation.

2015-10-28 Thread Zachary Ware
On Wed, Oct 28, 2015 at 10:09 AM, Vusa Moyo wrote: > Hi Guys, > > I've written a script to remove vowels from a string/sentence. > > the while loop I'm using below is to take care of duplicate vowels found in > a sentence, ie > > anti_vowel('The cow moos louder than the frog') > > It works, but ob

Re: [Tutor] Messy - Very Messy string manipulation.

2015-10-28 Thread Zachary Ware
On Wed, Oct 28, 2015 at 11:09 AM, Zachary Ware wrote: >assert remove_vowels('Did It work? Looks like.') == 'Dd t wrk? Lks Lke.' Of course I typo'd here (that's what you get for not testing!): there should be no final 'e' and the last 'L' s

Re: [Tutor] Working collaboratively (was: accessing modules found throughout a package?)

2015-10-19 Thread Zachary Ware
On Mon, Oct 19, 2015 at 2:53 PM, Alex Kleider wrote: > On 2015-10-19 12:37, Ben Finney wrote: >> Work >> with other Python programmers on a common code base, and watch your >> skills broaden and improve! > > > How I wish I could find such collaborator! > Are there any "starter level" PyPi projects

Re: [Tutor] Type Error

2015-09-14 Thread Zachary Ware
On Mon, Sep 14, 2015 at 9:29 AM, richard kappler wrote: > everything works except the os.remove(file) which gives the following error: > > Traceback (most recent call last): > File "DataFeedBatch.py", line 104, in > os.remove(file) > TypeError: coercing to Unicode: need string or buffer, f

Re: [Tutor] How should my code handle db connections? Should my db manager module use OOP?

2015-08-26 Thread Zachary Ware
On Aug 26, 2015 9:03 PM, "Steven D'Aprano" wrote: > - If your database lives on a NTFS partition, which is very common for > Linux/Unix users > these issues, especially on Linux when using NTFS. Surely you mean NFS, as in Network FileSystem, rather than NTFS as in New Technology FileSystem? :)

Re: [Tutor] Is it possible to archive subsets of data from an SQLite db and restore it later?

2015-08-17 Thread Zachary Ware
On Mon, Aug 17, 2015 at 10:44 PM, boB Stepp wrote: > My wife had an interesting request tonight: Would it be possible to > have two dbs, one that is the current working db, and the other an > archival db for students who have left the school? If yes, then the > archival db would need to be able

Re: [Tutor] Does composition only work with particular instances of objects?

2015-08-13 Thread Zachary Ware
On Thu, Aug 13, 2015 at 11:31 PM, boB Stepp wrote: > I was looking at an example illustrating composition from the book, > "Introducing Python" by Bill Lubanovic on p. 140: > class Bill: > def __init__(self, description): > self.description = description > class Tail:

[Tutor] _ vs. _name vs. __name vs. name_ vs. __name__ usages

2015-07-25 Thread Zachary Ware
On Saturday, July 25, 2015, boB Stepp > wrote: > > 5) __name__ is meant to be used only by the creators of Python for > their special built-in methods, such as __init__, __new__, etc. Everything up to this point was pretty accurate. You're only half right with this one, though; __dunder__ names a

Re: [Tutor] How to get a Tkinter window to print a color copy of itself as a .pdf file?

2015-04-15 Thread Zachary Ware
On Apr 15, 2015 9:59 AM, "boB Stepp" wrote: > > On Wed, Apr 15, 2015 at 8:50 AM, Zachary Ware > wrote: > > > > On Apr 15, 2015 9:38 AM, "boB Stepp" wrote: > >> Perhaps I am being foolish! But I do have my reasons, which, in this > >&g

Re: [Tutor] How to get a Tkinter window to print a color copy of itself as a .pdf file?

2015-04-15 Thread Zachary Ware
On Apr 15, 2015 9:38 AM, "boB Stepp" wrote: > Perhaps I am being foolish! But I do have my reasons, which, in this > case, is I wanted to take advantage of the pack and grid geometry > managers. These two tools seem to make the positioning of the widgets > much easier. Unless I am missing somethin

Re: [Tutor] annoying directory structure

2015-04-10 Thread Zachary Ware
On Thu, Apr 9, 2015 at 10:07 PM, Jim Mooney wrote: [Previously, I wrote:] >> I'll need to see some actual code (namely, where and how you used >> os.walk) to have any real idea of what's going on. The online docs for >> os.walk have a pretty good explanation and example. > > > This worked. I didn'

Re: [Tutor] annoying directory structure

2015-04-09 Thread Zachary Ware
On Thu, Apr 9, 2015 at 2:02 PM, Jim Mooney wrote: > "The safest method would probably be to do `pip freeze > requirements.txt`, > copy the requirements.txt file to the new machine, and run `pip install -r > requirements.txt" --Zach > > I looked at pip3 help (windows) and don't see a -r command. H

Re: [Tutor] migrating python to a new machine

2015-04-08 Thread Zachary Ware
On Apr 8, 2015 3:39 AM, "Jim Mooney" wrote: > > General question. I'm thinking of moving to a new machine although I hate > to abandon trusty XP. Will I have to reinstall all my pip installed modules > or can I just copy the site-packages directory? And if so, is anything else > needed, such as wh

Re: [Tutor] Unexpected results using enumerate() and .split()

2015-03-31 Thread Zachary Ware
On Tue, Mar 31, 2015 at 3:37 PM, boB Stepp wrote: > On Tue, Mar 31, 2015 at 3:28 PM, Zachary Ware > wrote: >> On Tue, Mar 31, 2015 at 3:23 PM, boB Stepp wrote: >>> The following behavior has me stumped: >>> >>> Python 2.7.8 (default, Jun 30 2014, 16:03

Re: [Tutor] Unexpected results using enumerate() and .split()

2015-03-31 Thread Zachary Ware
On Tue, Mar 31, 2015 at 3:23 PM, boB Stepp wrote: > The following behavior has me stumped: > > Python 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit > (Intel)] on win32 > Type "copyright", "credits" or "license()" for more information. L = ['#ROI:roi_0', '#TXT:text_0', '#1:one^two^

Re: [Tutor] file exists question

2015-03-09 Thread Zachary Ware
On Mar 9, 2015 7:25 PM, "Steven D'Aprano" wrote: > What I really want is an option to open() that only > opens a new file, and fails if the file already exists. If I'm not mistaken, this is the 'x' open mode, added in Python 3.4 (or maybe 3.3, I forget). -- Zach _

Re: [Tutor] Python 3 simple socket issue

2015-02-18 Thread Zachary Ware
On Wed, Feb 18, 2015 at 9:48 AM, Juan C. wrote: > We\'re sorry.. but your computer or network may be > sending automated queries. To protect our users, we can\'t process your > request right now.See https://support.google.com/websearch/answer/86640";>Google Help for more > information.https://

Re: [Tutor] How to easily recover the current index when using Python-style for loops?

2015-02-05 Thread Zachary Ware
On Thu, Feb 5, 2015 at 11:30 AM, boB Stepp wrote: > Python 2.4.4, Solaris 10. > > a_list = [item1, item2, item3] > for item in a_list: > print 'Item number', ???, 'is:', item > > Is there an easy, clever, Pythonic way (other than setting up a > counter) to replace ??? with the current index of

Re: [Tutor] Why is an instance smaller than the sum of its components?

2015-02-03 Thread Zachary Ware
On Tue, Feb 3, 2015 at 3:59 PM, Emile van Sebille wrote: > On 2/3/2015 1:12 PM, Jugurtha Hadjar wrote: >> 2 - Why are foo() and bar() the same size, even with bar()'s 4 integers? > > neither foo() nor bar() return anything explicitly, so both return the > default none This is not correct, foo() a

[Tutor] How to change default path output of 'logging'?

2014-12-22 Thread Zachary Ware
On Monday, December 22, 2014, Juan Christian > wrote: > I have a 'logging' on my code using: > > import logging > < ... > > logging.basicConfig(filename="bumpr.log", level=logging.INFO) > < ... > > > The thing is that the default location of this output when running via > Windows Task Scheduler is

Re: [Tutor] ran into a problem with pip install

2014-11-24 Thread Zachary Ware
On Mon, Nov 24, 2014 at 10:28 PM, Clayton Kirkwood wrote: > I was trying to pip install beautifulsoup and ran into the following error. > It appears to be 2.x because of the print. Your diagnosis is correct, beautifulsoup 3.2.1 is written for Python 2. > I am installing to a python 3.4.2. What d

Re: [Tutor] "Philosophical" question about string slicing from end of a string

2014-11-24 Thread Zachary Ware
On Mon, Nov 24, 2014 at 1:06 PM, boB Stepp wrote: > On Mon, Nov 24, 2014 at 12:57 PM, Zachary Ware > wrote: > [...] >> >> Have I clarified or muddied it for you? :) > > Clarified, I believe, if my following statements are correct: I did > not consider that t

Re: [Tutor] "Philosophical" question about string slicing from end of a string

2014-11-24 Thread Zachary Ware
On Mon, Nov 24, 2014 at 12:32 PM, boB Stepp wrote: > Python 2.7.8 > Win7Pro > str = "0123456789" str[-1] > '9' str[-3:-1] > '78' str[-3:] > '789' > > I understand that the above is "the way it is" in Python, but I am > puzzled why the designers did not choose that str[-3:-1] re

Re: [Tutor] Installing both Python 2.7 and Python 3.4 on Windows 7 Pro 64-bit: Install Python 2.7 FIRST!

2014-10-10 Thread Zachary Ware
On Sat, Oct 11, 2014 at 12:30 AM, boB Stepp wrote: > On Sat, Oct 11, 2014 at 12:24 AM, boB Stepp wrote: >> Cannot locate either of the mentioned py.ini files. I did a search for >> these on my PC and came up empty. I am going to try to create my own >> py.ini file and place it in C:\WINDOWS and s

[Tutor] Fwd: Installing both Python 2.7 and Python 3.4 on Windows 7 Pro 64-bit: Install Python 2.7 FIRST!

2014-10-10 Thread Zachary Ware
On Fri, Oct 10, 2014 at 11:34 PM, boB Stepp wrote: > I can live with 2.7.8 being the default Python, but if I wanted to > make 3.4.2 the default, how would I go about doing it? Check the output of "ftype Python.File", it should be: C:\>ftype Python.File Python.File="C:\Windows\py.exe" "%1" %*

Re: [Tutor] New to Python - print function - invalid syntax

2014-08-05 Thread Zachary Ware
On Tue, Aug 5, 2014 at 9:56 AM, Marc Tompkins wrote: > On Tue, Aug 5, 2014 at 12:48 AM, Maxime Steisel > wrote: >> I think this is because on windows, *.py files are associated with py.exe >> that choose the python version depending on the first line of your file. > > No. *ix operating systems

Re: [Tutor] conditional execution

2014-04-01 Thread Zachary Ware
Hi Patti, On Tue, Apr 1, 2014 at 11:07 AM, Patti Scott wrote: > I've been cheating: comment out the conditional statement and adjust the > indents. But, how do I make my program run with if __name__ == 'main': > main() at the end? I thought I understood the idea to run a module called > directl

Re: [Tutor] how do i delete the questions that i asked and it has been shared in web

2014-03-12 Thread Zachary Ware
On Wed, Mar 12, 2014 at 12:46 PM, S Tareq wrote: > this one http://code.activestate.com/lists/python-tutor/99408/ > > and there are other ones as well This is a mailing list. Once an email is sent, you can't unsend it. -- Zach ___ Tutor maillist -

Re: [Tutor] could please convert this code to 3.X by using 2to3

2014-02-18 Thread Zachary Ware
On Tue, Feb 18, 2014 at 12:18 PM, S Tareq wrote: > i am to convert coding to python 3.X. and some one told me to use 2to3 > program but i don't how to use 2to3 program i was reading and followed the > rules in python website ( > http://docs.python.org/3/library/2to3.html?highlight=2to3#module-lib

Re: [Tutor] Regular expression - I

2014-02-18 Thread Zachary Ware
On Tue, Feb 18, 2014 at 11:39 AM, Zachary Ware wrote: >>>> '' >'' > > The equivalent raw string is exactly the same in this case: > >>>> r'' >'' Oops, I mistyped both of t

Re: [Tutor] Regular expression - I

2014-02-18 Thread Zachary Ware
Hi Santosh, On Tue, Feb 18, 2014 at 9:52 AM, Santosh Kumar wrote: > > Hi All, > > If you notice the below example, case I is working as expected. > > Case I: > In [41]: string = "test" > > In [42]: re.match('',string).group() > Out[42]: '' > > But why is the raw string 'r' not working as expected

Re: [Tutor] Beginner - explaining 'Flip a coin' bug

2014-02-12 Thread Zachary Ware
Hi Marc, On Wed, Feb 12, 2014 at 9:25 AM, Marc Eymard wrote: > Hello there, > > I want to emulate a coin flip and count how many heads and tails when > flipping it a hundred times. > > I first coded coinflip_WRONG.py with "count_flips += 1" statement within the > if/else block. > When running it,

Re: [Tutor] subtyping builtin type

2013-12-31 Thread Zachary Ware
On Tue, Dec 31, 2013 at 11:53 AM, eryksun wrote: > Minor correction: > > It says str requires empty __slots__, but that's a bug in the docs. > It's referring to 2.x str. Else this thread wouldn't exist. In 3.x, > str is basically the unicode type from 2.x. Its __itemsize__ is 0 > because the char

Re: [Tutor] subtyping builtin type

2013-12-31 Thread Zachary Ware
On Tue, Dec 31, 2013 at 10:21 AM, Mark Lawrence wrote: > The glossary entry for __slots__ states "A declaration inside a class that > saves memory by pre-declaring space for instance attributes and eliminating > instance dictionaries. Though popular, the technique is somewhat tricky to > get right

Re: [Tutor] subtyping builtin type

2013-12-31 Thread Zachary Ware
On Tue, Dec 31, 2013 at 9:22 AM, spir wrote: > Thank you, Oscar & Zachary. I guess thus the way it is done is correct (for > my case), is it? Seems your last remark shows the source of my confusion: > probably, in past times, I subtyped builtin types and overrided their > __new__, thus had to call

Re: [Tutor] subtyping builtin type

2013-12-31 Thread Zachary Ware
On Tue, Dec 31, 2013 at 8:35 AM, spir wrote: > Hello, > > I don't remember exactly how to do that. As an example: > > class Source (str): > __slots__ = ['i', 'n'] > def __init__ (self, string): > self.i = 0 # current matching index in source > self.n = len(

Re: [Tutor] Built In Functions

2013-12-17 Thread Zachary Ware
On Tue, Dec 17, 2013 at 10:37 AM, Wolfgang Maier wrote: > Peter Otten <__peter__ web.de> writes: > >> Look at this line: >> >> > if __name__ == " __main__": >> > > do so very closely :) In monospaced font :) Took me forever to see it, thanks Gmail... -- Zach __

Re: [Tutor] unstring

2013-06-18 Thread Zachary Ware
Jim Mooney wrote: >Is there a way to unstring something? That is str(object) will give me >a string, but what if I want the original object back, for some >purpose, without a lot of foofaraw? Only by keeping the original reference to the object. str(object) produces a new object that has absolu

Re: [Tutor] Issue with string method: str(variable ** n)

2013-05-16 Thread Zachary Ware
On Thu, May 16, 2013 at 1:58 PM, Rafael Knuth wrote: > Hej, Hi Rafael, > I wrote a tiny little program which I was hoping would take a number as > input, square and print it: > > square = input ("Enter a number. ") > print (str(square) + " squared is " + str(square ** 2)) > > It seems I can't wo

Re: [Tutor] exit message

2013-05-05 Thread Zachary Ware
On Sun, May 5, 2013 at 11:24 PM, Jim Mooney wrote: > > I've noticed that if you exit() a program you always get a traceback message: > Traceback (most recent call last): > File "", line 1, in > exit('what now?') > File "C:\Python33\lib\site.py", line 380, in __call__ > raise SystemExi

Re: [Tutor] stumped by what looks like recursive list comprehension

2013-05-05 Thread Zachary Ware
On Sun, May 5, 2013 at 11:56 AM, Jim Mooney wrote: > I looked up "list comprehension" after the last explanation and it's > really cool. But the example below stumps me. I understand the second > part, "primes =" but the first part, "noprimes =" baffles me since it > swaps i and j back and forth i