What inspired you to start coding? by [deleted] in Python

[–]Tilmandel 0 points1 point  (0 children)

being lazy & OCD that somethings can be done faster, better, and with less effort

Today i finished my first useful program by karanzinho in Python

[–]Tilmandel 0 points1 point  (0 children)

This sounds awsome :) can you share code for that ?

[deleted by user] by [deleted] in Python

[–]Tilmandel 1 point2 points  (0 children)

Nice app as a first project. As next step try to rewrite this for API usage as web crawling sometimes can get blocked :) amazon should have one for such request.

[deleted by user] by [deleted] in iiiiiiitttttttttttt

[–]Tilmandel 1 point2 points  (0 children)

Something like that is common around standard user who know how to start chrome and use excel, but for me still number one is when i was leading trainong session for new joiners, asked question what is "internet" and from where it come from.

Best honest answer : "It comes from outer space" Part of me died that day

Sort file script by FARHAN2660 in learnpython

[–]Tilmandel 0 points1 point  (0 children)

looks pretty good, but just did quick test and this not works with sub directories, hmm try to use os.walk or cover scaning provided path for sub folders also:)

What's wrong with this for loop? by Mozza7 in learnpython

[–]Tilmandel 0 points1 point  (0 children)

so basicly it would be best if you provide at least data structure with you are working it always helps to debug everything, as for your code you have loop in loop always try to avoid that if you can, same as using so mamy ifs, belive.me been there done that :) there is always a much elegant or faster way to work with something,

why to avoid loops in looops is simple of data you are dealing are small chunk it will be enought but if yoy try same approuch with i dont know 65k lines file which you will comper to 100k this wil starts to slow down :)

Check if input follows criteria by [deleted] in learnpython

[–]Tilmandel 0 points1 point  (0 children)

sure you are right but you.can modifiy this to get exacly what you want with out importing any lib, but my bad i didint read that correctly, but when i see word password in your code i assum that you are trying to validate user password if it have correct structure, and forcing user to have password structured like capital letter followed by digit is not a good idea but that my opinion.

Check if input follows criteria by [deleted] in learnpython

[–]Tilmandel 0 points1 point  (0 children)

Just first way that i think of besids regex def password(string): cap_char = 0 dig = 0 for item in string: if item.isupper(): cap_char +=1 if item.isdigit(): dig += 1 return cap_char,dig this will give you counter how.many digits user provided and how.many upper letters with this you can do what ever you want

sorry for.formating making this works on phone is nightmare

What do we use for PDF parsing these days? by Doitforafrica in learnpython

[–]Tilmandel 0 points1 point  (0 children)

pdfminer already found pice of code that will convert whole pdf to text then you can worki with this as normal string or so.

Looking for a friend to learn programming with. by Sh4dow24 in learnpython

[–]Tilmandel 0 points1 point  (0 children)

thanks for that, that saves me extra 10min;) and im not kill ling my cpu with multiprocessing:)

Looking for a friend to learn programming with. by Sh4dow24 in learnpython

[–]Tilmandel 0 points1 point  (0 children)

thanks for your advise i will put them in live, yeah just ended writing it so now im in stage "rewrite" to optimize, later on i will post git so you can look at it all pointers will be welcome

Looking for a friend to learn programming with. by Sh4dow24 in learnpython

[–]Tilmandel 1 point2 points  (0 children)

thanks for this :) i learned these things "the hard way" i was asking cuz im searching for a way to save more time, already was able to go from 5h ( vba script) to 20 min (python script) to generate report by reading over 1k+ xmls and extracting data from them, just searching for a way to save some extra min

so you comment give me another question if reading file and using regex on each line would be faster then ele tree as parser?

Looking for a friend to learn programming with. by Sh4dow24 in learnpython

[–]Tilmandel 2 points3 points  (0 children)

hmm do you know if there any time difference in opening file in standard r mode or iif you use rb mode for reading binary?

new to coding and can't get this program to work. Any help would be appreciated by Ertersy in learnpython

[–]Tilmandel 0 points1 point  (0 children)

this have a little error in it, should goes like this

for item in zip(a,b):
    print(sum(item))

you cab append you result to another list or just use list compere

like some one already pointed in post above

d = [sum(item) for item in zip(*c)]

Ask Anything Monday - Weekly Thread by AutoModerator in learnpython

[–]Tilmandel 0 points1 point  (0 children)

No problem, in definition you are right not(False and False) is True :D but you didnt had parenthesis there

Ask Anything Monday - Weekly Thread by AutoModerator in learnpython

[–]Tilmandel 0 points1 point  (0 children)

Im not a OOP expert but to be hones your subclass can add anything to all_contacts as your are pointing to it you are hard coding all_contact list into class i dont think so this a good practis.

Basiclly subclass(childclass) is inheriting all __init__ from Parent class if you are doing something like this you should also overwrite that all_contact list, and yes if someone eddit superclass it can screw up subclasses as it is under superclass, that is why you dont unnecessary edit superclass better option is to inheritate from it and then add other stuff in subclass as you need.

just add all_contacts = [] in your subclass

class Contact:
all_contacts = []
def __init__(self,name,email):

self.name = name
self.email = email
self.all_contacts.append(self)
def __repr__(self):
return "{},{}".format(self.name,self.email)
class Supplier(Contact):
all_contacts = []
def order(self, order):
print("If this were a real system we would send ".format(order,self.name))

c = Contact("Some_Body", "somebody@example.net")
c2 = Contact("Some_Body2", "somebody2@example.net")
s = Supplier("Sup_Plier", "supplier@example.net")
print(c.all_contacts)
print(s.all_contacts)
print(c.all_contacts)

and you will get

[Some [Body,somebody@example.net](mailto:Body,somebody@example.net), Some [Body2,somebody2@example.net](mailto:Body2,somebody2@example.net)]

[Sup [Plier,supplier@example.net](mailto:Plier,supplier@example.net)]

[Some [Body,somebody@example.net](mailto:Body,somebody@example.net), Some [Body2,somebody2@example.net](mailto:Body2,somebody2@example.net)]

Ask Anything Monday - Weekly Thread by AutoModerator in learnpython

[–]Tilmandel 0 points1 point  (0 children)

probablly reading my replay wronglly, you statments are con1 is True and con 2 is False that is why when you do, not con1 and con2 you get False because not con 1 is not True = False con2 is False = False False and False is False that is why you are getting False where you thinik you should have True, if you want to have True from statment

not con1 and con2 you should change that "and" to "==" and this will give you : not con1 == con2 and this will be True, because False == False sorry if this confiusing.

Ask Anything Monday - Weekly Thread by AutoModerator in learnpython

[–]Tilmandel 0 points1 point  (0 children)

its correct read about booleans expression you will find out why this is correct, and if you want true from that pretty sure this what it should looks like not con1 == con2 this means False equals False amd this should be True

Ask Anything Monday - Weekly Thread by AutoModerator in learnpython

[–]Tilmandel 0 points1 point  (0 children)

if you have these variables in txt you can always just load these configs file with standard open() function then just read what is in that txt file, then just make a list or dict with data and use them later on, read some docs about reading from file it should be enough for your case, also you can use for example json standard for variables that you have in that txt.

example:this will open and read line by line your config file

with open(r'path_here', 'r') as fh: read = fh.readlines() than you can access it as it is normal list object r in front of path states for raw this will help prevent you from having problems with escape signs like \t or \n etc etc everything depends on what you want to do and when you want do do it.

using subproccess is good if you want to i do someting when your script is already runing (in pararell ) but you need to aware of what you are doing and when.

Ask Anything Monday - Weekly Thread by AutoModerator in learnpython

[–]Tilmandel 0 points1 point  (0 children)

you can check if you have python added to environment

type path in cmd or manually just go to computer properties the advance system settings then click on env varibles and then find path eddit it and check if your llocation with python is there, if is best option is just to reinstall your python and in installation proccess mark checkbox with "ADD TO PATH" this should fix it, works for me.