Re: l = range(int(1E9))

2015-05-02 Thread Ian Kelly
On Sat, May 2, 2015 at 5:51 PM, Terry Reedy wrote: > On 5/2/2015 5:31 PM, Ian Kelly wrote: > >> Would it have been better if range() had been implemented as xrange() >> from the beginning? Sure, that would have been great. Except for one >> small detail: the iterator pr

Re: when does newlines get set in universal newlines mode?

2015-05-04 Thread Ian Kelly
On Mon, May 4, 2015 at 9:17 AM, Peter Otten <__pete...@web.de> wrote: > OK, you convinced me. Then I tried: > with open("tmp.txt", "wb") as f: f.write("0\r\n3\r5\n7") > ... assert len(open("tmp.txt", "rb").read()) == 8 f = open("tmp.txt", "rU") f.readline() > '0\n' f.newlin

Re: Bitten by my C/Java experience

2015-05-04 Thread Ian Kelly
On Mon, May 4, 2015 at 9:20 AM, Cecil Westerhof wrote: > Potential dangerous bug introduced by programming in Python as if it > was C/Java. :-( > I used: > ++tries > that has to be: > tries += 1 > > Are there other things I have to be careful on? That does not work as > in C/Java, but is c

Re: Bitten by my C/Java experience

2015-05-04 Thread Ian Kelly
On Mon, May 4, 2015 at 11:59 AM, Mark Lawrence wrote: > On 04/05/2015 16:20, Cecil Westerhof wrote: >> >> Potential dangerous bug introduced by programming in Python as if it >> was C/Java. :-( >> I used: >> ++tries >> that has to be: >> tries += 1 >> >> Are there other things I have to

Re: Why from en to two times with sending email

2015-05-04 Thread Ian Kelly
On Mon, May 4, 2015 at 12:59 PM, Cecil Westerhof wrote: > I want to change an old Bash script to Python. When I look at: > https://docs.python.org/2/library/email-examples.html > > Then from and to have to be used two times? Why is that? Once to construct the message headers, and once to inst

Re: Step further with filebasedMessages

2015-05-05 Thread Ian Kelly
On May 5, 2015 5:46 AM, "Cecil Westerhof" wrote: > > Op Tuesday 5 May 2015 12:41 CEST schreef Steven D'Aprano: > > > # Untested. > > def get_message_slice(message_filename, start=0, end=None, step=1): > > real_file = expanduser(message_filename) > > messages = [] > > # FIXME: I assume this is expe

Re: asyncio: What is the difference between tasks, futures, and coroutines?

2015-05-05 Thread Ian Kelly
On Tue, May 5, 2015 at 9:22 AM, Paul Moore wrote: > I'm working my way through the asyncio documentation. I have got to the > "Tasks and coroutines" section, but I'm frankly confused as to the difference > between the various things described in that section: coroutines, tasks, and > futures.

Re: Throw the cat among the pigeons

2015-05-05 Thread Ian Kelly
On Tue, May 5, 2015 at 12:45 PM, Dave Angel wrote: > When the "simple" is True, the function takes noticeably and consistently > longer. For example, it might take 116 instead of 109 seconds. For the > same counts, your code took 111. I can't replicate this. What version of Python is it, and wh

Re: Throw the cat among the pigeons

2015-05-05 Thread Ian Kelly
On Tue, May 5, 2015 at 3:00 PM, Dave Angel wrote: > def loop(func, funcname, arg): > start = time.time() > for i in range(repeats): > func(arg, True) > print("{0}({1}) took {2:7.4}".format(funcname, arg, time.time()-start)) > > start = time.time() > for i in range(repea

Re: Throw the cat among the pigeons

2015-05-05 Thread Ian Kelly
On Tue, May 5, 2015 at 3:23 PM, Ian Kelly wrote: > On Tue, May 5, 2015 at 3:00 PM, Dave Angel wrote: >> def loop(func, funcname, arg): >> start = time.time() >> for i in range(repeats): >> func(arg, True) >> print("{0}({1}) took {2

Re: Throw the cat among the pigeons

2015-05-05 Thread Ian Kelly
On Tue, May 5, 2015 at 7:27 PM, Steven D'Aprano wrote: > Only the minimum is statistically useful. I disagree. The minimum tells you how fast the code *can* run, under optimal circumstances. The mean tells you how fast it *realistically* runs, under typical load. Both can be useful to measure. --

Re: Throw the cat among the pigeons

2015-05-06 Thread Ian Kelly
On Wed, May 6, 2015 at 9:12 AM, Paul Rubin wrote: > Steven D'Aprano writes: >> Multiplying upwards seems to be more expensive than multiplying >> downwards... I can only guess that it has something to do with the way >> multiplication is implemented, or perhaps the memory management >> involved,

Re: Throw the cat among the pigeons

2015-05-06 Thread Ian Kelly
On Wed, May 6, 2015 at 1:08 AM, Steven D'Aprano wrote: > On Wednesday 06 May 2015 15:58, Ian Kelly wrote: > >> On Tue, May 5, 2015 at 7:27 PM, Steven D'Aprano >> wrote: >>> Only the minimum is statistically useful. >> >> I disagree. The min

Re: Writing list of dictionaries to CSV

2015-05-06 Thread Ian Kelly
On Wed, May 6, 2015 at 12:22 PM, Tim Chase wrote: > On 2015-05-06 19:08, MRAB wrote: >> You could tell it to quote any value that's not a number: >> >> w = csv.DictWriter(f, pol_keys, >> quoting=csv.QUOTE_NONNUMERIC) >> >> It looks like all of the values you have are strings, so they'll >> a

Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API

2015-05-07 Thread Ian Kelly
On Thu, May 7, 2015 at 8:03 AM, Chris Angelico wrote: > On Thu, May 7, 2015 at 11:44 PM, Marko Rauhamaa wrote: >> Whole programming cultures, idioms and "right ways" differ between >> platforms. What's the right way to write a service (daemon)? That's >> probably completely different between Wind

Re: functions, optional parameters

2015-05-08 Thread Ian Kelly
On May 8, 2015 9:26 AM, "Steven D'Aprano" < steve+comp.lang.pyt...@pearwood.info> wrote: > > Do you think that Python will re-compile the body of the function every time > you call it? Setting the default is part of the process of compiling the > function. To be a bit pedantic, that's not accurate

Re: How to properly apply OOP in the bouncing ball code

2015-05-08 Thread Ian Kelly
On May 8, 2015 9:46 AM, "Tommy C" wrote: > > I'm trying to apply OOP in this bouncing ball code in order to have multiple balls bouncing around the screen. The objective of this code is to create a method called settings, which controls all the settings for the screen and the bouncing behaviour of

Re: functions, optional parameters

2015-05-09 Thread Ian Kelly
On Fri, May 8, 2015 at 9:50 AM, Michael Welle wrote: > > Steven D'Aprano writes: >> >> If your language uses late binding, it is very inconvenient to get early >> binding when you want it. But if your language uses early binding, it is >> very simple to get late binding when you want it: just put

Re: Moving to Python 3.x

2015-05-09 Thread Ian Kelly
On Sat, May 9, 2015 at 12:30 PM, Antranig Vartanian wrote: > Hay, > > I learned the basics of python using the book "Think Python" > (http://www.greenteapress.com/thinkpython/) which was good (IMHO), and it > teaches in Python 2.7. Now I'm trying to write my first python+gtk program. > > anyways,

Re: Calling a function is faster than not calling it?

2015-05-10 Thread Ian Kelly
On Sun, May 10, 2015 at 10:14 AM, Peter Otten <__pete...@web.de> wrote: > When there was an actual speed-up I also had a look at > PyEval_GetGlobals/Locals() which in turn call > > PyEval_GetFrame() > > and > > PyEvalPyFrame_FastToLocalsWithError() > > whatever these do. (The first function reminde

Re: anomaly

2015-05-10 Thread Ian Kelly
On Sun, May 10, 2015 at 10:34 AM, Mark Rosenblitt-Janssen wrote: > Here's something that might be wrong in Python (tried on v2.7): > class int(str): pass This defines a new class named "int" that is a subclass of str. It has no relation to the builtin class int. int(3) > '3' This crea

Re: Instead of deciding between Python or Lisp for a programming intro course...What about an intro course that uses *BOTH*? Good idea?

2015-05-10 Thread Ian Kelly
On Sun, May 10, 2015 at 3:16 PM, Marko Rauhamaa wrote: > Scheme is my favorite language. I think, however, it is a pretty > advanced language and requires a pretty solid basis in programming and > computer science. > > Python, in contrast, is a great introductory programming language. Sure, > you

Re: code blocks

2015-05-10 Thread Ian Kelly
On Sun, May 10, 2015 at 7:39 PM, zipher wrote: > Similarly, you'd want: > encode(codestr) > > to instantiate all objects in the codestr. You can't do this with eval, > because it doesn't allow assignment (eval(n=2) returns "InvalidSyntax"). Is exec what you're looking for? >>> exec('n = 2

Re: code blocks

2015-05-10 Thread Ian Kelly
On Sun, May 10, 2015 at 9:31 PM, Ian Kelly wrote: > On Sun, May 10, 2015 at 7:39 PM, zipher wrote: >> Similarly, you'd want: >> >>>>> encode(codestr) >> >> to instantiate all objects in the codestr. You can't do this with eval, >&

Re: anomaly

2015-05-12 Thread Ian Kelly
On Tue, May 12, 2015 at 9:34 AM, zipher wrote: >> * when it comes to built-in functions (e.g. sum, map, pow) >> and types (e.g. int, str, list) there are significant and >> important use-cases for allowing shadowing; > > Name one "significant and important" use case for shadowing built-in type

Re: Python file structure

2015-05-12 Thread Ian Kelly
On Tue, May 12, 2015 at 1:29 PM, Chris Angelico wrote: > On Wed, May 13, 2015 at 5:13 AM, wrote: >> If I find an error in command line parameters section I cannot call function >> usage() because it is not defined yet. >> >> I have few options here: >> 1. Put definition of usage function b

Re: Instead of deciding between Python or Lisp for a programming intro course...What about an intro course that uses *BOTH*? Good idea?

2015-05-12 Thread Ian Kelly
On Tue, May 12, 2015 at 9:11 PM, zipher wrote: > I know. That's because most people have fallen off the path > (http://c2.com/cgi/wiki?OneTruePath). You wrote that, didn't you? I recognize that combination of delusional narcissism and curious obsession with Turing machines. > You haven't done

Re: Basic misunderstanding on object creation

2015-05-13 Thread Ian Kelly
On Wed, May 13, 2015 at 8:42 AM, andrew cooke wrote: > On Wednesday, 13 May 2015 11:36:12 UTC-3, Thomas Rachel wrote: >> Am 13.05.2015 um 15:25 schrieb andrew cooke: >> >> class Foo: >> > ... def __new__(cls, *args, **kargs): >> > ... print('new', args, kargs) >> > ... su

Re: Basic misunderstanding on object creation

2015-05-13 Thread Ian Kelly
On Wed, May 13, 2015 at 8:45 AM, andrew cooke wrote: class Foo: > ... def __new__(cls, *args, **kargs): > ... print('new', args, kargs) > ... super().__new__(cls) > ... class Bar(Foo): > ... def __init__(self, a): > ... print('init', a) > ... Bar(1) >

Re: Instead of deciding between Python or Lisp for a programming intro course...What about an intro course that uses *BOTH*? Good idea?

2015-05-13 Thread Ian Kelly
I don't know why I'm replying to this... On Wed, May 13, 2015 at 8:44 AM, zipher wrote: > On Tuesday, May 12, 2015 at 10:35:29 PM UTC-5, Rustom Mody wrote: >> How history U-turns!! >> Lisp actually got every major/fundamental thing wrong >> - variables scopes were dynamic by mistake >> - lambdas

Re: Instead of deciding between Python or Lisp for a programming intro course...What about an intro course that uses *BOTH*? Good idea?

2015-05-13 Thread Ian Kelly
On Wed, May 13, 2015 at 12:07 PM, zipher wrote: > On Wednesday, May 13, 2015 at 10:27:23 AM UTC-5, Ian wrote: >> I don't know why I'm replying to this... > > Because you're trying to get an answer to a question that even Academia > hasn't answered or understood. > >> On Wed, May 13, 2015 at 8:44

Re: a python pitfall

2015-05-14 Thread Ian Kelly
On Thu, May 14, 2015 at 12:06 PM, Billy Earney wrote: > Hello friends: > > I saw the following example at > http://nafiulis.me/potential-pythonic-pitfalls.html#using-mutable-default-arguments > and did not believe the output produced and had to try it for myself See also https://docs.python.

Re: Survey -- Move To Trash function in Python?

2015-05-14 Thread Ian Kelly
On May 14, 2015 7:55 PM, "Chris Angelico" wrote: > (Though when > it comes to the bikeshedding phase, I'm sure there'll be some who say > "if it can't be trashed, just hard delete it", and others who say "if > it can't be trashed, raise an exception". And neither is truly wrong.) The answer is "r

Re: Building CPython

2015-05-15 Thread Ian Kelly
On Fri, May 15, 2015 at 6:43 AM, Steven D'Aprano wrote: > How much time would it save? Probably very little. After all, unless the > method call itself did bugger-all work, the time to create the method > object is probably insignificant. But it's a possible optimization. An interesting alternati

Re: Building CPython

2015-05-15 Thread Ian Kelly
On Fri, May 15, 2015 at 9:00 AM, Ian Kelly wrote: > On Fri, May 15, 2015 at 6:43 AM, Steven D'Aprano > wrote: >> How much time would it save? Probably very little. After all, unless the >> method call itself did bugger-all work, the time to create the method >> obj

Re: Fastest way to remove the first x characters from a very long string

2015-05-16 Thread Ian Kelly
On Sat, May 16, 2015 at 10:22 AM, wrote: > # Chris's Approach > # > lines = ss.split("\n") > new_text = "\n".join(line[8:] for line in lines) Looks like the approach you have may be fast enough already, but I'd wager the generator expression could be replaced with: map(oper

Re: Slices time complexity

2015-05-18 Thread Ian Kelly
On Mon, May 18, 2015 at 1:23 PM, Mario Figueiredo wrote: > I'd like to understand what I'm being told about slices in > https://wiki.python.org/moin/TimeComplexity > > Particularly, what's a 'del slice' and a 'set slice' and whether this > information pertains to both CPython 2.7 and 3.4. "Del Sl

Re: Slices time complexity

2015-05-19 Thread Ian Kelly
On May 19, 2015 4:16 AM, "Serhiy Storchaka" wrote: > > On 19.05.15 12:45, Steven D'Aprano wrote: >> >> On Tuesday 19 May 2015 05:23, Mario Figueiredo wrote: >>> >>> From the above link it seems slices work in linear time on all cases. >> >> >> I wouldn't trust that is always the case, e.g. deleti

Re: Why does the first loop go wrong with Python3

2015-05-19 Thread Ian Kelly
On Tue, May 19, 2015 at 8:44 AM, Cecil Westerhof wrote: > I looked at the documentation. Is it necessary to do a: > p.wait() > afterwards? It's good practice to clean up zombie processes by waiting on them, but they will also get cleaned up when your script exits. -- https://mail.python.org/

Re: Help regarding python run time

2015-05-20 Thread Ian Kelly
On Wed, May 20, 2015 at 7:02 AM, AKHIL RANA wrote: > Hi, > > I am student at IIT Kanpur and working on a Opencv based Python project. I > am working on program development which takes less time to execute. For that > i have tested my small program hello word on python to now the time taken by > th

Re: Help regarding python run time

2015-05-20 Thread Ian Kelly
On Wed, May 20, 2015 at 9:48 AM, Irmen de Jong wrote: > Or measure the actual CPU clock cycles taken instead of the wall clock run > time. > Then you should get a fairly constant number, if the program does the same > work every > time you run it. > > phobos:~ irmen$ time python test.py > real

Re: fork/exec & close file descriptors

2015-05-20 Thread Ian Kelly
On Tue, May 19, 2015 at 7:10 PM, Gregory Ewing wrote: >> On Tue, May 19, 2015 at 8:54 AM, Chris Angelico > > wrote: >> >> On Linux (and possibly some other Unixes), /proc/self/fd may be of >> use. > > > On MacOSX, /dev/fd seems to be the equivalent of this. Not a

Re: No ttk in 2.7

2015-05-20 Thread Ian Kelly
On Wed, May 20, 2015 at 12:54 PM, Cecil Westerhof wrote: > Op Wednesday 20 May 2015 19:03 CEST schreef Zachary Ware: >> try: >> import tkinter as tk >> from tkinter import ttk >> except ImportError: >> import Tkinter as tk >> import ttk > > When there goes something wrong with: > from tkinter

Re: Slices time complexity

2015-05-20 Thread Ian Kelly
On Wed, May 20, 2015 at 1:51 PM, Mario Figueiredo wrote: > On Wed, 20 May 2015 03:07:03 +1000, Steven D'Aprano > wrote: > >>Yes, a slice can be expensive, if you have (say) a ten billion element list, >>and take a slice list[1:]. > > Since nothing seems to surprise you and you seem so adamant on

Re: subprocess.Popen zombie

2015-05-21 Thread Ian Kelly
On May 21, 2015 12:41 AM, "Thomas Rachel" < nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa...@spamschutz.glglgl.de> wrote: > > Am 20.05.2015 um 18:44 schrieb Robin Becker: > >> not really, it's just normal to keep event routines short; the routine >> which beeps is after detection of the cat's entrance

Re: How to do integers to binary lists and back

2015-05-21 Thread Ian Kelly
On Thu, May 21, 2015 at 4:31 PM, Ben Finney wrote: "{foo:d}".format(foo=foo) > '4567' "{foo:b}".format(foo=foo) > '1000111010111' Which since there's nothing else in the format string can be simplified to: >>> format(foo, "b") '1000111010111' -- https://mail.python.org/mailman/listinf

Re: case-sensitive configparser without magical interpolation?

2015-05-22 Thread Ian Kelly
On Fri, May 22, 2015 at 10:59 AM, wrote: > [python 2.7] > I need to use a configparser that is case-sensitive for option names, but > does not do magical interpolation of percent sign. > I.e.: > > [Mapping0] > backupHost = eng%26 > dbNode = v_br_node0001 > > should be read (and later written) as

Re: Ah Python, you have spoiled me for all other languages

2015-05-22 Thread Ian Kelly
On Fri, May 22, 2015 at 1:34 PM, MRAB wrote: > On 2015-05-22 20:14, Laura Creighton wrote: >> >> The first time you discover that in javascript typeof(null) is 'object' >> and >> not 'null' you will scream. I wonder how many home versions of typeof >> to replace the system one exist out in the wi

Re: Ah Python, you have spoiled me for all other languages

2015-05-22 Thread Ian Kelly
On Fri, May 22, 2015 at 2:55 PM, Tim Chase wrote: > I've wondered this on multiple occasions, as I've wanted to just make > an attribute bag and have to do something like > > class AttrBag(object): pass > ab = AttrBag() > ab.x = 42 > ab.y = "some other value" > > because just doing > > a

Re: Ah Python, you have spoiled me for all other languages

2015-05-22 Thread Ian Kelly
On Fri, May 22, 2015 at 9:31 PM, Michael Torrie wrote: > On 05/22/2015 07:54 PM, Terry Reedy wrote: >> On 5/22/2015 5:40 PM, Tim Daneliuk wrote: >> >>> Lo these many years ago, I argued that Python is a whole lot more than >>> a programming language: >>> >>> https://www.tundraware.com/Technica

Re: Ah Python, you have spoiled me for all other languages

2015-05-22 Thread Ian Kelly
On Fri, May 22, 2015 at 10:20 PM, Ben Finney wrote: > Ian Kelly writes: > >> On Fri, May 22, 2015 at 9:31 PM, Michael Torrie wrote: >> > On 05/22/2015 07:54 PM, Terry Reedy wrote: >> >> On 5/22/2015 5:40 PM, Tim Daneliuk wrote: >> >> >> >

Re: Ah Python, you have spoiled me for all other languages

2015-05-22 Thread Ian Kelly
On Fri, May 22, 2015 at 10:30 PM, Michael Torrie wrote: > On 05/22/2015 10:10 PM, Ian Kelly wrote: >> Sure it is. Without some prior reason to trust the certificate, the >> certificate is meaningless. How is the browser to distinguish between >> a legitimate self-signed c

Re: Human Rights and Justice in Islam

2015-05-24 Thread Ian Kelly
On Sat, May 23, 2015 at 5:34 PM, hamilton wrote: > So if you are a Member of Islamic State you have rights, other wise you are > an infidel and subject to death from the whim of Allah or whom ever thinks > they are Allah. > > > Does that sound right ?? Please don't reply to spammers. I guarantee

Re: Ah Python, you have spoiled me for all other languages

2015-05-24 Thread Ian Kelly
On Sat, May 23, 2015 at 8:57 PM, Michael Torrie wrote: > On 05/23/2015 05:40 AM, Chris Angelico wrote: >> On Sat, May 23, 2015 at 9:34 PM, Tim Chase >> wrote: >>> A self-signed certificate may be of minimal worth the *first* time you >>> visit a site, but if you return to the site, that initial >

Re: mix-in classes

2015-05-24 Thread Ian Kelly
On Sat, May 23, 2015 at 7:53 PM, Dr. John Q. Hacker wrote: > The post on "different types of inheritence..." brought up a thought. > > Let's say, I'm adding flexibility to a module by letting users change class > behaviors by adding different mix-in classes. > > What should happen when there's a n

Re: Documentaion of dunder methods

2015-05-25 Thread Ian Kelly
On Mon, May 25, 2015 at 8:17 PM, Steven D'Aprano wrote: > PEP 8 states that developers should never invent their own dunder methods: > > __double_leading_and_trailing_underscore__ : > "magic" objects or attributes that live in user-controlled > namespaces. E.g. __init__ , __imp

Re: a more precise distance algorithm

2015-05-25 Thread Ian Kelly
On Mon, May 25, 2015 at 1:21 PM, ravas wrote: > I read an interesting comment: > """ > The coolest thing I've ever discovered about Pythagorean's Theorem is an > alternate way to calculate it. If you write a program that uses the distance > form c = sqrt(a^2 + b^2) you will suffer from the lose

Re: different types of inheritence...

2015-05-26 Thread Ian Kelly
On Tue, May 26, 2015 at 2:52 PM, Michael Torrie wrote: > On 05/26/2015 08:57 AM, zipher wrote: >> Comprende? I'm not trying to be cryptic here. This is a bit of OOP >> theory to be discussed. > > No, sorry. Maybe an actual example (with use case) would spur discussion. Better yet, ignore the t

Re: should "self" be changed?

2015-05-28 Thread Ian Kelly
On Thu, May 28, 2015 at 9:01 AM, Marko Rauhamaa wrote: > Anssi Saari : > >> Do you have an example of state pattern using nested classes and >> python? With a quick look I didn't happen to find one in any language. > > Here's an sampling from my mail server: I think I would be more inclined to us

Re: Fwd: Lossless bulletproof conversion to unicode (backslashing) (fwd)

2015-05-29 Thread Ian Kelly
On Fri, May 29, 2015 at 2:05 AM, anatoly techtonik wrote: > Added Mailman to my suxx tracker: > https://github.com/techtonik/suxx-tracker#mailman What a useless tool. Instead of tiredly complaining that things suck, why not take some initiative to make them better? I'm curious about your complai

Re: Fwd: Lossless bulletproof conversion to unicode (backslashing) (fwd)

2015-05-29 Thread Ian Kelly
On Fri, May 29, 2015 at 4:44 AM, Jon Ribbens wrote: > On 2015-05-29, Ian Kelly wrote: >> On Fri, May 29, 2015 at 2:05 AM, anatoly techtonik >> wrote: >>> Added Mailman to my suxx tracker: >>> https://github.com/techtonik/suxx-tracker#mailman >> >

Re: What use for reversed()?

2015-05-31 Thread Ian Kelly
On Sun, May 31, 2015 at 1:58 PM, Denis McMahon wrote: > reversed returns an iterator, not a list, so it returns the reversed list > of elements one at a time. You can use list() or create a list from > reversed and then join the result: > > $ python > Python 2.7.3 (default, Dec 18 2014, 19:10:20)

Re: lotto number generator

2015-06-01 Thread Ian Kelly
On Mon, Jun 1, 2015 at 10:23 AM, gm wrote: > Hi. > I am new to python so am still in learning phase. > > I was thinking to make one program that will print out all possible > combinations of 10 pairs. I think this is a good way for something "bigger" > :-). > > This is how this looks like: > > 1.)

Re: lotto number generator

2015-06-01 Thread Ian Kelly
On Mon, Jun 1, 2015 at 11:13 AM, Ian Kelly wrote: > On Mon, Jun 1, 2015 at 10:23 AM, gm wrote: >> Hi. >> I am new to python so am still in learning phase. >> >> I was thinking to make one program that will print out all possible >> combinations of 10 pair

Re: Using a particular python binary with venv

2015-06-01 Thread Ian Kelly
On Mon, Jun 1, 2015 at 3:33 PM, wrote: > According to this https://docs.python.org/3.4/library/venv.html#module-venv > 'Each virtual environment has its own Python binary (allowing creation of > environments with various Python versions)' > So how would I create a virtual environment using the

Re: How to access the low digits of a list

2015-06-02 Thread Ian Kelly
On Tue, Jun 2, 2015 at 6:35 AM, Rustom Mody wrote: > For that matter even this works > But I am not sure whats happening or that I like it > [x[-2:] for x in lines] > ['12', '42', '49', '56', '25', '36', '49', '64', '81', '00'] x[-2:] selects all items in the sequence with index i such that

Re: Everything is an object in python - object class and type class

2015-06-02 Thread Ian Kelly
On Mon, Jun 1, 2015 at 4:59 PM, BartC wrote: > I'm developing a new language along the lines of Python, perhaps a brief > description of how things are done there might help. Or just give a > different perspective. > > Objects in this language are tagged: there's a code attached to each > indicati

Re: Everything is an object in python - object class and type class

2015-06-02 Thread Ian Kelly
On Tue, Jun 2, 2015 at 12:10 PM, Ned Batchelder wrote: > On Tuesday, June 2, 2015 at 1:59:37 PM UTC-4, BartC wrote: >> Javascript primitives include Number and String. >> >> What does Python allow to be done with its Number (int, etc) and String >> types that can't be done with their Javascript co

Re: Everything is an object in python - object class and type class

2015-06-02 Thread Ian Kelly
On Tue, Jun 2, 2015 at 3:47 PM, Mark Lawrence wrote: > The classic response to "Super Considered Harmful" for those who may be > interested is > https://rhettinger.wordpress.com/2011/05/26/super-considered-super/ and > recently https://www.youtube.com/watch?v=EiOglTERPEo I feel slightly cheated.

Re: should "self" be changed?

2015-06-02 Thread Ian Kelly
On Tue, Jun 2, 2015 at 11:19 AM, Marko Rauhamaa wrote: > Steven D'Aprano : > >> On Fri, 29 May 2015 12:00 pm, Steven D'Aprano wrote: >> >> [...] >>> in a language where classes are >>> themselves values, there is no reason why a class must be instantiated, >>> particularly if you're only using a s

Re: Everything is an object in python - object class and type class

2015-06-03 Thread Ian Kelly
On Wed, Jun 3, 2015 at 2:57 AM, Marko Rauhamaa wrote: > Steven D'Aprano : > >> On Wednesday 03 June 2015 08:33, Marko Rauhamaa wrote: >>> In Python, classes are little more than constructor functions. >> >> [...] >> >> Classes give you an inheritance hierarchy. > > That's encapsulated in the const

Re: How to access the low digits of a list

2015-06-03 Thread Ian Kelly
On Wed, Jun 3, 2015 at 3:08 PM, Rustom Mody wrote: > On Tuesday, June 2, 2015 at 7:50:58 PM UTC+5:30, Ian wrote: >> On Tue, Jun 2, 2015 at 6:35 AM, Rustom Mody wrote: >> > For that matter even this works >> > But I am not sure whats happening or that I like it >> > >> [x[-2:] for x in lines

Re: Can Python function return multiple data?

2015-06-04 Thread Ian Kelly
On Wed, Jun 3, 2015 at 3:56 PM, Mark Lawrence wrote: > Now does Python pass by value or by reference? Happily sits back and waits > for 10**6 emails to arrive as this is discussed for the 10**6th time. Troll. -- https://mail.python.org/mailman/listinfo/python-list

Re: How to inverse a particle emitter

2015-06-04 Thread Ian Kelly
On Thu, Jun 4, 2015 at 5:15 PM, wrote: > hey, i really need help, im a straight up beginner in scripting and i need to > figure out how to make an inverted particle emitter using python in maya No idea. This sounds more like a Maya question than a Python question. Maybe there is a Maya forum th

Re: How to inverse a particle emitter

2015-06-04 Thread Ian Kelly
On Thu, Jun 4, 2015 at 5:47 PM, wrote: > On Thursday, June 4, 2015 at 4:15:29 PM UTC-7, stephenp...@gmail.com wrote: >> hey, i really need help, im a straight up beginner in scripting and i need >> to figure out how to make an inverted particle emitter using python in maya > > unfortunitly i hav

Re: Get html DOM tree by only basic builtin moudles

2015-06-05 Thread Ian Kelly
On Fri, Jun 5, 2015 at 12:10 PM, Wesley wrote: > Hi Laura, > Sure, I got special requirement that just parse html file into DOM tree, by > only general basic modules, and based on my DOM tree structure, draft an > bitmap. > > So, could you give me an direction how to get the DOM tree? > Curr

Re: Testing random

2015-06-07 Thread Ian Kelly
On Sun, Jun 7, 2015 at 10:44 AM, Chris Angelico wrote: > On Mon, Jun 8, 2015 at 2:36 AM, Thomas 'PointedEars' Lahn > wrote: >>> The greater the multiplier, the lower the chance that any element will >>> have no hits. >> >> Wrong. >> >>> [ex falso quodlibet] > > Huh. Do you want to explain how, ma

Re: How to find number of whole weeks between dates?

2015-06-10 Thread Ian Kelly
On Wed, Jun 10, 2015 at 11:05 AM, Sebastian M Cheung via Python-list wrote: > Say in 2014 April to May whole weeks would be 7th, 14th 28th April and May > would be 5th, 12th and 19th. So expecting 7 whole weeks in total >>> from datetime import date >>> d1 = date(2014, 4, 7) >>> d2 = date(2014,

Re: Testing random

2015-06-10 Thread Ian Kelly
On Wed, Jun 10, 2015 at 11:03 AM, Thomas 'PointedEars' Lahn wrote: > Jussi Piitulainen wrote: > >> Thomas 'PointedEars' Lahn writes: >>> Jussi Piitulainen wrote: Thomas 'PointedEars' Lahn writes: > 8 3 6 3 1 2 6 8 2 1 6. There are more than four hundred thousand ways to get th

Re: How to find number of whole weeks between dates?

2015-06-10 Thread Ian Kelly
On Wed, Jun 10, 2015 at 2:11 PM, Sebastian M Cheung via Python-list wrote: > On Wednesday, June 10, 2015 at 6:06:09 PM UTC+1, Sebastian M Cheung wrote: >> Say in 2014 April to May whole weeks would be 7th, 14th 28th April and May >> would be 5th, 12th and 19th. So expecting 7 whole weeks in tota

Re: How to find number of whole weeks between dates?

2015-06-10 Thread Ian Kelly
On Wed, Jun 10, 2015 at 8:01 PM, Sebastian M Cheung via Python-list wrote: > yes just whole weeks given any two months, I did looked into calendar module > but couldn't find specifically what i need. >>> cal.monthdays2calendar(2014, 4) + cal.monthdays2calendar(2014, 5) [[(0, 0), (1, 1), (2, 2),

Re: How to find number of whole weeks between dates?

2015-06-10 Thread Ian Kelly
On Wed, Jun 10, 2015 at 9:19 PM, Michael Torrie wrote: > On 06/10/2015 02:11 PM, Sebastian M Cheung via Python-list wrote: >> On Wednesday, June 10, 2015 at 6:06:09 PM UTC+1, Sebastian M Cheung wrote: >>> Say in 2014 April to May whole weeks would be 7th, 14th 28th April and May >>> would be 5th

Re: Error in or

2015-06-11 Thread Ian Kelly
On Thu, Jun 11, 2015 at 9:40 AM, wrote: > if write this it is working fine, but if I write > > if ("AND" in inp1) or ("OR" in inp1) or ("NOT" in inp1) or (">" in inp1) or > ("&" in inp1) or ("MAYBE" in inp1) or ("(" in inp1) or ("*" in inp1) or (''' > " ''' in inp1): > > the portion of (

Re: Error in or

2015-06-11 Thread Ian Kelly
On Thu, Jun 11, 2015 at 10:39 AM, wrote: > On Thursday, June 11, 2015 at 9:20:59 PM UTC+5:30, Ian wrote: >> On Thu, Jun 11, 2015 at 9:40 AM, >> > if write this it is working fine, but if I write >> > >> > if ("AND" in inp1) or ("OR" in inp1) or ("NOT" in inp1) or (">" in inp1) >> > or ("&" i

Re: os.system error returns

2015-06-12 Thread Ian Kelly
On Jun 12, 2015 7:21 AM, "Grawburg" wrote: > > I have a piece of code written for a Raspberry Pi with no explanation for two of the lines -- and I can't find an explanation I understand. > > Here are the lines: > if os.system('modprobe --first-time -q w1_gpio') ==0 > > if os.system('modprobe -q w1

Re: os.system error returns

2015-06-12 Thread Ian Kelly
On Jun 12, 2015 7:54 AM, "Ian Kelly" wrote: > > On Jun 12, 2015 7:21 AM, "Grawburg" wrote: > > > > I have a piece of code written for a Raspberry Pi with no explanation for two of the lines -- and I can't find an explanation I understand. > > &

Re: Java to Python autoconverters

2015-06-12 Thread Ian Kelly
On Jun 12, 2015 6:53 AM, "Stefan Behnel" wrote: > > Sebastian M Cheung via Python-list schrieb am 12.06.2015 um 13:36: > > Are these available? Any good ones to recommend? > > I recommend not doing that. You'd end up with ugly and unidiomatic Python > code that's impossible to maintain, whereas yo

Re: zip as iterator and bad/good practices

2015-06-12 Thread Ian Kelly
On Fri, Jun 12, 2015 at 9:00 AM, Fabien wrote: > Folks, > > I am developing a program which I'd like to be python 2 and 3 compatible. I > am still relatively new to python and I use primarily py3 for development. > Every once in a while I use a py2 interpreter to see if my tests pass > through. >

Re: Path, strings, and lines

2015-06-12 Thread Ian Kelly
On Fri, Jun 12, 2015 at 1:39 PM, Malik Rumi wrote: > I am trying to find a list of strings in a directory of files. Here is my > code: > > # -*- coding: utf-8 -*- > import os > import fileinput > > s2 = os.listdir('/home/malikarumi/Projects/P5/shortstories') Note that the filenames that will be

Re: Testing random

2015-06-12 Thread Ian Kelly
On Fri, Jun 12, 2015 at 3:32 PM, Thomas 'PointedEars' Lahn wrote: > Ian Kelly wrote: > >> The probability of 123456789 and 1 are equal. The probability >> of a sequence containing all nine numbers and a sequence containing >> only 1s are *not* equal. &g

Re: Testing random

2015-06-12 Thread Ian Kelly
On Jun 12, 2015 4:16 PM, "Thomas 'PointedEars' Lahn" wrote: > > Ian Kelly wrote: > > > […] Thomas 'PointedEars' Lahn […] wrote: > >> Ian Kelly wrote: > >>> The probability of 123456789 and 1 are equal. The probabil

Re: Struggling with os.path.join and fileinput (was 'Path, strings, and lines'

2015-06-15 Thread Ian Kelly
On Mon, Jun 15, 2015 at 8:00 PM, Malik Rumi wrote: > I have struggled with this for several hours and not made much progress. I > was not sure if your 'names' variable was supposed to be the same as > 'filenames'. Also, it should be 'os.path.join', not os.join. Anyway, I > thought you had some

Re: Pyitect - Plugin architectural system for Python 3.0+ (feedback?)

2015-06-16 Thread Ian Kelly
On Mon, Jun 8, 2015 at 10:42 PM, Ben Powers wrote: > As importlib has been added in python 3 and up I decided to use it's > abilities to create a plugin system for truly modular development in python. > > Pyitect has the ability to drop in components and resolve dependencies. Even > load different

Re: Creating .exe file in Python

2015-06-16 Thread Ian Kelly
On Tue, Jun 16, 2015 at 9:17 AM, wrote: > On Tuesday, June 16, 2015 at 8:35:39 PM UTC+5:30, Laura Creighton wrote: >> In a message of Tue, 16 Jun 2015 06:56:12 -0700, writes: >> >ii) In a class how may I include if __name__ == "__main__": with multiple >> >methods? But I think this is easy ques

Re: Testing random

2015-06-16 Thread Ian Kelly
On Tue, Jun 16, 2015 at 4:30 PM, wrote: > On Tuesday, June 16, 2015 at 3:01:06 PM UTC-7, Thomas 'PointedEars' Lahn > wrote: >> This should give you pause: In real mathematics, events with zero >> probability can occur. > > Nobody will disagree with that. The probability of me winning the lotter

Re: Testing random

2015-06-16 Thread Ian Kelly
On Jun 16, 2015 4:58 PM, "Ian Kelly" wrote: > > On Tue, Jun 16, 2015 at 4:30 PM, wrote: > > On Tuesday, June 16, 2015 at 3:01:06 PM UTC-7, Thomas 'PointedEars' Lahn wrote: > >> This should give you pause: In real mathematics, events with zero > &

Re: Testing random

2015-06-17 Thread Ian Kelly
On Wed, Jun 17, 2015 at 8:04 AM, Grant Edwards wrote: > On 2015-06-17, Mark Lawrence wrote: > >> An alternative explanation is that he's just a plain, old fashioned >> troll, as pointed out by Denis McMahon some weeks ago. Now what is >> the probability of that? :) > > Looks to me like it's asym

Re: Documenting a function signature (was: Set a flag on the function or a global?)

2015-06-17 Thread Ian Kelly
On Wed, Jun 17, 2015 at 6:04 PM, Ben Finney wrote: > Steven D'Aprano writes: > >> The full signature is: >> >> edir([object [, glob=''] [, dunders=True] [, meta=False]]) >> >> All four arguments are optional, and dunders and meta are >> keyword-only. > > The official documentation seems to prefer

Re: Get off the list

2015-06-18 Thread Ian Kelly
On Thu, Jun 18, 2015 at 1:05 AM, Cecil Westerhof wrote: > On Wednesday 17 Jun 2015 09:09 CEST, Deogratius Musiige wrote: > >> How can i get off this mailing list? > > Looking at the headers: > List-Unsubscribe: , >

Re: CLI Arguments That Call Functions?

2015-06-18 Thread Ian Kelly
On Thu, Jun 18, 2015 at 11:56 AM, Tony the Tiger wrote: > I would have assumed there would be something built in to the > ArgumentParser, but I can't detect anything that seems to do what I want, > so I wrote the following: [SNIP] > So, is there something already in the Python libs? Do I continu

<    20   21   22   23   24   25   26   27   28   29   >