richieking 44 Master Poster

You can also try this.
This is according to your post

hello i'm trying to figure out how to write a program in c++ that check when i insert a password and force me to add at least 2 capital letters and 2 numbers in the password (you've seen this before right? when signing up for new account and checks for password stringth)

Below is a simple code to mimic such thing.

bool chkUperDegitPwd( const std::string pwd){
    static size_t sCount=0; // static count

   for(auto &p: pwd){  // >= c++11
        if(std::isdigit(p)){
            sCount++;
        }else if(std::isalpha(p)){
           if(std::isupper(p)){
               sCount++;
            }
        }
   }
   return pwd.length() == sCount ?true:false;
}

// use case
std::string pwd;
std::getline(std::cin,pwd);
if(chkUperDegitPwd(pwd)){
  //do your stuff
}else{
 // password error
}
richieking 44 Master Poster

You may wanna change your class name to say txt or whatever.
Array is a C++ lib. MosChops just warned you aboout that.
Now add change to say class txt and add this code.

   enum {MAX_INT=5};// global enum

  bool operator ==(txt a){
      return a.getSize() == getSize();
            }

    const int getSize(void)const{
        int sum  = 0;
        for (int x=0; x < MAX_INT; x++) {
            sum += arr[x];
        }
        return sum;
    }

I want you to figure things out yourself.

richieking 44 Master Poster

You can not simply connect to your database on another system like that.
There must be a contact or a server on the remote system that you will use to open the way to the inner operation.
This is simply done by running a server on the remote system that will connect to your app and via the connection have access to the DB.
Look into sockets and clients howtos.

So in short, there must be a server and a client.
Besides this there is no way to just connect to remote DB like what you want. Well i stand to be corrected but i am pretty confident with my answer as i have done this numerous times.

richieking 44 Master Poster

Are you talking about this?
Well show some code next time. We are here to help not to do your homework.

float recSq(float x, float y){
   return x*y;
   }
richieking 44 Master Poster

Master when do you need your programme? How soon? Anything again master?

richieking 44 Master Poster

And you expect us to do that for you dont you master?
Sure we will.. just give us one more month please master.

richieking 44 Master Poster

And your code?

richieking 44 Master Poster

Also you can bring the innitializing of the
int[] values = new int[numbValues]; into the constructor.

 Object(int numbValues) {
values = new int[numbValues];
this.numbValues = numbValues;
}

but leave the declaration outside .
that is
`int [] values;'

By this you will be fine also.
that means you will need to called the class with a value new Object(33);

nostalgia commented: Solved my problem, thanks! +0
richieking 44 Master Poster

There are 2 thing that may help fix your problem. At least anyone of them is enough for the task.
1.Thread
2.javax swing Timer.

1.if you need thread then you will need to call the runnable method to innitiate the clock. This must be called in an event.

  1. If you use the javax swing timer, then thhats more easier..
    Timer timer = new Timer(int);
    then you innitiate the timer.start(); in the event.

Also to make things more protective . Always organize data that you will use in many places so that there wont be a subtle error.

here.

Font font = new Font("Impact", Font.BOLD, 45);

min.setFont(font);

You get the idea?

richieking 44 Master Poster

Also you are using the standard laout manager with Swing. How do you want to see the app layout, can you draw or show us a pic or something how you want to see your layout so that we can assist you?

richieking 44 Master Poster

what is your level in c++?
Do you need to store something permanent ?
Do you have experience with database?

sarafadeenl1 commented: fairly good, i dont need to store something permanently, i do have little +0
richieking 44 Master Poster

try google py4a. there is layers for that.

richieking 44 Master Poster

pyPdf is a simple as abc. it cant get cheaper than that!

Bosterk commented: Thank +1
richieking 44 Master Poster

Try this

>>> print "\n".join([x for x in "dog,cat,bird,good,bad,blah,blah,blah".split(",")])
dog
cat
bird
good
bad
blah
blah
blah
>>>
richieking 44 Master Poster

For some reason it just jumps to the else statement instead of going to if and elif.
Any input would really be apreciated.

a=raw_input( "What is your name: ")
b= int(raw_input( "What year were you born: "))
c= int(raw_input( "What year is it now: "))
print "Hello",a,"you are",c-b,"years old."
class object():
    'userAge'== c-b
    'teenager'== (13,14,15,16,17,18,19)
    if 'userAge' <=12:
         print "You are really young"
    elif 'userAge'=='teenager':
         print "You are a teen"
    else:
         print "You're really old."
         
         
object()

You just need to take your time and learn python. Read pybooks and practice a lot

Ene Uran commented: agree +8
richieking 44 Master Poster

what a nice piece of article tony. you got talent my friend :) .

Azmah commented: agreed +2
richieking 44 Master Poster

Google for pyaudio. Also if you want a linux native app, there are other libs for banshe,audacious, in pytyon that you can use then it will use their audio engine respectively.

richieking 44 Master Poster

Never knew wx python does not yet support python3.x because that's what i use currently, do you think that in the nearest future it will.

Dont Even think about that for now. It will take some time. There is a lot of loads on the developers at the moment.

Just stick to TK if you want py3k, else you may atleast use py2.7 which goes well with wxpy2.8 and still call in the future function in into your code.

vegaseat commented: good point +13
richieking 44 Master Poster

look at the right -> there is up and down sign.
click on up.

richieking 44 Master Poster
print "Equations"

print "a+1 (1), a+2 (2), a+3 (3), a+4 (4)"

while True:
	d=int(raw_input("number:" ))
	if d==0:
		break;
	if d == 1:
		print a+1
		
## Then continue from there
richieking 44 Master Poster

what a teacher your are Snippsat. impressed!

richieking 44 Master Poster
print(["/".join(date.split("-"))])

2011/03/03

from my htc phone ;)

richieking 44 Master Poster

why dont you only read the lines into a list and slize it???

The increment the index to get what you want?

listc = [x.split() for x in f.readline()]
## now you get the data like
ins =0
ins2 =0
for x in listc:
   print listc[ins:ins2+1],listc[ins+2:ins2+3]
   ins+=3
   ins2+=4

something like this. coming from my HTC fone.
hope you get the idea

BirdaoGwra commented: I solved my problem bcos of his help +2
richieking 44 Master Poster

Yep line 36.
Assignment operator needed not comparism.

monthN = "Decemeber";

instead

richieking 44 Master Poster

or this.........

a = a= [(x+2,x*2) for x in range(1,300)]

And plot some graph with it ;)

richieking 44 Master Poster

backslash is native to windows as forwardslash to linux/unix/bsd file path. if you want to write an app. for network , then your good choice shout be forwardslash.

richieking 44 Master Poster

There are 3 things going on with your script.
1. a is global variable assigned the value of 10.
2. You function is a function that has a default value set. that is global a which got the value of 10.
due to that

foo()

will print the default value which is

def foo(x=10)

because a=10. So when you call

foo()

it will return the default value.

Try and call foo(a) on line 6. This will print the current value of a which is 5.

3.Variable scope and function definations are very simple once you master them.
As you can see.

foo()

took no value. As long as you dont give a value to

foo()

.... It will keep printing the value of first a which is 10.

Try and change the value of first a and call

foo()

without a value to see.

Hope you get the idea. happy codding :)

richieking 44 Master Poster

on line 53.... you have wx.EXPAND flat set but you have not given the permission to expand. Change to this,,,,,,,,,

sizer.Add(myEditor, 1, wx.EXPAND)

1 is the proportion/permission. so change the 0 to 1 anywhere you want to expand.
If you got more than one expand... Then you increase the proportion of the bigger control you want to .

;)

ShadyTyrant commented: Found solution +2
richieking 44 Master Poster

yep...

because pyserial has included it.
example.,,,,

import serial
ser = serial.Serial (0 , baudrate = 57600 , timeout = 1) #open serial port (1) - 1
line = ser.readline() ## will get the implementation of FileList method readline() if you dont have a local readline() method define

ser.close()
richieking 44 Master Poster

def on_paint(event):
self.dc == wx.PaintDC(event.GetEventObject())
self.dc.SetPen(wx.Pen("BLACK", 4))

self.hangingman.Bind(wx.EVT_PAINT, on_paint)

There error is this method you creadted is not part of the class without the keyword self. try this.......

def on_paint(self,event):
        self.dc == wx.PaintDC(event.GetEventObject())
        self.dc.SetPen(wx.Pen("BLACK", 4))

self.hangingman.Bind(wx.EVT_PAINT, on_paint)

And here you go ;)

richieking 44 Master Poster
>>> d="hello"
>>> d[0]
'h'
>>>

from idle.

richieking 44 Master Poster

You can upvote me a lil and close the thread
;)
thanks

richieking 44 Master Poster

Because text your classs for text2 is wrong.
Try this..
(text2.py)

class Text(object): ## object not very important. you can remove that.
   def text(self):
     return("Hello world")

now call text2.py class.
(text1.py)

from text2 import Text
hello = Text()
print hello.text()

##output
Hello world

Very simple. I think its well explained yea ;)

altXerror commented: thanks. this really helped me. +1
richieking 44 Master Poster

Grib

You eat and drink python..!
What a man! ;)

Tcll commented: I love Grib, he's amazing! =3 +4
richieking 44 Master Poster

A proper build server will no just give access to its directories. There must e some checks here and there. You will also need the ftplib.

I think thats your best hit.

richieking 44 Master Poster

Happy Newyear.
This is your newyear gift.

str="4:14.4-17M,5:14.4-2e13M,6:14.4-4e9M,7:14.4-8e,22:28.4-35M,\
23:28.4-2e30M,24:28.4-4e26M,25:28.4-8e18M,26:28.4-16e2M,27:28.4-18e,\
28:14.16-36M,29:14.16-2e32M,30:14.16-4e28M,31:14.16-8e20M"

d=[c for c in str.split(",")]
print([int(f.split(":")[0]) for f in d ])

##out Put
[4, 5, 6, 7, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]

And if you like it. you can upvote me a lil ok? :)

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

If you know everything, then write your programs as properly as possible and use proper English. "i knw u ll" is not proper English.

Waltp

This is not an english classes or forum. i dont like that.! Take things easy will you?

richieking 44 Master Poster

This is my final work

import dicom
import Image


Ima=dicom.ReadFile("/home/richie/d1.dcm") # change the path

ds=Ima.InstitutionName="Any name" # not realy needed
# I just had to print this Ima.pixel_array out to show you the lists
f=Ima.pixel_array
print f # print
sa= Image.fromarray(f) ## Hear is the Image module. It needs the array method as the details from Ima. is array
if sa.show():    
   sa.save("foo.gif") # save the dat converted to gif.
print("Copy converted to file with name...[foo.gif]")

And dont forget to show some love by upvoting me ok? ;)

python_user commented: Thanks for your help +1
richieking 44 Master Poster

Dos-killer,

The job is done i think.

Check with this link.
It will be great if you put the server on your notebook. Then you will have more control because you need to convert audio to MIDI because you can control that easily on the notebook to speed the audio transfer. Nokia CPU is a piece of ant brain. You need speed. Once the audio is converted to MIDI, s60 can handel MIDI without any issue.

Then use this S60 python module http://www.mobilenin.com/pys60/ex_sound_recorder_player.htm.

You code like this....

#Demo
import audio
import sockeck

## Like this

con,addr=s.accept()
midi=con.recv(1200)
audio.sound.play(midi)

#To record on the reciever ... Its very tricky. No that record do not have to finish. There must be a while 1: loop to keep sending data to both end.
# Here on the nokia.

audiorec=audio.sound.record()# kind of or you ....
socket.send(audiorec)

Take this link doc. http://www.mobilenin.com/pys60/resources/API_Reference_for_Python.pdf

Hay lil upvote will be nice ;)
Try this.....
;)

richieking 44 Master Poster

Hi, look

on line 21-25

moveFunction is not a function but a variable.

why are you calling

moveFunction ("bla bla")

instead of

moveFunction ="bla bla"

Fix that ok ;)

MUFC4life commented: Very helpful +1
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

your error was expalined i think.
no module name regex.

import re as regex

thats if you cant do without regex.
;)

richieking 44 Master Poster

I dont see why you cant change that. You extended the wx.Frame class so you can overide methods and variables in your calss if you want.

The only problem i see is your gridsizer not well coded hence breaks apart when expanded.

;)

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

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

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

Use the style wx.TE_RIGHT ok?

eg

wx.TextCtrl(self,-1,style=wx.TE_RIGHT)
ciliath commented: genial +0
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

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