richieking 44 Master Poster

Well you are welcome. You can now close the thread and upvote me if you liked my lil help ;)

richieking 44 Master Poster

Tkinter not that matured for game. very limited....

richieking 44 Master Poster

Do you want a consul script or GUI???

be specific plz ;)

richieking 44 Master Poster

I think you need a GUI script. That will be more handy.

Writting a recursive script to recurse through your entire file system is not that good on resources.

Think about it.
;)

richieking 44 Master Poster

Use the style wx.TE_RIGHT ok?

eg

wx.TextCtrl(self,-1,style=wx.TE_RIGHT)
ciliath commented: genial +0
richieking 44 Master Poster

Here is corrected version with advice from StackOverflow:
Python Syntax (Toggle Plain Text)

1.
from __future__ import print_function
2.
import time
3.
import sys
4.
wipe = '\b'*len(time.asctime())
5.
print("The current date and time are: "+' '*len(wipe), end='')
6.
while True:
7.
print(wipe+time.asctime(), end='')
8.
sys.stdout.flush()
9.
time.sleep(1)

from __future__ import print_function import time import sys wipe = '\b'*len(time.asctime()) print("The current date and time are: "+' '*len(wipe), end='') while True: print(wipe+time.asctime(), end='') sys.stdout.flush() time.sleep(1)

stdout must be flushed manually if not use newline.

I recommend of trying to use ContextEditor and setup starting the python program by F9-, commands. You can easily test multiple versions of Python, and program does not run in changed environment.
23 Hours Ago 1:23 pm

tonyjv

There is something wrong with all these IDEs. All the known ide's for python failed to execute your code well. Syntaticaly your code it right so i could not think of any errors again. You are matured with python than i am.

Well it only worked flawlessly via CMD prompt.....
The question is... What is wrong?? the ide's or pyhton????
coming from C++ to python, i find a lot of stuffs scary at times with python. Today(Nov 28 ) is exactly 17 days since i started pythoning.

Yea i know. Python is easy to pick up.
Well good one there.
;)

richieking 44 Master Poster

Can you at least provide us with your code...???
;)

richieking 44 Master Poster

I see ;)

richieking 44 Master Poster

Ysisoft..

Have you tried your code?

The logic on line 3 ie. wipe=len(time.asctime())*'\b'

Instead of backspacing... It is forwardspacing time the len.
That is on idle.
On Geany it is not outputting anything.
And on my favourite Pydev kum Aptana/c++/Java/php It is doing the same like Idle with unicode error

richieking 44 Master Poster

Of course if you would like to show real time instead of doing exercise you would do for example:
Python Syntax (Toggle Plain Text)

1.
from __future__ import print_function
2.
import time
3.

4.
old_t =''
5.
print("The current date and time are: ", end='')
6.
while True:
7.
t = time.asctime()
8.
print('\b'*len(old_t)+t, end='')
9.
old_t = t
10.

11.
time.sleep(1)

Well Ysisoft....

I have added some nice bits to your code. I think we are getting there.

Check this out.

from __future__ import print_function
import time,os

old_t =''
while True:
    t = time.asctime()
    print((os.system('clear'), "The current date and time are: ",u''*len(old_t)+t, end='')
    old_t = t
    time.sleep(1)
richieking 44 Master Poster

or you can do this

print ("The total is %f"%( discounted_total))

I prefer this ....

richieking 44 Master Poster

VulcanDesign.....

Can you please give a benchmark to support your claim or just dont write what you dont know.
The world is waiting for your benchmark pleeeeeeeeeeeeeease

;)

Besides the screen clearing prove i have given you... and besides the one i say it works cross platform...

Do you have a different one?
If not. Please dont disturb anyone anymore ok?
;)

Note. the syntax is not print("\n") *100 , but print("\n" *100) and this prints nothing ok??? Blah

Its python syntatic suger. have a try ok?

richieking 44 Master Poster

Put your idea into a class. You see you are importing a basic file which has only function not a class. That means python will not be able to import that.

secondly you when you import trial.

To use any variable or method in trial.... do

trial.ip
trial.foo
trial.get_config.ip

With this .. python will get it for you.

Hope you get the idea ;)

richieking 44 Master Poster

I suggest doing a class for your module with normal methods with return values.

I am getting your idea.

why not like.....

1. The system ask for cmd (1.to add ip, 2. to exit)
2. User makes a choice. if choice 1.
3.The user get cmd. Please add ip.....

4.After ip added and enter..
5. Another choice. 1. to add shares to the entered ip, 2. to enter new ip , 3. to quit.

Hope you get the idea. It will be full interaction with the user and also easy for you to process the code.

note. IP's and Shares are packed into dict with ip as keys and shares as values.
That is IP(key) can have as many values (shares) as possible.

;)

richieking 44 Master Poster

aaahhh do you have any benchmark to your claims.???

print('\n' *100)
is use for clearing the screen if you do not know.
it is just like os.system('clear') on *nix system and os.system('CLS') on dos,windows.

print "\n"*100 works for cross platform. ok ??
;)

richieking 44 Master Poster

Well mark the thread close and if you wish to upvote me....... you are welcome. ;)

richieking 44 Master Poster

look you can add this to make it a little interesting

import time



a = 0
b = 0
FirstRun = True

while 1:               
    a = a + 1               #Adds one second
    if a > 59:              #Accounts for minutes
        b = b + 1
        a = a - 60
    print '\n' *100   
    print("The current time is  %d :%d"%( b  ,a))
    time.sleep(1)

This makes the screen clear so that it looks like a real time.
;)

richieking 44 Master Poster

try this

import time,

a = 0
b = 0
FirstRun = True

while 1:               
    a = a + 1               #Adds one second
    if a > 59:              #Accounts for minutes
        b = b + 1
        a = a - 60
       
    print("The current time is  %d :%d"%( b  ,a))
    time.sleep(1)

;)

richieking 44 Master Poster

1.You have on line 2 assigned config_list and on line 7 again????
2.You exit logic is no where to be found
3.Why are you checking ip with a string (if ip.lower()==deny.lower())???

ip is a series of numbers so there is no lower method

Besides the logic behind your code i dont get it.

Please explain very well what you intend to do.

;)

richieking 44 Master Poster

Please close the thread and upvote me if you think i deserve it. ;)
Thanks

richieking 44 Master Poster

Well you can try this.

from __future__ import division

my_list=list(raw_input("enter number: ")) # you take the input from the user
avg=sum([int(x) for x in my_list])/len(my_list) 
print(avg)

#out Put
enter number: 1234
     2.5

hope it helps ;)

richieking 44 Master Poster

well you are always welcome buddy. i was once like you ;)

richieking 44 Master Poster

Look at this example. The if was not tested with True

word="The lazy fox jump over the fence"

word=word.split()
for x in word:
    if x:
      print x
print ("X now is finished, X is null or zero")

Just play around stuff you will get it ;)

richieking 44 Master Poster

The if will fail once the object is equal to 0/Null.

The logic is
1. you checked for a condition if it is True.
2. if the condition is not.... then branch.

To check for True condition with if... You do not repeat True as if default condition check is True. So repeating True again does not make any impact.
Hope you get it.
;)

richieking 44 Master Poster

I will replace C# with C++ and java with python.

C++ and python are taking the PL. Expecialy Java is sucking nowadays since it take you too much typing for a simple stuff in python.

well thats my take ;)

richieking 44 Master Poster

You can checkup mysql multiple selct query from mysql website.
1.left join
2. inner join
3.right join

richieking 44 Master Poster

Check your logic well.

Your code will not do waht you expects. Try something that takes real data as you will only have either True or false for the whole bunch .

Doesnt worth it.
Check it up again.
;)

richieking 44 Master Poster

What about if the python script not running???

I think you need a cron job. With cron job you are in win win situation for this operation.

;)

richieking 44 Master Poster

Post your code please ;)

richieking 44 Master Poster

Wooo Slate and tonyjv are really complex

Infact the pseudo of slate is flawless but will a newbie understand the algos.?

I just wrote this as a step by step to the solution. I real life, i advice you to use Slate's example.

labyrinth = \
[[0,0,0,0,0,0,1,0],
[0,1,0,1,1,1,1,0],
[0,1,1,1,0,1,0,0],
[0,1,0,0,0,0,0,0],
[0,1,1,0,1,1,1,0],
[0,0,1,1,1,0,0,0],
[0,1,1,0,1,1,1,0],
[0,1,0,0,0,0,0,0]]

de=0
for x in labyrinth:
	for y in x:
		de=de+1
		if y == 0:
			print '##',
		else:
			print ".",
		if de == 8:
			print '\n'
			de=0

for fun ;)

richieking 44 Master Poster

I like personally the wx.FlexGridSizer than all the sizers.
with FlexGridSizer and the normal wx.BoxSizer you can make layouts that you realy desire.
;)

richieking 44 Master Poster

haha,

tonyjv

Cant you see that it was just a mistake with naming?
Take it easy ok?

richieking 44 Master Poster

try this
gives you the idea. no checkups anyway

#Find odd numbers

def odd_find(fr, to):
    if fr > to:
        trans = fr
        fr = to
        to = trans
    odd = []
    noOdd = []
    
    for x in range(fr, to):
        if x % 2 == 0:
            odd.append(x)
        else:
            noOdd.append(x)

    print  'Odd Stuff', odd
    print 'Not odd', noOdd

odd_find(5,40 )

print out:
Odd Stuff [6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38]
Not odd [5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]

;)

richieking 44 Master Poster

Just incase your last file names are in the third file, use the result to open and read the third file.

thats it :)

richieking 44 Master Poster

meaning????

that file1.txt contains the name of file2.txt and file3.txt and so forth?

make things a bit clearer plz ;)

richieking 44 Master Poster

tonyjv

i admire your python skills
;)

richieking 44 Master Poster

do you have the filenames in another file and want to read those filename one after the other and use the names to open the real files?????

more info needed ;)

richieking 44 Master Poster

Hi, to be precise

1. Your method/function needs 2 arg but you gave only 1.
2. The logic of your function is not complete and will never get you what you want.
The logic flow is not ok.

If you want a fuction to check up words in your dic, its a piece of cake. But untils know... we are going in circles i think.

Put the cards on the table.... what do you really need. We need to solve this once and for all.
;)

richieking 44 Master Poster

How do you guys expert a newbie to understand short algorithm like this.????

Are you helping or showing off???
;)

qingmui does not get you guys ;)

richieking 44 Master Poster

Try this fancy stuff:

import time # for time

def chec(sa):
    fd=sa
    for x in range(1, 10): #fancy.... You dont really need this but mmmm
        print ".",         #
        time.sleep(1)      #
    print '\n'               # you can try

    data = []; #make a list
    try:
        for x in sa:
            data.append(x.lower()); #pack the result into the list

        d1, d2 = (data[0], data[-1]);
    except:
        print "Values needed"
    else:
        if d1 == d2:     #check up the results
            print 'Check Results'
            print "-"*30
            print d1.upper(), d2.upper(), 'are the same\n';
        else:
            print 'Check Results'
            print "-"*30
            print d1.upper(), d2.upper(), 'are not the same\n'
    print "You entered:",fd ,'\n\n'

while True:  #
    choice = raw_input("Please enter choice [Enter] or  Q[to quit]: ").lower().strip()#get data
    if choice == "q": #check data
        break; #action
    else:
        try: #exception check
            palin = raw_input("Please enter a Phrase: ")
            chec(palin)
        except ValueError: #catch
            print "Enter phrase to check";
print "Check finished" #final line

Look is fun ok ;)

richieking 44 Master Poster

Try this fancy one.

def chec(sa):
    data=[]; #make a list
    for x in sa:
        data.append(x.lower()); #pack the result into the list
   
    d1 ,d2 =(data[0], data[-1]);
    if d1 == d2:     #check up the results
        print d1 ,d2 , "are the same";
    else:
        print d1 , d2 , "are not the same"


chec("racecar")
#============== Reuults=============
r r are the same

will do what you wnat i think ;)

richieking 44 Master Poster

We dont solve problems here my good friend.

we share ideas and give direction.

You are welcome anytime ;)

richieking 44 Master Poster

The dic Dictionary is not declared anywhere in your function toPirate.
Neither is it refferenced to. how do you code.
line #8

for words in dic.split(string) #?????

define your function to either contain the dic. Such as

def toPirate(string, **dic):

here you can pass the dic as the last arg.

Also on line 12
result+=[dic[word]] ## wrong
just code

result+=dic[word]

Hope you get the idea ;)

richieking 44 Master Poster

look i dont ge you. do you have to search the dictionary for the word occurance and print them out + a custom words ???

help is on the way

richieking 44 Master Poster

very neat stuff! ;)

richieking 44 Master Poster

check your indentation from for loop to end.

Also why not do things the easy way.??

;)

richieking 44 Master Poster

Well i think mitchems just said it all.

Look no one needs the actual data. just make a dummy one for love sake ok?

We are all interested in challenges as prog. junkies.
Make us a dummy data to play with ok?
;)

richieking 44 Master Poster

I just need a copy of your file or something more concrete to work on. You see giving abstract info is always not the best.
I still dont get you good friend.

richieking 44 Master Poster

how is your file formated....?

Yep you can read from a file into an array and check or straight from the file.
To an array if you care about speed.

I dont see any problem with $Major in this check up.

;)

post your file ok? Need to look through.

richieking 44 Master Poster

Why dont you try perl, ;)