Re: how to check if a value is a floating point or not

2014-06-19 Thread Ian Kelly
On Fri, Jun 20, 2014 at 12:14 AM, Nicholas Cannon wrote: > Guys i am only a beginner at python most of the stuff you are saying i need > to do i dont understand. All we're saying is that the simplest and most accurate way to determine whether a string can be converted to an int or a float is to

Re: how to check if a value is a floating point or not

2014-06-19 Thread Nicholas Cannon
Guys i am only a beginner at python most of the stuff you are saying i need to do i dont understand. -- https://mail.python.org/mailman/listinfo/python-list

Re: Under what kind of situation, time.sleep(n) would sleep much longer than n seconds?

2014-06-19 Thread Chris Angelico
On Fri, Jun 20, 2014 at 12:33 PM, Terry Reedy wrote: > Most any* console script runs fine** in Idle once you load it into the > editor and press F5. Prompts and prints go the shell window (default blue on > white) and input comes from the same (default black on white). I figured it'd be easy, jus

Re: Under what kind of situation, time.sleep(n) would sleep much longer than n seconds?

2014-06-19 Thread Terry Reedy
On 6/19/2014 3:42 AM, Chris Angelico wrote: On Thu, Jun 19, 2014 at 5:18 PM, Christian Gollwitzer wrote: My advice: 1) First try parsing the command line. (Example: All Unix tools) 2) If you require more interaction and maybe state preservation, just write a couple of functions and run it i

Re: Under what kind of situation, time.sleep(n) would sleep much longer than n seconds?

2014-06-19 Thread Chris Angelico
On Fri, Jun 20, 2014 at 3:17 AM, Christian Gollwitzer wrote: > While I don't understand the purpose of the program (is it a game?), it > shows exactly why this is a bad idea. It's a tool for calculating stuff about railway tracks. Never mind about the details of what it does with the info, but th

Re: Understanding Python Code

2014-06-19 Thread Ian Kelly
On Thu, Jun 19, 2014 at 12:44 PM, wrote: > Dear Group, > Generally most of the issues are tackled here, but as I am trying to cross > check my understanding I found another question, > > f_curr[st] = e[st][x_i] * prev_f_sum > > Here, if I give one print command and see the results, > print "$$2"

Re: Understanding Python Code

2014-06-19 Thread subhabangalore
On Thursday, June 19, 2014 7:57:38 PM UTC+5:30, wrote: > On Thursday, June 19, 2014 7:39:42 PM UTC+5:30, Ian wrote: > > > On Thu, Jun 19, 2014 at 3:48 AM, wrote: > > > > > > > I am trying to see this line, > > > > > > > prev_f_sum = sum(f_prev[k]*a[k][st] for k in states) > > > > > > > >

Re: Under what kind of situation, time.sleep(n) would sleep much longer than n seconds?

2014-06-19 Thread Christian Gollwitzer
Am 19.06.14 09:42, schrieb Chris Angelico: On Thu, Jun 19, 2014 at 5:18 PM, Christian Gollwitzer wrote: Am 19.06.14 01:38, schrieb Chris Angelico: a good console UI just requires this: something = raw_input("Enter something: ") print("Result: "+result) That is actually one of the worst co

Re: Not Responding When Dealing with Large Data

2014-06-19 Thread MRAB
On 2014-06-19 17:21, Peter Pearson wrote: On Thu, 19 Jun 2014 12:25:23 +0100, MRAB wrote: [snip] and then you can say: def myCase(c): if len(c) < 8 or len(c) > 80: return False if c in mySet: return False return True which can be sho

Re: Not Responding When Dealing with Large Data

2014-06-19 Thread Peter Pearson
On Thu, 19 Jun 2014 12:25:23 +0100, MRAB wrote: [snip] > and then you can say: > > def myCase(c): > if len(c) < 8 or len(c) > 80: > return False > > if c in mySet: > return False > > return True > > which can be shortened to: > > def m

Re: Understanding Python Code

2014-06-19 Thread subhabangalore
On Thursday, June 19, 2014 7:39:42 PM UTC+5:30, Ian wrote: > On Thu, Jun 19, 2014 at 3:48 AM, wrote: > > > I am trying to see this line, > > > prev_f_sum = sum(f_prev[k]*a[k][st] for k in states) > > > > > > a[k][st], and f_prev[k] I could take out and understood. > > > Now as it is doing sum(

Re: urllib/urllib2 support for specifying ip address

2014-06-19 Thread Chris Angelico
On Fri, Jun 20, 2014 at 12:19 AM, Robin Becker wrote: > in practice [monkeypatching socket] worked well with urllib in python27. Excellent! That's empirical evidence of success, then. Like with all monkey-patching, you need to keep it as visible as possible, but if your driver script is only a p

Re: urllib/urllib2 support for specifying ip address

2014-06-19 Thread Robin Becker
On 19/06/2014 13:03, Chris Angelico wrote: . I can use python >= 3.3 if required. The main reason I ask is in case something's changed. Basically, what I did was go to my Python 2 installation (which happens to be 2.7.3, because that's what Debian Wheezy ships with - not sure why it has

Re: Understanding Python Code

2014-06-19 Thread Ian Kelly
On Thu, Jun 19, 2014 at 3:48 AM, wrote: > I am trying to see this line, > prev_f_sum = sum(f_prev[k]*a[k][st] for k in states) > > a[k][st], and f_prev[k] I could take out and understood. > Now as it is doing sum() so it must be over a list, > I am trying to understand the number of entities in t

Re: Create flowcharts from Python

2014-06-19 Thread Wolfgang Keller
> Is there a library for Python that can easily create flowcharts using > a simple API? Graphviz (->TikZ->LaTeX->PDF) > But the users want to see this as a visual flowchart too. It would > be the best to have it automatically arranged; or at least open it an > editor so they can move the nodes a

Re: pyhon 1.5.2 problem

2014-06-19 Thread Steven D'Aprano
Are you really using Python 1.5.2? Wow. That's really old :-) Please copy and paste the *full* traceback that Python shows. A few more comments below: On Thu, 19 Jun 2014 14:55:36 +0200, Pat Fourie wrote: > This is the python code > > # > Import SER No it isn't. "Import SER" is a syntax error

Re: DHCP query script not work.

2014-06-19 Thread 不坏阿峰
On Thursday, June 19, 2014 8:49:21 PM UTC+7, Anssi Saari wrote: > 不坏阿峰 writes: > > > > > Dear all > > > > > > i got code recipes from here. and i want to run it on win 7. > > > http://code.activestate.com/recipes/577649-dhcp-query/ > > > > It works for me as is in Windows 7. It's a Pytho

Re: DHCP query script not work.

2014-06-19 Thread Anssi Saari
不坏阿峰 writes: > Dear all > > i got code recipes from here. and i want to run it on win 7. > http://code.activestate.com/recipes/577649-dhcp-query/ It works for me as is in Windows 7. It's a Python 3 script though which might be your problem. -- https://mail.python.org/mailman/listinfo/python-li

Re: how to check if a value is a floating point or not

2014-06-19 Thread Sturla Molden
wrote: > I am making a calculator and i need it to support floating point values > but i am using the function isnumeric to check if the user has entered an > int value. I need the same for floating point types so i could implement > an or in the if statement that checks the values the user has en

Re: DHCP query script not work.

2014-06-19 Thread 不坏阿峰
在 2014年6月19日星期四UTC+7下午8时23分17秒,Peter Otten写道: > 不坏阿峰 wrote: > > > > > i got code recipes from here. and i want to run it on win 7. > > > http://code.activestate.com/recipes/577649-dhcp-query/ > > > > > > i have do some modify and use print to check how it is work, but i am > > > stucked now

Re: pyhon 1.5.2 problem

2014-06-19 Thread Peter Otten
Pat Fourie wrote: > Good Day all, > > I have the following problem. > > This is the python code > > # > > Import SER > > # > > SER.set_speed('115200','8N1') > > .. > > .. > > .. > > When I run the above code I get the following error : > > > > SER.set_speed('115200','8N1') > > Attri

Re: DHCP query script not work.

2014-06-19 Thread soneedu
On Thursday, June 19, 2014 8:23:17 PM UTC+7, Peter Otten wrote: > 不坏阿峰 wrote: > > > > > i got code recipes from here. and i want to run it on win 7. > > > http://code.activestate.com/recipes/577649-dhcp-query/ > > > > > > i have do some modify and use print to check how it is work, but i am

Re: DHCP query script not work.

2014-06-19 Thread Peter Otten
不坏阿峰 wrote: > i got code recipes from here. and i want to run it on win 7. > http://code.activestate.com/recipes/577649-dhcp-query/ > > i have do some modify and use print to check how it is work, but i am > stucked now. > > hope someone can help me. thanks a lot. > > i meet this error: > > Tr

pyhon 1.5.2 problem

2014-06-19 Thread Pat Fourie
Good Day all, I have the following problem. This is the python code # Import SER # SER.set_speed('115200','8N1') .. .. .. When I run the above code I get the following error : SER.set_speed('115200','8N1') AttributeError : set_speed Can anyone help as this did work before.I have

Re: DHCP query script not work.

2014-06-19 Thread Steven D'Aprano
On Thu, 19 Jun 2014 05:56:57 -0700, 不坏阿峰 wrote: > Traceback (most recent call last): > File "D:/Workspace/TestExcel/Test/test_DHCP.py", line 138, in > offer = DHCPOffer(data, discoverPacket.transactionID) > File "D:/Workspace/TestExcel/Test/test_DHCP.py", line 82, in __init__ > self.

DHCP query script not work.

2014-06-19 Thread 不坏阿峰
Dear all i got code recipes from here. and i want to run it on win 7. http://code.activestate.com/recipes/577649-dhcp-query/ i have do some modify and use print to check how it is work, but i am stucked now. hope someone can help me. thanks a lot. i meet this error: Traceback (most recent c

Re: Backport fix on #16611 to Python 2.7

2014-06-19 Thread Makoto Kuwata
Sorry, I failed to post reply: -- Forwarded message -- From: Makoto Kuwata Date: Wed, Jun 18, 2014 at 5:32 PM Subject: Re: Backport fix on #16611 to Python 2.7 To: Terry Reedy On Wed, Jun 18, 2014 at 12:31 PM, Terry Reedy wrote: > > Do you have any plan to upgrade to 3.4, so

Re: urllib/urllib2 support for specifying ip address

2014-06-19 Thread Chris Angelico
On Thu, Jun 19, 2014 at 9:51 PM, Robin Becker wrote: >> Since you mention urllib2, I'm assuming this is Python 2.x, not 3.x. >> The exact version may be significant. >> > I can use python >= 3.3 if required. The main reason I ask is in case something's changed. Basically, what I did was go to my

Re: can I get 0./0. to return nan instead of exception?

2014-06-19 Thread Chris Angelico
On Thu, Jun 19, 2014 at 9:31 PM, Joel Goldstick wrote: > On Jun 19, 2014 7:05 AM, "Neal Becker" wrote: >> >> Can I change behavior of py3 to return nan for 0./0. instead of raising an >> exception? > > There is no nan in python. Yes, there is, but it's not normal to get it as a division result l

Re: urllib/urllib2 support for specifying ip address

2014-06-19 Thread Robin Becker
.. Since you mention urllib2, I'm assuming this is Python 2.x, not 3.x. The exact version may be significant. I can use python >= 3.3 if required. Can you simply query the server by IP address rather than host name? According to the docs, urllib2.urlopen() doesn't check the certific

Re: can I get 0./0. to return nan instead of exception?

2014-06-19 Thread Chris “Kwpolska” Warrick
On Thu, Jun 19, 2014 at 1:31 PM, Joel Goldstick wrote: > > On Jun 19, 2014 7:05 AM, "Neal Becker" wrote: >> >> Can I change behavior of py3 to return nan for 0./0. instead of raising an >> exception? > > There is no nan in python. Wrong: >>> float('nan') nan >>> also: https://docs.python.org/

Re: can I get 0./0. to return nan instead of exception?

2014-06-19 Thread Joel Goldstick
On Jun 19, 2014 7:05 AM, "Neal Becker" wrote: > > Can I change behavior of py3 to return nan for 0./0. instead of raising an > exception? There is no nan in python. > > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list

Re: Not Responding When Dealing with Large Data

2014-06-19 Thread MRAB
On 2014-06-19 09:17, cutey Love wrote: update_idletasks didn't work. The code is this file_path = filedialog.askopenfilename(filetypes=[('text files', '.txt')], multiple=True, defaultextension=".txt") for path in file_path: fo = open(path, "r") for line in fo:

can I get 0./0. to return nan instead of exception?

2014-06-19 Thread Neal Becker
Can I change behavior of py3 to return nan for 0./0. instead of raising an exception? -- https://mail.python.org/mailman/listinfo/python-list

Re: Python 3 on Mac OS X 10.8.4

2014-06-19 Thread Andrew Jaffe
On 19/06/2014 08:02, Une Bévue wrote: On my mac i do have : $ python --version Python 2.7.2 I want to install Python 3 such as python-3.4.0-macosx10.6.dmg avoiding disturbing the "built-in" version. Is that possible ? The python.org packages are explicitly created in order to have no conflict

Re: Understanding Python Code

2014-06-19 Thread subhabangalore
On Thursday, June 19, 2014 12:30:12 PM UTC+5:30, Ian wrote: > On Wed, Jun 18, 2014 at 11:50 PM, wrote: > > > Thank you for the reply. But as I checked it again I found, > > > f_prev[k] is giving values of f_curr[st] = e[st][x_i] * prev_f_sum > > > which is calculated later and again uses prev_

Re: urllib/urllib2 support for specifying ip address

2014-06-19 Thread Chris Angelico
On Thu, Jun 19, 2014 at 7:22 PM, Robin Becker wrote: > I want to run torture tests against an https server on domain A; I have > configured apache on the server to respond to a specific hostname ipaddress. > > I don't want to torture the live server so I have set up an alternate > instance on a di

Re: Under what kind of situation, time.sleep(n) would sleep much longer than n seconds?

2014-06-19 Thread Marko Rauhamaa
Chris Angelico : > Yeah, I think [raw_]input() isn't so bad after all. I have never used it. I *have* used getpass.getpass(). Unfortunately, it doesn't have a corresponding prompt and raw input variant so I've had to essentially copy over getpass() code and modify that: fd = os.open('/dev/tt

urllib/urllib2 support for specifying ip address

2014-06-19 Thread Robin Becker
I want to run torture tests against an https server on domain A; I have configured apache on the server to respond to a specific hostname ipaddress. I don't want to torture the live server so I have set up an alternate instance on a different ip address. Is there a way to get urlib or urllib2

Re: Python 3 on Mac OS X 10.8.4

2014-06-19 Thread Une Bévue
Le 19/06/14 09:52, Andrea D'Amore a écrit : Brew should require the smaller command line package. OK, fine thanks, I'll use brew. -- https://mail.python.org/mailman/listinfo/python-list

Re: Python Fails to Write to File

2014-06-19 Thread Mark Lawrence
On 19/06/2014 08:54, cutey Love wrote: Thank you very much, that fixed it. What do you not understand about top posting and using google groups? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free f

Re: Not Responding When Dealing with Large Data

2014-06-19 Thread cutey Love
update_idletasks didn't work. The code is this file_path = filedialog.askopenfilename(filetypes=[('text files', '.txt')], multiple=True, defaultextension=".txt") for path in file_path: fo = open(path, "r") for line in fo: if myCase(line.lowe

Re: Python Fails to Write to File

2014-06-19 Thread cutey Love
Thank you very much, that fixed it. On Thursday, June 19, 2014 12:03:43 AM UTC+1, cutey Love wrote: > I'm trying to write data to a text file > > > > But I'm getting the error: > > > > TypeError: invalid file: <_io.TextIOWrapper > > > > Code is > > > > def saveFile(): > > file_p

Re: Python 3 on Mac OS X 10.8.4

2014-06-19 Thread Andrea D'Amore
On 2014-06-19 07:02:21 +, Une Bévue said: I want to install Python 3 such as python-3.4.0-macosx10.6.dmg avoiding disturbing the "built-in" version. Is that possible ? The Installer app won't let you see the target path of each package in the metapackage so you'll have to open each of th

Re: Under what kind of situation, time.sleep(n) would sleep much longer than n seconds?

2014-06-19 Thread Chris Angelico
On Thu, Jun 19, 2014 at 5:18 PM, Christian Gollwitzer wrote: > Am 19.06.14 01:38, schrieb Chris Angelico: > >> a good console UI just requires this: >> >> something = raw_input("Enter something: ") >> print("Result: "+result) > > > That is actually one of the worst console UIs possible > > My

Re: how to check if a value is a floating point or not

2014-06-19 Thread Ian Kelly
On Thu, Jun 19, 2014 at 1:23 AM, Ian Kelly wrote: > On Thu, Jun 19, 2014 at 12:48 AM, Nicholas Cannon > wrote: >> On Thursday, June 19, 2014 1:53:31 PM UTC+8, Nicholas Cannon wrote: >>> I am making a calculator and i need it to support floating point values but >>> i am using the function isnume

Re: how to check if a value is a floating point or not

2014-06-19 Thread Ian Kelly
On Thu, Jun 19, 2014 at 12:48 AM, Nicholas Cannon wrote: > On Thursday, June 19, 2014 1:53:31 PM UTC+8, Nicholas Cannon wrote: >> I am making a calculator and i need it to support floating point values but >> i am using the function isnumeric to check if the user has entered an int >> value. I n

Re: how to check if a value is a floating point or not

2014-06-19 Thread Ben Finney
Nicholas Cannon writes: > #checks if the user input is an integer value > def checkint(a): > if a.isnumeric(): > return True > else: > if a.isalpha(): > return False > else: > return True What code

Re: Under what kind of situation, time.sleep(n) would sleep much longer than n seconds?

2014-06-19 Thread Christian Gollwitzer
Am 19.06.14 01:38, schrieb Chris Angelico: a good console UI just requires this: something = raw_input("Enter something: ") print("Result: "+result) That is actually one of the worst console UIs possible. Almost all beginner's courses start with programs like that, requiring the user to key

Python 3 on Mac OS X 10.8.4

2014-06-19 Thread Une Bévue
On my mac i do have : $ python --version Python 2.7.2 I want to install Python 3 such as python-3.4.0-macosx10.6.dmg avoiding disturbing the "built-in" version. Is that possible ? -- https://mail.python.org/mailman/listinfo/python-list

Re: Understanding Python Code

2014-06-19 Thread Ian Kelly
On Wed, Jun 18, 2014 at 11:50 PM, wrote: > Thank you for the reply. But as I checked it again I found, > f_prev[k] is giving values of f_curr[st] = e[st][x_i] * prev_f_sum > which is calculated later and again uses prev_f_sum. f_prev is the f_curr that was calculated on the previous iteration of