Re: Useless expressions [was Re: Undefined behaviour in C]

2016-03-29 Thread Steven D'Aprano
On Monday 28 March 2016 23:18, BartC wrote: > On 28/03/2016 02:24, Steven D'Aprano wrote: >> Don't think about floats and ints and strings. Think of complex objects >> with operator overloading. You're probably thinking of `x + y`. Instead, >> think of things like: >> >> graph + node >> database

Re: Useless expressions

2016-03-29 Thread Ben Finney
Steven D'Aprano writes: > On Monday 28 March 2016 23:18, BartC wrote: > > > (There are also docstrings, but until yesterday I didn't even know > > they were also expressions. Wikipedia says this: > > > > "Python docstrings appear as a string literal (not an expression) as > > the first statement

Re: Re-using TCL code from python over network

2016-03-29 Thread Karim
On 29/03/2016 07:20, sharad1...@gmail.com wrote: Hi We've a test automation framework written in TCL (including the automated test cases). We are evaluating shifting to Python and have a test framework in Python (including the automated test cases). Python provides a lot more 3rd party libr

Re: Meta Data

2016-03-29 Thread Nick
I did find a couple of patterns in Effective Python: 59 Specific Ways to Write Better Python (Effective Software Development). Registering classes and a field example. Thanks N. -- https://mail.python.org/mailman/listinfo/python-list

Re: Statements as expressions [was Re: Undefined behaviour in C]

2016-03-29 Thread Steven D'Aprano
On Monday 28 March 2016 12:40, Paul Rubin wrote: > Steven D'Aprano writes: >> if condition: >> print(1) >> print(2) >> else: >> print(3) >> print(4) >> what value should it return? Justify your choice. > > It could whatever value that the last call to print() returns. Lisp > has

Help me

2016-03-29 Thread Smith
https://github.com/githubdavide/ip-pubblico-send/blob/master/ip-pubblico.py -- https://mail.python.org/mailman/listinfo/python-list

Re: Re-using TCL code from python over network

2016-03-29 Thread sharad1087
@Christian: Thanks! @Karim: Thanks. My requirement is to run tcl code from python. tclpython allows executing python code from tcl. "but I now I migrated all the TCL code to python one indeed" - did you re-write the TCL code in Python? -- https://mail.python.org/mailman/listinfo/python-list

Re: repeat items in a list

2016-03-29 Thread Antonio Caminero Garcia
On Monday, March 28, 2016 at 11:26:08 PM UTC+2, Chris Angelico wrote: > On Tue, Mar 29, 2016 at 4:30 AM, Rob Gaddi > wrote: > > beliav...@aol.com wrote: > > > >> On Saturday, March 26, 2016 at 7:24:10 PM UTC-4, Erik wrote: > >>> > >>> Or, if you want to "import operator" first, you can use 'operat

Re: Statements as expressions [was Re: Undefined behaviour in C]

2016-03-29 Thread Paul Rubin
Steven D'Aprano writes: > The point is that there's nothing intrinsically obvious or right about > "return the value of the last statement in the block". Strictly speaking it returns the value of the block itself. The block is usually evaluated by PROG which returns the last value of the block

Re: Statements as expressions [was Re: Undefined behaviour in C]

2016-03-29 Thread Chris Angelico
On Tue, Mar 29, 2016 at 7:26 PM, Steven D'Aprano wrote: > del x > > Should it return None? The string 'x'? How about the value that x had just > before it was deleted? True if that allowed the value to be garbage > collected, False if it wasn't? Or the other way around? None of these > suggests fe

Re: Re-using TCL code from python over network

2016-03-29 Thread Sharad Singla
Thanks. This is more of invoking python code from TCL. I am looking for the other way round. Curious, did you rewrite all your TCL code in python? Regards Sharad On Mar 29, 2016 1:10 PM, "Karim" wrote: > > > On 29/03/2016 07:20, sharad1...@gmail.com wrote: > >> Hi >> >> We've a test automation

Re: Help me

2016-03-29 Thread Ben Finney
Smith writes: > [a URL] You'll get better help if you: * Summarise the problem briefly in the Subject field. * Actually say anything useful in the message body. -- \ “My house is on the median strip of a highway. You don't really | `\notice, except I have to leave the driveway

error installing scipy on python 3.5, win 10 64 bit

2016-03-29 Thread Sinay Goldberg
Please help -- https://mail.python.org/mailman/listinfo/python-list

Re: Statements as expressions [was Re: Undefined behaviour in C]

2016-03-29 Thread Marko Rauhamaa
Steven D'Aprano : > On Monday 28 March 2016 12:40, Paul Rubin wrote: > >> Steven D'Aprano writes: >>> if condition: >>> print(1) >>> print(2) >>> else: >>> print(3) >>> print(4) >>> what value should it return? Justify your choice. >> >> It could whatever value that the last call

Re: Which are best, well-tested ways to create REST services, with Json, in Python?

2016-03-29 Thread Sven R. Kunze
Not heard of any but I can recommend django-restframework. We've got good experience with that. On 28.03.2016 23:06, David Shi via Python-list wrote: Has anyone done a recent reviews of creating REST services, in Python? Regards. David -- https://mail.python.org/mailman/listinfo/python-list

[OT] C# -- sharp or carp? was Re: Learning Python (or Haskell) makes you a worse programmer

2016-03-29 Thread Peter Otten
Steven D'Aprano wrote: > http://lukeplant.me.uk/blog/posts/why-learning-haskell-python-makes-you-a-worse-programmer/ I was about to post that in a few years' time C# will acquire enough features to make code that follows the functional paradigm feasible in that language. Then I noted that this

Re: Learning Python (or Haskell) makes you a worse programmer

2016-03-29 Thread Sven R. Kunze
On 29.03.2016 06:13, Michael Torrie wrote: On 03/28/2016 06:44 PM, Steven D'Aprano wrote: http://lukeplant.me.uk/blog/posts/why-learning-haskell-python-makes-you-a-worse-programmer/ I have the same problem as the writer. Working in Python makes me really dislike working in any other language

Re: [OT] C# -- sharp or carp? was Re: Learning Python (or Haskell) makes you a worse programmer

2016-03-29 Thread Sven R. Kunze
On 29.03.2016 11:39, Peter Otten wrote: My question to those who know a bit of C#: what is the state-of-the-art equivalent to "\n".join(foo.description() for foo in mylist if foo.description() != "") Using LINQ, I suppose: https://en.wikipedia.org/wiki/Language_Inte

Re: newbie question

2016-03-29 Thread Sven R. Kunze
On 28.03.2016 17:34, ast wrote: "Matt Wheeler" a écrit dans le message de news:mailman.92.1458825746.2244.python-l...@python.org... On Thu, 24 Mar 2016 11:10 Sven R. Kunze, wrote: On 24.03.2016 11:57, Matt Wheeler wrote: import ast s = "(1, 2, 3, 4)" t = ast.literal_eval(s

Re: Re-using TCL code from python over network

2016-03-29 Thread Karim
On 29/03/2016 10:29, Sharad Singla wrote: Thanks. This is more of invoking python code from TCL. I am looking for the other way round. Curious, did you rewrite all your TCL code in python? Regards Sharad On Mar 29, 2016 1:10 PM, "Karim" > wrote: On 29/03

Re: Threading is foobared?

2016-03-29 Thread Sven R. Kunze
On 27.03.2016 05:01, Steven D'Aprano wrote: Am I the only one who has noticed that threading of posts here is severely broken? It's always been the case that there have been a few posts here and there that break threading, but now it seems to be much more common. I agree. Didn't we both already

Re: Re-using TCL code from python over network

2016-03-29 Thread Christian Gollwitzer
Am 29.03.16 um 09:40 schrieb Karim: You can find below a partial example where I launch a python process from a tcl program to get data from python which reads a database. You just have to get and compile tclpython (google is your best friend) which is a C interface bridging python and tcl and al

Re: Statements as expressions [was Re: Undefined behaviour in C]

2016-03-29 Thread BartC
On 29/03/2016 09:26, Steven D'Aprano wrote: On Monday 28 March 2016 12:40, Paul Rubin wrote: The point is that there's nothing intrinsically obvious or right about "return the value of the last statement in the block". But that's exactly what happens inside a typical function: you have lin

DSL design (was DSLs in perl and python)

2016-03-29 Thread Rustom Mody
On Saturday, March 19, 2016 at 7:37:52 AM UTC+5:30, Rustom Mody wrote: > On Friday, March 18, 2016 at 6:52:53 PM UTC+5:30, Peter Otten wrote: > > Rustom Mody wrote: > > > > > On Friday, March 18, 2016 at 4:17:06 AM UTC+5:30, MRAB wrote: > > >> Stick an "x" on the end of the regex: /something/x or

Re: DSL design (was DSLs in perl and python)

2016-03-29 Thread Chris Angelico
On Wed, Mar 30, 2016 at 12:28 AM, Rustom Mody wrote: > Thanks once again to Peter and Jussi. > With that groupindex pointer, this tiny dsl for re's is here > https://github.com/rusimody/redsl > [How BTW did you folks go about unearth that groupindex?? Dont see it in docs] Depending on your versio

Re: Exclude every nth element from list?

2016-03-29 Thread Sven R. Kunze
On 26.03.2016 18:06, Peter Otten wrote: beliavsky--- via Python-list wrote: I can use x[::n] to select every nth element of a list. Is there a one-liner to get a list that excludes every nth element? del x[::n] ;) Actually quite nice. -- https://mail.python.org/mailman/listinfo/python-list

Re: DSL design (was DSLs in perl and python)

2016-03-29 Thread Jussi Piitulainen
Rustom Mody writes: > [How BTW did you folks go about unearth that groupindex?? Dont see it > in docs] The following reveal its existence: dir(re.compile("")) help(re.compile("")) But help only lists it as one of "data descriptors defined here" (in Python 3.4.3). I think I just guessed from its

Finding methods, was Re: DSL design (was DSLs in perl and python)

2016-03-29 Thread Peter Otten
Rustom Mody wrote: > [How BTW did you folks go about unearth that groupindex?? Dont see it in > [docs] While it's there https://docs.python.org/dev/library/re.html#re.regex.groupindex my personal search algorithm for this category of questions is mostly "I saw something like that before", then

Re: Suggestion: make sequence and map interfaces more similar

2016-03-29 Thread Antoon Pardon
Op 28-03-16 om 03:05 schreef Steven D'Aprano: > On Mon, 28 Mar 2016 05:01 am, Marco S. wrote: > >> Steven D'Aprano wrote: >> >>> The point you might have missed is that treating lists as if they were >>> mappings violates at least one critical property of mappings: that the >>> relationship between

Re: Suggestion: make sequence and map interfaces more similar

2016-03-29 Thread Chris Angelico
On Wed, Mar 30, 2016 at 1:08 AM, Antoon Pardon wrote: > Op 28-03-16 om 03:05 schreef Steven D'Aprano: >> When you add a new key:value to a dict, the other key:value pairs don't >> change. That is the whole point of a mapping! Of course you can >> deliberately change the value by re-assignment: >>

Re: Re-using TCL code from python over network

2016-03-29 Thread sharad1087
Thanks Christian. You are right. Our TCL is 32 bit and runs on FreeBSD. We are planning to use Python (64 bit) on CentOS. -- https://mail.python.org/mailman/listinfo/python-list

Re: [OT] C# -- sharp or carp? was Re: Learning Python (or Haskell) makes you a worse programmer

2016-03-29 Thread Sven R. Kunze
On 29.03.2016 12:18, Sven R. Kunze wrote: On 29.03.2016 11:39, Peter Otten wrote: My question to those who know a bit of C#: what is the state-of-the-art equivalent to "\n".join(foo.description() for foo in mylist if foo.description() != "") Using LINQ, I suppose:

Simple, fast responsive, secure way of creating REST services

2016-03-29 Thread David Shi via Python-list
Hello, Justin, What you said is very interesting and useful. I just wonder whether there are much simpler alternatives for fast, responsive, secure REST services.  Python at server-side.  It provides REST services.  Data exchange with the web--page.  Formatted XML or Json. Ideally, it uses the le

Re: [OT] C# -- sharp or carp? was Re: Learning Python (or Haskell) makes you a worse programmer

2016-03-29 Thread Peter Otten
Sven R. Kunze wrote: > On 29.03.2016 12:18, Sven R. Kunze wrote: >> On 29.03.2016 11:39, Peter Otten wrote: >>> My question to those who know a bit of C#: what is the state-of-the-art >>> equivalent to >>> >>> "\n".join(foo.description() for foo in mylist >>> if foo.descr

Re: [OT] C# -- sharp or carp? was Re: Learning Python (or Haskell) makes you a worse programmer

2016-03-29 Thread Sven R. Kunze
On 29.03.2016 18:05, Peter Otten wrote: Reformatting it a bit String.Join( "\n", mylist.Where( foo => !String.IsNullOrEmpty(foo.description) ).Select( foo => foo.description)) this looks like a variant of Python's str.join( "\n", map(lambda foo: foo.des

Re: error installing scipy on python 3.5, win 10 64 bit

2016-03-29 Thread Rob Gaddi
Sinay Goldberg wrote: >Please help Alright, let's try making this an exercise for the student. You're asking a bunch of strangers on the Internet to take time out of their day to fix your problems. Is there, perhaps, any way that you could make their task easier so as to reduce the size of

Re: [stdlib-sig] Can imaplib be improved?

2016-03-29 Thread Random832
I'd posted this to stdlib-...@python.org without realizing that that list is mostly dead. On Thu, Mar 24, 2016, at 22:33, Random832 wrote: > I assume that everyone who has ever used imaplib is familiar with how > painful its output format is to deal with. I am wondering if anyone else > has any id

Re: [stdlib-sig] Can imaplib be improved?

2016-03-29 Thread Grant Edwards
On 2016-03-29, Random832 wrote: > I'd posted this to stdlib-...@python.org without realizing that that > list is mostly dead. > > On Thu, Mar 24, 2016, at 22:33, Random832 wrote: >> I assume that everyone who has ever used imaplib is familiar with how >> painful its output format is to deal with.

Re: [stdlib-sig] Can imaplib be improved?

2016-03-29 Thread Random832
On Tue, Mar 29, 2016, at 14:45, Grant Edwards wrote: > I think giving up on backwards compatiblity and starting from scratch > is the best idea. > > I like imaplib2 > > https://pypi.python.org/pypi/imaplib2 > https://github.com/bcoe/imaplib2 > https://sourceforge.net/projects/imaplib2/ > > imapc

Re: Re-using TCL code from python over network

2016-03-29 Thread blacksqr
On Tuesday, March 29, 2016 at 5:24:37 AM UTC-5, Karim wrote: > But it was a good experience to learn TCL (weaknesses). > > Karim I would be interested to know what you consider to be the top weaknesses of Tcl compared to Python which prompted your decision to switch. -- https://mail.python.org

Help with python code

2016-03-29 Thread okdk
This is my code import random import time pizzatype = [3.50,4.20,5.20,5.80,5.60] drinktype = [0.90,0.80,0.90] topping = [0.50,0.50,0.50,0.50] def Total_cost_cal (pt ,dt ,t): total = pt + dt + t return total print ("Welcome to Pizza Shed!") order = raw_input ("\n\nPLEASE PRESS ENTER TO O

Re: Help with python code

2016-03-29 Thread BartC
On 29/03/2016 22:00, okdk wrote: pizzatype = [3.50,4.20,5.20,5.80,5.60] drinktype = [0.90,0.80,0.90] topping = [0.50,0.50,0.50,0.50] total_cost = total_cost_cal(pizzatotal, drinktotal, topping_cost) print ("") print ("Calculating bill") print ("---

Re: Help with python code

2016-03-29 Thread Rob Gaddi
okdk wrote: > This is my code > import random > import time > > pizzatype = [3.50,4.20,5.20,5.80,5.60] > drinktype = [0.90,0.80,0.90] > topping = [0.50,0.50,0.50,0.50] > > def Total_cost_cal (pt ,dt ,t): > total = pt + dt + t > return total > > print ("Welcome to Pizza Shed!") > > order =

Re: repeat items in a list

2016-03-29 Thread Vito De Tullio
Random832 wrote: > How do you turn ['a', 'c', 'b'] into ['a', 'a', 'a', 'c', 'c', 'c', 'b', > 'b', 'b']? >>> sum([[e]*3 for e in ['a', 'c', 'b']], []) ['a', 'a', 'a', 'c', 'c', 'c', 'b', 'b', 'b'] -- By ZeD -- https://mail.python.org/mailman/listinfo/python-list

Re: Help with python code

2016-03-29 Thread Yum Di
import random import time pizzatype = [3.50,4.20,5.20,5.80,5.60] drinktype = [0.90,0.80,0.90] topping = [0.50,0.50,0.50,0.50] def Total_cost_cal (pt ,dt ,t): total = pt + dt + t return total print ("Welcome to Pizza Shed!") order = raw_input ("\n\nPLEASE PRESS ENTER TO ORDER." ) tablen

Re: [OT] C# -- sharp or carp? was Re: Learning Python (or Haskell) makes you a worse programmer

2016-03-29 Thread Vito De Tullio
Sven R. Kunze wrote: >>> My question to those who know a bit of C#: what is the state-of-the-art >>> equivalent to >>> >>> "\n".join(foo.description() for foo in mylist >>> if foo.description() != "") > Friend of mine told me something like this: > > String.Join("\n", m

Re: Help with python code

2016-03-29 Thread Rob Gaddi
Yum Di wrote: > I still don't get it.. Sorry, I'm still quite new to this > I've have made few minor changes, but it still doesn't work Then try entering one line at a time of your program into the interactive interpreter. Copy and paste is fine, but use the interpreter to look at the actual val

Calculate Bill

2016-03-29 Thread Yum Di
import random import time print ("Welcome to Pizza Shed!") order = raw_input ("\n\nPLEASE PRESS ENTER TO ORDER." ) tablenum = input ("Enter table number from 1-25 \n ") while tablenum>25 or tablenum <=0: tablenum = input ("Enter the correct table number, there are only 25 tables ") #Pi

Re: Suggestion: make sequence and map interfaces more similar

2016-03-29 Thread Marco Sulla via Python-list
On 29 March 2016 at 16:31, Chris Angelico wrote: > But the definition of a sequence, and likewise the definition of a > mapping, goes deeper than that. A sequence has *relative* stability; > if one item is at a lower index than another, it will continue to be > at a lower index, until you change o

IPython and Jupyter

2016-03-29 Thread David Shi via Python-list
Ipython-4.1.2 I thought that I installed Ipython. I typed in ipython notebook. But a WARNING came up, saying Subcommand 'ipython notebook is deprecated and will be removed in future versions. Then Jupyter turned up. How can I make available both Ipython notebook and Jupyter?, so that I can switch

Re: Help with python code

2016-03-29 Thread Wildman via Python-list
On Tue, 29 Mar 2016 21:19:05 +, Rob Gaddi wrote: >> menu = input("Enter the type of pizza that you want to order from 1-5 \n") >> while menu>5 or menu <=0: >> menu = input ("Enter the right number ") >> pizza_cost = pizzatype[menu] As it has already been pointed out, a Python list starts

Re: Calculate Bill

2016-03-29 Thread Chris Angelico
On Wed, Mar 30, 2016 at 9:33 AM, Yum Di wrote: > Hey.. this code works. However, i need it to calculate the total cost. > I dont know how to do that. Can someone help me.. > thanks It does indeed appear to work. And thank you for posting your current code. However... > print ("Welcome to Pizza S

Re: Learning Python (or Haskell) makes you a worse programmer

2016-03-29 Thread Eric S. Johansson
On 3/29/2016 6:05 AM, Sven R. Kunze wrote: Python = English As someone who writes English text and code using speech recognition, I can assure you that Python is not English. :-) -- https://mail.python.org/mailman/listinfo/python-list

Re: Threading is foobared?

2016-03-29 Thread Steven D'Aprano
On Tue, 29 Mar 2016 09:26 pm, Sven R. Kunze wrote: > On 27.03.2016 05:01, Steven D'Aprano wrote: >> Am I the only one who has noticed that threading of posts here is >> severely broken? It's always been the case that there have been a few >> posts here and there that break threading, but now it se

Re: Threading is foobared?

2016-03-29 Thread Rob Gaddi
Steven D'Aprano wrote: > Am I the only one who has noticed that threading of posts here is severely > broken? It's always been the case that there have been a few posts here and > there that break threading, but now it seems to be much more common. > > For instance, I see Jerry Martens' post "help

Re: Statements as expressions [was Re: Undefined behaviour in C]

2016-03-29 Thread Steven D'Aprano
On Tue, 29 Mar 2016 10:31 pm, BartC wrote: > On 29/03/2016 09:26, Steven D'Aprano wrote: >> On Monday 28 March 2016 12:40, Paul Rubin wrote: > > >> The point is that there's nothing intrinsically obvious or right about >> "return the value of the last statement in the block". > > But that's exa

Re: Calculate Bill

2016-03-29 Thread Steven D'Aprano
On Wed, 30 Mar 2016 09:33 am, Yum Di wrote: [...] > print ("Thank You for ordering at Pizza Shed! ") > > Hey.. this code works. However, i need it to calculate the total cost. > I dont know how to do that. Can someone help me.. > thanks Think about how people calculate the bill at a real pizza

Re: Suggestion: make sequence and map interfaces more similar

2016-03-29 Thread Terry Reedy
On 3/29/2016 6:29 PM, Marco Sulla via Python-list wrote: Let me add that an items() and keys() for sequences will be also useful for day-by-day programming, since they will be a shortcut for enumerate(seq) and range(len(seq)) To me they are useless and confusing duplications since enumerate()(

Re: Suggestion: make sequence and map interfaces more similar

2016-03-29 Thread Chris Angelico
On Wed, Mar 30, 2016 at 9:29 AM, Marco Sulla via Python-list wrote: > On 29 March 2016 at 16:31, Chris Angelico wrote: >> But the definition of a sequence, and likewise the definition of a >> mapping, goes deeper than that. A sequence has *relative* stability; >> if one item is at a lower index t

Re: Statements as expressions [was Re: Undefined behaviour in C]

2016-03-29 Thread Rustom Mody
On Tuesday, March 29, 2016 at 12:18:38 AM UTC+5:30, Paul Rubin wrote: > BartC writes: > > With more recent ones I've dropped that model, so that statements and > > expressions are different, and that is strictly enforced. This makes > > implementation simpler, and detects lots more errors. > > Yo

Re: Threading is foobared?

2016-03-29 Thread Random832
On Tue, Mar 29, 2016, at 19:54, Rob Gaddi wrote: > Just read on Usenet instead of through the mailing list. That way > you can accept broken threading as a given rather than wonder why it's > happening in a particular case. It's a given everywhere. Any thread that contains a sufficient number of

Re: Suggestion: make sequence and map interfaces more similar

2016-03-29 Thread Random832
On Tue, Mar 29, 2016, at 20:56, Chris Angelico wrote: > The map contract is this: > > x = StrangeDict() > x[123] = 456 > ... > assert x[123] == 456 > > Your mapping does violate the map contract. So, you can put *anything* in that "..."? x = dict() x[123] = 456 x[123] = 789 assert x[123] == 456

Re: Suggestion: make sequence and map interfaces more similar

2016-03-29 Thread Steven D'Aprano
On Wednesday 30 March 2016 14:38, Random832 wrote: > On Tue, Mar 29, 2016, at 20:56, Chris Angelico wrote: >> The map contract is this: >> >> x = StrangeDict() >> x[123] = 456 >> ... >> assert x[123] == 456 >> >> Your mapping does violate the map contract. > > So, you can put *anything* in that

Re: Suggestion: make sequence and map interfaces more similar

2016-03-29 Thread Steven D'Aprano
On Wednesday 30 March 2016 16:43, Steven D'Aprano wrote: > This is not an argument about dicts being mutable, because clearly they > aren't. Er, I meant *immutable*. Dicts aren't immutable. -- Steve -- https://mail.python.org/mailman/listinfo/python-list