Re: Constructive Criticism

2014-01-10 Thread Alister
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, [email protected] 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 
>> 
>>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
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Time zones and why they change so damned often

2014-01-10 Thread Alister
On Fri, 10 Jan 2014 07:31:11 +, Bob Martin wrote:

> in 714232 20140109 120741 Alister  wrote:
>>On Thu, 09 Jan 2014 07:17:25 +, Mark Lawrence wrote:
>>
>>> On 09/01/2014 04:14, Chris Angelico wrote:
 On Thu, Jan 9, 2014 at 2:54 PM, Ben Finney
 
 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
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: unicode troubles and postgres

2014-01-10 Thread wxjmfauth
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


-- 
https://mail.python.org/mailman/listinfo/python-list


[OT]All right, I'me trying, really I am

2014-01-10 Thread 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

--
https://mail.python.org/mailman/listinfo/python-list


Re: Monkeypatching a staticmethod?

2014-01-10 Thread Piet van Oostrum
Ian Kelly  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 
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 2.x and 3.x usage survey

2014-01-10 Thread 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.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 2.x and 3.x usage survey

2014-01-10 Thread 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

--
https://mail.python.org/mailman/listinfo/python-list


Re: Time zones and why they change so damned often (was: the Gravity of Python 2)

2014-01-10 Thread 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.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 2.x and 3.x usage survey

2014-01-10 Thread 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~
--
https://mail.python.org/mailman/listinfo/python-list


Re: Time zones and why they change so damned often

2014-01-10 Thread 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.



--
https://mail.python.org/mailman/listinfo/python-list


Re: Time zones and why they change so damned often

2014-01-10 Thread 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

--
https://mail.python.org/mailman/listinfo/python-list


Input Error issues - Windows 7

2014-01-10 Thread bryan . kardisco
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 "", line 1, in 
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?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 2.x and 3.x usage survey

2014-01-10 Thread 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.  :^(
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Input Error issues - Windows 7

2014-01-10 Thread Ned Batchelder

On 1/10/14 2:38 PM, [email protected] 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 "", line 1, in 
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

--
https://mail.python.org/mailman/listinfo/python-list


Re: Python 2.x and 3.x usage survey

2014-01-10 Thread 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

--
https://mail.python.org/mailman/listinfo/python-list


Re: Python 2.x and 3.x usage survey

2014-01-10 Thread 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

--
https://mail.python.org/mailman/listinfo/python-list


Re: Time zones and why they change so damned often

2014-01-10 Thread Grant Edwards
On 2014-01-10, Mark Lawrence  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

  
-- 
https://mail.python.org/mailman/listinfo/python-list


Porting mailing list underused?

2014-01-10 Thread 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

--
https://mail.python.org/mailman/listinfo/python-list


Re: Constructive Criticism

2014-01-10 Thread 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, [email protected] 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 
> 
> >> 
> 
> >>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. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Constructive Criticism

2014-01-10 Thread Chris Angelico
On Sat, Jan 11, 2014 at 7:26 AM, jeremiah valerio
 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
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Porting mailing list underused?

2014-01-10 Thread 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
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Time zones and why they change so damned often

2014-01-10 Thread 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 

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.
-- 
https://mail.python.org/mailman/listinfo/python-list


L[:]

2014-01-10 Thread 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?

~~

-- 
https://mail.python.org/mailman/listinfo/python-list


Send array back in result from urllib2.urlopen(request, postData)

2014-01-10 Thread vanommen . robert
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.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Constructive Criticism

2014-01-10 Thread 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

--
https://mail.python.org/mailman/listinfo/python-list


Re: Porting mailing list underused?

2014-01-10 Thread 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

--
https://mail.python.org/mailman/listinfo/python-list


Re: L[:]

2014-01-10 Thread 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

--
https://mail.python.org/mailman/listinfo/python-list


Re: L[:]

2014-01-10 Thread Terry Reedy

On 1/10/2014 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]


Unless L is aliased, this is silly code. The list comp makes a new list 
object, so if L does not have aliases, it would be best to rebind 'L' to 
the existing list object instead of copying it. To do the replacement 
'in place':

L = [x ** 2 for x in range(10)]
for i, n in enumerate(L):
  L[i] = "foo_" + str(n)
print(L)
>>>
['foo_0', 'foo_1', 'foo_4', 'foo_9', 'foo_16', 'foo_25', 'foo_36', 
'foo_49', 'foo_64', 'foo_81']

--
Terry Jan Reedy


--
https://mail.python.org/mailman/listinfo/python-list


Re: Send array back in result from urllib2.urlopen(request, postData)

2014-01-10 Thread John Gordon
In  
[email protected] writes:

> result = urllib2.urlopen(request, postData)

> para = result.read()
> print para

> the output is:

> [null,null,null,null,null,"J"]

> print para[1]

> the output is:

> n

Probably because para is a string with the value
'[null,null,null,null,null,"J"]'

> How can I change the data back to an array? I've tried with json, but
> that doesn't change anything.

As far as I know, result.read() only returns text.  If you want your results
in some other format (like an array), you'll need to parse the string.

This is a very simple (and ugly) way to do it, but it may give you a
starting point:

# open the url
result = urllib2.urlopen(request, postData)

# read the raw text results
raw_text = result.read()

# strip off the leading '[' and trailing ']'
raw_text = raw_text[1:-1]

# split raw_text into an array of strings 
text_array = raw_text.split(',')

# declare a new list for storing the parsed items
para = []

# process each string
for item in text_array:
if item == 'null':
para.append(None)
else:
para.append(item)

The python csv module might have a better way to do this; have a look.

-- 
John Gordon Imagine what it must be like for a real medical doctor to
[email protected] 'House', or a real serial killer to watch 'Dexter'.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Send array back in result from urllib2.urlopen(request, postData)

2014-01-10 Thread Dave Angel
On Fri, 10 Jan 2014 12:57:59 -0800 (PST), [email protected] 
wrote:


No idea about the php..

In python when i do 



para = result.read()
print para



the output is:
[null,null,null,null,null,"J"]


That's a string that just looks like a list.


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?

There are no data fields in a string. 


And why is para[5] not "J" but ,   ?


That's character 5 of the string.

How can I change the data back to an array? I've tried with json, 

but that doesn't change anything.

You have to parse it. I don't know what rules you used at the php 
end, but at a guess, I'd start by stripping the brackets, then 
splitting by comma. Then iterate through each item looking for 
special cases. Each item consisting of null gets replaced by None, 
each item starting with quotes gets them stripped,  and perhaps 
anything else is replaced by float (item).


Still questions to ask like whether quoted item can have embedded 
comma.


--
DaveA

--
https://mail.python.org/mailman/listinfo/python-list


Re: Input Error issues - Windows 7

2014-01-10 Thread Dave Angel
On Fri, 10 Jan 2014 11:38:32 -0800 (PST), [email protected] 
wrote:

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():


Ned has pointed out your path problem.  But you have another,  
perhaps caused by overexposure to java. You have a package,  a module 
and a class, all with the same name. Convention says at least 
uppercase for the class. I say make every name unique till you learn 
how they work.


--
DaveA

--
https://mail.python.org/mailman/listinfo/python-list


Re: Send array back in result from urllib2.urlopen(request, postData)

2014-01-10 Thread Denis McMahon
On Fri, 10 Jan 2014 12:57:59 -0800, vanommen.robert wrote:

> 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;

This is php code that prints out a string representation of the variable, 
in so far as it can.

What you probably want to do is encode the array somehow, such as one 
element value per line, or json encode, or some other method, and then 
decode it in your python.

> In python when i do
> 
> para = result.read()
> print para
> 
> the output is:
> 
> [null,null,null,null,null,"J"]

Yep, that's because para is a string containing the text:

'[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 ,   ?

This is because python is looking at a string containing the character 
sequence '[null,null,null,null,null,"J"]'

para[0] = '['
para[1] = 'n'
para[2] = 'u'
para[3] = 'l'
para[4] = 'l'
para[5] = ','
para[6] = 'n'
para[7] = 'u'

> How can I change the data back to an array? I've tried with json, but
> that doesn't change anything.

To use json to convert it back to an array in the python code, you also 
need to use json to serialise the array in the php code.

eg in the php:

echo $para;

would become:

echo php_json_encoding_function( para );

and in the python:

para = result.read()

would become:

para = python_json_decoding_function( result.read() )

or possibly even:

para = json.decode( result.read() )

(I don't know the details, I'm trying to give you the general idea so you 
can work out where to look to figure this out)

These two web pages may also help:

http://uk3.php.net/manual/en/function.json-encode.php
http://docs.python.org/2/library/json.html

-- 
Denis McMahon, [email protected]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Send array back in result from urllib2.urlopen(request, postData)

2014-01-10 Thread MRAB

On 2014-01-10 20:57, [email protected] wrote:

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.


[snip]

What exactly do you mean by "json doesn't change anything"? I get this:

>>> para = '[null,null,null,null,null,"J"]'
>>> print para
[null,null,null,null,null,"J"]
>>> import json
>>> print json.loads(para)
[None, None, None, None, None, u'J']

--
https://mail.python.org/mailman/listinfo/python-list


Re: Time zones and why they change so damned often (was: the Gravity of Python 2)

2014-01-10 Thread Roy Smith
In article ,
 Peter Pearson  wrote:

> 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.

30 years ago, that would have been a plausible choice.  Today, not so 
much.
-- 
https://mail.python.org/mailman/listinfo/python-list


With this artifact, everyone can easily invent new languages

2014-01-10 Thread Simeon Chaos
How is peasy (https://github/chaosim/peasy) simpler and more powerful than 
other parser tools?

Simpler and more powerful? Maybe it is a bit contrary to common sense. True or 
false? To affirm, please give this project (https://github.com/chaosim/peasy) a 
glimpse at first. Because of being simple , you can comprehend it in a little 
while; because of being powerful, it will deserve your every minute.

All along, the design of programming languages ​​is a complex task. Because we 
need to understand the esoteric compiler theory and technology, and one of the 
most critical and very difficult part is to define the rules of the new 
language and to parse with them.To solve this problem, there have been many 
theories , techniques and tools . These tools can be roughly divided into two 
categories: one is parser generator, another is to write the parser by hand 
with or without a parser library.

The parser generator generally based on some type of formal languages ​​, by 
which the generator make the lexer and parser from some rules. Strong aspect of 
these tools is that they can produce the most efficient parser support for 
their own form of language types , according to the characteristics of formal 
language , generally ensures linear time complexity. Commonly divided into 
three types : LR technology , LL technology , PEG technology. LR technology 
language has shift/reduction , from the bottom up , the most right derived and 
other technical features , they can only support LR languages ​​, more 
accurately, mainly LALR variants , plus some special treatment for the priority 
of operator. One of the most famous was undoubtedly the lex / yacc and its 
numerous subsequent variants ( such as bison, jison (javascript language ), ply 
(python lex / yacc) , etc. ) . LL technology has a top-down form of the 
language , recursive descent , the most left-dereived and other technical 
features , although the concept is easier to understand than the LR language , 
but because LL covers less languages, so not used as universal as lex / yacc. 
Representative products are antlr. PEG technology refers to parsing expression 
grammar parser generator. peg is a kind of formal grammar particularly suited 
to be parsed, currently there are already many tools appear. The most common 
method is packrat  algorithm based implementations. Such as rats, ometa (there 
are many versions , such as ometa / squeak, ometa-js, pyMeta etc. ), pyPEG 
under python, peg.js  under javascript, treetop and citrus under ruby, and so 
on.

No matter what type of parser generator , the method to use them is to design 
rules for these tools , and then the tools generate parser. This is the 
difficult aspects. First, the object program is generated based on the state 
transfer and stack process, it is difficult to understand, debug and modify. 
Second, we must understand parser theory and technology of these tools is based 
on, the rules used by these tools is actually a domain-specific language , 
their expressivenes is very limited, while we must understand and become 
familiar with the new language in order to design rules. Third, we must embed 
certain processing ( abstract syntax tree structure , semantics, error 
reporting and handling , etc) in the form of object parser language  into 
lex/parser rules. Difficulties in these areas prevent the most programmers to 
easily use this type of tool.

Meanwhile, people have also been pursuing a more relaxed and flexible approach 
to write parsers. Most of these methods produce tools can be classified as 
combinational parser library , or peg grammar-based peg library . Use of such 
libraries, programmers can use their own language in daily use to design a new 
universal language , parsing text, so they are used more freguently. 
Representative works is parsec under haskell language  which maybe is the most 
mature and powerful. However, because haskell is too academic, and parsec is 
not universally popular. c + + language has boost phoenix library, probably 
because it depends on the c++ template, an advanced language features, it has 
not been widely used too. Python has pyparsing, which is used by many users. 
For specific questions , there are many applications do not use any tools or 
libraries, but manually write the entire parser , for example: cpython 
implementation, esprima for javascript. However, unfortunately,  in their 
grammar and parsing of these tools, there are two obvious difficulties not been 
solved: the first is left recursive grammar, because left-recursive function 
will lead to an unconditional infinite recursion. The second is the parsing 
efficiency. In order to obtain a linear time complexity , we should only parse 
same syntax component only once at any position. To achieve the latter, the 
result of parsing is required. Meanwhile , the parser also need to be 
considered in conjunction to produce abstract syntax trees , semantic 
processing , error handling , etc.

Re: With this artifact, everyone can easily invent new languages

2014-01-10 Thread Chris Angelico
On Sat, Jan 11, 2014 at 11:59 AM, Simeon Chaos  wrote:
> All along, the design of programming languages is a complex task. Because we 
> need to understand the esoteric compiler theory and technology, and one of 
> the most critical and very difficult part is to define the rules of the new 
> language and to parse with them.To solve this problem, there have been many 
> theories , techniques and tools . These tools can be roughly divided into two 
> categories: one is parser generator, another is to write the parser by hand 
> with or without a parser library.
>

No tool will change the fact that the *design* of a language is a
complex task. Long before you get to implementing anything, you have
to decide what your language will look like, what its special features
are, how it distinguishes one thing from another, etc etc etc. That
work won't change based on the tool you use - or rather, if it DOES
change, it's because the tool is too restrictive. First write some
code in your new language, then and only then work out how to
implement an interpreter/compiler. The first part of the job is pretty
complex (and extremely important), and tools don't come into play till
the second.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


python first project

2014-01-10 Thread ngangsia akumbo
Hi everyone, 

I have been around this group for some time and i saw that we have very helpful 
people here.

i have been learning python just for about 5 months now and i have been given a 
task to do. This will be a leap into the programming industry for me.


i am programming a system that will be giving details about finance, 
purchase(bills pending bills and paid bill), employees record and salary 
details, warehouse records.

That is just all i intend to do this all on one GUI application window and to 
make it to be able to keep records for all the transaction which has been done 
inputted.  

I have started programming it , but i still feel there are a lot of things i 
miss out.

Please i need some support from any honest person, please and also how to guide 
me complete this.

I am also looking for guides and sources which can help me complete it.






import os, sys

print "#" * 50

print "#" * 50

def fin_sec():
print "The financial sector"
fin_name = raw_input("Enter your Name: ")
fin_amount = input("Enter the amount for finance: ")

if fin_amount > 0:
print "We have a "DEBIT BALANCE" of", fin_amount,"FCFA"
else:
print "There is "CREDIT BALANCE" of", fin_amount, "FCFA"
 

print "Name of person doing the the transaction is ", fin_name
print "Amount available for finance is ", fin_amount



print "#" * 50
print "#" * 50


def purch_sec():
print "#" * 20

print "The purchase center"

purchase_name_good = raw_input("Please enter the name of good or goods 
purchase: ")
if not purch_name_good istitle():
purch_name_good.capitalize()
purch_price = input("Please enter the price for purchase made: ")
purch_p = raw_input("Please enter the reason of this purchase made: ")
purch_customer = raw_input("Please enter the name of customer: ")
purch_address = raw_input("Please enter the contact details for the 
customer: ")

print "Name of goods purchase: ", purch_name_good
print "Price of Good:",purch_price,"FCFA"
print "Reason for the purchase: ", purch_p
print "Customers name is: ", purch_customer
print "Contact: ",purch_address



def purch_Bill():
print "Regulating the Bills"

bill_total= int(input("Please enter the total bill of purchase: ")

bill_paid = int(input("Enter the bills paid in: ")

#bill_pending = input("Please enter the amount for pending bills: ")

print "The total bill paid: ", bill_total,"FCFA"

print "The amount already paid: ", bill_paid,"FCFA"

#print "The amount still left: ", bill_total - bill_paid,":::", "FCFA"


if bill_total == bill_paid:
print "Tne purchase amount was completed"
elif bill_total > bill_paid:
i = bill_total - bill_paid
print "The purchase amount left to be paid is ", i


print "DONE"


print "##" * 50

print ":::" * 50


def emp_rec():

print "Employee Record and Details"

emp_name = raw_input("Please enter the employee name: ")

emp_age = int(input("Age: ")


if emp_age > 18:
pass
else:
print "The candidate is too young to be an employee"

print "Name: ", emp_name
print "Age:", emp_age
 


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python first project

2014-01-10 Thread Chris Angelico
On Sat, Jan 11, 2014 at 3:18 PM, ngangsia akumbo  wrote:
> purch_price = input("Please enter the price for purchase made: ")
> purch_p = raw_input("Please enter the reason of this purchase made: ")

Never use input() in a Python 2 program... always use raw_input()
instead. You're mostly right, but you have a few cases where you're
using input(). Probably what you want is int(input()) or
float(input()).

Incidentally, is there a strong reason for using Python 2 for this? If
not, I'd recommend moving immediately to Python 3, as there are an
increasing number of advantages. Unless something actually binds you
to Py2, save yourself the trouble of shifting in a few years' time and
just use Py3 now.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: With this artifact, everyone can easily invent new languages

2014-01-10 Thread Simeon Chaos
Yes, it's complex to design a new language. So don't let the tool stand in the 
way. There is a saying: Grinding a chopper will not hold up the work of cutting 
firewood.

在 2014年1月11日星期六UTC+8上午10时17分33秒,Chris Angelico写道:
> On Sat, Jan 11, 2014 at 11:59 AM, Simeon Chaos wrote:
> 
> > All along, the design of programming languages is a complex task. Because 
> > we need to understand the esoteric compiler theory and technology, and one 
> > of the most critical and very difficult part is to define the rules of the 
> > new language and to parse with them.To solve this problem, there have been 
> > many theories , techniques and tools . These tools can be roughly divided 
> > into two categories: one is parser generator, another is to write the 
> > parser by hand with or without a parser library.
> 
> >
> 
> 
> 
> No tool will change the fact that the *design* of a language is a
> 
> complex task. Long before you get to implementing anything, you have
> 
> to decide what your language will look like, what its special features
> 
> are, how it distinguishes one thing from another, etc etc etc. That
> 
> work won't change based on the tool you use - or rather, if it DOES
> 
> change, it's because the tool is too restrictive. First write some
> 
> code in your new language, then and only then work out how to
> 
> implement an interpreter/compiler. The first part of the job is pretty
> 
> complex (and extremely important), and tools don't come into play till
> 
> the second.
> 
> 
> 
> ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: With this artifact, everyone can easily invent new languages

2014-01-10 Thread James Harris
"Simeon Chaos"  wrote in message 
news:[email protected]...
> ? 2014?1?11UTC+8??10?17?33?,Chris Angelico??:
> > On Sat, Jan 11, 2014 at 11:59 AM, Simeon Chaos wrote:
> >
> > > All along, the design of programming languages is a complex task. 
> > > Because we need to understand the esoteric compiler theory and 
> > > technology, and one of the most critical and very difficult part is to 
> > > define the rules of the new language and to parse with them.To solve 
> > > this problem, there have been many theories , techniques and tools . 
> > > These tools can be roughly divided into two categories: one is parser 
> > > generator, another is to write the parser by hand with or without a 
> > > parser library.

> Yes, it's complex to design a new language. So don't let the tool stand in 
> the way. There is a saying: Grinding a chopper will not hold up the work 
> of cutting firewood.

To the OP: this is a suitable topic for comp.lang.misc which is used for 
discussions about programming language design and implementation such as 
parse mechanisms.

James


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Time zones and why they change so damned often

2014-01-10 Thread Bob Martin
in 714281 20140110 090409 Alister  wrote:
>On Fri, 10 Jan 2014 07:31:11 +, Bob Martin wrote:
>
>> in 714232 20140109 120741 Alister  wrote:
>>>On Thu, 09 Jan 2014 07:17:25 +, Mark Lawrence wrote:
>>>
>>>> On 09/01/2014 04:14, Chris Angelico wrote:
>>>>> On Thu, Jan 9, 2014 at 2:54 PM, Ben Finney
>>>>> 
>>>>> 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 :-)

Sorry, but you are wrong again!  
Just Google it.
-- 
https://mail.python.org/mailman/listinfo/python-list