Torna indietro   Hardware Upgrade Forum > Software > Programmazione

DJI Osmo Nano: la piccola fotocamera alla prova sul campo
DJI Osmo Nano: la piccola fotocamera alla prova sul campo
La nuova fotocamera compatta DJI spicca per l'abbinamento ideale tra le dimensioni ridotte e la qualità d'immagine. Può essere installata in punti di ripresa difficilmente utilizzabili con le tipiche action camera, grazie ad una struttura modulare con modulo ripresa e base con schermo che possono essere scollegati tra di loro. Un prodotto ideale per chi fa riprese sportive, da avere sempre tra le mani
FUJIFILM X-T30 III, la nuova mirrorless compatta
FUJIFILM X-T30 III, la nuova mirrorless compatta
FUJIFILM X-T30 III è la nuvoa fotocamera mirrorless pensata per chi si avvicina alla fotografia e ricerca una soluzione leggera e compatta, da avere sempre a disposizione ma che non porti a rinunce quanto a controllo dell'immagine.
Oracle AI World 2025: l'IA cambia tutto, a partire dai dati
Oracle AI World 2025: l'IA cambia tutto, a partire dai dati
Da Las Vegas, la visione di Larry Ellison e la concretezza di Clay Magouyrk definiscono la nuova traiettoria di Oracle: portare l’intelligenza artificiale ai dati, non i dati all’intelligenza, costruendo un’infrastruttura cloud e applicativa in cui gli agenti IA diventano parte integrante dei processi aziendali, fino al cuore delle imprese europee
Tutti gli articoli Tutte le news

Vai al Forum
Rispondi
 
Strumenti
Old 04-11-2009, 12:23   #1
AMD_GO
Senior Member
 
L'Avatar di AMD_GO
 
Iscritto dal: Jan 2006
Città: Prov.Cagliari
Messaggi: 1583
[Pyton] Controllo sintassi di uno script Python

Salve ragazzi, c'è un modo per controllare la correttezza sintattica di uno script pyton senza che venga eseguito?
Esempio:

Codice:
#! /usr/bin/env python

print 39
istruzione sbagliata
print 40
Vorrei che mi segnalasse l'errore "istruzione sbagliata" senza però eseguire la print 39.

Grazie a tutti!
__________________
MB: ASUS Prime x570-P - CPU: AMD Ryzen 9 3900x with Arctic Liquid Freezer II 240 - Memorie: G.Skill Ripjaws DDR4 2x16GB 3200 - HDs: Samsung 970 EVO plus and Crucial P2 1TB - Ali: Seasonic Focus GX-650 - Video: AMD Asus GTX770 Direct CU II - Concluso Positivamente con : M@x27, mirco2034, max x2, relativo, Mighty Max e tanti altri
AMD_GO è offline   Rispondi citando il messaggio o parte di esso
Old 04-11-2009, 14:37   #2
cdimauro
Senior Member
 
L'Avatar di cdimauro
 
Iscritto dal: Jan 2002
Città: Germania
Messaggi: 26110
Puoi provare con la funzione built-in compile:
compile( string, filename, kind[, flags[, dont_inherit]])

Compile the string into a code object. Code objects can be executed by an exec statement or evaluated by a call to eval(). The filename argument should give the file from which the code was read; pass some recognizable value if it wasn't read from a file ('<string>' is commonly used). The kind argument specifies what kind of code must be compiled; it can be 'exec' if string consists of a sequence of statements, 'eval' if it consists of a single expression, or 'single' if it consists of a single interactive statement (in the latter case, expression statements that evaluate to something else than None will be printed).
When compiling multi-line statements, two caveats apply: line endings must be represented by a single newline character ('\n'), and the input must be terminated by at least one newline character. If line endings are represented by '\r\n', use the string replace() method to change them into '\n'.

The optional arguments flags and dont_inherit (which are new in Python 2.2) control which future statements (see PEP 236) affect the compilation of string. If neither is present (or both are zero) the code is compiled with those future statements that are in effect in the code that is calling compile. If the flags argument is given and dont_inherit is not (or is zero) then the future statements specified by the flags argument are used in addition to those that would be used anyway. If dont_inherit is a non-zero integer then the flags argument is it - the future statements in effect around the call to compile are ignored.

Future statements are specified by bits which can be bitwise or-ed together to specify multiple statements. The bitfield required to specify a given feature can be found as the compiler_flag attribute on the _Feature instance in the __future__ module.
Basta che gli passi la stringa o il nome del file da compilare, e vedere se genera un'eccezione.
__________________
Per iniziare a programmare c'è solo Python con questo o quest'altro (più avanzato) libro
@LinkedIn Non parlo in alcun modo a nome dell'azienda per la quale lavoro
Ho poco tempo per frequentare il forum; eventualmente, contattatemi in PVT o nel mio sito. Fanboys
cdimauro è offline   Rispondi citando il messaggio o parte di esso
 Rispondi


DJI Osmo Nano: la piccola fotocamera alla prova sul campo DJI Osmo Nano: la piccola fotocamera alla prova ...
FUJIFILM X-T30 III, la nuova mirrorless compatta FUJIFILM X-T30 III, la nuova mirrorless compatta
Oracle AI World 2025: l'IA cambia tutto, a partire dai dati Oracle AI World 2025: l'IA cambia tutto, a parti...
Micron e millisecondi: la piattaforma ServiceNow guida l'infrastruttura IT di Aston Martin F1 Micron e millisecondi: la piattaforma ServiceNow...
ASUS GeForce RTX 5080 Noctua OC Edition: una custom fenomenale, ma anche enorme ASUS GeForce RTX 5080 Noctua OC Edition: una cus...
Un post di Sean Duffy (amministratore ad...
SpaceX ha già lanciato oltre 135 ...
GeForce RTX 5060 Ti 8GB: non piace neanc...
Isar Aerospace Spectrum: il fallimento d...
'State lontani dalla GeForce RTX 5090 Fo...
GJ 251 c è la ''super-Terra'' sco...
Halo è ufficialmente multipiattaf...
Windows 11 25H2 e 24H2: come attivare su...
Brembo Solutions e Microsoft danno vita ...
Migliaia di pacchi Amazon rubati ai legi...
Ex CEO di Stellantis: Musk lascerà...
Record storico per i giochi Windows su L...
GPU introvabili: Microsoft accusa i mine...
RedTiger prende di mira i gamer: furto d...
Microsoft sotto accusa: avrebbe nascosto...
Chromium
GPU-Z
OCCT
LibreOffice Portable
Opera One Portable
Opera One 106
CCleaner Portable
CCleaner Standard
Cpu-Z
Driver NVIDIA GeForce 546.65 WHQL
SmartFTP
Trillian
Google Chrome Portable
Google Chrome 120
VirtualBox
Tutti gli articoli Tutte le news Tutti i download

Strumenti

Regole
Non Puoi aprire nuove discussioni
Non Puoi rispondere ai messaggi
Non Puoi allegare file
Non Puoi modificare i tuoi messaggi

Il codice vB è On
Le Faccine sono On
Il codice [IMG] è On
Il codice HTML è Off
Vai al Forum


Tutti gli orari sono GMT +1. Ora sono le: 23:08.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Served by www3v