Python Forum
Search Results
Post Author Forum Replies Views Posted [asc]
    Thread: Need to fix my brain on classes
Post: Need to fix my brain on classes

I want to do a simple calendar to learn practical use of classes, because I find classes counterintuitive in python and I struggle a lot with it. my code rn looks like this: from dataclasses import d...
blackknite General Coding Help 2 1,225 Apr-29-2022, 03:36 PM
    Thread: How to understand the byte notation in python3
Post: RE: How to understand the byte notation in python3

Okay, thank you for your answer. You have made it very clear but this points me to another issue - How I am supposed to know if some byte is a part of another one? It looks tricky: In [75]: bstr = b...
blackknite General Coding Help 3 2,912 Feb-23-2021, 02:24 PM
    Thread: How to understand the byte notation in python3
Post: How to understand the byte notation in python3

Hey, I am trying to learn low-level stuff in py3 for some crypto project, and it is pretty hard so far. In [63]: int(b'\x12AY5'.hex(),16) Out[63]: 306272565 #Value of some weird byte In [64]: int('...
blackknite General Coding Help 3 2,912 Feb-23-2021, 07:00 AM
    Thread: Need to speed up my code.
Post: RE: Need to speed up my code.

Hey. Sorry for my response time. So the oneliner using collections.Counter seems to be fastest, but I cant understand why and how. My fastest solution for this, without importing any external modules...
blackknite Code Review 6 3,881 Jan-19-2020, 01:24 AM
    Thread: Need to speed up my code.
Post: Need to speed up my code.

I have to return a simple sum of the most present values in the array, ie [3,5,2,1,2,3,2,2] - > should return 4, because (2,2,2,2). The array sometimes is crazy focking big, and I cannot pass the e...
blackknite Code Review 6 3,881 Jan-14-2020, 05:04 PM
    Thread: I dont understand bytes in python.
Post: RE: I dont understand bytes in python.

Thx for replying! Okay, now its a whole lot clearer. Yet I still may have few small questions: -How to properly concat two hex strings? -When to use '0x80' and when 'x80'? In example - 'hex(112)' s...
blackknite General Coding Help 3 4,014 Oct-02-2019, 12:46 AM
    Thread: I dont understand bytes in python.
Post: I dont understand bytes in python.

Everything is so confusing here, ie: >>> z = b'\x93\x39\x02\x49\x83\x02\x82\xf3\x23\xf8\xd3\x13' >>> list(z) [147, 57, 2, 73, 131, 2, 130, 243, 35, 248, 211, 19]So what EXACTLY is th...
blackknite General Coding Help 3 4,014 Oct-01-2019, 10:20 PM
    Thread: My dict is not good
Post: RE: My dict is not good

(Sep-23-2019, 10:01 AM)wavic Wrote: Did you see the code in my previous post? Yeah, page wasnt refreshed or I just overlooked it. It works. thank you.
blackknite General Coding Help 9 3,634 Sep-23-2019, 10:44 AM
    Thread: My dict is not good
Post: RE: My dict is not good

I just want to have a dict with words as keys, and summed ascii value of all letters in that word as values, I dont know if I can say it any clearer. Maybe dont even look at code from my second post ...
blackknite General Coding Help 9 3,634 Sep-23-2019, 09:29 AM
    Thread: My dict is not good
Post: RE: My dict is not good

Hey. Thx for replying! The file with name "coded" contains permutations of a second file "words", and some random alphanumeric strings that I have to filter. Its like 'blablah<EOL>', and EOL is...
blackknite General Coding Help 9 3,634 Sep-22-2019, 03:22 PM
    Thread: My dict is not good
Post: My dict is not good

I want to create a dict from txt file, with words & summed ascii value but once again I have been defeated. I guess I have never really understood dicts, in Python they arent intuitive at all and ...
blackknite General Coding Help 9 3,634 Sep-22-2019, 02:03 PM
    Thread: Using function argument in lists comprehension.
Post: RE: Using function argument in lists comprehension...

It should count all the paremeter given digits in the string and Im still doing something wrong somehow. def nb_dig(n,d): r = [n**2 for n in range(1,n)] digz = [r.count(d)] print(r,digz) ...
blackknite General Coding Help 5 3,054 Apr-23-2019, 09:05 PM
    Thread: Using function argument in lists comprehension.
Post: Using function argument in lists comprehension.

def nb_dig(n,d): r = [n**2 for n in range(1,n)] digz = [d for d in r] print(r,digz) nb_dig(10,1)Output:>>>[1, 4, 9, 16, 25, 36, 49, 64, 81] [1, 4, 9, 16, 25, 36, 49, 64, 81]So, I ...
blackknite General Coding Help 5 3,054 Apr-23-2019, 07:29 PM
    Thread: Hard time with prime factors in the task.
Post: Hard time with prime factors in the task.

Hey people.Im trying to do some harder python challenges to learn some new things. Given a string,and a number, I have to get an ascii value of a char, get the largest prime factor of the number and a...
blackknite General Coding Help 1 1,842 Jan-23-2019, 07:51 AM
    Thread: FTP file size
Post: RE: FTP file size

Locally I prefer: >>> import os >>> s = os.path.getsize("C:/WinPEpge.sys") >>> s 536870912 But idk about your FTP, you gave no intel on what libs and soft are you using th...
blackknite General Coding Help 2 4,983 Jan-23-2019, 07:31 AM
    Thread: ' | ' Operator and 'OR'
Post: RE: ' | ' Operator and 'OR'

(Jan-11-2019, 05:51 AM)nilamo Wrote: Those are not the same thing. If you add the "==0" check to the bitwise operation, you'd also have failures. ie: this should fail: is_divisible = lambda n,x,y:...
blackknite General Coding Help 10 4,700 Jan-11-2019, 09:32 PM
    Thread: ' | ' Operator and 'OR'
Post: RE: ' | ' Operator and 'OR'

Thank you all for replying guys. To be more precise I have to say that version with '==0' (after first expression) and without it both works the same. is_divisible = lambda n,x,y : n % x | n % y == 0 ...
blackknite General Coding Help 10 4,700 Jan-10-2019, 11:08 PM
    Thread: ' | ' Operator and 'OR'
Post: RE: ' | ' Operator and 'OR'

Thx for replying! Why its incomplete? If 'n % x' is not ==0 then returns 1 which is equal to True, otherwise its False, works for me in Python3. Im still trying to figure out how exactly this 'binary...
blackknite General Coding Help 10 4,700 Jan-10-2019, 04:47 PM
    Thread: ' | ' Operator and 'OR'
Post: ' | ' Operator and 'OR'

Hey folks. Im doing some online challanges, and I got some things that gets me confused a bit, could use some explanation! The first one is this, I dont know what I did and why this even works? is_d...
blackknite General Coding Help 10 4,700 Jan-10-2019, 01:10 AM
    Thread: First non-repeating char and some errors.
Post: First non-repeating char and some errors.

Hey, I do some coding challenges online and I have issue with this one. At first I did this: >>> q = lambda s:['' if not s else c for c in s if s.count(c)<=1][0] >>> q('~><...
blackknite General Coding Help 1 2,275 Jan-06-2019, 01:36 PM

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020