RE: Some Python Feedback plz

hmm Now that I've got most of my mathematical programs to work a lot faster (thnx to the tips from gothicbob, jjbutler88 and ynori7), I decided to learn a bit about file I/O.
Problem 8 @ Project Euler seems to be a good place to start!

RE: Some Python Feedback plz

aiight.
This will be my first program ever. This is not a challenge or an equation.
My friend who's working as a mod on a game site, they do usually check for ip matches to find cheaters, he asked me in case I could make a short program that can check the file of PLAYER1 and file of PLAYER2 for ip and time matches.

Now the program menu will have 2 options:
1- Check for date and time matches irrespective of IP for 15 mins range of time between Player1 and Player2.
2- Check for IP matches irrespective of time and date for Player1 and Player2

If the program find any matches it should print them out. That's all

This is easy to do if not for the date matching thing. What syntax should I use to compare the date and time in 2 different files?

You don't have to write any codes, just mention the syntax you see fit this project the best and I'll do the googling

RE: Some Python Feedback plz

Demons Halo wrote:
This is easy to do if not for the date matching thing. What syntax should I use to compare the date and time in 2 different files?

Well, if all it is is just a date written in the file, you just parse it and check that the years match, then month, then day, then hour, and then just subtract the minutes of one from the other to check whether it's within 15 minutes (i.e. if absolute value of min1-min2<=15).

Author

RE: Some Python Feedback plz

ynori7 wrote:
Well, if all it is is just a date written in the file, you just parse it and check that the years match, then month, then day, then hour, and then just subtract the minutes of one from the other to check whether it's within 15 minutes (i.e. if absolute value of min1-min2<=15).

That was my plan B
I just though that maybe there is a simpler way of doing it. I'm almost done with the second menu choice.
If only there was a built in command for comparing dates well.. I guess I'll have to make one myself xD

Author

RE: Some Python Feedback plz

hmm my idea was to have the ip as a key and the date + time as the value of the key, and then compare values in the dictionary. If the date is the same, the program should check the time for matches within a cap of +- 15 mins.

what I've realized is that using a dictionary makes it just 10 times harder than it should be. I'm almost certain there there is a better method for prasing an input string than using a dictionary. I'm going to test assigning a piece of a string to a variable and then comparing variables from 2 different files, but this might not even work :/

But seriously, by now you should be able to do this yourself. This isn't that complicated. You can't keep asking for help otherwise you'll never learn. This is the last time I help you unless you have a good question.

nice, but remember to put functions before the loop into a variable, so it gets evaluated only once, and not multiple times. Also dont solve whole problem for the guy, this isn't that hard to code

[img][/img]

spyware - "They see me trollin'..."<yaragn> ever seen that movie? The Matrix?
<yaragn> with those green lines of flying text?
<yaragn> *THAT'S* Perl

Author

RE: Some Python Feedback plz

Demons Halo wrote:
haha that Is not what I had in mind.
I'm tired of using the same syntax over and over again in every program I create, so I thopugh maybe I should get into some advance syntax this time. Creating loops that checks arrays is basic syntax, I'm trying to get into some more "serious" programing, Like the date/time module.

What makes you think that using built-in modules like date/time is more "serious"? Anyone can use a predefined function; it doesn't take any special skills, just a simple google search. And I hate to break it to you, but if you don't like making loops then programming is not for you.

clone4 wrote:
remember to put functions before the loop into a variable, so it gets evaluated only once

Yeah, I know. I wrote it fast and didn't bother with finer details.

Author

RE: Some Python Feedback plz

Demons Halo wrote:
haha that Is not what I had in mind.
I'm tired of using the same syntax over and over again in every program I create, so I thopugh maybe I should get into some advance syntax this time. Creating loops that checks arrays is basic syntax, I'm trying to get into some more "serious" programing, Like the date/time module.

What makes you think that using built-in modules like date/time is more "serious"? Anyone can use a predefined function; it doesn't take any special skills, just a simple google search. And I hate to break it to you, but if you don't like making loops then programming is not for you.

I'm just trying to practice the syntax so that I can have a wider understanding of the language!
Don't get me wrong, I like creating loops etc. I just want to get more serious and I don't really know where to begin. I'm trying with project Euler, but the problems there are mathematical, so you end up using the same syntax almost all the time with different mathematical equations :/ (a bit of variation can't hurt you )

Author

RE: Some Python Feedback plz

Try the timed challenges, or come up with an idea for a program that will make your life easier. Look up modules as you need them. They're merely useful tools that somebody created, they are not part of the language.

Author

RE: Some Python Feedback plz

Posts: 586Location: He is back and he's bad!Joined: 25.11.07 Rank: Mad User

Posted on 27-04-09 19:55

Demons Halo wrote:
I'm just trying to practice the syntax so that I can have a wider understanding of the language!
Don't get me wrong, I like creating loops etc. I just want to get more serious and I don't really know where to begin. I'm trying with project Euler, but the problems there are mathematical, so you end up using the same syntax almost all the time with different mathematical equations :/ (a bit of variation can't hurt you )

You are repeating 'syntax' all the time, but python's got probably the easiest (understandable to be more exact) syntax amongst high level languages, so there isn't that much to practice(dont want to sound like it's really easy to learn python though). If you want wider understanding of the language, good idea is first to set the aim, is it gonna be sockets, string manipulation or something else. Then take that aboard and start doing some projects, research modules and built in functions, read a quality code, and then write a backdoor, your own encryption algo, or web bruteforcer, the possibilities are endless...

[img][/img]

spyware - "They see me trollin'..."<yaragn> ever seen that movie? The Matrix?
<yaragn> with those green lines of flying text?
<yaragn> *THAT'S* Perl

RE: Some Python Feedback plz

clone4 wrote:
You are repeating 'syntax' all the time, but python's got probably the easiest (understandable to be more exact) syntax amongst high level languages, so there isn't that much to practice(dont want to sound like it's really easy to learn python though). If you want wider understanding of the language, good idea is first to set the aim, is it gonna be sockets, string manipulation or something else. Then take that aboard and start doing some projects, research modules and built in functions, read a quality code, and then write a backdoor, your own encryption algo, or web bruteforcer, the possibilities are endless...

That's why I love python, the short and easy syntax. Ideas like backdorrs/web bruteforcer are the type of things I'm looking for Awesome advice thnx.

@ynori7
well I find it easy to work with python, all I need is a couple of creative ideas to work on that's all.
I've been doing timed challenges and Project Euler for a long time now, so I got kind a bored. That's why I went looking for ways to shrink my codes in order to make them shorter & faster using module syntax