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
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
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
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
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
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
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]:
>
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
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
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
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
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
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
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
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
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,
--
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
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
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
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
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
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
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):
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
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
On Tue, Feb 7, 2017 at 12:59 PM, Alan Gauld via Tutor <tutor@python.org> 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 work
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
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):
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
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
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 <alan.ga...@btinternet.com> wrote:
> On 15/02/16 21:08, Zachary Ware wrote:
>> This is not all asyncio can do. Callbacks are only one way of using i
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
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
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
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')
>
On Wed, Oct 28, 2015 at 11:09 AM, Zachary Ware
<zachary.ware+py...@gmail.com> 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' should be l
On Wed, Oct 28, 2015 at 11:09 AM, Zachary Ware
<zachary.ware+py...@gmail.com> 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
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
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:
On Aug 26, 2015 9:03 PM, Steven D'Aprano st...@pearwood.info wrote:
- If your database lives on a NTFS partition, which is very common for
Linux/Unix users
snip
these issues, especially on Linux when using NTFS.
Surely you mean NFS, as in Network FileSystem, rather than NTFS as in New
On Mon, Aug 17, 2015 at 10:44 PM, boB Stepp robertvst...@gmail.com 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
On Thu, Aug 13, 2015 at 11:31 PM, boB Stepp robertvst...@gmail.com 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
On Saturday, July 25, 2015, boB Stepp robertvst...@gmail.com
javascript:_e(%7B%7D,'cvml','robertvst...@gmail.com'); 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
On Apr 15, 2015 9:38 AM, boB Stepp robertvst...@gmail.com 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
On Apr 15, 2015 9:59 AM, boB Stepp robertvst...@gmail.com wrote:
On Wed, Apr 15, 2015 at 8:50 AM, Zachary Ware
zachary.ware+py...@gmail.com wrote:
On Apr 15, 2015 9:38 AM, boB Stepp robertvst...@gmail.com wrote:
Perhaps I am being foolish! But I do have my reasons, which, in this
case
On Thu, Apr 9, 2015 at 10:07 PM, Jim Mooney cybervigila...@gmail.com 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
On Thu, Apr 9, 2015 at 2:02 PM, Jim Mooney cybervigila...@gmail.com 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
On Apr 8, 2015 3:39 AM, Jim Mooney cybervigila...@gmail.com 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
On Tue, Mar 31, 2015 at 3:23 PM, boB Stepp robertvst...@gmail.com 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',
On Tue, Mar 31, 2015 at 3:37 PM, boB Stepp robertvst...@gmail.com wrote:
On Tue, Mar 31, 2015 at 3:28 PM, Zachary Ware
zachary.ware+py...@gmail.com wrote:
On Tue, Mar 31, 2015 at 3:23 PM, boB Stepp robertvst...@gmail.com wrote:
The following behavior has me stumped:
Python 2.7.8 (default
On Mar 9, 2015 7:25 PM, Steven D'Aprano st...@pearwood.info 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
On Wed, Feb 18, 2015 at 9:48 AM, Juan C. juan0christ...@gmail.com wrote:
h1We\'re sorry.../h1p... but your computer or network may be
sending automated queries. To protect our users, we can\'t process your
request right now./p/divdiv style=margin-left: 4em;See a href=
On Thu, Feb 5, 2015 at 11:30 AM, boB Stepp robertvst...@gmail.com 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
On Tue, Feb 3, 2015 at 3:59 PM, Emile van Sebille em...@fenx.com 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
On Monday, December 22, 2014, Juan Christian juan0christ...@gmail.com
javascript:_e(%7B%7D,'cvml','juan0christ...@gmail.com'); 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
On Mon, Nov 24, 2014 at 12:32 PM, boB Stepp robertvst...@gmail.com 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] returns
On Mon, Nov 24, 2014 at 1:06 PM, boB Stepp robertvst...@gmail.com wrote:
On Mon, Nov 24, 2014 at 12:57 PM, Zachary Ware
zachary.ware+py...@gmail.com wrote:
[...]
Have I clarified or muddied it for you? :)
Clarified, I believe, if my following statements are correct: I did
not consider
On Mon, Nov 24, 2014 at 10:28 PM, Clayton Kirkwood c...@godblessthe.us 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
Forwarding my original to the list, as I failed earlier
On Fri, Oct 10, 2014 at 11:34 PM, boB Stepp robertvst...@gmail.com 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
On Sat, Oct 11, 2014 at 12:30 AM, boB Stepp robertvst...@gmail.com wrote:
On Sat, Oct 11, 2014 at 12:24 AM, boB Stepp robertvst...@gmail.com 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
On Tue, Aug 5, 2014 at 9:56 AM, Marc Tompkins marc.tompk...@gmail.com wrote:
On Tue, Aug 5, 2014 at 12:48 AM, Maxime Steisel maximestei...@gmail.com
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
Hi Patti,
On Tue, Apr 1, 2014 at 11:07 AM, Patti Scott pscott...@yahoo.com 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
On Wed, Mar 12, 2014 at 12:46 PM, S Tareq stare...@yahoo.com 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
___
Hi Santosh,
On Tue, Feb 18, 2014 at 9:52 AM, Santosh Kumar rhce@gmail.com wrote:
Hi All,
If you notice the below example, case I is working as expected.
Case I:
In [41]: string = H*testH*
In [42]: re.match('H\*',string).group()
Out[42]: 'H*'
But why is the raw string 'r' not
On Tue, Feb 18, 2014 at 11:39 AM, Zachary Ware
zachary.ware+py...@gmail.com wrote:
snip
'H\*'
'H\*'
The equivalent raw string is exactly the same in this case:
r'H\*'
'H\*'
Oops, I mistyped both of these. The repr should be 'H\\*' in both cases.
Sorry for the confusion
On Tue, Feb 18, 2014 at 12:18 PM, S Tareq stare...@yahoo.com 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 (
Hi Marc,
On Wed, Feb 12, 2014 at 9:25 AM, Marc Eymard marc_eym...@hotmail.com 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.
On Tue, Dec 31, 2013 at 8:35 AM, spir denis.s...@gmail.com 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
On Tue, Dec 31, 2013 at 9:22 AM, spir denis.s...@gmail.com 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__,
On Tue, Dec 31, 2013 at 10:21 AM, Mark Lawrence breamore...@yahoo.co.uk 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
On Tue, Dec 31, 2013 at 11:53 AM, eryksun eryk...@gmail.com 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
On Tue, Dec 17, 2013 at 10:37 AM, Wolfgang Maier
wolfgang.ma...@biologie.uni-freiburg.de wrote:
Peter Otten __peter__ at 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
Jim Mooney cybervigila...@gmail.com 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
On Thu, May 16, 2013 at 1:58 PM, Rafael Knuth rafael.kn...@gmail.com 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
On Sun, May 5, 2013 at 11:56 AM, Jim Mooney cybervigila...@gmail.com
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
On Sun, May 5, 2013 at 11:24 PM, Jim Mooney cybervigila...@gmail.com wrote:
I've noticed that if you exit() a program you always get a traceback message:
Traceback (most recent call last):
File pyshell#1, line 1, in module
exit('what now?')
File C:\Python33\lib\site.py, line 380, in
76 matches
Mail list logo