Re: [Tutor] Error 22

2015-01-09 Thread diliup gabadamudalige
:)

On Thu, Jan 8, 2015 at 3:02 AM, Danny Yoo  wrote:

> >>> How I fix this error? when I open my python project (.py) it closes
> >>> immediately.
> >>
> >> Since the op sent from Windows, I'm guessing he isn't opening up a cmd
> >> window then running his program.  But I'm not a windows guy lately.
> >> Perhaps someone can tell him how to invoke the program?
>
> I think we simply need more information.  "Error 22" on Windows is,
> according to web searches, associated with some kind of device driver
> failure.  (What?!)
>
> So I am very confused.  Without knowing anything else about the
> program, I'm at a loss and my first instinct is to think that this has
> nothing to do with Python.  I think we don't have enough information,
> so let's hear back from the original questioner.
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>



-- 
Diliup Gabadamudalige

http://www.diliupg.com
http://soft.diliupg.com/

**
This e-mail is confidential. It may also be legally privileged. If you are
not the intended recipient or have received it in error, please delete it
and all copies from your system and notify the sender immediately by return
e-mail. Any unauthorized reading, reproducing, printing or further
dissemination of this e-mail or its contents is strictly prohibited and may
be unlawful. Internet communications cannot be guaranteed to be timely,
secure, error or virus-free. The sender does not accept liability for any
errors or omissions.
**
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] File Compare

2015-01-09 Thread Danny Yoo
> The ideal of output of this program is to show if there is any new
> number added to the new file.
>
> In other words,  the file content of file1 [0001.hk, 0002.hk, 0003.hk,
> 0004.hk] is comparing with the file content of file2 [0001.hk,
> 0002.hk, 0003.hk, 0005.hk].
>
> The result should be +0005.hk, -0004.hk

Ok, this is helpful.  Thanks.

If the file content were to be scrambled a bit (say, like 0005.hk shows up
first in the file), should that affect the answer you want?
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] File Compare

2015-01-09 Thread Peter Otten
Crusier wrote:

> Hi Danny,
> 
> Thanks for your suggestion.
> 
> The ideal of output of this program is to show if there is any new
> number added to the new file.
> 
> In other words,  the file content of file1 [0001.hk, 0002.hk, 0003.hk,
> 0004.hk] is comparing with the file content of file2 [0001.hk,
> 0002.hk, 0003.hk, 0005.hk].
> 
> The result should be +0005.hk, -0004.hk
> 
> Ah.  One other thing.  Can you explain what you're intending to do
> with this statement?
> 
>A = file_contentsA.split(',')
> 
> My thinking is I want to make both files as a list, so I can compare
> the two files. However, as you can see, it is only my wishful
> thinking.

As Dave already mentioned you need to split on whitespace:

>>> file_contentsA = "0001.hk 0002.hk 0003.hk"
>>> file_contentsA.split()
['0001.hk', '0002.hk', '0003.hk']

The easiest way to get the added/removed entries is set arithmetic:

>>> file_contentsB = "0001.hk 0002.hk 0005.hk 0006.hk"
>>> entriesA = set(file_contentsA.split())
>>> entriesB = set(file_contentsB.split())
>>> entriesA - entriesB # removed items:
{'0003.hk'}
>>> entriesB - entriesA # added items:
{'0005.hk', '0006.hk'}

Now let's work on the output format:

>>> added = entriesB - entriesA
>>> removed = entriesA - entriesB
>>> added_or_removed = added | removed # union of both sets
>>> for entry in sorted(added_or_removed):
... if entry in added:
... print("+" + entry)
... else:
... print("-" + entry)
... 
-0003.hk
+0005.hk
+0006.hk

Limitations of this approach:
- information about duplicate entries is lost
- the original order of entries is lost

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] (no subject)

2015-01-09 Thread Jenacee
I know next to nothing about programing and I would very much like to learn how.
Anything on how to get started or understanding how to start would be really 
great.

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] (no subject)

2015-01-09 Thread Alan Gauld

On 10/01/15 06:30, Jenacee wrote:

I know next to nothing about programing and I would very much like to learn how.
Anything on how to get started or understanding how to start would be really 
great.


There are lots of beginners tutorials on the web.
This page lists some.

https://wiki.python.org/moin/BeginnersGuide/NonProgrammers

Which one suits you best depends on your own style and background. The 
best thing is to try a couple and see what feels like the best fit for 
you. If you get stuck ask questions here.


We like to know:
The OS and Python version you use
A full listing of any error messages
A listing of the code resulting in the error.


Have fun,

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] (no subject)

2015-01-09 Thread Steven D'Aprano
On Sat, Jan 10, 2015 at 12:30:21AM -0600, Jenacee wrote:
> I know next to nothing about programing and I would very much like to learn 
> how.
> Anything on how to get started or understanding how to start would be really 
> great.

Here you go, have fun:

https://duckduckgo.com/?q=python%20tutorial

Or if you prefer:

https://duckduckgo.com/?q=getting%20started%20with%20python

Have a look at those and come back if you need help.


-- 
Steve
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor