richieking 44 Master Poster

Hay Job done.

Just had to rush this one for you. I have too much on me but i hope you will be happy with this. Well a litle upvoting will be great
:)

alphabet = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
crypalph = []

ROT13 = 13
for x in range(0,52):
  crypalph.append(alphabet[(x + ROT13) % 52])

#----------------------------------------------------------------Ask user input

user_input = raw_input ("Please enter some text: \t").strip() # Clean the input

#-----------------------------------------------------Define blank cryptmessage

encryptmessage =''
sub=len(user_input) # Get the lenght tou use for slice

#------------------------------------------------------------Encrypt user input

for x in user_input:
  if x in alphabet:
    encryptmessage += crypalph[alphabet.index(x)]
  else:
    encryptmessage += x

#------------------------------------------------------------------------------

print "__________________________________________"
print "\nEncrypted message: \t\t" + encryptmessage

print "__________________________________________"
raw_input ("\nPress [Enter] to decode '" + encryptmessage + "'")

#----------------------------------------------------------Define blank message

message =''

#-----------------------------------------------------------Decrypt the message

for x in encryptmessage:
  if x in alphabet:
    user_input += crypalph[alphabet.index(x)]
  else:
    user_input += x

#------------------------------------------------------------------------------
fx=[]            # New list to Help Take the eccess data.
for w in user_input:  # Run Through to get each data
    for z in w:       # This step could be done oneliner But i thought you may want to
     fx.append(z)     # Now how everything works better
user_input=fx[:-sub]  #<-- This is were you slice the excess
user_input="".join(user_input)  #<-- Join stuff for out put
print "__________________________________________"
print "\nDecrypted message: \t\t" + user_input + '\n'

raw_input ("\n\nPress [Enter] to continue")

#OUT PUT
Please enter some text: 	Richie the King
__________________________________________

Encrypted message: 		evpuvr Gur XvAt
__________________________________________

Press [Enter] to decode 'evpuvr Gur XvAt'
__________________________________________

Decrypted message: …
richieking 44 Master Poster

Not bad ;)

richieking 44 Master Poster

You can close the thread as solve ...... :)
happy coding ***

richieking 44 Master Poster

This is very simple.

Extend the Small list with Uppercase letters. A-Z Just a-z
And on line 14. take away

x.lower()

Just put

x

And the job is done. I just tried it and it work fine.
Good job. :)

richieking 44 Master Poster

As list in python
So is array in c,c++

They are all the same stuff with different names. :)

richieking 44 Master Poster

If you want CheckBox in staticbox Try this

import wx

class Frame(wx.Frame):
    def __init__(self,parent):
        wx.Frame.__init__(self,parent,size=(400,300),title="STATIC CHECK BOX ")
        
        self.pan=wx.Panel(self,-1)
        
        wx.StaticBox(self.pan, -1, 'BOXES', (5, 5), size=(100, 250))
        self.dat()
        self.Show()  
    def dat(self):
        for x in range(1,10):
            wx.CheckBox(self.pan,-1,"%s %d"%("BOX",x),(15,20*x))
a=wx.App()
Frame(None)
a.MainLoop()
richieking 44 Master Poster

This is another version.

You take read the zipfile and use the file type you want to create a new zip file. Simple.

import zipfile

if __name__ =="__main__":
    ext=["py","txt","doc"]
    nfile=[]  #to take new file list
    ffile=zipfile.ZipFile("/home/richie/r.zip","w") # New zip
    zfile= zipfile.ZipFile("/home/richie/GUI2Exe.zip","r")# Main zip
    for xfile in zfile.namelist():
        if xfile.split(".")[-1] in ext: #Check extention
            nfile.append(xfile)         #append
            ffile.write("/home/richie/"+xfile)  # write new one
    print "New zip file data: ", nfile      
    ff.close()
    zfile.close()
richieking 44 Master Poster

Well you can close the thread as solved.
You are welcome
;)

richieking 44 Master Poster

Take this

ad =[[x for x in range(1,10,2)],[w for w in range(2,20,3)]]

print(ad)
## out put
[[1, 3, 5, 7, 9], [2, 5, 8, 11, 14, 17]]
richieking 44 Master Poster

Quick work out.

have fun

from random import *


while 1:
  ime_f = raw_input("Vnesi ime fanta: ");
  priimek_f = raw_input("Vnesi priimek fanta: ");
  ime_z = raw_input("Vnesi ime deklice: ");
  priimek_z = raw_input("Vnesi priimek deklice: ");
  x = randint(0, 70);
  if ime_f == "Lojze" and priimek_f == "Slak" and ime_z == "Mihela" and priimek_z == "Cas":
    print "Ujemanje je 100%";
    break
  else:
     print x;
richieking 44 Master Poster

pydev plugin to eclipse/aptana also allow you to choose your taste. ;)

vegaseat commented: thanks for the info +13
richieking 44 Master Poster

like i stated on the top.

simple format print

;)

richieking 44 Master Poster

simple format print

stuff="""
      Hi folk, I fairly new to Python 2.7 and Python 3 and
      like to find out how I would get a print to appear in
      the middle of the output screen without putting in a
      load of spaces into a print statement. Please keep it
      simple for me.
      """
print("%20s"% stuff) ## increase the figure  for more indentation

flavours ;)

richieking 44 Master Poster

You will need to time and threading modules very carefuly.

They can make your life more easier.
;)

richieking 44 Master Poster

You can use wx.Timer to bind to self to do that job.

eg.

import wx

class Frame(wx.Frame):
    """
    #Class stuff decl
    """
    def __init__(self,parent):
        wx.Frame.__init__(self,parent)
        self.timer=wx.Timer(self)
        self.count=0
       
        #timer event Always must be bound to self
        self.Bind(wx.EVT_TIMER,self.evt_timer)
        self.Bind(wx.EVT_PAINT,self.paint)
        self.Show()
        ############### event  methods ###########
    def paint(self,event):
        self.timer.Start(100)# increase the value for more time
            
    def evt_timer(self,event):
        self.count +=1
        if self.count== 20:
            # Do your more stuff here
            print ("hello world")  
            self.count=0 # reset the count
            
if __name__ =="__main__":
    app=wx.App()
    Frame(None)
    app.MainLoop()

This should help you for now......
;)

richieking 44 Master Poster

why not. you can install more than 1 version.

Are you on linux ,OSX or windows?
if linux, what flavour?
;)

richieking 44 Master Poster

They work the same, they need the same data type.

socket.connect((11.11.111.11,"1911")) 
##OR
 socket.bind((11.11.111.11,"1911"))

;)

richieking 44 Master Poster

Your code is not bullet proof. its far from ok.

And i was thinking why dont you break them apart into methods in a class. It will be more handy and easy to work on it.

richieking 44 Master Poster

Your wish list is very strange however itertool permutation module may help you. Just figure what you are looking for because values entered and results wished are far apart.

;)

richieking 44 Master Poster

As griswolf pointed to you about you using dict to save your item values its one of the best advice for you.

Your data are more static and moreoevr you have paired them in a staic way which you pull the results from the lists. Its not efficient. You need a key and value stuff, a hash data type which is a dict in python.

Besides you code loop works fine with me.

Work on that.. ;)

richieking 44 Master Poster

i will wait till you put your code in the code tag tomorrow before i comment.
;)

richieking 44 Master Poster

well this is a way to atleast find a word and its position out.

from __future__ import print_function
list= ["gene","fooo","spam","spat","foo","gene","geni","spilat"]
print([(count,gene) for count,gene in enumerate(list)if gene=="gene"], end="")

##output
[(0, 'gene'), (5, 'gene')]

Hope it helps
;)

richieking 44 Master Poster

Call the function where needed to perform its duties.
;)

richieking 44 Master Poster

can you give more idea what your code is supposed to do?

richieking 44 Master Poster

i dont get Mr. dmurder.....

can you help us to help you. Until now no one jnows what you want to achieve.

richieking 44 Master Poster

well goodluck ;)

richieking 44 Master Poster

Novice20 just doesnt want to do or take advice. ;)

richieking 44 Master Poster

I realy dont get what you want but i just optimised your code. Hope it helps

def getScores(totalScores, number): 
        score = input('Enter their score: ')
        while score <=0 or score >=100:
            print'You must enter a number between 0 and 100'
            score = input('Enter a number between 0 and 100:')
        for counter in range(0, number):
            totalScores = totalScores + score
        return totalScores

Your code was just missing the indentation to exclude the for loop from the while.
The for loop could not run unless the while look kicks in.
;)

richieking 44 Master Poster

Just look for close thread button and use it to close the thread.;)

richieking 44 Master Poster

your paste came with line numbers. who wrote this class?

repaste again well... ;)

richieking 44 Master Poster

or this

from __future__ import print_function
products = ["YELLOW,SMALL,STRETCH,ADULT,T21fdsfdsfs",
            "YELLOW,SMALL,STRETCH,ADULT,Tdsfs",
            "YELLOW,SMALL,STRETCH,ADULT,TD"]
print([this.split(",")[0:-1] for this in products],end="")

##output##
[['YELLOW', 'SMALL', 'STRETCH', 'ADULT'], ['YELLOW', 'SMALL', 'STRETCH', 'ADULT'], ['YELLOW', 'SMALL', 'STRETCH', 'ADULT']]
richieking 44 Master Poster

Look for a close thread button and just do that.
:)

richieking 44 Master Poster

you are welcome ;)

richieking 44 Master Poster

Do you want to strip all spaces ???
This will join all the text together.

New line is also counted as space so what are you realy looking for?
;)

richieking 44 Master Poster

Well get a pencil and a notebook. Always write down what you want your application to do and arreange them how they should work step by step.

Is a good idea to understand what you want to do. Dont rush with big tasks. Design by divide and conquer. Meaning make huge task very simplified. Comment your code for future. Leave space for improvements and updates.

Look through over and over. Once you get the idea....
Draw a flowchat or something. Put your ideas in a very human understandable way. No rushing,
Then start coding.

Thats my take ;)

richieking 44 Master Poster

just close the thread will you ? ;)

richieking 44 Master Poster

There are several ways to achieve this.
You can define enumration of colors. These color got id which are int. eg.

RED=200
BLUE=300
YELLOW=400
PINK=500

Then import random to rand the range from 200-500 by 100 (100,500,100)
Then provide the result in the bind method to set the color of the button.

2. You can also have a counter to count when ever the button is click and use the counter variable to help know which color come next.

You got the idea ? ;)

richieking 44 Master Poster

Polanski

rstrip()/strip() methods only strip well only on inputs. To make things simple.
if you recieve input from the user, then use the r/strip().


You can not use the strip only mechanism to strip a text file which is already formatted.

Also strip() methods will only strip the buffer provided. That means you can read word by word and strip them but what is the point as they will come striped already.

In short, only rstrip() will not get you what you want so tell your teacher ok?
;)

richieking 44 Master Poster

post your code again inside the code tags please.

richieking 44 Master Poster

That shouldnt be hard. How exactly is your text formatted? can you shoe a copy of that? or is the same as what you got up there.

This code would loop through 60/2 data combination (1 combination = TEXT + BINARY DATA). What I tried, was to read the entire data set, find the word "BASELINE", count characters to the end of the TEXT, and then read the BINARY DATA.

Ans also what you you mean by this.?? what is end of the text? Do you mean till you meet another baseline or what?

more info plz ;

richieking 44 Master Poster

Hi,
on #35 you provided a return statement. That is good but return will not print a value. you must either use a print there or use a print on #14 on the function.

Mixing print and return can get confuse noob. optimise that part. ok ?
;)

richieking 44 Master Poster

Just look around.. something live thread solved button or link.

and dont forget to upvote me. ;)

richieking 44 Master Poster

give me the upvote buddy ;)

Please mark thread as solved.
good luck ;)

richieking 44 Master Poster

well you can try this ok? GPL feel free to use it ;)

from __future__ import print_function
import re

with open("frisky.py","r") as file:
      real_value=[ re.sub('[_\W]*', "", value) for value in file] #I could make all one-liner but i thought you may want to extend on the code. wont you? ;)
      print("\n".join(real_value))

This code will strip every marks and punctiations for you provided the data without a headach ;) If you want your output together, remove "\n" from the join method

Number 2.

from __future__ import print_function
import re,urllib

file=urllib.urlopen("http://daniweb.com") # scrap daniweb
real_value=[ re.sub('[_\W]*', "", value) for value in file] # clean stuff
print("\n".join(real_value),end="")  # output. toggle "\n" if you want all togeter
richieking 44 Master Poster

mmmmm well i like your code. ;)

nice tit bits

richieking 44 Master Poster

Well more streamlined

from __future__ import print_function
words=["happy",'monty python',"hello","zombi","bone","monty"]
print([x[:-1]+"ier" for x in words if x.endswith("y")] )
print([x+"r" for x in words if x.endswith("e")] )

Getting more interesting after i opened the show ;)

richieking 44 Master Poster

ha ha.... not that cruel am i?
;)

richieking 44 Master Poster

Improve over this script. This should work for you.

from __future__ import print_function

words=["happy",'monty python',"hello","zombi","bone","monty"]

def word(words):
 for x in words:
    if x.endswith('y'): #get the ends
      f=[y for y in x]  #strip to list for easy slicing
      fex1=f[0:-1]      #take the end away
      fex1.append("ier") # append your wish
      print("".join(fex1)) #convert to string.
    elif x.endswith('e'):
      f=[y for y in x]
      fex2=f
      str(fex2.append("r"))   
      print("".join(fex2))
##output
happier
boner
montier

help your self ;)

richieking 44 Master Poster

Gribouillis updated

Information like this will always need a callback into action. Therefore i thought of updating your script a little.

with open("logfile.txt","a+") as logfile:
     logfile.writelines(str(stdout_value)+"\n") # To get the newline. easy to work with that

In the end. You can read-in your data for further manipulation if needed.
I understand Gribouillis just gave you a simple pseudo just to give you the idea.

;)

richieking 44 Master Poster

Start looking into wxpython ok? You must at least start with a GUI . I prefer wxpython.
I can write you one but the problem is, will you understand the script at all to even extend it??

Your answer plz. ;)