Re: SOLVED! Re: Weird Stuff (Markdown, syntax highlighting and Python)

2024-05-29 Thread dn via Python-list
On 29/05/24 06:49, Gilmeh Serda via Python-list wrote: Solved by using a different method. Hedonist for hire... no job too easy! This combination of sig-file and content seems sadly ironic. How about CONTRIBUTING to the community by explaining 'the solution' to people who may find a simi

Re: SOLVED! Re: Weird Stuff (Markdown, syntax highlighting and Python)

2024-05-29 Thread o1bigtenor via Python-list
On Tue, May 28, 2024 at 9:48 PM Gilmeh Serda via Python-list < python-list@python.org> wrote: > > Solved by using a different method. > > - - - And that was how? TIA -- https://mail.python.org/mailman/listinfo/python-list

Re: Weird Stuff (Markdown, syntax highlighting and Python)

2024-05-27 Thread Thomas Passin via Python-list
On 5/26/2024 2:28 AM, Gilmeh Serda via Python-list wrote: The web claims (I think on all pages I've read about Markdown and Python) that this code should work, with some very minor variants on the topic: ```python import os with open(os.path.join('/home/user/apath', 'somefile')) as f: pri

Re: Weird Stuff (Markdown, syntax highlighting and Python)

2024-05-27 Thread dn via Python-list
With reference to another reply here, the "Weird stuff" came from reading the question, finding it unclear, and only later realising that whereas most people write Markdown-formatted documents for later processing, or perhaps docstrings in Markdown-format for collection by documentation systems

Re: Weird Stuff (Markdown, syntax highlighting and Python)

2024-05-27 Thread Grant Edwards via Python-list
On 2024-05-26, Gilmeh Serda via Python-list wrote: > The web claims (I think on all pages I've read about Markdown and Python) > that this code should work, with some very minor variants on the topic: > > ```python > > import os > > with open(os.path.join('/home/user/apath', 'somefile')) as f: >

Re: Weird strace of #! python script

2022-03-14 Thread Barry
> On 14 Mar 2022, at 21:29, Dan Stromberg wrote: > > I expected to see an exec of /usr/bin/python2, but I don't. I just see an > exec of /tmp/t. I understand that the kernel handles the #! Line itself, which is why you do not see it in strace. Barry -- https://mail.python.org/mailman/l

Re: Weird strace of #! python script

2022-03-14 Thread Chris Angelico
On Tue, 15 Mar 2022 at 08:28, Dan Stromberg wrote: > > Hi folks. > > First off, I know, python2 is ancient history. Porting to 3.x is on my > list of things to do (though I'm afraid it's not yet at the top of the > list), and the same thing happens with python3. > > So anyway, I'm strace'ing a #!

Re: Weird behavior for IDLE...

2020-10-13 Thread Terry Reedy
On 10/13/2020 4:51 AM, Steve wrote: Why does IDLE always open with the lowest three lines of the window end up hidden below the bottom of the screen behind the task bar? Every time I use it, I have to stop and grab the top of the window and drag it up to see the line and row information. I expl

Re: Weird Python Bug

2019-09-13 Thread MRAB
On 2019-09-13 20:17, CrazyVideoGamez wrote: For some reason, if you put in the code def odd_ones_out(numbers): for num in numbers: count = numbers.count(num) if not count % 2 == 0: for i in range(count): numbers.remove(num) return numbers

RE: Weird Python Bug

2019-09-13 Thread David Raymond
2 comments: First: Deleting from a list while you're iterating over it is a bad idea. Your first iteration gives nums[0] which is 72. But then you delete that and (in effect) everything moves up. So now the 4 is in the nums[0] slot. Your second iteration returns nums[1] which is now the 82 mean

Re: Weird side effect of default parameter

2018-05-07 Thread Robert Latest via Python-list
Steven D'Aprano wrote: > Python function default values use *early binding*: the default parameter > is evaluated, ONCE, when the function is defined, and that value is used > each time it is needed. Thanks, "early binding" was the clue I was missing. robert -- https://mail.python.org/mailman/

Re: Weird side effect of default parameter

2018-05-04 Thread Steven D'Aprano
On Thu, 03 May 2018 19:47:37 +, Robert Latest via Python-list wrote: > Hello, > > I don't understand the behavior of the code below. Why does the dict > property "a" of both objects contain the same keys? This is only if > "a=dict" is in the initializer. If I put self.a = dict() into the init

Re: Weird side effect of default parameter

2018-05-03 Thread Gary Herron
This is a well known feature of Python.   It's a very common "gotcha" to new Python programmers. Google "Mutable default parameters in Python" for long list of explanations and fixes. In short, don't use a mutable object as a default parameter. Gary Herron On 05/03/2018 12:47 PM, python-

Re: Weird python 2.7 import thing

2016-02-19 Thread Dan Stromberg
On Fri, Feb 19, 2016 at 10:33 AM, Dan Stromberg wrote: > On Thu, Feb 18, 2016 at 5:40 PM, Dan Stromberg wrote: > >> >> BTW, this is not a package I pip installed from pypi - it's an >> internal-only project. > > I need to correct this: It's not installed from pypi.python.org, but > it probably is

Re: Weird python 2.7 import thing

2016-02-19 Thread Dan Stromberg
On Thu, Feb 18, 2016 at 5:40 PM, Dan Stromberg wrote: > > BTW, this is not a package I pip installed from pypi - it's an > internal-only project. I need to correct this: It's not installed from pypi.python.org, but it probably is installed from our internal pypi server. Thanks! -- https://mail

Re: Weird and sparese cgi:error

2016-02-19 Thread Φώντας Λαδοπρακόπουλος
[root@nexus cgi-bin]# head -10 ./metrites.py #!/usr/bin/python3 # coding=utf-8 import cgitb; cgitb.enable() import cgi, re, os, sys, socket, time, datetime, locale, codecs, random, smtplib, subprocess, pymysql, geoip2.database from datetime import datetime, timedelta from http import cookies #

Re: Weird and sparese cgi:error

2016-02-19 Thread Φώντας Λαδοπρακόπουλος
#!/usr/bin/python3 # coding=utf-8 import cgitb; cgitb.enable() import cgi, re, os, sys, socket, time, datetime, locale, codecs, random, smtplib, subprocess, pymysql, geoip2.database from datetime import datetime, timedelta from http import cookies === [root@nexus cgi-bin]# /usr/b

Re: Weird and sparese cgi:error

2016-02-17 Thread Chris Angelico
On Thu, Feb 18, 2016 at 12:47 AM, Jeremy Leonard wrote: > On Tuesday, February 16, 2016 at 3:02:40 PM UTC-5, Φώντας Λαδοπρακόπουλος > wrote: >> Hello, >> >> I recentely changed VPS server and when i try to load my webiste iam >> receiving 500 error which i wasnt receiving in my old VPS server wi

Re: Weird and sparese cgi:error

2016-02-17 Thread Jeremy Leonard
On Tuesday, February 16, 2016 at 3:02:40 PM UTC-5, Φώντας Λαδοπρακόπουλος wrote: > Hello, > > I recentely changed VPS server and when i try to load my webiste iam > receiving 500 error which i wasnt receiving in my old VPS server with the > same exact cgi scripts. > > After looking at Apacher's

Re: Weird list conversion

2015-12-13 Thread Chris Angelico
On Mon, Dec 14, 2015 at 7:31 AM, Erik wrote: > On 13/12/15 20:28, Erik wrote: >> >> When you call "print", then the list class's __repr__() method is called >> which in turn calls the contained objects' __repr__() methods in turn > > > I mean the __str__() method, not __repr__() in this case - how

Re: Weird list conversion

2015-12-13 Thread Larry Hudson via Python-list
On 12/13/2015 12:05 PM, KP wrote: On Sunday, 13 December 2015 11:57:57 UTC-8, Laura Creighton wrote: In a message of Sun, 13 Dec 2015 11:45:19 -0800, KP writes: Hi all, f = open("stairs.bin", "rb") data = list(f.read(16)) print data returns ['=', '\x04', '\x00', '\x05', '\

Re: Weird list conversion

2015-12-13 Thread Erik
On 13/12/15 20:28, Erik wrote: When you call "print", then the list class's __repr__() method is called which in turn calls the contained objects' __repr__() methods in turn I mean the __str__() method, not __repr__() in this case - however, the answer is otherwise the same. E. -- https://m

Re: Weird list conversion

2015-12-13 Thread Ian Kelly
On Sun, Dec 13, 2015 at 1:05 PM, KP wrote: > On Sunday, 13 December 2015 11:57:57 UTC-8, Laura Creighton wrote: >> In a message of Sun, 13 Dec 2015 11:45:19 -0800, KP writes: >> >Hi all, >> > >> > f = open("stairs.bin", "rb") >> > data = list(f.read(16)) >> > print data >> > >> >re

Re: Weird list conversion

2015-12-13 Thread Erik
On 13/12/15 20:05, KP wrote: On Sunday, 13 December 2015 11:57:57 UTC-8, Laura Creighton wrote: In a message of Sun, 13 Dec 2015 11:45:19 -0800, KP writes: Hi all, f = open("stairs.bin", "rb") data = list(f.read(16)) print data returns ['=', '\x04', '\x00', '\x05', '\x00', '\x01', '\x00', '

Re: Weird list conversion

2015-12-13 Thread KP
On Sunday, 13 December 2015 11:57:57 UTC-8, Laura Creighton wrote: > In a message of Sun, 13 Dec 2015 11:45:19 -0800, KP writes: > >Hi all, > > > > f = open("stairs.bin", "rb") > > data = list(f.read(16)) > > print data > > > >returns > > > >['=', '\x04', '\x00', '\x05', '\x00', '\

Re: Weird list conversion

2015-12-13 Thread Ian Kelly
On Sun, Dec 13, 2015 at 12:45 PM, wrote: > Hi all, > > f = open("stairs.bin", "rb") > data = list(f.read(16)) > print data > > returns > > ['=', '\x04', '\x00', '\x05', '\x00', '\x01', '\x00', '\x00', '\x00', '\x00', > '\x00', '\x00', '\x00', '\x00', '\x00', '\x00'] > > The fir

Re: Weird list conversion

2015-12-13 Thread Laura Creighton
In a message of Sun, 13 Dec 2015 11:45:19 -0800, high5stor...@gmail.com writes: >Hi all, > > f = open("stairs.bin", "rb") > data = list(f.read(16)) > print data > >returns > >['=', '\x04', '\x00', '\x05', '\x00', '\x01', '\x00', '\x00', '\x00', '\x00', >'\x00', '\x00', '\x00', '\x0

Re: Weird behavior on __dict__ attr

2015-02-10 Thread Steven D'Aprano
Shiyao Ma wrote: > Hi. > > My context is a little hard to reproduce. > > NS3 is a network simulation tool written in C++. I am using its Python > binding. > > So the class I am dealing with is from a .so file. So it is written in (probably) C and you don't have source code for it. > Say, I do

Re: Weird behavior on __dict__ attr

2015-02-09 Thread Dave Angel
On 02/09/2015 09:52 PM, Shiyao Ma wrote: Hi. My context is a little hard to reproduce. WHY don't you try? Telling us about a class without showing how it's defined leaves us all guessing. Start by telling us Python version. And if it's 2.x, tell us whether this class is an old style or n

Re: Weird connection problem

2014-10-25 Thread Roland Hedberg
It’s a special HTTPS url and searching further it seems to be a SNI problem talked about here: http://stackoverflow.com/questions/18578439/using-requests-with-tls-doesnt-give-sni-support > 25 okt 2014 kl. 08:48 skrev Joel Goldstick : > > On Sat, Oct 25, 2014 at 9:40 AM, Roland Hedberg wrote: >

Re: Weird connection problem

2014-10-25 Thread Joel Goldstick
On Sat, Oct 25, 2014 at 9:40 AM, Roland Hedberg wrote: > When I try to access a URL using requests I always get: > socket.error: [Errno 104] Connection reset by peer > > If I try to access the same URL using curl I get no error message instead I > get the page. > The same result if I use a web br

Re: Weird connection problem

2014-10-25 Thread Roland Hedberg
Oh, by the way! To make this more interesting :-/ I saw this behavior on a Linux machine (Ubuntu 14.04 LTS) using Python 2.7.6 if I do the same exercise on a Mac OS X machine also with Python 2.7.6 - no problem what so ever. > 25 okt 2014 kl. 08:40 skrev Roland Hedberg : > > When I try to acce

Re: Weird SSL problem

2014-10-01 Thread Roland Hedberg
30 sep 2014 kl. 00:55 skrev Ned Deily : > In article , > Roland Hedberg wrote: > >> Hi! >> >> I¹m trying to access >> https://stsadweb.one.microsoft.com/adfs/.well-known/openid-configuration >> >> Doing it the simplest way I get the following: >> > import urllib > f = > urllib.

Re: Weird SSL problem

2014-09-29 Thread Ned Deily
In article , Roland Hedberg wrote: > Hi! > > I¹m trying to access > https://stsadweb.one.microsoft.com/adfs/.well-known/openid-configuration > > Doing it the simplest way I get the following: > > >>> import urllib > >>> f = > >>> urllib.urlopen("https://stsadweb.one.microsoft.com/adfs/.well

Re: Weird problem with UDP and gevent

2013-10-19 Thread Grant Edwards
On 2013-10-18, James Harris wrote: > "Roy Smith" wrote in message > news:l3riea$82$1...@panix2.panix.com... >> I'm running: >> >> Ubuntu Precise >> Python 2.7.3 >> django 1.4.5 >> gunicorn 0.17.4 >> gevent 1.0dev (rc3) >> >> I haven't been able to pin this down exactly, but it looks like if I >>

Re: Weird problem with UDP and gevent

2013-10-18 Thread Roy Smith
On Friday, October 18, 2013 1:04:38 PM UTC-4, James Harris wrote: > Those are two different things. You would normally use connect() on a > SOCK_STREAM socket. It requires that the remote endpoint, in this case > localhost:9700, has an open socket listening for connections. sendto() is > the rig

Re: Weird problem with UDP and gevent

2013-10-18 Thread James Harris
"Roy Smith" wrote in message news:l3riea$82$1...@panix2.panix.com... > I'm running: > > Ubuntu Precise > Python 2.7.3 > django 1.4.5 > gunicorn 0.17.4 > gevent 1.0dev (rc3) > > I haven't been able to pin this down exactly, but it looks like if I > do (inside of a custom logging.Handler subclass):

Re: Weird bahaviour from shlex - line no

2013-09-28 Thread Piet van Oostrum
Peter Otten <__pete...@web.de> writes: > Dave Angel wrote: > >> On 28/9/2013 02:26, Daniel Stojanov wrote: >> >>> Can somebody explain this. The line number reported by shlex depends >>> on the previous token. I want to be able to tell if I have just popped >>> the last token on a line. [...] > T

Re: Weird bahaviour from shlex - line no

2013-09-28 Thread Peter Otten
Dave Angel wrote: > On 28/9/2013 02:26, Daniel Stojanov wrote: > >> Can somebody explain this. The line number reported by shlex depends >> on the previous token. I want to be able to tell if I have just popped >> the last token on a line. >> > > I agree that it seems weird. However, I don't th

Re: Weird bahaviour from shlex - line no

2013-09-28 Thread Dave Angel
On 28/9/2013 02:26, Daniel Stojanov wrote: > Can somebody explain this. The line number reported by shlex depends > on the previous token. I want to be able to tell if I have just popped > the last token on a line. > I agree that it seems weird. However, I don't think you have made clear why it'

Re: Weird bahaviour from shlex - line no

2013-09-28 Thread Andreas Perstinger
On 28.09.2013 08:26, Daniel Stojanov wrote: Can somebody explain this. The line number reported by shlex depends on the previous token. I want to be able to tell if I have just popped the last token on a line. [SNIP] second = shlex.shlex("word1 word2,\nword3") Punctuation characters like th

Re: Weird ttk behaviour

2013-09-17 Thread Chris Angelico
On Wed, Sep 18, 2013 at 2:11 AM, Rotwang wrote: > I don't know tkinter well enough either, but the fact that it behaves > differently on Linux and Windows suggests to me that at least one version is > bugging out. Do you think this is worth raising on bugs.python.org? Possibly, but I'd keep it he

Re: Weird ttk behaviour

2013-09-17 Thread Rotwang
On 17/09/2013 15:35, Chris Angelico wrote: On Wed, Sep 18, 2013 at 12:25 AM, Rotwang wrote: In fact, if I replace tkderp with this: # begin tkderp.py import tkinter as tk _root = tk.Tk() _root.withdraw() # end tkderp.py then simply importing tkderp before tkderp2 is enough to make the la

Re: Weird ttk behaviour

2013-09-17 Thread Chris Angelico
On Wed, Sep 18, 2013 at 12:25 AM, Rotwang wrote: > In fact, if I replace tkderp with this: > > > # begin tkderp.py > > import tkinter as tk > > _root = tk.Tk() > _root.withdraw() > > # end tkderp.py > > > then simply importing tkderp before tkderp2 is enough to make the latter > work properly Nic

Re: Weird ttk behaviour

2013-09-17 Thread Rotwang
On 17/09/2013 12:32, Chris Angelico wrote: [...] If reloading and doing it again makes things different, what happens if you simply trigger your code twice without reloading? I've no idea if it'll help, it just seems like an attack vector on the problem, so to speak. Thanks for the suggestion

Re: Weird ttk behaviour

2013-09-17 Thread Chris Angelico
On Tue, Sep 17, 2013 at 9:27 PM, Rotwang wrote: > On 16/09/2013 23:34, Chris Angelico wrote: >> >> On Tue, Sep 17, 2013 at 2:28 AM, Rotwang wrote: >>> >>> If I then uncomment those two lines, reload the module and call f() again >>> (by entering tkderp.reload(tkderp).f()), the function works like

Re: Weird ttk behaviour

2013-09-17 Thread Rotwang
On 16/09/2013 23:34, Chris Angelico wrote: On Tue, Sep 17, 2013 at 2:28 AM, Rotwang wrote: If I then uncomment those two lines, reload the module and call f() again (by entering tkderp.reload(tkderp).f()), the function works like it was supposed to in the first place: two warnings, no exception

Re: Weird ttk behaviour

2013-09-17 Thread Rotwang
On 16/09/2013 19:43, Serhiy Storchaka wrote: 16.09.13 19:28, Rotwang написав(ла): On Windows 7 (sys.version is '3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:57:17) [MSC v.1600 64 bit (AMD64)]') there's no problem; f() works fine in the first place. Does anybody know what's going on? What _root.

Re: Weird ttk behaviour

2013-09-16 Thread Chris Angelico
On Tue, Sep 17, 2013 at 2:28 AM, Rotwang wrote: > If I then uncomment those two lines, reload the module and call f() again > (by entering tkderp.reload(tkderp).f()), the function works like it was > supposed to in the first place: two warnings, no exceptions. I can reload > the module as many tim

Re: Weird ttk behaviour

2013-09-16 Thread Serhiy Storchaka
16.09.13 19:28, Rotwang написав(ла): On Windows 7 (sys.version is '3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:57:17) [MSC v.1600 64 bit (AMD64)]') there's no problem; f() works fine in the first place. Does anybody know what's going on? What _root.wantobjects() returns? -- https://mail.pytho

Re: weird behavior. bug perhaps?

2013-06-19 Thread rusi
On Jun 18, 8:31 pm, zoom wrote: > > yes, that's the hing. > > thanks a lot > > FYI this happens because >  >>> shape(mean(m,1)) > (4, 1) >  >>> shape(mean(array(m),1)) > (4,) > > thanks again And thank you for the 'Thank you' !! Given the noob-questions the list is currently dealing with, your q

Re: weird behavior. bug perhaps?

2013-06-18 Thread zoom
On 06/18/2013 05:25 PM, Robert Kern wrote: On 2013-06-18 15:23, zoom wrote: Hi, I have a strange problem here. Perhaps someone would care to help me. In the file test.py I have the following code: from scipy import matrix, tile, mean, shape import unittest class TestSequenceFunctions(unittest

Re: weird behavior. bug perhaps?

2013-06-18 Thread zoom
On 06/18/2013 04:27 PM, rusi wrote: On Jun 18, 7:23 pm, zoom wrote: Hi, I have a strange problem here. Perhaps someone would care to help me. In the file test.py I have the following code: from scipy import matrix, tile, mean, shape import unittest class TestSequenceFunctions(unittest.TestCa

Re: weird behavior. bug perhaps?

2013-06-18 Thread Robert Kern
On 2013-06-18 15:23, zoom wrote: Hi, I have a strange problem here. Perhaps someone would care to help me. In the file test.py I have the following code: from scipy import matrix, tile, mean, shape import unittest class TestSequenceFunctions(unittest.TestCase): def setUp(self):

Re: weird behavior. bug perhaps?

2013-06-18 Thread Marcel Rodrigues
Note that print [shape(m)[1],1] just prints a list with two elements where the first element is shape(m)[1] and the second is the number 1 (regardless of the value of m). I'm pretty sure that's not what you want. 2013/6/18 zoom > Hi, I have a strange problem here. Perhaps someone would care t

Re: weird behavior. bug perhaps?

2013-06-18 Thread rusi
On Jun 18, 7:23 pm, zoom wrote: > Hi, I have a strange problem here. Perhaps someone would care to help me. > > In the file test.py I have the following code: > > from scipy import matrix, tile, mean, shape > import unittest > > class TestSequenceFunctions(unittest.TestCase): > >      def setUp(se

Re: Weird python behavior

2013-04-26 Thread rusi
On Apr 26, 11:25 am, rusi wrote: > To present these kind of errors, Erlang has a concept of sticky > modules -- those that come from the system… ??present?? should have been 'prevent' -- http://mail.python.org/mailman/listinfo/python-list

Re: Weird python behavior

2013-04-25 Thread rusi
On Apr 26, 11:04 am, Tim Roberts wrote: > Forafo San wrote: > > >OK, lesson learned: Take care not to have module names that conflict with > >python's built ins. Sorry for being so obtuse. > > You don't have to apologize.  We've all been bitten by this at least once. Yes… When it comes to keywo

Re: Weird python behavior

2013-04-25 Thread Tim Roberts
Forafo San wrote: > >OK, lesson learned: Take care not to have module names that conflict with >python's built ins. Sorry for being so obtuse. You don't have to apologize. We've all been bitten by this at least once. -- Tim Roberts, t...@probo.com Providenza & Boekelheide, Inc. -- http://mail

Re: Weird python behavior

2013-04-24 Thread Forafo San
On Wednesday, April 24, 2013 3:08:27 PM UTC-4, Neil Cerutti wrote: > On 2013-04-24, Forafo San wrote: > > > Hello All, > > > I'm running Python version 2.7.3_6 on a FreeBSD system. The following > > session in a Python interpreter throws a mysterious TypeError: > > > > > > ---

Re: Weird python behavior

2013-04-24 Thread Neil Cerutti
On 2013-04-24, Forafo San wrote: > Hello All, > I'm running Python version 2.7.3_6 on a FreeBSD system. The following session > in a Python interpreter throws a mysterious TypeError: > > -- > [ppvora@snowfall ~/xbrl]$ python > Python 2.7.3 (default, Apr 22

Re: Weird behaviour?

2013-04-22 Thread Steven D'Aprano
On Mon, 22 Apr 2013 07:29:57 -0700, nn wrote: > On Apr 21, 9:19 pm, Steven D'Aprano +comp.lang.pyt...@pearwood.info> wrote: >> On Mon, 22 Apr 2013 10:56:11 +1000, Chris Angelico wrote: >> > You're running this under Windows. The convention on Windows is for >> > end-of-line to be signalled with \

Re: Weird behaviour?

2013-04-22 Thread Chris Angelico
On Tue, Apr 23, 2013 at 9:06 AM, wrote: > On Tuesday, April 23, 2013 12:29:57 AM UTC+10, nn wrote: > >> Maybe it is related to this bug? >> >> http://bugs.python.org/issue11272 > > I'm running Python 2.7.2 (on Windows) and that version doesn't appear to have > that bug: > > Python 2.7.2 (defau

Re: Weird behaviour?

2013-04-22 Thread jussij
On Tuesday, April 23, 2013 12:29:57 AM UTC+10, nn wrote: > Maybe it is related to this bug? > > http://bugs.python.org/issue11272 I'm running Python 2.7.2 (on Windows) and that version doesn't appear to have that bug: Python 2.7.2 (default, Apr 23 2013, 11:49:52) [MSC v.1500 32 bit (Intel)]

Re: Weird behaviour?

2013-04-22 Thread nn
On Apr 21, 9:19 pm, Steven D'Aprano wrote: > On Mon, 22 Apr 2013 10:56:11 +1000, Chris Angelico wrote: > > You're running this under Windows. The convention on Windows is for > > end-of-line to be signalled with \r\n, but the convention inside Python > > is to use just \n. With the normal use of b

Re: Weird behaviour?

2013-04-21 Thread jussij
On Monday, April 22, 2013 11:05:11 AM UTC+10, Steven D'Aprano wrote: > I cannot confirm that behaviour. It works fine for me. As Chris pointed out there is a \r character at the end of the string and that is causing the if to fail. I can now see the \r :) So this is *Windows only* behaviour.

Re: Weird behaviour?

2013-04-21 Thread Steven D'Aprano
On Mon, 22 Apr 2013 10:56:11 +1000, Chris Angelico wrote: > You're running this under Windows. The convention on Windows is for > end-of-line to be signalled with \r\n, but the convention inside Python > is to use just \n. With the normal use of buffered and parsed input, > this is all handled for

Re: Weird behaviour?

2013-04-21 Thread Chris Angelico
On Mon, Apr 22, 2013 at 11:05 AM, Steven D'Aprano wrote: > I cannot confirm that behaviour. It works fine for me. I should mention: Under Linux, there's no \r, so -u or no -u, the program will work fine. ChrisA -- http://mail.python.org/mailman/listinfo/python-list

Re: Weird behaviour?

2013-04-21 Thread jussij
On Monday, April 22, 2013 10:56:11 AM UTC+10, Chris Angelico wrote: > so your string actually contains '120\r', as will be revealed > by its repr(). Thanks Chris. That makes sense. Cheers Jussi -- http://mail.python.org/mailman/listinfo/python-list

Re: Weird behaviour?

2013-04-21 Thread Steven D'Aprano
On Sun, 21 Apr 2013 17:37:18 -0700, jussij wrote: > Can someone please explain the following behaviour? > > I downloaded and compiled the Python 2.7.2 code base. > > I then created this simple c:\temp\test.py macro: > > import sys > > def main(): > print("Please Input 120:

Re: Weird behaviour?

2013-04-21 Thread Chris Angelico
On Mon, Apr 22, 2013 at 10:37 AM, wrote: > Can someone please explain the following behaviour? > > If I run the macro using the -u (flush buffers) option the if statement > always fails: > > C:\Temp>python.exe -u c:\temp\test.py > Please Input 120: > 120 > Value Inputed: 120 >

Re: Weird exception handling behavior -- late evaluation in except clause

2012-12-02 Thread Chris Angelico
On Mon, Dec 3, 2012 at 6:30 PM, Steven D'Aprano wrote: > Yeah, in hindsight it was a pretty crappy example. But this sort of > dynamism really is useful: > > def testRaises(exc, func, *args): > try: > result = func(*args) > except exc: > return > raise AssertionError("e

Re: Weird exception handling behavior -- late evaluation in except clause

2012-12-02 Thread Steven D'Aprano
On Mon, 03 Dec 2012 16:24:50 +1100, Chris Angelico wrote: > On Mon, Dec 3, 2012 at 8:31 AM, Steven D'Aprano > wrote: >> Consider this piece of legal Python code: >> >> Err = None >> if condition(x) > 100: >> Err = OneException >> elif another_condition(x): >> Err = AnotherException >> try

Re: Weird exception handling behavior -- late evaluation in except clause

2012-12-02 Thread Chris Angelico
On Mon, Dec 3, 2012 at 8:31 AM, Steven D'Aprano wrote: > Consider this piece of legal Python code: > > Err = None > if condition(x) > 100: > Err = OneException > elif another_condition(x): > Err = AnotherException > try: > spam(a, b, c) > except Err: > recover() Legal it may be, b

Re: Weird exception handling behavior -- late evaluation in except clause

2012-12-02 Thread Steven D'Aprano
On Sun, 02 Dec 2012 12:25:22 -0500, Roy Smith wrote: > This is kind of weird (Python 2.7.3): > > try: > print "hello" > except foo: > print "foo" > > prints "hello". The problem (IMHO) is that apparently the except clause > doesn't get evaluated until after some exception is caught. Wh

Re: Weird exception handling behavior -- late evaluation in except clause

2012-12-02 Thread Terry Reedy
On 12/2/2012 12:25 PM, Roy Smith wrote: This is kind of weird (Python 2.7.3): try: print "hello" except foo: print "foo" prints "hello". The problem (IMHO) is that apparently the except clause doesn't get evaluated until after some exception is caught. Which means it never notices t

Re: Weird exception handling behavior -- late evaluation in except clause

2012-12-02 Thread Hans Mulder
On 2/12/12 18:25:22, Roy Smith wrote: > This is kind of weird (Python 2.7.3): > > try: > print "hello" > except foo: > print "foo" > > prints "hello". The problem (IMHO) is that apparently the except clause > doesn't get evaluated until after some exception is caught. Which means > it

Re: Weird import failure with "nosetests --processes=1"

2012-11-29 Thread Roy Smith
In article <50b78e26$0$6945$e4fe5...@news2.news.xs4all.nl>, Hans Mulder wrote: > That is baffling indeed. It looks like nose is adding some > directory to sys.path, which contains a module pyza.py instead > of a package. We finally figured it out. As it turns out, that's pretty close. > Anot

Re: weird isinstance/issubclass behavior?

2012-11-29 Thread Terry Reedy
On 11/29/2012 9:59 AM, lars van gemerden wrote: Hi, I have encountered some strange behavior of isinstance(/issubclass): depending on the import path used for classes i get different output, while the classes i compare are in the same file. Basically if i import a class as: from mod1.mo

Re: weird isinstance/issubclass behavior?

2012-11-29 Thread Ian Kelly
On Thu, Nov 29, 2012 at 9:07 AM, lars van gemerden wrote: > > PS: this is somewhat simpler than the actual case i've encountered, and > i haven't tested this exact case, but for now i hope this is enough to get > some of your insight. > > I know for sure that the imports both import the same file,

Re: Weird import failure with "nosetests --processes=1"

2012-11-29 Thread Hans Mulder
On 29/11/12 04:13:57, Roy Smith wrote: > I've got a minimal test script: > > - > $ cat test_foo.py > import pyza.models > print pyza.models > > def test_foo(): > pass > - > > pyza.models is a package. Under normal conditions, I can imp

Re: weird isinstance/issubclass behavior?

2012-11-29 Thread lars van gemerden
On Thursday, November 29, 2012 3:59:37 PM UTC+1, lars van gemerden wrote: > Hi, > > > > I have encountered some strange behavior of isinstance(/issubclass): > depending on the import path used for classes i get different output, while > the classes i compare are in the same file. > > > > B

Re: weird isinstance/issubclass behavior?

2012-11-29 Thread Chris Angelico
On Fri, Nov 30, 2012 at 1:59 AM, lars van gemerden wrote: > Basically if i import a class as: > > from mod1.mod2 import A > > or: > > from mod0.mod1.mod2 import A > > which both result in importing the same class, a call to isinstance(inst, A) > in another module can have a different outp

Re: weird behaviour: pygame plays in shell but not in script

2012-04-03 Thread Jean-Michel Pichavant
Mik wrote: Oh thanks alex! that's kind! PS: It looks like a party indeed: plenty of interesting discussions :-) On Mar 30, 4:33 am, alex23 wrote: On Mar 29, 10:41 pm, Mik wrote: What a nice way to introduce myself to the group!!! :-) Hey, don't beat yourself up, you: - su

Re: weird behaviour: pygame plays in shell but not in script

2012-04-03 Thread Chris Angelico
On Thu, Mar 29, 2012 at 11:41 PM, Mik wrote: > > I can't believe I am so dumb! > > after sound.play() the script was terminating > I didn't notice that 'play()' actually returns... > > What a nice way to introduce myself to the group!!! :-) > > sorry for bothering you guys :-) You've just pro

Re: weird behaviour: pygame plays in shell but not in script

2012-04-02 Thread rusi
On Mar 30, 8:33 am, alex23 wrote: > On Mar 29, 10:41 pm, Mik wrote: > > > What a nice way to introduce myself to the group!!! :-) > > Hey, don't beat yourself up, you: > >  - summarised the problem in the subject heading >  - included actual code showing the problem >  - reported back on the prob

Re: weird behaviour: pygame plays in shell but not in script

2012-04-02 Thread Mik
Oh thanks alex! that's kind! PS: It looks like a party indeed: plenty of interesting discussions :-) On Mar 30, 4:33 am, alex23 wrote: > On Mar 29, 10:41 pm, Mik wrote: > > > What a nice way to introduce myself to the group!!! :-) > > Hey, don't beat yourself up, you: > >  - summarised the prob

Re: weird behaviour: pygame plays in shell but not in script

2012-04-02 Thread alex23
On Mar 29, 10:41 pm, Mik wrote: > What a nice way to introduce myself to the group!!! :-) Hey, don't beat yourself up, you: - summarised the problem in the subject heading - included actual code showing the problem - reported back on the problem you found That puts you ahead of most new post

Re: weird behaviour: pygame plays in shell but not in script

2012-04-02 Thread Mik
I can't believe I am so dumb! after sound.play() the script was terminating I didn't notice that 'play()' actually returns... What a nice way to introduce myself to the group!!! :-) sorry for bothering you guys :-) -- http://mail.python.org/mailman/listinfo/python-list

Re: Weird newbie question

2012-01-26 Thread Matty Sarro
The issue was a version mismatch. When installing python on windows, it installs a shortcut so when you right click, you can edit things in IDLE. I had installed python 3 after installing 2.7, so it apparently changed the extension. As for not showing tracebacks, I couldn't. When I ran the program

Re: Weird newbie question

2012-01-26 Thread Rick Johnson
On Jan 26, 4:05 pm, Matty Sarro wrote: > Here's my code: > > from sys import argv > script,filename=argv > txt=open(filename) > print "Here is your file %r:" % filename > print txt.read() > print "I'll also ask you to type it again:" > file_again=raw_input("> ") > txt_again=open(file_again) > pri

Re: Weird newbie question

2012-01-26 Thread John Gordon
In Matty Sarro writes: > Hey everyone. I'm running into a funky error as I work through "Learn > Python the Hard Way." What's weird is both idle and the python > interpreter in idle spit out an error about syntax, but when I run the > same script from the command line it works just fine, with n

Re: Weird newbie question

2012-01-26 Thread Ethan Furman
Matty Sarro wrote: from sys import argv script,filename=argv txt=open(filename) print "Here is your file %r:" % filename print txt.read() print "I'll also ask you to type it again:" file_again=raw_input("> ") txt_again=open(file_again) print txt_again.read() IDLE is saying that my error is on li

Re: Weird newbie question

2012-01-26 Thread Steven D'Aprano
On Thu, 26 Jan 2012 17:05:57 -0500, Matty Sarro wrote: > Hey everyone. I'm running into a funky error as I work through "Learn > Python the Hard Way." What's weird is both idle and the python > interpreter in idle spit out an error about syntax, but when I run the > same script from the command li

Re: Weird newbie question

2012-01-26 Thread Andrea Crotti
On 01/26/2012 10:05 PM, Matty Sarro wrote: Hey everyone. I'm running into a funky error as I work through "Learn Python the Hard Way." What's weird is both idle and the python interpreter in idle spit out an error about syntax, but when I run the same script from the command line it works just fi

Re: Weird Loop Behaviour

2012-01-20 Thread Arnaud Delobelle
On 20 January 2012 20:47, Yigit Turgut wrote: > Hi, > > In the following code, I am trying to run "black" screen for 3 seconds > and respectively 2 seconds "white" screen. Black routine takes 3 > seconds and white 2 seconds, 2 x black + white = 8 seconds which > should be the expected value but wh

Re: Weird Loop Behaviour

2012-01-20 Thread Emile van Sebille
On 1/20/2012 12:47 PM Yigit Turgut said... Hi, In the following code, I am trying to run "black" screen for 3 seconds and respectively 2 seconds "white" screen. Black routine takes 3 seconds and white 2 seconds, 2 x black + white = 8 seconds which should be the expected value but when I run it I

Re: Weird Loop Behaviour

2012-01-20 Thread MRAB
On 20/01/2012 20:47, Yigit Turgut wrote: Hi, In the following code, I am trying to run "black" screen for 3 seconds and respectively 2 seconds "white" screen. Black routine takes 3 seconds and white 2 seconds, 2 x black + white = 8 seconds which should be the expected value but when I run it I g

Re: Weird interaction with nested functions inside a decorator-producing function and closuring of outer data...

2011-08-24 Thread Steven D'Aprano
Adam Jorgensen wrote: > Thanks :-) Sorry about the size, I wasn't sure what was relevant... We prefer that you don't top-post here, because it makes it hard to see context when people reply. In general, people asking questions should always try to reduce the problem to the simplest code that wil

Re: Weird interaction with nested functions inside a decorator-producing function and closuring of outer data...

2011-08-24 Thread Adam Jorgensen
Thanks :-) Sorry about the size, I wasn't sure what was relevant... On 24 August 2011 15:29, Peter Otten <__pete...@web.de> wrote: > Adam Jorgensen wrote: > >> Hi all, I'm experiencing a weird issue with closuring of parameters >> and some nested functions I have inside two functions that >> retur

  1   2   3   4   >