comp.lang.python - 26 new messages in 10 topics - digest
comp.lang.python
http://groups.google.com/group/comp.lang.python?hl=en
comp.lang.python@googlegroups.com
Today's topics:
* Time zones and why they change so damned often - 6 messages, 6 authors
http://groups.google.com/group/comp.lang.python/t/0afb505736567141?hl=en
* unicode troubles and postgres - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/86d230494673282e?hl=en
* All right, I'me trying, really I am - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/be931cfe1fd08211?hl=en
* Monkeypatching a staticmethod? - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/0c5e826b14d4f2e9?hl=en
* Python 2.x and 3.x usage survey - 6 messages, 4 authors
http://groups.google.com/group/comp.lang.python/t/243fc29a8c4a8ba5?hl=en
* Input Error issues - Windows 7 - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.python/t/cfc5383c35e58a27?hl=en
* Constructive Criticism - 3 messages, 3 authors
http://groups.google.com/group/comp.lang.python/t/45821f6b72d33dbb?hl=en
* Porting mailing list underused? - 3 messages, 2 authors
http://groups.google.com/group/comp.lang.python/t/518be458ecf0c20b?hl=en
* Send array back in result from urllib2.urlopen(request, postData) - 1
messages, 1 author
http://groups.google.com/group/comp.lang.python/t/bf6b03d8b9c08321?hl=en
* L[:] - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.python/t/8c4883bbe077624c?hl=en
==============================================================================
TOPIC: Time zones and why they change so damned often
http://groups.google.com/group/comp.lang.python/t/0afb505736567141?hl=en
==============================================================================
== 1 of 6 ==
Date: Fri, Jan 10 2014 1:04 am
From: Alister
On Fri, 10 Jan 2014 07:31:11 +0000, Bob Martin wrote:
> in 714232 20140109 120741 Alister <alister.ware@ntlworld.com> wrote:
>>On Thu, 09 Jan 2014 07:17:25 +0000, Mark Lawrence wrote:
>>
>>> On 09/01/2014 04:14, Chris Angelico wrote:
>>>> On Thu, Jan 9, 2014 at 2:54 PM, Ben Finney
>>>> <ben+python@benfinney.id.au>
>>>> wrote:
>>>>> I'm approaching it with the goal of knowing better what I'm talking
>>>>> about when I advocate scrapping the whole DST system :-)
>>>>
>>>> I would definitely support the scrapping of DST. I'm less sure that
>>>> we need exactly 24 timezones around the world, though. It's not
>>>> nearly as big a problem to have the half-hour and quarter-hour
>>>> timezones - though it would be easier if timezone were strictly an
>>>> integer number of hours. But DST is the real pain.
>>>>
>>>> What I find, most of the time, is that it's Americans who can't
>>>> handle DST. I run an international Dungeons and Dragons campaign (we
>>>> play online, and new players are most welcome, as are people
>>>> watching!), and the Aussies (myself included) know to check UTC time,
>>>> the Brits and Europeans check UTC or just know what UTC is, and the
>>>> Americans say "Doesn't that happen at 8 o'clock Eastern time?" and
>>>> get confused.
>>>> I don't understand this. Are my players drawn exclusively from the
>>>> pool of people who've never worked with anyone in Arizona [1]? Yes,
>>>> I'm stereotyping a bit here, and not every US player has had problems
>>>> with this, but it's the occasional US player who knows to check, and
>>>> the rare European, British, or Aussie player who doesn't.
>>>>
>>>> In any case, the world-wide abolition of DST would eliminate the
>>>> problem. The only remaining problem would be reminding people to
>>>> change the batteries in their smoke detectors.
>>>>
>>>> ChrisA
>>>>
>>>> [1] For those who aren't right up on timezone trivia, AZ has no DST.
>>>> Similarly the Australian state of Queensland does not shift its
>>>> clocks.
>>>>
>>>>
>>> I remember this "From February 1968 to November 1971 the UK kept
>>> daylight saving time throughout the year mainly for commercial
>>> reasons, especially regarding time conformity with other European
>>> countries". My source
>>> http://www.timeanddate.com/time/uk/time-zone-background.html
>>
>>we dont have "Daylight saving time" we switch between GMT (Greenwich
>>Mean Time) and BST (British Summer Time) at some point in the past we
>>have also used DST (Double Summer Time).
>
> British Summer Time *is* Daylight Saving Time.
My point is in the UK we have never refered to it as Daylight saving Time
that is an Americanism :-)
--
if (argc > 1 && strcmp(argv[1], "-advice") == 0) {
printf("Don't Panic!\n");
exit(42);
}
-- Arnold Robbins in the LJ of February '95, describing RCS
== 2 of 6 ==
Date: Fri, Jan 10 2014 10:22 am
From: Peter Pearson
On Thu, 9 Jan 2014 15:14:55 +1100, Chris Angelico wrote:
[snip]
> What I find, most of the time, is that it's Americans who can't handle
> DST. I run an international Dungeons and Dragons campaign (we play
> online, and new players are most welcome, as are people watching!),
> and the Aussies (myself included) know to check UTC time, the Brits
> and Europeans check UTC or just know what UTC is, and the Americans
> say "Doesn't that happen at 8 o'clock Eastern time?" and get confused.
Around 30 years ago, the Wall Street Journal ran an opinion piece
advocating the abandonment of time zones and the unification of the
globe into a single glorious time zone. After enumerating the
efficiencies to be achieved by this system, the writer briefly
addressed the question of whose time zone would become the global
standard, promptly arriving at the conclusion that, due to the
concentration of important commerce, the logical choice was the
east coast of the United States.
My point: we deserve the teasing.
--
To email me, substitute nowhere->spamcop, invalid->net.
== 3 of 6 ==
Date: Fri, Jan 10 2014 10:48 am
From: MRAB
On 2014-01-10 18:22, Peter Pearson wrote:
> On Thu, 9 Jan 2014 15:14:55 +1100, Chris Angelico wrote:
> [snip]
>> What I find, most of the time, is that it's Americans who can't handle
>> DST. I run an international Dungeons and Dragons campaign (we play
>> online, and new players are most welcome, as are people watching!),
>> and the Aussies (myself included) know to check UTC time, the Brits
>> and Europeans check UTC or just know what UTC is, and the Americans
>> say "Doesn't that happen at 8 o'clock Eastern time?" and get confused.
>
> Around 30 years ago, the Wall Street Journal ran an opinion piece
> advocating the abandonment of time zones and the unification of the
> globe into a single glorious time zone. After enumerating the
> efficiencies to be achieved by this system, the writer briefly
> addressed the question of whose time zone would become the global
> standard, promptly arriving at the conclusion that, due to the
> concentration of important commerce, the logical choice was the
> east coast of the United States.
>
What a silly idea!
The logical choice is UTC. :-)
> My point: we deserve the teasing.
>
== 4 of 6 ==
Date: Fri, Jan 10 2014 10:53 am
From: Mark Lawrence
On 10/01/2014 18:48, MRAB wrote:
> On 2014-01-10 18:22, Peter Pearson wrote:
>> On Thu, 9 Jan 2014 15:14:55 +1100, Chris Angelico wrote:
>> [snip]
>>> What I find, most of the time, is that it's Americans who can't handle
>>> DST. I run an international Dungeons and Dragons campaign (we play
>>> online, and new players are most welcome, as are people watching!),
>>> and the Aussies (myself included) know to check UTC time, the Brits
>>> and Europeans check UTC or just know what UTC is, and the Americans
>>> say "Doesn't that happen at 8 o'clock Eastern time?" and get confused.
>>
>> Around 30 years ago, the Wall Street Journal ran an opinion piece
>> advocating the abandonment of time zones and the unification of the
>> globe into a single glorious time zone. After enumerating the
>> efficiencies to be achieved by this system, the writer briefly
>> addressed the question of whose time zone would become the global
>> standard, promptly arriving at the conclusion that, due to the
>> concentration of important commerce, the logical choice was the
>> east coast of the United States.
>>
> What a silly idea!
>
> The logical choice is UTC. :-)
Hell will freeze over first. But apparently it already has in
Minnesota. Drat, drat and double drat!!!
>
>> My point: we deserve the teasing.
>>
>
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
== 5 of 6 ==
Date: Fri, Jan 10 2014 11:55 am
From: Grant Edwards
On 2014-01-10, Mark Lawrence <breamoreboy@yahoo.co.uk> wrote:
> Hell will freeze over first. But apparently it already has in
> Minnesota. Drat, drat and double drat!!!
It got darned cold here in Minnesota on Monday (-23F in Minneapolis,
-35F in Embarass), but Hell is in Michigan -- where it only got down
to -15F.
http://en.wikipedia.org/wiki/Hell,_Michigan
http://www.roadsideamerica.com/tip/2456
== 6 of 6 ==
Date: Fri, Jan 10 2014 12:26 pm
From: Gene Heskett
On Friday 10 January 2014 15:24:11 Mark Lawrence did opine:
> On 10/01/2014 18:48, MRAB wrote:
> > On 2014-01-10 18:22, Peter Pearson wrote:
> >> On Thu, 9 Jan 2014 15:14:55 +1100, Chris Angelico wrote:
> >> [snip]
> >>
> >>> What I find, most of the time, is that it's Americans who can't
> >>> handle DST. I run an international Dungeons and Dragons campaign
> >>> (we play online, and new players are most welcome, as are people
> >>> watching!), and the Aussies (myself included) know to check UTC
> >>> time, the Brits and Europeans check UTC or just know what UTC is,
> >>> and the Americans say "Doesn't that happen at 8 o'clock Eastern
> >>> time?" and get confused.
> >>
> >> Around 30 years ago, the Wall Street Journal ran an opinion piece
> >> advocating the abandonment of time zones and the unification of the
> >> globe into a single glorious time zone. After enumerating the
> >> efficiencies to be achieved by this system, the writer briefly
> >> addressed the question of whose time zone would become the global
> >> standard, promptly arriving at the conclusion that, due to the
> >> concentration of important commerce, the logical choice was the
> >> east coast of the United States.
> >
> > What a silly idea!
> >
> > The logical choice is UTC. :-)
>
> Hell will freeze over first. But apparently it already has in
> Minnesota. Drat, drat and double drat!!!
That Hell the headlines referred to is in Michigan... Its a headline they
drag out every time we get a cold snap & its ano otherwise slow news day.
Nothing to see here, now move along please...
>
> >> My point: we deserve the teasing.
Cheers, Gene
--
"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
Genes Web page <http://geneslinuxbox.net:6309/gene>
Young men want to be faithful and are not; old men want to be faithless and
cannot.
-- Oscar Wilde
A pen in the hand of this president is far more
dangerous than 200 million guns in the hands of
law-abiding citizens.
==============================================================================
TOPIC: unicode troubles and postgres
http://groups.google.com/group/comp.lang.python/t/86d230494673282e?hl=en
==============================================================================
== 1 of 1 ==
Date: Fri, Jan 10 2014 2:44 am
From: wxjmfauth@gmail.com
Le jeudi 9 janvier 2014 19:49:27 UTC+1, Ethan Furman a écrit :
> So I'm working with postgres, and I get a datadump which I try to restore to my test system, and I get this:
>
>
>
> ERROR: value too long for type character varying(4)
>
> CONTEXT: COPY res_currency, line 32, column symbol: "руб"
>
>
>
> "py6" sure looks like it should fit, but it don't. Further investigation revealed that "py6" is made up of the bytes d1
>
> 80 d1 83 d0 b1.
>
>
>
> Any ideas on what that means, exactly?
>
>
When one has to face such a characteristic sequence,
the first thing to do is to think "utf-8".
(Not a proof)
>>> a = list(range(0x0410, 0x0415))
>>> a += list(range(0x0440, 0x0445))
>>> a += list(range(0x0480, 0x0485))
>>> import unicodedata as ud
>>> for i in a:
... hex(i), chr(i).encode('utf-8'), ud.name(chr(i))
...
('0x410', b'\xd0\x90', 'CYRILLIC CAPITAL LETTER A')
('0x411', b'\xd0\x91', 'CYRILLIC CAPITAL LETTER BE')
('0x412', b'\xd0\x92', 'CYRILLIC CAPITAL LETTER VE')
('0x413', b'\xd0\x93', 'CYRILLIC CAPITAL LETTER GHE')
('0x414', b'\xd0\x94', 'CYRILLIC CAPITAL LETTER DE')
('0x440', b'\xd1\x80', 'CYRILLIC SMALL LETTER ER')
('0x441', b'\xd1\x81', 'CYRILLIC SMALL LETTER ES')
('0x442', b'\xd1\x82', 'CYRILLIC SMALL LETTER TE')
('0x443', b'\xd1\x83', 'CYRILLIC SMALL LETTER U')
('0x444', b'\xd1\x84', 'CYRILLIC SMALL LETTER EF')
('0x480', b'\xd2\x80', 'CYRILLIC CAPITAL LETTER KOPPA')
('0x481', b'\xd2\x81', 'CYRILLIC SMALL LETTER KOPPA')
('0x482', b'\xd2\x82', 'CYRILLIC THOUSANDS SIGN')
('0x483', b'\xd2\x83', 'COMBINING CYRILLIC TITLO')
('0x484', b'\xd2\x84', 'COMBINING CYRILLIC PALATALIZATION')
jmf
==============================================================================
TOPIC: All right, I'me trying, really I am
http://groups.google.com/group/comp.lang.python/t/be931cfe1fd08211?hl=en
==============================================================================
== 1 of 1 ==
Date: Fri, Jan 10 2014 4:43 am
From: Mark Lawrence
It's a peanuts cartoon https://www.pinterest.com/pin/44613852532468697/
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
==============================================================================
TOPIC: Monkeypatching a staticmethod?
http://groups.google.com/group/comp.lang.python/t/0c5e826b14d4f2e9?hl=en
==============================================================================
== 1 of 1 ==
Date: Fri, Jan 10 2014 6:04 am
From: Piet van Oostrum
Ian Kelly <ian.g.kelly@gmail.com> writes:
> I suggest defining x as a normal function and writing the assignment
> as "Foo.x = staticmethod(x)" to keep x callable from the global
> namespace. Or just del it after doing the monkey patch.
You can use Foo.x = staticmethod(lambda: 2)
--
Piet van Oostrum <piet@vanoostrum.org>
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]
==============================================================================
TOPIC: Python 2.x and 3.x usage survey
http://groups.google.com/group/comp.lang.python/t/243fc29a8c4a8ba5?hl=en
==============================================================================
== 1 of 6 ==
Date: Fri, Jan 10 2014 9:36 am
From: John Ladasky
I responded to the survey about a week ago. Dan, I hope you will share the results with us soon. I also tried to reply to this thread, but I lost the ability to post to newsgroups for about a week. It seems to have been restored, so I will try again.
My transition from Py2 to Py3 is implicitly documented in several posts here on comp.lang.python. I switched over to Py3 about a year ago, and I'm not looking back. I couldn't move to Py3 until numpy and matplotlib were ported. But once that was done, the advantages outweighed the costs, and I switched.
Changing over has not been painless. I'm doing without wxPython for now, my favorite GUI. I know that Phoenix is coming to take wxPython's place. Meanwhile, I'm willing to be sold on any other Linux- and Py3-compatible GUI -- besides TKinter, that is.
I also miss psyco. I had a lot of Py2 code which made very little use of dynamic typing. Psyco accelerated it nicely. I believe that that a lot of my Py3 code would also benefit from JIT compilation.
Finally, I have encountered some small mental hurdles concerning Unicode. I am teaching a Silicon Valley test engineer Python on the side. His task is to implement an automated device testing suite over a telnet connection. We have to remember to convert between the remote device's expectation of strings of bytes, and Python's expectation of strings of Unicode characters. When we forget, there can be bugs. I'm sure that I'll get used to it eventually.
== 2 of 6 ==
Date: Fri, Jan 10 2014 9:48 am
From: Ned Batchelder
On 1/10/14 12:36 PM, John Ladasky wrote:
> I responded to the survey about a week ago. Dan, I hope you will share the results with us soon. I also tried to reply to this thread, but I lost the ability to post to newsgroups for about a week. It seems to have been restored, so I will try again.
>
> My transition from Py2 to Py3 is implicitly documented in several posts here on comp.lang.python. I switched over to Py3 about a year ago, and I'm not looking back. I couldn't move to Py3 until numpy and matplotlib were ported. But once that was done, the advantages outweighed the costs, and I switched.
>
> Changing over has not been painless. I'm doing without wxPython for now, my favorite GUI. I know that Phoenix is coming to take wxPython's place. Meanwhile, I'm willing to be sold on any other Linux- and Py3-compatible GUI -- besides TKinter, that is.
>
> I also miss psyco. I had a lot of Py2 code which made very little use of dynamic typing. Psyco accelerated it nicely. I believe that that a lot of my Py3 code would also benefit from JIT compilation.
>
> Finally, I have encountered some small mental hurdles concerning Unicode. I am teaching a Silicon Valley test engineer Python on the side. His task is to implement an automated device testing suite over a telnet connection. We have to remember to convert between the remote device's expectation of strings of bytes, and Python's expectation of strings of Unicode characters. When we forget, there can be bugs. I'm sure that I'll get used to it eventually.
>
On Python-Dev, Dan Stromberg posted this link with the results:
http://stromberg.dnsalias.org/~strombrg/python-2.x-vs-3.x-survey/
--
Ned Batchelder, http://nedbatchelder.com
== 3 of 6 ==
Date: Fri, Jan 10 2014 10:02 am
From: Ethan Furman
On 01/10/2014 09:36 AM, John Ladasky wrote:
>
> We have to remember to convert between the remote device's
> expectation of strings of bytes, and Python's expectation of
> strings of Unicode characters. When we forget, there can be
> bugs. I'm sure that I'll get used to it eventually.
A useful data point for why you don't just use bytes on the Python side would be valuable for the discussions currently
taking place on PyDev.
--
~Ethan~
== 4 of 6 ==
Date: Fri, Jan 10 2014 11:43 am
From: John Ladasky
On Friday, January 10, 2014 9:48:43 AM UTC-8, Ned Batchelder wrote:
> On Python-Dev, Dan Stromberg posted this link with the results:
>
> http://stromberg.dnsalias.org/~strombrg/python-2.x-vs-3.x-survey/
That link gave me a 404. :^(
== 5 of 6 ==
Date: Fri, Jan 10 2014 11:53 am
From: MRAB
On 2014-01-10 19:43, John Ladasky wrote:
> On Friday, January 10, 2014 9:48:43 AM UTC-8, Ned Batchelder wrote:
>
>> On Python-Dev, Dan Stromberg posted this link with the results:
>>
>> http://stromberg.dnsalias.org/~strombrg/python-2.x-vs-3.x-survey/
>
> That link gave me a 404. :^(
>
It's available here:
https://wiki.python.org/moin/2.x-vs-3.x-survey?action=AttachFile&do=view&target=2013-2014+Python+2.x-3.x+survey.pdf
== 6 of 6 ==
Date: Fri, Jan 10 2014 11:50 am
From: Ned Batchelder
On 1/10/14 2:43 PM, John Ladasky wrote:
> On Friday, January 10, 2014 9:48:43 AM UTC-8, Ned Batchelder wrote:
>
>> On Python-Dev, Dan Stromberg posted this link with the results:
>>
>> http://stromberg.dnsalias.org/~strombrg/python-2.x-vs-3.x-survey/
>
> That link gave me a 404. :^(
>
Sorry, it worked when I read it when first posted. They've been put on
the Python wiki: https://wiki.python.org/moin/2.x-vs-3.x-survey
--
Ned Batchelder, http://nedbatchelder.com
==============================================================================
TOPIC: Input Error issues - Windows 7
http://groups.google.com/group/comp.lang.python/t/cfc5383c35e58a27?hl=en
==============================================================================
== 1 of 2 ==
Date: Fri, Jan 10 2014 11:38 am
From: bryan.kardisco@gmail.com
I'm new to python and am trying to just get some basic stuff up and going.
I have a very basic module called foo
It's in the following directory on my machine
C:\workspace\PyFoo\src\foo
In that folder is __init__.py (created automatically) and foo.py
foo.py looks like this
class foo():
def __init__(self, name, number):
self.name = name
self.number = number
def getName(self):
return self.name
def getNumber(self):
return self.number
If I open up command prompt and do following it works:
C:\workspace\PyFoo\src\foo>python
Python 3.3.3 (v3.3.3:c3896275c0f6, Nov 18 2013, 21:18:40) [MSC v.1600 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from foo import foo
>>> f = foo(1,2)
>>> f.getName()
1
>>>
However, if I run this from C:\ I get the following
C:\>python
Python 3.3.3 (v3.3.3:c3896275c0f6, Nov 18 2013, 21:18:40) [MSC v.1600 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from foo import foo
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'foo'
>>>
I thought, well maybe it's a system error
>>> import sys
>>> print(sys.path)
['', 'C:\\Python33', 'C:\\Python33\\Lib', 'C:\\Python33\\DLLs', 'C:\\workspace', 'C:\\Windows\\system32\\python33.zip',
'C:\\Python33\\lib\\site-packages']
>>>
C:\>echo %PYTHONPATH%
C:\Python33;C:\Python33\Lib;C:\Python33\DLLs;C:\workspace
However, that seems OK.
Is there something I'm missing?
== 2 of 2 ==
Date: Fri, Jan 10 2014 11:48 am
From: Ned Batchelder
On 1/10/14 2:38 PM, bryan.kardisco@gmail.com wrote:
> I'm new to python and am trying to just get some basic stuff up and going.
Welcome!
>
> I have a very basic module called foo
>
> It's in the following directory on my machine
>
> C:\workspace\PyFoo\src\foo
> In that folder is __init__.py (created automatically) and foo.py
>
> foo.py looks like this
>
> class foo():
> def __init__(self, name, number):
> self.name = name
> self.number = number
> def getName(self):
> return self.name
> def getNumber(self):
> return self.number
>
>
> If I open up command prompt and do following it works:
>
> C:\workspace\PyFoo\src\foo>python
> Python 3.3.3 (v3.3.3:c3896275c0f6, Nov 18 2013, 21:18:40) [MSC v.1600 32 bit (Intel)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
>>>> from foo import foo
>>>> f = foo(1,2)
>>>> f.getName()
> 1
>>>>
>
>
> However, if I run this from C:\ I get the following
>
> C:\>python
> Python 3.3.3 (v3.3.3:c3896275c0f6, Nov 18 2013, 21:18:40) [MSC v.1600 32 bit (Intel)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
>>>> from foo import foo
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> ImportError: No module named 'foo'
>>>>
>
>
> I thought, well maybe it's a system error
>
>>>> import sys
>>>> print(sys.path)
> ['', 'C:\\Python33', 'C:\\Python33\\Lib', 'C:\\Python33\\DLLs', 'C:\\workspace', 'C:\\Windows\\system32\\python33.zip',
> 'C:\\Python33\\lib\\site-packages']
>>>>
>
> C:\>echo %PYTHONPATH%
> C:\Python33;C:\Python33\Lib;C:\Python33\DLLs;C:\workspace
>
> However, that seems OK.
>
> Is there something I'm missing?
>
The PYTHONPATH contains the directories that will be searched for
modules and packages. Your package is called foo, and is in
c:\workspace\PyFoo\src. That directory is not on the Python path, and
it isn't the current directory. Therefore, your package can't be found
and imported.
BTW: writting getters like getName and getNumber is unusual in Python.
The much more common technique is to simply use the attribute: f.name
--
Ned Batchelder, http://nedbatchelder.com
==============================================================================
TOPIC: Constructive Criticism
http://groups.google.com/group/comp.lang.python/t/45821f6b72d33dbb?hl=en
==============================================================================
== 1 of 3 ==
Date: Fri, Jan 10 2014 12:26 pm
From: jeremiah valerio
On Friday, January 10, 2014 2:56:14 AM UTC-6, Alister wrote:
> On Thu, 09 Jan 2014 13:05:23 -0800, jeremiah valerio wrote:
>
>
>
> > On Thursday, January 9, 2014 2:54:44 PM UTC-6, Christopher Welborn
>
> > wrote:
>
> >> On 01/08/2014 11:56 PM, jeremiahvalerio123@gmail.com wrote:
>
> >>
>
> >> > Hi, hows it going I've been self teaching myself python, and i typed
>
> >> > up this small script now i know its not the best the coding is not
>
> >> > the best but i would like to know of ways to make a small script like
>
> >> > this better so all constructive critisim is Welcome.
>
> >>
>
> >>
>
> >> >
>
> >>
>
> >> >
>
> >>
>
> >> >
>
> >> > Here is the link to the code
>
> >>
>
> >>
>
> >> >
>
> >> > " http://pastebin.com/5uCFR2pz "
>
> >>
>
> >>
>
> >> >
>
> >>
>
> >>
>
> >> I'm not sure if someone already pointed this out, but imports only need
>
> >>
>
> >> to be done once. Usually at the beginning of the file, but not always.
>
> >>
>
> >> In your case I would say yes, at the beginning.
>
> >>
>
> >>
>
> >>
>
> >> import sys
>
> >>
>
> >> import time
>
> >>
>
> >>
>
> >>
>
> >> def countdown(seconds):'
>
> >>
>
> >> # start at 'seconds' and count down with a for-loop
>
> >>
>
> >> for i in range(seconds, 0, -1):
>
> >>
>
> >> # print the current second (i)
>
> >>
>
> >> print('closing in {} seconds.'.format(i))
>
> >>
>
> >> # sleep for one second (no need to import time again).
>
> >>
>
> >> time.sleep(1)
>
> >>
>
> >>
>
> >>
>
> >> # Example usage:
>
> >>
>
> >> print('hello')
>
> >>
>
> >> # Prints the countdown.
>
> >>
>
> >> countdown(10)
>
> >>
>
> >> sys.exit(0)
>
> >>
>
> >> --
>
> >>
>
> >>
>
> >>
>
> >> - Christopher Welborn <cjwelborn@live.com>
>
> >>
>
> >> http://welbornprod.com
>
> >
>
> > Mr.Peter Otten did
>
> >
>
> > "- You should import modules just once, at the beginning of your script.
>
> > "
>
> >
>
> > -Peter Otten
>
> > With his help this is what i have now
>
> >
>
> > def countdown():
>
> > import time for seconds_left in reversed(range(1, 10)):
>
> > print("Closing in", seconds_left, "seconds")
>
> > time.sleep(1)
>
> > exit()
>
> >
>
> > if user_input == "yes" :
>
> > user_input = input("\nGreat what should we talk
>
> > about?\nSports\nWeather")
>
> > elif user_input == "no" :
>
> > print("\nAlrighty bye have a nice day! :)\n\nClosing in 10.")
>
> > countdown()
>
>
>
> you could improve your countdown function further by adding an optional
>
> count vaule
>
>
>
> def countdown(count=10):
>
> for timeleft in reversed(1,count):
>
> print ("Shutting down in {} Seconds".format(timeleft))
>
> time.sleep(1)
>
> --
>
> Most people can't understand how others can blow their noses differently
>
> than they do.
>
> -- Turgenev
So always think of the if's and possibility's that
other people might do, thanks for you input.
== 2 of 3 ==
Date: Fri, Jan 10 2014 12:34 pm
From: Chris Angelico
On Sat, Jan 11, 2014 at 7:26 AM, jeremiah valerio
<jeremiahvalerio123@gmail.com> wrote:
> So always think of the if's and possibility's that
> other people might do, thanks for you input.
Also think of the possibility that someone will read your post and its
quoted text. Please get off Google Groups, or if you must keep using
it, clean up your quotes - they're all coming out double-spaced.
You may find the mailing list easier to use:
https://mail.python.org/mailman/listinfo/python-list
ChrisA
== 3 of 3 ==
Date: Fri, Jan 10 2014 1:24 pm
From: Mark Lawrence
On 10/01/2014 20:26, jeremiah valerio wrote:
For the second time of asking would you please read and action this
https://wiki.python.org/moin/GoogleGroupsPython to prevent us seeing
double line spacing, thanks. Failing that, please arm yourself with a
semi-decent email client, there are umpteen to choose from.
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
==============================================================================
TOPIC: Porting mailing list underused?
http://groups.google.com/group/comp.lang.python/t/518be458ecf0c20b?hl=en
==============================================================================
== 1 of 3 ==
Date: Fri, Jan 10 2014 12:29 pm
From: Mark Lawrence
Given the adverse publicity recently over the problems with porting from
2 to 3, I find it strange that the subject list has only 351 messages
that I can see dating from 15/12/2008 to 05/01/2014. This is despite it
being clearly mentioned here http://www.python.org/community/lists/
Anyone in the know who can explain this phenomenon?
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
== 2 of 3 ==
Date: Fri, Jan 10 2014 12:38 pm
From: Skip Montanaro
> Anyone in the
> know who can explain this phenomenon?
I don't think I can explain it authoritatively, but I can hazard a
guess. Skimming the archives sorted by author, it looks like most/all
the correspondents are Python core developers. That leads me to
believe this was a list created for the core Python developers to
discuss issues related to porting tools such as 2to3 or six. I doubt
it was intended for Python programmers to get help porting their own
code. From the Python core development perspective, I think automated
porting tools are likely pretty mature at this point and don't warrant
a lot of discussion.
Skip
== 3 of 3 ==
Date: Fri, Jan 10 2014 1:31 pm
From: Mark Lawrence
On 10/01/2014 20:38, Skip Montanaro wrote:
>> Anyone in the
>> know who can explain this phenomenon?
>
> I don't think I can explain it authoritatively, but I can hazard a
> guess. Skimming the archives sorted by author, it looks like most/all
> the correspondents are Python core developers. That leads me to
> believe this was a list created for the core Python developers to
> discuss issues related to porting tools such as 2to3 or six. I doubt
> it was intended for Python programmers to get help porting their own
> code. From the Python core development perspective, I think automated
> porting tools are likely pretty mature at this point and don't warrant
> a lot of discussion.
>
> Skip
>
If the dumbo OP had remembered to say that
https://mail.python.org/mailman/listinfo/python-porting states rather
vaguely "This list is to contain discussion of porting Python code
between versions, mainly from Python 2.x to 3.x." it might have helped
garner more answers. Still, if we leave the list open for long enough
we'll all be able to discuss porting python 2.x to python 4.x :)
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
==============================================================================
TOPIC: Send array back in result from urllib2.urlopen(request, postData)
http://groups.google.com/group/comp.lang.python/t/bf6b03d8b9c08321?hl=en
==============================================================================
== 1 of 1 ==
Date: Fri, Jan 10 2014 12:57 pm
From: vanommen.robert@gmail.com
Hello,
I have a Raspberry Pi with 10 temperature sensors. I send the data from the sensors and some other values with json encoding and:
result = urllib2.urlopen(request, postData)
to a online PHP script wich places the data in a mysql database.
In the result:
result.read()
i am trying to send data back from the PHP to the RPI. I make an array in PHP
$para[0] = $REGELING_ORG;
$para[1] = $VLVERWL_ORG;
$para[2] = $VLOERVRAAG_ORG;
$para[3] = $TIJDVLOER_ORG;
$para[4] = $SETPOINT_ORG;
echo $para;
In python when i do
para = result.read()
print para
the output is:
[null,null,null,null,null,"J"]
This is correct according to the data in PHP from the mysql.
when I do
print para[1]
the output is:
n
the seccond character from the data. Why is this not the seccond datafield?
And why is para[5] not "J" but , ?
How can I change the data back to an array? I've tried with json, but that doesn't change anything.
Thanks in advance for the kind reactions!
Greetings Robert.
==============================================================================
TOPIC: L[:]
http://groups.google.com/group/comp.lang.python/t/8c4883bbe077624c?hl=en
==============================================================================
== 1 of 2 ==
Date: Fri, Jan 10 2014 9:38 am
From: Albert-Jan Roskam
In Python Cookbook, one of the authors (I forgot who) consistently used the "L[:]" idiom like below. If the second line simply starts with "L =" (so no "[:]") only the name "L" would be rebound, not the underlying object. That was the authorś explanation as far as I can remember. I do not get that. Why is the "L[:]" idiom more memory-efficient here? How could the increased efficiency be demonstrated?
#Python 2.7.3 (default, Sep 26 2013, 16:38:10) [GCC 4.7.2] on linux2
>>> L = [x ** 2 for x in range(10)]
>>> L[:] = ["foo_" + str(x) for x in L]
Thanks!
Regards,
Albert-Jan
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
All right, but apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, a
fresh water system, and public health, what have the Romans ever done for us?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
== 2 of 2 ==
Date: Fri, Jan 10 2014 2:03 pm
From: Ned Batchelder
On 1/10/14 12:38 PM, Albert-Jan Roskam wrote:
> In Python Cookbook, one of the authors (I forgot who) consistently used the "L[:]" idiom like below. If the second line simply starts with "L =" (so no "[:]") only the name "L" would be rebound, not the underlying object. That was the authorś explanation as far as I can remember. I do not get that. Why is the "L[:]" idiom more memory-efficient here? How could the increased efficiency be demonstrated?
>
> #Python 2.7.3 (default, Sep 26 2013, 16:38:10) [GCC 4.7.2] on linux2
>>>> L = [x ** 2 for x in range(10)]
>>>> L[:] = ["foo_" + str(x) for x in L]
>
I'm not sure there is a memory efficiency argument to make here. The
big difference is that the first line make L refer to a completely new
list, while the second line replaces the contents of an existing list.
This makes a big difference if there are other names referring to the list:
>>> L = [1, 2, 3, 4]
>>> L2 = L
>>> L[:] = []
>>> print L2
[]
>>> L = [1, 2, 3, 4]
>>> L2 = L
>>> L = []
>>> print L2
[1, 2, 3, 4]
Names and values in Python can be confusing. Here's an explanation of
the mechanics: http://nedbatchelder.com/text/names.html
HTH,
--Ned.
>
> Thanks!
>
>
> Regards,
>
> Albert-Jan
--
Ned Batchelder, http://nedbatchelder.com
==============================================================================
You received this message because you are subscribed to the Google Groups "comp.lang.python"
group.
To post to this group, visit http://groups.google.com/group/comp.lang.python?hl=en
To unsubscribe from this group, send email to comp.lang.python+unsubscribe@googlegroups.com
To change the way you get mail from this group, visit:
http://groups.google.com/group/comp.lang.python/subscribe?hl=en
To report abuse, send email explaining the problem to abuse@googlegroups.com
==============================================================================
Google Groups: http://groups.google.com/?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home